From fe343d270ceb034284c7d0216a7d7315e821977d Mon Sep 17 00:00:00 2001 From: "raveit65 (via Travis CI)" Date: Tue, 10 Dec 2024 08:58:29 +0000 Subject: Deploy mate-desktop/mate-power-manager to github.com/mate-desktop/mate-power-manager.git:gh-pages --- .../0.html | 2469 ++++++ .../1.html | 311 + .../10.html | 6753 +++++++++++++++ .../100.html | 365 + .../101.html | 1947 +++++ .../102.html | 355 + .../103.html | 453 + .../104.html | 887 ++ .../105.html | 401 + .../106.html | 1333 +++ .../107.html | 3313 ++++++++ .../108.html | 1345 +++ .../109.html | 1591 ++++ .../11.html | 2025 +++++ .../110.html | 1603 ++++ .../111.html | 807 ++ .../112.html | 1047 +++ .../113.html | 893 ++ .../114.html | 1227 +++ .../12.html | 309 + .../13.html | 437 + .../14.html | 489 ++ .../15.html | 383 + .../16.html | 6079 +++++++++++++ .../17.html | 433 + .../18.html | 725 ++ .../19.html | 533 ++ .../2.html | 393 + .../20.html | 335 + .../21.html | 8907 ++++++++++++++++++++ .../22.html | 2941 +++++++ .../23.html | 439 + .../24.html | 1159 +++ .../25.html | 339 + .../26.html | 3107 +++++++ .../27.html | 1341 +++ .../28.html | 321 + .../29.html | 2915 +++++++ .../3.html | 393 + .../30.html | 343 + .../31.html | 4187 +++++++++ .../32.html | 637 ++ .../33.html | 537 ++ .../34.html | 405 + .../35.html | 1333 +++ .../36.html | 741 ++ .../37.html | 4569 ++++++++++ .../38.html | 365 + .../39.html | 553 ++ .../4.html | 311 + .../40.html | 413 + .../41.html | 353 + .../42.html | 327 + .../43.html | 1577 ++++ .../44.html | 417 + .../45.html | 1777 ++++ .../46.html | 351 + .../47.html | 335 + .../48.html | 553 ++ .../49.html | 357 + .../5.html | 1315 +++ .../50.html | 1175 +++ .../51.html | 401 + .../52.html | 561 ++ .../53.html | 321 + .../54.html | 1613 ++++ .../55.html | 375 + .../56.html | 623 ++ .../57.html | 317 + .../58.html | 925 ++ .../59.html | 803 ++ .../6.html | 863 ++ .../60.html | 1823 ++++ .../61.html | 385 + .../62.html | 385 + .../63.html | 377 + .../64.html | 413 + .../65.html | 583 ++ .../66.html | 395 + .../67.html | 413 + .../68.html | 387 + .../69.html | 483 ++ .../7.html | 1309 +++ .../70.html | 2203 +++++ .../71.html | 1087 +++ .../72.html | 715 ++ .../73.html | 1411 ++++ .../74.html | 365 + .../75.html | 307 + .../76.html | 1087 +++ .../77.html | 2175 +++++ .../78.html | 321 + .../79.html | 393 + .../8.html | 1769 ++++ .../80.html | 391 + .../81.html | 2597 ++++++ .../82.html | 323 + .../83.html | 417 + .../84.html | 1705 ++++ .../85.html | 351 + .../86.html | 397 + .../87.html | 1661 ++++ .../88.html | 397 + .../89.html | 795 ++ .../9.html | 397 + .../90.html | 793 ++ .../91.html | 395 + .../92.html | 363 + .../93.html | 4273 ++++++++++ .../94.html | 365 + .../95.html | 567 ++ .../96.html | 567 ++ .../97.html | 1187 +++ .../98.html | 441 + .../99.html | 1223 +++ .../index.html | 1060 +++ .../stats.html | 203 + .../style.css | 177 + 118 files changed, 130667 insertions(+) create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/0.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/1.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/10.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/100.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/101.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/102.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/103.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/104.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/105.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/106.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/107.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/108.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/109.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/11.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/110.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/111.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/112.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/113.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/114.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/12.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/13.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/14.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/15.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/16.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/17.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/18.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/19.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/2.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/20.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/21.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/22.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/23.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/24.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/25.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/26.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/27.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/28.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/29.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/3.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/30.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/31.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/32.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/33.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/34.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/35.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/36.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/37.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/38.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/39.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/4.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/40.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/41.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/42.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/43.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/44.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/45.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/46.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/47.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/48.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/49.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/5.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/50.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/51.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/52.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/53.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/54.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/55.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/56.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/57.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/58.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/59.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/6.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/60.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/61.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/62.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/63.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/64.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/65.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/66.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/67.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/68.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/69.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/7.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/70.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/71.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/72.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/73.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/74.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/75.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/76.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/77.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/78.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/79.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/8.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/80.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/81.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/82.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/83.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/84.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/85.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/86.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/87.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/88.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/89.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/9.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/90.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/91.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/92.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/93.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/94.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/95.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/96.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/97.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/98.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/99.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/index.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/stats.html create mode 100644 2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/style.css (limited to '2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1') diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/0.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/0.html new file mode 100644 index 0000000..b6a66f9 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/0.html @@ -0,0 +1,2469 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
   1
+   2
+   3
+   4
+   5
+   6
+   7
+   8
+   9
+  10
+  11
+  12
+  13
+  14
+  15
+  16
+  17
+  18
+  19
+  20
+  21
+  22
+  23
+  24
+  25
+  26
+  27
+  28
+  29
+  30
+  31
+  32
+  33
+  34
+  35
+  36
+  37
+  38
+  39
+  40
+  41
+  42
+  43
+  44
+  45
+  46
+  47
+  48
+  49
+  50
+  51
+  52
+  53
+  54
+  55
+  56
+  57
+  58
+  59
+  60
+  61
+  62
+  63
+  64
+  65
+  66
+  67
+  68
+  69
+  70
+  71
+  72
+  73
+  74
+  75
+  76
+  77
+  78
+  79
+  80
+  81
+  82
+  83
+  84
+  85
+  86
+  87
+  88
+  89
+  90
+  91
+  92
+  93
+  94
+  95
+  96
+  97
+  98
+  99
+ 100
+ 101
+ 102
+ 103
+ 104
+ 105
+ 106
+ 107
+ 108
+ 109
+ 110
+ 111
+ 112
+ 113
+ 114
+ 115
+ 116
+ 117
+ 118
+ 119
+ 120
+ 121
+ 122
+ 123
+ 124
+ 125
+ 126
+ 127
+ 128
+ 129
+ 130
+ 131
+ 132
+ 133
+ 134
+ 135
+ 136
+ 137
+ 138
+ 139
+ 140
+ 141
+ 142
+ 143
+ 144
+ 145
+ 146
+ 147
+ 148
+ 149
+ 150
+ 151
+ 152
+ 153
+ 154
+ 155
+ 156
+ 157
+ 158
+ 159
+ 160
+ 161
+ 162
+ 163
+ 164
+ 165
+ 166
+ 167
+ 168
+ 169
+ 170
+ 171
+ 172
+ 173
+ 174
+ 175
+ 176
+ 177
+ 178
+ 179
+ 180
+ 181
+ 182
+ 183
+ 184
+ 185
+ 186
+ 187
+ 188
+ 189
+ 190
+ 191
+ 192
+ 193
+ 194
+ 195
+ 196
+ 197
+ 198
+ 199
+ 200
+ 201
+ 202
+ 203
+ 204
+ 205
+ 206
+ 207
+ 208
+ 209
+ 210
+ 211
+ 212
+ 213
+ 214
+ 215
+ 216
+ 217
+ 218
+ 219
+ 220
+ 221
+ 222
+ 223
+ 224
+ 225
+ 226
+ 227
+ 228
+ 229
+ 230
+ 231
+ 232
+ 233
+ 234
+ 235
+ 236
+ 237
+ 238
+ 239
+ 240
+ 241
+ 242
+ 243
+ 244
+ 245
+ 246
+ 247
+ 248
+ 249
+ 250
+ 251
+ 252
+ 253
+ 254
+ 255
+ 256
+ 257
+ 258
+ 259
+ 260
+ 261
+ 262
+ 263
+ 264
+ 265
+ 266
+ 267
+ 268
+ 269
+ 270
+ 271
+ 272
+ 273
+ 274
+ 275
+ 276
+ 277
+ 278
+ 279
+ 280
+ 281
+ 282
+ 283
+ 284
+ 285
+ 286
+ 287
+ 288
+ 289
+ 290
+ 291
+ 292
+ 293
+ 294
+ 295
+ 296
+ 297
+ 298
+ 299
+ 300
+ 301
+ 302
+ 303
+ 304
+ 305
+ 306
+ 307
+ 308
+ 309
+ 310
+ 311
+ 312
+ 313
+ 314
+ 315
+ 316
+ 317
+ 318
+ 319
+ 320
+ 321
+ 322
+ 323
+ 324
+ 325
+ 326
+ 327
+ 328
+ 329
+ 330
+ 331
+ 332
+ 333
+ 334
+ 335
+ 336
+ 337
+ 338
+ 339
+ 340
+ 341
+ 342
+ 343
+ 344
+ 345
+ 346
+ 347
+ 348
+ 349
+ 350
+ 351
+ 352
+ 353
+ 354
+ 355
+ 356
+ 357
+ 358
+ 359
+ 360
+ 361
+ 362
+ 363
+ 364
+ 365
+ 366
+ 367
+ 368
+ 369
+ 370
+ 371
+ 372
+ 373
+ 374
+ 375
+ 376
+ 377
+ 378
+ 379
+ 380
+ 381
+ 382
+ 383
+ 384
+ 385
+ 386
+ 387
+ 388
+ 389
+ 390
+ 391
+ 392
+ 393
+ 394
+ 395
+ 396
+ 397
+ 398
+ 399
+ 400
+ 401
+ 402
+ 403
+ 404
+ 405
+ 406
+ 407
+ 408
+ 409
+ 410
+ 411
+ 412
+ 413
+ 414
+ 415
+ 416
+ 417
+ 418
+ 419
+ 420
+ 421
+ 422
+ 423
+ 424
+ 425
+ 426
+ 427
+ 428
+ 429
+ 430
+ 431
+ 432
+ 433
+ 434
+ 435
+ 436
+ 437
+ 438
+ 439
+ 440
+ 441
+ 442
+ 443
+ 444
+ 445
+ 446
+ 447
+ 448
+ 449
+ 450
+ 451
+ 452
+ 453
+ 454
+ 455
+ 456
+ 457
+ 458
+ 459
+ 460
+ 461
+ 462
+ 463
+ 464
+ 465
+ 466
+ 467
+ 468
+ 469
+ 470
+ 471
+ 472
+ 473
+ 474
+ 475
+ 476
+ 477
+ 478
+ 479
+ 480
+ 481
+ 482
+ 483
+ 484
+ 485
+ 486
+ 487
+ 488
+ 489
+ 490
+ 491
+ 492
+ 493
+ 494
+ 495
+ 496
+ 497
+ 498
+ 499
+ 500
+ 501
+ 502
+ 503
+ 504
+ 505
+ 506
+ 507
+ 508
+ 509
+ 510
+ 511
+ 512
+ 513
+ 514
+ 515
+ 516
+ 517
+ 518
+ 519
+ 520
+ 521
+ 522
+ 523
+ 524
+ 525
+ 526
+ 527
+ 528
+ 529
+ 530
+ 531
+ 532
+ 533
+ 534
+ 535
+ 536
+ 537
+ 538
+ 539
+ 540
+ 541
+ 542
+ 543
+ 544
+ 545
+ 546
+ 547
+ 548
+ 549
+ 550
+ 551
+ 552
+ 553
+ 554
+ 555
+ 556
+ 557
+ 558
+ 559
+ 560
+ 561
+ 562
+ 563
+ 564
+ 565
+ 566
+ 567
+ 568
+ 569
+ 570
+ 571
+ 572
+ 573
+ 574
+ 575
+ 576
+ 577
+ 578
+ 579
+ 580
+ 581
+ 582
+ 583
+ 584
+ 585
+ 586
+ 587
+ 588
+ 589
+ 590
+ 591
+ 592
+ 593
+ 594
+ 595
+ 596
+ 597
+ 598
+ 599
+ 600
+ 601
+ 602
+ 603
+ 604
+ 605
+ 606
+ 607
+ 608
+ 609
+ 610
+ 611
+ 612
+ 613
+ 614
+ 615
+ 616
+ 617
+ 618
+ 619
+ 620
+ 621
+ 622
+ 623
+ 624
+ 625
+ 626
+ 627
+ 628
+ 629
+ 630
+ 631
+ 632
+ 633
+ 634
+ 635
+ 636
+ 637
+ 638
+ 639
+ 640
+ 641
+ 642
+ 643
+ 644
+ 645
+ 646
+ 647
+ 648
+ 649
+ 650
+ 651
+ 652
+ 653
+ 654
+ 655
+ 656
+ 657
+ 658
+ 659
+ 660
+ 661
+ 662
+ 663
+ 664
+ 665
+ 666
+ 667
+ 668
+ 669
+ 670
+ 671
+ 672
+ 673
+ 674
+ 675
+ 676
+ 677
+ 678
+ 679
+ 680
+ 681
+ 682
+ 683
+ 684
+ 685
+ 686
+ 687
+ 688
+ 689
+ 690
+ 691
+ 692
+ 693
+ 694
+ 695
+ 696
+ 697
+ 698
+ 699
+ 700
+ 701
+ 702
+ 703
+ 704
+ 705
+ 706
+ 707
+ 708
+ 709
+ 710
+ 711
+ 712
+ 713
+ 714
+ 715
+ 716
+ 717
+ 718
+ 719
+ 720
+ 721
+ 722
+ 723
+ 724
+ 725
+ 726
+ 727
+ 728
+ 729
+ 730
+ 731
+ 732
+ 733
+ 734
+ 735
+ 736
+ 737
+ 738
+ 739
+ 740
+ 741
+ 742
+ 743
+ 744
+ 745
+ 746
+ 747
+ 748
+ 749
+ 750
+ 751
+ 752
+ 753
+ 754
+ 755
+ 756
+ 757
+ 758
+ 759
+ 760
+ 761
+ 762
+ 763
+ 764
+ 765
+ 766
+ 767
+ 768
+ 769
+ 770
+ 771
+ 772
+ 773
+ 774
+ 775
+ 776
+ 777
+ 778
+ 779
+ 780
+ 781
+ 782
+ 783
+ 784
+ 785
+ 786
+ 787
+ 788
+ 789
+ 790
+ 791
+ 792
+ 793
+ 794
+ 795
+ 796
+ 797
+ 798
+ 799
+ 800
+ 801
+ 802
+ 803
+ 804
+ 805
+ 806
+ 807
+ 808
+ 809
+ 810
+ 811
+ 812
+ 813
+ 814
+ 815
+ 816
+ 817
+ 818
+ 819
+ 820
+ 821
+ 822
+ 823
+ 824
+ 825
+ 826
+ 827
+ 828
+ 829
+ 830
+ 831
+ 832
+ 833
+ 834
+ 835
+ 836
+ 837
+ 838
+ 839
+ 840
+ 841
+ 842
+ 843
+ 844
+ 845
+ 846
+ 847
+ 848
+ 849
+ 850
+ 851
+ 852
+ 853
+ 854
+ 855
+ 856
+ 857
+ 858
+ 859
+ 860
+ 861
+ 862
+ 863
+ 864
+ 865
+ 866
+ 867
+ 868
+ 869
+ 870
+ 871
+ 872
+ 873
+ 874
+ 875
+ 876
+ 877
+ 878
+ 879
+ 880
+ 881
+ 882
+ 883
+ 884
+ 885
+ 886
+ 887
+ 888
+ 889
+ 890
+ 891
+ 892
+ 893
+ 894
+ 895
+ 896
+ 897
+ 898
+ 899
+ 900
+ 901
+ 902
+ 903
+ 904
+ 905
+ 906
+ 907
+ 908
+ 909
+ 910
+ 911
+ 912
+ 913
+ 914
+ 915
+ 916
+ 917
+ 918
+ 919
+ 920
+ 921
+ 922
+ 923
+ 924
+ 925
+ 926
+ 927
+ 928
+ 929
+ 930
+ 931
+ 932
+ 933
+ 934
+ 935
+ 936
+ 937
+ 938
+ 939
+ 940
+ 941
+ 942
+ 943
+ 944
+ 945
+ 946
+ 947
+ 948
+ 949
+ 950
+ 951
+ 952
+ 953
+ 954
+ 955
+ 956
+ 957
+ 958
+ 959
+ 960
+ 961
+ 962
+ 963
+ 964
+ 965
+ 966
+ 967
+ 968
+ 969
+ 970
+ 971
+ 972
+ 973
+ 974
+ 975
+ 976
+ 977
+ 978
+ 979
+ 980
+ 981
+ 982
+ 983
+ 984
+ 985
+ 986
+ 987
+ 988
+ 989
+ 990
+ 991
+ 992
+ 993
+ 994
+ 995
+ 996
+ 997
+ 998
+ 999
+1000
+1001
+1002
+1003
+1004
+1005
+1006
+1007
+1008
+1009
+1010
+1011
+1012
+1013
+1014
+1015
+1016
+1017
+1018
+1019
+1020
+1021
+1022
+1023
+1024
+1025
+1026
+1027
+1028
+1029
+1030
+1031
+1032
+1033
+1034
+1035
+1036
+1037
+1038
+1039
+1040
+1041
+1042
+1043
+1044
+1045
+1046
+1047
+1048
+1049
+1050
+1051
+1052
+1053
+1054
+1055
+1056
+1057
+1058
+1059
+1060
+1061
+1062
+1063
+1064
+1065
+1066
+1067
+1068
+1069
+1070
+1071
+1072
+1073
+1074
+1075
+1076
+1077
+1078
+1079
+1080
+1081
+1082
+1083
+1084
+1085
+1086
+1087
+1088
+1089
+1090
+1091
+1092
+1093
+1094
+1095
+1096
+1097
+1098
+1099
+1100
+1101
+1102
+1103
+1104
+1105
+1106
+1107
+1108
+1109
+1110
+1111
+1112
+1113
+1114
+1115
+1116
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * MATE Power Manager Brightness Applet
+ * Copyright (C) 2006 Benjamin Canou <bookeldor@gmail.com>
+ * Copyright (C) 2007 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+
+#include <stdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <mate-panel-applet.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdk/gdkkeysyms.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <dbus/dbus-glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "gpm-common.h"
+
+#define GPM_TYPE_BRIGHTNESS_APPLET		(gpm_brightness_applet_get_type ())
+#define GPM_BRIGHTNESS_APPLET(o)		(G_TYPE_CHECK_INSTANCE_CAST ((o), GPM_TYPE_BRIGHTNESS_APPLET, GpmBrightnessApplet))
+#define GPM_BRIGHTNESS_APPLET_CLASS(k)		(G_TYPE_CHECK_CLASS_CAST((k), GPM_TYPE_BRIGHTNESS_APPLET, GpmBrightnessAppletClass))
+#define GPM_IS_BRIGHTNESS_APPLET(o)		(G_TYPE_CHECK_INSTANCE_TYPE ((o), GPM_TYPE_BRIGHTNESS_APPLET))
+#define GPM_IS_BRIGHTNESS_APPLET_CLASS(k)	(G_TYPE_CHECK_CLASS_TYPE ((k), GPM_TYPE_BRIGHTNESS_APPLET))
+#define GPM_BRIGHTNESS_APPLET_GET_CLASS(o)	(G_TYPE_INSTANCE_GET_CLASS ((o), GPM_TYPE_BRIGHTNESS_APPLET, GpmBrightnessAppletClass))
+
+typedef struct{
+	MatePanelApplet parent;
+	/* applet state */
+	gboolean call_worked; /* g-p-m refusing action */
+	gboolean popped; /* the popup is shown */
+	/* the popup and its widgets */
+	GtkWidget *popup, *slider, *btn_plus, *btn_minus;
+	/* the icon and a cache for size*/
+	GdkPixbuf *icon;
+	gint icon_width, icon_height;
+	/* connection to g-p-m */
+	DBusGProxy *proxy;
+	DBusGConnection *connection;
+	guint bus_watch_id;
+	guint level;
+	/* a cache for panel size */
+	gint size;
+	/* the slider action delaying */
+	guint slider_delay_id;
+} GpmBrightnessApplet;
+
+typedef struct{
+	MatePanelAppletClass	parent_class;
+} GpmBrightnessAppletClass;
+
+GType                gpm_brightness_applet_get_type  (void);
+
+#define	GPM_DBUS_SERVICE		"org.mate.PowerManager"
+#define	GPM_DBUS_PATH_BACKLIGHT		"/org/mate/PowerManager/Backlight"
+#define	GPM_DBUS_INTERFACE_BACKLIGHT	"org.mate.PowerManager.Backlight"
+
+G_DEFINE_TYPE (GpmBrightnessApplet, gpm_brightness_applet, PANEL_TYPE_APPLET)<--- There is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE is a macro then please configure it.
+
+static void      gpm_applet_get_icon              (GpmBrightnessApplet *applet);
+static void      gpm_applet_check_size            (GpmBrightnessApplet *applet);
+static gboolean  gpm_applet_draw_cb               (GpmBrightnessApplet *applet);
+static void      gpm_applet_change_background_cb  (GpmBrightnessApplet *applet,
+						   MatePanelAppletBackgroundType arg1,
+						   cairo_pattern_t *arg2, gpointer data);
+static void      gpm_applet_theme_change_cb (GtkIconTheme *icon_theme, gpointer data);
+static void      gpm_applet_stop_scroll_events_cb (GtkWidget *widget, GdkEvent  *event);
+static gboolean  gpm_applet_destroy_popup_cb      (GpmBrightnessApplet *applet);
+static void      gpm_applet_update_tooltip        (GpmBrightnessApplet *applet);
+static void      gpm_applet_update_popup_level    (GpmBrightnessApplet *applet);
+static gboolean  gpm_applet_plus_cb               (GtkWidget *w, GpmBrightnessApplet *applet);
+static gboolean  gpm_applet_minus_cb              (GtkWidget *w, GpmBrightnessApplet *applet);
+static gboolean  gpm_applet_key_press_cb          (GtkWidget *popup, GdkEventKey *event, GpmBrightnessApplet *applet);
+static gboolean  gpm_applet_scroll_cb             (GpmBrightnessApplet *applet, GdkEventScroll *event);
+static gboolean  gpm_applet_slide_cb              (GtkWidget *w, GpmBrightnessApplet *applet);
+static void      gpm_applet_create_popup          (GpmBrightnessApplet *applet);
+static gboolean  gpm_applet_popup_cb              (GpmBrightnessApplet *applet, GdkEventButton *event);
+static void      gpm_applet_dialog_about_cb       (GtkAction *action, gpointer data);
+static gboolean  gpm_applet_cb                    (MatePanelApplet *_applet, const gchar *iid, gpointer data);
+static void      gpm_applet_destroy_cb            (GtkWidget *widget);
+
+#define GPM_BRIGHTNESS_APPLET_ID		"BrightnessApplet"
+#define GPM_BRIGHTNESS_APPLET_FACTORY_ID	"BrightnessAppletFactory"
+#define GPM_BRIGHTNESS_APPLET_ICON		"mate-brightness-applet"
+#define GPM_BRIGHTNESS_APPLET_ICON_DISABLED	"gpm-brightness-lcd-disabled"
+#define GPM_BRIGHTNESS_APPLET_ICON_INVALID	"gpm-brightness-lcd-invalid"
+#define GPM_BRIGHTNESS_APPLET_NAME		_("Power Manager Brightness Applet")
+#define GPM_BRIGHTNESS_APPLET_DESC		_("Adjusts laptop panel brightness.")
+#define MATE_PANEL_APPLET_VERTICAL(p)					\
+	 (((p) == MATE_PANEL_APPLET_ORIENT_LEFT) || ((p) == MATE_PANEL_APPLET_ORIENT_RIGHT))
+
+/* The frequency (in milliseconds) at which update the brightness when the UI
+ * slider is moved.  A too short value might lead to freezing the UI, and a
+ * too long one will seem unresponsive. */
+#define GPM_BRIGHTNESS_APPLET_SLIDER_FREQUENCY	100
+
+/**
+ * gpm_applet_get_brightness:
+ * Return value: Success value, or zero for failure
+ **/
+static gboolean
+gpm_applet_get_brightness (GpmBrightnessApplet *applet)
+{
+	GError  *error = NULL;
+	gboolean ret;
+	guint policy_brightness;
+
+	if (applet->proxy == NULL) {
+		g_warning ("not connected\n");
+		return FALSE;
+	}
+
+	ret = dbus_g_proxy_call (applet->proxy, "GetBrightness", &error,
+				 G_TYPE_INVALID,
+				 G_TYPE_UINT, &policy_brightness,
+				 G_TYPE_INVALID);
+	if (error) {
+		g_debug ("ERROR: %s\n", error->message);
+		g_error_free (error);
+	}
+	if (ret) {
+		applet->level = policy_brightness;
+	} else {
+		/* abort as the DBUS method failed */
+		g_warning ("GetBrightness failed!\n");
+	}
+
+	return ret;
+}
+
+/**
+ * gpm_applet_set_brightness:
+ * Return value: Success value, or zero for failure
+ **/
+static gboolean
+gpm_applet_set_brightness (GpmBrightnessApplet *applet)
+{
+	GError  *error = NULL;
+	gboolean ret;
+
+	if (applet->proxy == NULL) {
+		g_warning ("not connected");
+		return FALSE;
+	}
+
+	ret = dbus_g_proxy_call (applet->proxy, "SetBrightness", &error,
+				 G_TYPE_UINT, applet->level,
+				 G_TYPE_INVALID,
+				 G_TYPE_INVALID);
+	if (error) {
+		g_debug ("ERROR: %s", error->message);
+		g_error_free (error);
+	}
+	if (!ret) {
+		/* abort as the DBUS method failed */
+		g_warning ("SetBrightness failed!");
+	}
+
+	return ret;
+}
+
+/**
+ * gpm_applet_get_icon:
+ * @applet: Brightness applet instance
+ *
+ * retrieve an icon from stock with a size adapted to panel
+ **/
+static void
+gpm_applet_get_icon (GpmBrightnessApplet *applet)
+{
+	const gchar *icon;
+
+	/* free */
+	if (applet->icon != NULL) {
+		g_object_unref (applet->icon);
+		applet->icon = NULL;
+	}
+
+	if (applet->size <= 2) {
+		return;
+	}
+
+	/* get icon */
+	if (applet->proxy == NULL) {
+		icon = GPM_BRIGHTNESS_APPLET_ICON_INVALID;
+	} else if (applet->call_worked == FALSE) {
+		icon = GPM_BRIGHTNESS_APPLET_ICON_DISABLED;
+	} else {
+		icon = GPM_BRIGHTNESS_APPLET_ICON;
+	}
+
+	applet->icon = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
+						 icon, applet->size - 2, 0, NULL);
+
+	if (applet->icon == NULL) {
+		g_warning ("Cannot find %s!\n", icon);
+	} else {
+		g_debug ("got icon %s!\n", icon);
+		/* update size cache */
+		applet->icon_height = gdk_pixbuf_get_height (applet->icon);
+		applet->icon_width = gdk_pixbuf_get_width (applet->icon);
+	}
+}
+
+/**
+ * gpm_applet_check_size:
+ * @applet: Brightness applet instance
+ *
+ * check if panel size has changed and applet adapt size
+ **/
+static void
+gpm_applet_check_size (GpmBrightnessApplet *applet)
+{
+	GtkAllocation allocation;
+
+	/* we don't use the size function here, but the yet allocated size because the
+	   size value is false (kind of rounded) */
+	gtk_widget_get_allocation (GTK_WIDGET (applet), &allocation);
+	if (MATE_PANEL_APPLET_VERTICAL(mate_panel_applet_get_orient (MATE_PANEL_APPLET (applet)))) {
+		if (applet->size != allocation.width) {
+			applet->size = allocation.width;
+			gpm_applet_get_icon (applet);
+			gtk_widget_set_size_request (GTK_WIDGET(applet), applet->size, applet->icon_height + 2);
+		}
+	} else {
+		if (applet->size != allocation.height) {
+			applet->size = allocation.height;
+			gpm_applet_get_icon (applet);
+			gtk_widget_set_size_request (GTK_WIDGET(applet), applet->icon_width + 2, applet->size);
+		}
+	}
+}
+
+/**
+ * gpm_applet_draw_cb:
+ * @applet: Brightness applet instance
+ *
+ * draws applet content (background + icon)
+ **/
+static gboolean
+gpm_applet_draw_cb (GpmBrightnessApplet *applet)
+{
+	gint w, h, bg_type;
+	GdkRGBA color;
+	cairo_t *cr;
+	cairo_pattern_t *pattern;
+	GtkStyleContext *context;
+	GtkAllocation allocation;
+
+	if (gtk_widget_get_window (GTK_WIDGET(applet)) == NULL) {
+		return FALSE;
+	}
+
+	/* retrieve applet size */
+	gpm_applet_get_icon (applet);
+	gpm_applet_check_size (applet);
+	if (applet->size <= 2) {
+		return FALSE;
+	}
+
+	/* if no icon, then don't try to display */
+	if (applet->icon == NULL) {
+		return FALSE;
+	}
+
+	gtk_widget_get_allocation (GTK_WIDGET (applet), &allocation);
+	w = allocation.width;
+	h = allocation.height;
+
+	cr = gdk_cairo_create (gtk_widget_get_window (GTK_WIDGET(applet)));
+
+	/* draw pixmap background */
+	bg_type = mate_panel_applet_get_background (MATE_PANEL_APPLET (applet), &color, &pattern);
+	if (bg_type == PANEL_PIXMAP_BACKGROUND && !applet->popped) {
+		/* fill with given background pixmap */
+		cairo_set_source (cr, pattern);
+		cairo_rectangle (cr, 0, 0, w, h);
+		cairo_fill (cr);
+	}
+
+	/* draw color background */
+	if (bg_type == PANEL_COLOR_BACKGROUND && !applet->popped) {
+		gdk_cairo_set_source_rgba (cr, &color);
+		cairo_rectangle (cr, 0, 0, w, h);
+		cairo_fill (cr);
+	}
+
+	/* fill with selected color if popped */
+	if (applet->popped) {
+		context = gtk_widget_get_style_context (GTK_WIDGET(applet));
+		gtk_style_context_get_color (context, GTK_STATE_FLAG_SELECTED, &color);
+		gdk_cairo_set_source_rgba (cr, &color);
+		cairo_rectangle (cr, 0, 0, w, h);
+		cairo_fill (cr);
+	}
+
+	/* draw icon at center */
+	gdk_cairo_set_source_pixbuf (cr, applet->icon, (w - applet->icon_width)/2, (h - applet->icon_height)/2);
+	cairo_paint (cr);
+
+	cairo_destroy (cr);
+
+	return TRUE;
+}
+
+/**
+ * gpm_applet_change_background_cb:
+ *
+ * Enqueues an expose event (don't know why it's not the default behaviour)
+ **/
+static void
+gpm_applet_change_background_cb (GpmBrightnessApplet *applet,
+				 MatePanelAppletBackgroundType arg1,
+				 cairo_pattern_t *arg2, gpointer data)
+{
+	gtk_widget_queue_draw (GTK_WIDGET (applet));
+}
+
+/**
+ * gpm_applet_destroy_popup_cb:
+ * @applet: Brightness applet instance
+ *
+ * destroys the popup (called if orientation has changed)
+ **/
+static gboolean
+gpm_applet_destroy_popup_cb (GpmBrightnessApplet *applet)
+{
+	if (applet->popup != NULL) {
+		gtk_widget_destroy (applet->popup);
+		applet->popup = NULL;
+		applet->popped = FALSE;
+		gpm_applet_update_tooltip (applet);
+	}
+	return TRUE;
+}
+
+/**
+ * gpm_applet_update_tooltip:
+ * @applet: Brightness applet instance
+ *
+ * sets tooltip's content (percentage or disabled)
+ **/
+static void
+gpm_applet_update_tooltip (GpmBrightnessApplet *applet)
+{
+	gchar *buf = NULL;
+	if (applet->popped == FALSE) {
+		if (applet->proxy == NULL) {
+			buf = g_strdup (_("Cannot connect to mate-power-manager"));
+		} else if (applet->call_worked == FALSE) {
+			buf = g_strdup (_("Cannot get laptop panel brightness"));
+		} else {
+			buf = g_strdup_printf (_("LCD brightness : %u%%"), applet->level);
+		}
+		gtk_widget_set_tooltip_text (GTK_WIDGET(applet), buf);
+	} else {
+		gtk_widget_set_tooltip_text (GTK_WIDGET(applet), NULL);
+	}
+	g_free (buf);
+}
+
+/**
+ * gpm_applet_update_popup_level:
+ * @applet: Brightness applet instance
+ * @get_hw: set UI value from HW value
+ * @set_hw: set HW value from UI value
+ *
+ * updates popup and hardware level of brightness
+ * FALSE FAlSE -> set UI from cached value
+ * TRUE  FAlSE -> set UI from HW value
+ * TRUE  FALSE -> set HW from UI value, then set UI from HW value
+ * FALSE TRUE  -> set HW from UI value
+ **/
+static void
+gpm_applet_update_popup_level (GpmBrightnessApplet *applet)
+{
+	if (applet->popup != NULL) {
+		gtk_widget_set_sensitive (applet->btn_plus, applet->level < 100);
+		gtk_widget_set_sensitive (applet->btn_minus, applet->level > 0);
+		gtk_range_set_value (GTK_RANGE(applet->slider), (guint) applet->level);
+	}
+	gpm_applet_update_tooltip (applet);
+}
+
+/**
+ * gpm_applet_plus_cb:
+ * @widget: The sending widget (plus button)
+ * @applet: Brightness applet instance
+ *
+ * callback for the plus button
+ **/
+static gboolean
+gpm_applet_plus_cb (GtkWidget *w, GpmBrightnessApplet *applet)
+{
+	if (applet->level < 100) {
+		applet->level++;
+	}
+	applet->call_worked = gpm_applet_set_brightness (applet);
+	gpm_applet_update_popup_level (applet);
+	return TRUE;
+}
+
+/**
+ * gpm_applet_minus_cb:
+ * @widget: The sending widget (minus button)
+ * @applet: Brightness applet instance
+ *
+ * callback for the minus button
+ **/
+static gboolean
+gpm_applet_minus_cb (GtkWidget *w, GpmBrightnessApplet *applet)
+{
+	if (applet->level > 0) {
+		applet->level--;
+	}
+	applet->call_worked = gpm_applet_set_brightness (applet);
+	gpm_applet_update_popup_level (applet);
+	return TRUE;
+}
+
+/**
+ * gpm_applet_slide_delayed_cb:
+ * @data: Brightness applet instance
+ *
+ * callback for the delayed slider changes, actually performing the DBus call
+ **/
+static gboolean
+gpm_applet_slide_delayed_cb (gpointer data)
+{
+	GpmBrightnessApplet *applet = data;
+
+	applet->call_worked = gpm_applet_set_brightness (applet);
+	gpm_applet_update_popup_level (applet);
+	applet->slider_delay_id = 0;
+
+	return FALSE;
+}
+
+/**
+ * gpm_applet_slide_cb:
+ * @widget: The sending widget (slider)
+ * @applet: Brightness applet instance
+ *
+ * callback for the slider
+ **/
+static gboolean
+gpm_applet_slide_cb (GtkWidget *w, GpmBrightnessApplet *applet)
+{
+	applet->level = gtk_range_get_value (GTK_RANGE(applet->slider));
+	/* we delay applying the new value to improve reactivity, because the
+	 * DBus call might be slow (and we don't want to spam the bus either) */
+	if (! applet->slider_delay_id)
+		applet->slider_delay_id = g_timeout_add (GPM_BRIGHTNESS_APPLET_SLIDER_FREQUENCY,
+							 gpm_applet_slide_delayed_cb, applet);
+	return TRUE;
+}
+
+/**
+ * gpm_applet_slide_cb:
+ * @applet: Brightness applet instance
+ * @event: The key press event
+ *
+ * callback handling keyboard
+ * mainly escape to unpop and arrows to change brightness
+ **/
+static gboolean
+gpm_applet_key_press_cb (GtkWidget *popup, GdkEventKey *event, GpmBrightnessApplet *applet)
+{
+	int i;
+
+	switch (event->keyval) {
+	case GDK_KEY_KP_Enter:
+	case GDK_KEY_ISO_Enter:
+	case GDK_KEY_3270_Enter:
+	case GDK_KEY_Return:
+	case GDK_KEY_space:
+	case GDK_KEY_KP_Space:
+	case GDK_KEY_Escape:
+		/* if yet popped, hide */
+		if (applet->popped) {
+			gtk_widget_hide (applet->popup);
+			applet->popped = FALSE;
+			gpm_applet_update_tooltip (applet);
+			return TRUE;
+		} else {
+			return FALSE;
+		}
+		break;
+	case GDK_KEY_Page_Up:
+		for (i = 0;i < 10;i++) {
+			gpm_applet_plus_cb (NULL, applet);
+		}
+		return TRUE;
+		break;
+	case GDK_KEY_Left:
+	case GDK_KEY_Up:
+		gpm_applet_plus_cb (NULL, applet);
+		return TRUE;
+		break;
+	case GDK_KEY_Page_Down:
+		for (i = 0;i < 10;i++) {
+			gpm_applet_minus_cb (NULL, applet);
+		}
+		return TRUE;
+		break;
+	case GDK_KEY_Right:
+	case GDK_KEY_Down:
+		gpm_applet_minus_cb (NULL, applet);
+		return TRUE;
+		break;
+	default:
+		return FALSE;
+		break;
+	}
+
+	return FALSE;
+}
+
+/**
+ * gpm_applet_scroll_cb:
+ * @applet: Brightness applet instance
+ * @event: The scroll event
+ *
+ * callback handling mouse scrolls, either when the applet
+ * is not popped and the mouse is over the applet, or when
+ * the applet is popped and no matter where the mouse is.
+ **/
+static gboolean
+gpm_applet_scroll_cb (GpmBrightnessApplet *applet, GdkEventScroll *event)
+{
+	int i;
+
+	if (event->type == GDK_SCROLL) {
+		if (event->direction == GDK_SCROLL_UP) {
+			for (i = 0;i < 5;i++) {
+				gpm_applet_plus_cb (NULL, applet);
+			}
+
+		} else {
+			for (i = 0;i < 5;i++) {
+				gpm_applet_minus_cb (NULL, applet);
+			}
+		}
+		return TRUE;
+	}
+
+	return FALSE;
+}
+
+/**
+ * on_popup_button_press:
+ * @applet: Brightness applet instance
+ * @event: The button press event
+ *
+ * hide popup on focus loss.
+ **/
+static gboolean
+on_popup_button_press (GtkWidget      *widget,
+                       GdkEventButton *event,
+                       GpmBrightnessApplet *applet)
+{
+	GtkWidget *event_widget;
+
+	if (event->type != GDK_BUTTON_PRESS) {
+		return FALSE;
+	}
+	event_widget = gtk_get_event_widget ((GdkEvent *)event);
+	g_debug ("Button press: %p dock=%p", event_widget, widget);
+	if (event_widget == widget) {
+		gtk_widget_hide (applet->popup);
+		applet->popped = FALSE;
+		gpm_applet_update_tooltip (applet);
+		return TRUE;
+	}
+
+	return FALSE;
+}
+
+/**
+ * gpm_applet_create_popup:
+ * @applet: Brightness applet instance
+ *
+ * cretes a new popup according to orientation of panel
+ **/
+static void
+gpm_applet_create_popup (GpmBrightnessApplet *applet)
+{
+	static GtkWidget *box, *frame;
+	GtkWidget       *toplevel;
+	GtkStyleContext *context;
+	GdkScreen       *screen;
+	GdkVisual       *visual;
+	gint orientation = mate_panel_applet_get_orient (MATE_PANEL_APPLET (MATE_PANEL_APPLET (applet)));
+
+	gpm_applet_destroy_popup_cb (applet);
+
+	/* slider */
+	if (MATE_PANEL_APPLET_VERTICAL(orientation)) {
+		applet->slider = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, 0, 100, 1);
+		gtk_widget_set_size_request (applet->slider, 100, -1);
+	} else {
+		applet->slider = gtk_scale_new_with_range (GTK_ORIENTATION_VERTICAL, 0, 100, 1);
+		gtk_widget_set_size_request (applet->slider, -1, 100);
+	}
+	gtk_range_set_inverted (GTK_RANGE(applet->slider), TRUE);
+	gtk_scale_set_draw_value (GTK_SCALE(applet->slider), FALSE);
+	gtk_range_set_value (GTK_RANGE(applet->slider), applet->level);
+	g_signal_connect (G_OBJECT(applet->slider), "value-changed", G_CALLBACK(gpm_applet_slide_cb), applet);
+
+	/* minus button */
+	applet->btn_minus = gtk_button_new_with_label ("\342\210\222"); /* U+2212 MINUS SIGN */
+	gtk_button_set_relief (GTK_BUTTON(applet->btn_minus), GTK_RELIEF_NONE);
+	gtk_widget_set_can_focus (applet->btn_minus, FALSE);
+	g_signal_connect (G_OBJECT(applet->btn_minus), "pressed", G_CALLBACK(gpm_applet_minus_cb), applet);
+
+	/* plus button */
+	applet->btn_plus = gtk_button_new_with_label ("+");
+	gtk_button_set_relief (GTK_BUTTON(applet->btn_plus), GTK_RELIEF_NONE);
+	gtk_widget_set_can_focus (applet->btn_plus, FALSE);
+	g_signal_connect (G_OBJECT(applet->btn_plus), "pressed", G_CALLBACK(gpm_applet_plus_cb), applet);
+
+	/* box */
+	if (MATE_PANEL_APPLET_VERTICAL(orientation)) {
+		box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 1);
+	} else {
+		box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 1);
+	}
+	gtk_box_pack_start (GTK_BOX(box), applet->btn_plus, FALSE, FALSE, 0);
+	gtk_box_pack_start (GTK_BOX(box), applet->slider, TRUE, TRUE, 0);
+	gtk_box_pack_start (GTK_BOX(box), applet->btn_minus, FALSE, FALSE, 0);
+
+	/* frame */
+	frame = gtk_frame_new (NULL);
+	gtk_frame_set_shadow_type (GTK_FRAME(frame), GTK_SHADOW_OUT);
+	gtk_container_add (GTK_CONTAINER(frame), box);
+
+	/* window */
+	applet->popup = gtk_window_new (GTK_WINDOW_POPUP);
+	gtk_window_set_type_hint (GTK_WINDOW(applet->popup), GDK_WINDOW_TYPE_HINT_UTILITY);
+	gtk_container_add (GTK_CONTAINER(applet->popup), frame);
+
+	/* window events */
+	g_signal_connect (G_OBJECT(applet->popup), "button-press-event",
+	                  G_CALLBACK (on_popup_button_press), applet);
+
+	g_signal_connect (G_OBJECT(applet->popup), "key-press-event",
+	                  G_CALLBACK(gpm_applet_key_press_cb), applet);
+
+	/* Set volume control frame, slider and toplevel window to follow panel volume control theme */
+	toplevel = gtk_widget_get_toplevel (frame);
+	context = gtk_widget_get_style_context (GTK_WIDGET(toplevel));
+	gtk_style_context_add_class(context,"mate-panel-applet-slider");
+	/*Make transparency possible in gtk3 theme3 */
+	screen = gtk_widget_get_screen(GTK_WIDGET(toplevel));
+	visual = gdk_screen_get_rgba_visual(screen);
+	gtk_widget_set_visual(GTK_WIDGET(toplevel), visual);
+}
+
+/**
+ * gpm_applet_popup_cb:
+ * @applet: Brightness applet instance
+ *
+ * pops and unpops
+ **/
+static gboolean
+gpm_applet_popup_cb (GpmBrightnessApplet *applet, GdkEventButton *event)
+{
+	GtkAllocation allocation, popup_allocation;
+	gint orientation, x, y;
+	GdkWindow *window;
+	GdkDisplay *display;
+	GdkSeat *seat;
+
+	/* react only to left mouse button */
+	if (event->button != 1) {
+		return FALSE;
+	}
+
+	/* if yet popped, release focus and hide */
+	if (applet->popped) {
+		gtk_widget_hide (applet->popup);
+		applet->popped = FALSE;
+		gpm_applet_update_tooltip (applet);
+		return TRUE;
+	}
+
+	/* otherwise pop */
+	applet->popped = TRUE;
+
+	/* create a new popup (initial or if panel parameters changed) */
+	if (applet->popup == NULL) {
+		gpm_applet_create_popup (applet);
+	}
+
+	/* update UI for current brightness */
+	gpm_applet_update_popup_level (applet);
+
+	gtk_widget_show_all (applet->popup);
+
+	/* retrieve geometry parameters and move window appropriately */
+	orientation = mate_panel_applet_get_orient (MATE_PANEL_APPLET (MATE_PANEL_APPLET (applet)));
+	gdk_window_get_origin (gtk_widget_get_window (GTK_WIDGET(applet)), &x, &y);
+
+	gtk_widget_get_allocation (GTK_WIDGET (applet), &allocation);
+	gtk_widget_get_allocation (GTK_WIDGET (applet->popup), &popup_allocation);
+	switch (orientation) {
+	case MATE_PANEL_APPLET_ORIENT_DOWN:
+		x += allocation.x + allocation.width/2;
+		y += allocation.y + allocation.height;
+		x -= popup_allocation.width/2;
+		break;
+	case MATE_PANEL_APPLET_ORIENT_UP:
+		x += allocation.x + allocation.width/2;
+		y += allocation.y;
+		x -= popup_allocation.width/2;
+		y -= popup_allocation.height;
+		break;
+	case MATE_PANEL_APPLET_ORIENT_RIGHT:
+		y += allocation.y + allocation.height/2;
+		x += allocation.x + allocation.width;
+		y -= popup_allocation.height/2;
+		break;
+	case MATE_PANEL_APPLET_ORIENT_LEFT:
+		y += allocation.y + allocation.height/2;
+		x += allocation.x;
+		x -= popup_allocation.width;
+		y -= popup_allocation.height/2;
+		break;
+	default:
+		g_assert_not_reached ();
+	}
+
+	gtk_window_move (GTK_WINDOW (applet->popup), x, y);
+
+	/* grab input */
+	window = gtk_widget_get_window (GTK_WIDGET (applet->popup));
+	display = gdk_window_get_display (window);
+	seat = gdk_display_get_default_seat (display);
+	gdk_seat_grab (seat,
+	               window,
+	               GDK_SEAT_CAPABILITY_ALL,
+	               TRUE,
+	               NULL,
+	               NULL,
+	               NULL,
+	               NULL);
+
+	return TRUE;
+}
+
+/**
+ * gpm_applet_theme_change_cb:
+ *
+ * Updtes icon when theme changes
+ **/
+static void
+gpm_applet_theme_change_cb (GtkIconTheme *icon_theme, gpointer data)
+{
+	GpmBrightnessApplet *applet = GPM_BRIGHTNESS_APPLET (data);
+	gpm_applet_get_icon (applet);
+}
+
+/**
+ * gpm_applet_stop_scroll_events_cb:
+ *
+ * Prevents scroll events from reaching the tooltip
+ **/
+static void
+gpm_applet_stop_scroll_events_cb (GtkWidget *widget, GdkEvent  *event)
+{
+	if (event->type == GDK_SCROLL)
+		g_signal_stop_emission_by_name (widget, "event-after");
+}
+
+/**
+ * gpm_applet_dialog_about_cb:
+ *
+ * displays about dialog
+ **/
+static void
+gpm_applet_dialog_about_cb (GtkAction *action, gpointer data)
+{
+	static const gchar *authors[] = {
+		"Benjamin Canou <bookeldor@gmail.com>",
+		"Richard Hughes <richard@hughsie.com>",
+		NULL
+	};
+
+	const char *documenters [] = {
+		NULL
+	};
+
+	const char *license[] = {
+		 N_("Power Manager is free software; you can redistribute it and/or "
+		   "modify it under the terms of the GNU General Public License "
+		   "as published by the Free Software Foundation; either version 2 "
+		   "of the License, or (at your option) any later version."),
+
+		 N_("Power Manager is distributed in the hope that it will be useful, "
+		   "but WITHOUT ANY WARRANTY; without even the implied warranty of "
+		   "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the "
+		   "GNU General Public License for more details."),
+
+		 N_("You should have received a copy of the GNU General Public License "
+		   "along with this program; if not, write to the Free Software "
+		   "Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA "
+		   "02110-1301, USA.")
+	};
+
+	char *license_trans;
+
+	license_trans = g_strjoin("\n\n", _(license[0]), _(license[1]), _(license[2]), NULL);
+
+	gtk_show_about_dialog (NULL,
+	                       "program-name", GPM_BRIGHTNESS_APPLET_NAME,
+	                       "version", VERSION,
+	                       "title", _("About Power Manager Brightness Applet"),
+	                       "comments", GPM_BRIGHTNESS_APPLET_DESC,
+	                       "copyright", _("Copyright \xC2\xA9 2006 Benjamin Canou\n"
+	                                      "Copyright \xC2\xA9 2011-2021 MATE developers"),
+	                       "icon-name", GPM_BRIGHTNESS_APPLET_ICON,
+	                       "logo-icon-name", GPM_BRIGHTNESS_APPLET_ICON,
+	                       "license", license_trans,
+	                       "authors", authors,
+	                       "documenters", documenters,
+	                       "translator-credits", _("translator-credits"),
+	                       "wrap-license", TRUE,
+	                       "website", PACKAGE_URL,
+	                       NULL);
+
+	g_free (license_trans);
+}
+
+/**
+ * gpm_applet_help_cb:
+ *
+ * open gpm help
+ **/
+static void
+gpm_applet_help_cb (GtkAction *action, gpointer data)
+{
+	gpm_help_display ("applets-general#applets-brightness");
+}
+
+/**
+ * gpm_applet_destroy_cb:
+ * @widget: Class instance to destroy
+ **/
+static void
+gpm_applet_destroy_cb (GtkWidget *widget)
+{
+	GpmBrightnessApplet *applet = GPM_BRIGHTNESS_APPLET(widget);
+
+	if (applet->slider_delay_id) {
+		g_source_remove (applet->slider_delay_id);
+		applet->slider_delay_id = 0;
+	}
+
+	g_bus_unwatch_name (applet->bus_watch_id);
+	if (applet->icon != NULL)
+		g_object_unref (applet->icon);
+}
+
+/**
+ * gpm_brightness_applet_class_init:
+ * @klass: Class instance
+ **/
+static void
+gpm_brightness_applet_class_init (GpmBrightnessAppletClass *class)
+{
+	/* nothing to do here */
+}
+
+static void
+brightness_changed_cb (DBusGProxy          *proxy,
+		       guint	            brightness,
+		       GpmBrightnessApplet *applet)
+{
+	g_debug ("BrightnessChanged detected: %u\n", brightness);
+	applet->level = brightness;
+}
+
+/**
+ * gpm_brightness_applet_dbus_connect:
+ **/
+static gboolean
+gpm_brightness_applet_dbus_connect (GpmBrightnessApplet *applet)
+{
+	GError *error = NULL;
+
+	if (applet->connection == NULL) {
+		g_debug ("get connection\n");
+		g_clear_error (&error);
+		applet->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+		if (error != NULL) {
+			g_warning ("Could not connect to DBUS daemon: %s", error->message);
+			g_error_free (error);
+			applet->connection = NULL;
+			return FALSE;
+		}
+	}
+	if (applet->proxy == NULL) {
+		g_debug ("get proxy\n");
+		g_clear_error (&error);
+		applet->proxy = dbus_g_proxy_new_for_name_owner (applet->connection,
+							 GPM_DBUS_SERVICE,
+							 GPM_DBUS_PATH_BACKLIGHT,
+							 GPM_DBUS_INTERFACE_BACKLIGHT,
+							 &error);
+		if (error != NULL) {
+			g_warning ("Cannot connect, maybe the daemon is not running: %s\n", error->message);
+			g_error_free (error);
+			applet->proxy = NULL;
+			return FALSE;
+		}
+		dbus_g_proxy_add_signal (applet->proxy, "BrightnessChanged",
+					 G_TYPE_UINT, G_TYPE_INVALID);
+		dbus_g_proxy_connect_signal (applet->proxy, "BrightnessChanged",
+					     G_CALLBACK (brightness_changed_cb),
+					     applet, NULL);
+		/* reset, we might be starting race */
+		applet->call_worked = gpm_applet_get_brightness (applet);
+	}
+	return TRUE;
+}
+
+/**
+ * gpm_brightness_applet_dbus_disconnect:
+ **/
+static gboolean
+gpm_brightness_applet_dbus_disconnect (GpmBrightnessApplet *applet)
+{
+	if (applet->proxy != NULL) {
+		g_debug ("removing proxy\n");
+		g_object_unref (applet->proxy);
+		applet->proxy = NULL;
+	}
+	return TRUE;
+}
+
+/**
+ * gpm_brightness_applet_name_appeared_cb:
+ **/
+static void
+gpm_brightness_applet_name_appeared_cb (GDBusConnection *connection,
+					const gchar *name,
+					const gchar *name_owner,
+					GpmBrightnessApplet *applet)
+{
+	gpm_brightness_applet_dbus_connect (applet);
+	gpm_applet_update_tooltip (applet);
+	gpm_applet_draw_cb (applet);
+}
+
+/**
+ * gpm_brightness_applet_name_vanished_cb:
+ **/
+static void
+gpm_brightness_applet_name_vanished_cb (GDBusConnection *connection,
+					 const gchar *name,
+					 GpmBrightnessApplet *applet)
+{
+	gpm_brightness_applet_dbus_disconnect (applet);
+	gpm_applet_update_tooltip (applet);
+	gpm_applet_draw_cb (applet);
+}
+
+/**
+ * gpm_brightness_applet_init:
+ * @applet: Brightness applet instance
+ **/
+static void
+gpm_brightness_applet_init (GpmBrightnessApplet *applet)
+{
+	/* initialize fields */
+	applet->size = 0;
+	applet->call_worked = TRUE;
+	applet->popped = FALSE;
+	applet->popup = NULL;
+	applet->icon = NULL;
+	applet->connection = NULL;
+	applet->proxy = NULL;
+	applet->slider_delay_id = 0;
+
+	/* Add application specific icons to search path */
+	gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (),
+	                                   GPM_ICONS_DATA);
+
+	/* monitor the daemon */
+	applet->bus_watch_id =
+		g_bus_watch_name (G_BUS_TYPE_SESSION,
+				  GPM_DBUS_SERVICE,
+				  G_BUS_NAME_WATCHER_FLAGS_NONE,
+				  (GBusNameAppearedCallback) gpm_brightness_applet_name_appeared_cb,
+				  (GBusNameVanishedCallback) gpm_brightness_applet_name_vanished_cb,
+				  applet, NULL);
+
+	/* coldplug */
+	applet->call_worked = gpm_applet_get_brightness (applet);
+	gpm_applet_update_popup_level (applet);
+
+	/* prepare */
+	mate_panel_applet_set_flags (MATE_PANEL_APPLET (applet), MATE_PANEL_APPLET_EXPAND_MINOR);
+	gtk_widget_set_events (GTK_WIDGET (applet), GDK_SCROLL_MASK);
+
+	/* show */
+	gtk_widget_show_all (GTK_WIDGET(applet));
+
+	/* set appropriate size and load icon accordingly */
+	gpm_applet_draw_cb (applet);
+
+	/* connect */
+	g_signal_connect (G_OBJECT(applet), "button-press-event",
+			  G_CALLBACK(gpm_applet_popup_cb), NULL);
+
+	g_signal_connect (G_OBJECT(applet), "scroll-event",
+			  G_CALLBACK(gpm_applet_scroll_cb), NULL);
+
+	/* We use g_signal_connect_after because letting the panel draw
+	 * the background is the only way to have the correct
+	 * background when a theme defines a background picture. */
+	g_signal_connect_after (G_OBJECT(applet), "draw",
+				G_CALLBACK(gpm_applet_draw_cb), NULL);
+
+	g_signal_connect (G_OBJECT(applet), "change-background",
+			  G_CALLBACK(gpm_applet_change_background_cb), NULL);
+
+	g_signal_connect (G_OBJECT(applet), "change-orient",
+			  G_CALLBACK(gpm_applet_draw_cb), NULL);
+
+	g_signal_connect (G_OBJECT(applet), "change-orient",
+			  G_CALLBACK(gpm_applet_destroy_popup_cb), NULL);
+
+	g_signal_connect (G_OBJECT(applet), "destroy",
+			  G_CALLBACK(gpm_applet_destroy_cb), NULL);
+
+	/* prevent scroll events from reaching the tooltip */
+	g_signal_connect (G_OBJECT (applet), "event-after", G_CALLBACK (gpm_applet_stop_scroll_events_cb), NULL);
+
+	g_signal_connect (gtk_icon_theme_get_default (), "changed", G_CALLBACK (gpm_applet_theme_change_cb), applet);
+}
+
+/**
+ * gpm_applet_cb:
+ * @_applet: GpmBrightnessApplet instance created by the applet factory
+ * @iid: Applet id
+ *
+ * the function called by libmate-panel-applet factory after creation
+ **/
+static gboolean
+gpm_applet_cb (MatePanelApplet *_applet, const gchar *iid, gpointer data)
+{
+	GpmBrightnessApplet *applet = GPM_BRIGHTNESS_APPLET(_applet);
+	GtkActionGroup *action_group;
+
+	static const GtkActionEntry menu_actions [] = {
+		{ "About", "help-about", N_("_About"),
+		  NULL, NULL,
+		  G_CALLBACK (gpm_applet_dialog_about_cb) },
+		{ "Help", "help-browser", N_("_Help"),
+		  NULL, NULL,
+		  G_CALLBACK (gpm_applet_help_cb) }
+	};
+
+	if (strcmp (iid, GPM_BRIGHTNESS_APPLET_ID) != 0) {
+		return FALSE;
+	}
+
+	action_group = gtk_action_group_new ("Brightness Applet Actions");
+	gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
+	gtk_action_group_add_actions (action_group,
+				      menu_actions,
+				      G_N_ELEMENTS (menu_actions),
+				      applet);
+	mate_panel_applet_setup_menu_from_file (MATE_PANEL_APPLET (applet),
+	                                        BRIGHTNESS_MENU_UI_DIR "/brightness-applet-menu.xml",
+	                                        action_group);
+	g_object_unref (action_group);
+
+	gpm_applet_draw_cb (applet);
+	return TRUE;
+}
+
+/**
+ * this generates a main with a applet factory
+ **/
+MATE_PANEL_APPLET_OUT_PROCESS_FACTORY
+ (/* the factory iid */
+ GPM_BRIGHTNESS_APPLET_FACTORY_ID,
+ /* generates brighness applets instead of regular mate applets  */
+ GPM_TYPE_BRIGHTNESS_APPLET,
+ /* the applet name */
+ "BrightnessApplet",
+ /* our callback (with no user data) */
+ gpm_applet_cb, NULL);
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/1.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/1.html new file mode 100644 index 0000000..d60d987 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/1.html @@ -0,0 +1,311 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2005-2007 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __GPMCOMMON_H
+#define __GPMCOMMON_H
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+G_BEGIN_DECLS
+
+void 		 gpm_help_display				(const gchar	*link_id);
+#ifdef EGG_TEST
+void		 gpm_common_test				(gpointer	 data);
+#endif
+
+G_END_DECLS
+
+#endif	/* __GPMCOMMON_H */
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/10.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/10.html new file mode 100644 index 0000000..7e5c7c9 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/10.html @@ -0,0 +1,6753 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
   1
+   2
+   3
+   4
+   5
+   6
+   7
+   8
+   9
+  10
+  11
+  12
+  13
+  14
+  15
+  16
+  17
+  18
+  19
+  20
+  21
+  22
+  23
+  24
+  25
+  26
+  27
+  28
+  29
+  30
+  31
+  32
+  33
+  34
+  35
+  36
+  37
+  38
+  39
+  40
+  41
+  42
+  43
+  44
+  45
+  46
+  47
+  48
+  49
+  50
+  51
+  52
+  53
+  54
+  55
+  56
+  57
+  58
+  59
+  60
+  61
+  62
+  63
+  64
+  65
+  66
+  67
+  68
+  69
+  70
+  71
+  72
+  73
+  74
+  75
+  76
+  77
+  78
+  79
+  80
+  81
+  82
+  83
+  84
+  85
+  86
+  87
+  88
+  89
+  90
+  91
+  92
+  93
+  94
+  95
+  96
+  97
+  98
+  99
+ 100
+ 101
+ 102
+ 103
+ 104
+ 105
+ 106
+ 107
+ 108
+ 109
+ 110
+ 111
+ 112
+ 113
+ 114
+ 115
+ 116
+ 117
+ 118
+ 119
+ 120
+ 121
+ 122
+ 123
+ 124
+ 125
+ 126
+ 127
+ 128
+ 129
+ 130
+ 131
+ 132
+ 133
+ 134
+ 135
+ 136
+ 137
+ 138
+ 139
+ 140
+ 141
+ 142
+ 143
+ 144
+ 145
+ 146
+ 147
+ 148
+ 149
+ 150
+ 151
+ 152
+ 153
+ 154
+ 155
+ 156
+ 157
+ 158
+ 159
+ 160
+ 161
+ 162
+ 163
+ 164
+ 165
+ 166
+ 167
+ 168
+ 169
+ 170
+ 171
+ 172
+ 173
+ 174
+ 175
+ 176
+ 177
+ 178
+ 179
+ 180
+ 181
+ 182
+ 183
+ 184
+ 185
+ 186
+ 187
+ 188
+ 189
+ 190
+ 191
+ 192
+ 193
+ 194
+ 195
+ 196
+ 197
+ 198
+ 199
+ 200
+ 201
+ 202
+ 203
+ 204
+ 205
+ 206
+ 207
+ 208
+ 209
+ 210
+ 211
+ 212
+ 213
+ 214
+ 215
+ 216
+ 217
+ 218
+ 219
+ 220
+ 221
+ 222
+ 223
+ 224
+ 225
+ 226
+ 227
+ 228
+ 229
+ 230
+ 231
+ 232
+ 233
+ 234
+ 235
+ 236
+ 237
+ 238
+ 239
+ 240
+ 241
+ 242
+ 243
+ 244
+ 245
+ 246
+ 247
+ 248
+ 249
+ 250
+ 251
+ 252
+ 253
+ 254
+ 255
+ 256
+ 257
+ 258
+ 259
+ 260
+ 261
+ 262
+ 263
+ 264
+ 265
+ 266
+ 267
+ 268
+ 269
+ 270
+ 271
+ 272
+ 273
+ 274
+ 275
+ 276
+ 277
+ 278
+ 279
+ 280
+ 281
+ 282
+ 283
+ 284
+ 285
+ 286
+ 287
+ 288
+ 289
+ 290
+ 291
+ 292
+ 293
+ 294
+ 295
+ 296
+ 297
+ 298
+ 299
+ 300
+ 301
+ 302
+ 303
+ 304
+ 305
+ 306
+ 307
+ 308
+ 309
+ 310
+ 311
+ 312
+ 313
+ 314
+ 315
+ 316
+ 317
+ 318
+ 319
+ 320
+ 321
+ 322
+ 323
+ 324
+ 325
+ 326
+ 327
+ 328
+ 329
+ 330
+ 331
+ 332
+ 333
+ 334
+ 335
+ 336
+ 337
+ 338
+ 339
+ 340
+ 341
+ 342
+ 343
+ 344
+ 345
+ 346
+ 347
+ 348
+ 349
+ 350
+ 351
+ 352
+ 353
+ 354
+ 355
+ 356
+ 357
+ 358
+ 359
+ 360
+ 361
+ 362
+ 363
+ 364
+ 365
+ 366
+ 367
+ 368
+ 369
+ 370
+ 371
+ 372
+ 373
+ 374
+ 375
+ 376
+ 377
+ 378
+ 379
+ 380
+ 381
+ 382
+ 383
+ 384
+ 385
+ 386
+ 387
+ 388
+ 389
+ 390
+ 391
+ 392
+ 393
+ 394
+ 395
+ 396
+ 397
+ 398
+ 399
+ 400
+ 401
+ 402
+ 403
+ 404
+ 405
+ 406
+ 407
+ 408
+ 409
+ 410
+ 411
+ 412
+ 413
+ 414
+ 415
+ 416
+ 417
+ 418
+ 419
+ 420
+ 421
+ 422
+ 423
+ 424
+ 425
+ 426
+ 427
+ 428
+ 429
+ 430
+ 431
+ 432
+ 433
+ 434
+ 435
+ 436
+ 437
+ 438
+ 439
+ 440
+ 441
+ 442
+ 443
+ 444
+ 445
+ 446
+ 447
+ 448
+ 449
+ 450
+ 451
+ 452
+ 453
+ 454
+ 455
+ 456
+ 457
+ 458
+ 459
+ 460
+ 461
+ 462
+ 463
+ 464
+ 465
+ 466
+ 467
+ 468
+ 469
+ 470
+ 471
+ 472
+ 473
+ 474
+ 475
+ 476
+ 477
+ 478
+ 479
+ 480
+ 481
+ 482
+ 483
+ 484
+ 485
+ 486
+ 487
+ 488
+ 489
+ 490
+ 491
+ 492
+ 493
+ 494
+ 495
+ 496
+ 497
+ 498
+ 499
+ 500
+ 501
+ 502
+ 503
+ 504
+ 505
+ 506
+ 507
+ 508
+ 509
+ 510
+ 511
+ 512
+ 513
+ 514
+ 515
+ 516
+ 517
+ 518
+ 519
+ 520
+ 521
+ 522
+ 523
+ 524
+ 525
+ 526
+ 527
+ 528
+ 529
+ 530
+ 531
+ 532
+ 533
+ 534
+ 535
+ 536
+ 537
+ 538
+ 539
+ 540
+ 541
+ 542
+ 543
+ 544
+ 545
+ 546
+ 547
+ 548
+ 549
+ 550
+ 551
+ 552
+ 553
+ 554
+ 555
+ 556
+ 557
+ 558
+ 559
+ 560
+ 561
+ 562
+ 563
+ 564
+ 565
+ 566
+ 567
+ 568
+ 569
+ 570
+ 571
+ 572
+ 573
+ 574
+ 575
+ 576
+ 577
+ 578
+ 579
+ 580
+ 581
+ 582
+ 583
+ 584
+ 585
+ 586
+ 587
+ 588
+ 589
+ 590
+ 591
+ 592
+ 593
+ 594
+ 595
+ 596
+ 597
+ 598
+ 599
+ 600
+ 601
+ 602
+ 603
+ 604
+ 605
+ 606
+ 607
+ 608
+ 609
+ 610
+ 611
+ 612
+ 613
+ 614
+ 615
+ 616
+ 617
+ 618
+ 619
+ 620
+ 621
+ 622
+ 623
+ 624
+ 625
+ 626
+ 627
+ 628
+ 629
+ 630
+ 631
+ 632
+ 633
+ 634
+ 635
+ 636
+ 637
+ 638
+ 639
+ 640
+ 641
+ 642
+ 643
+ 644
+ 645
+ 646
+ 647
+ 648
+ 649
+ 650
+ 651
+ 652
+ 653
+ 654
+ 655
+ 656
+ 657
+ 658
+ 659
+ 660
+ 661
+ 662
+ 663
+ 664
+ 665
+ 666
+ 667
+ 668
+ 669
+ 670
+ 671
+ 672
+ 673
+ 674
+ 675
+ 676
+ 677
+ 678
+ 679
+ 680
+ 681
+ 682
+ 683
+ 684
+ 685
+ 686
+ 687
+ 688
+ 689
+ 690
+ 691
+ 692
+ 693
+ 694
+ 695
+ 696
+ 697
+ 698
+ 699
+ 700
+ 701
+ 702
+ 703
+ 704
+ 705
+ 706
+ 707
+ 708
+ 709
+ 710
+ 711
+ 712
+ 713
+ 714
+ 715
+ 716
+ 717
+ 718
+ 719
+ 720
+ 721
+ 722
+ 723
+ 724
+ 725
+ 726
+ 727
+ 728
+ 729
+ 730
+ 731
+ 732
+ 733
+ 734
+ 735
+ 736
+ 737
+ 738
+ 739
+ 740
+ 741
+ 742
+ 743
+ 744
+ 745
+ 746
+ 747
+ 748
+ 749
+ 750
+ 751
+ 752
+ 753
+ 754
+ 755
+ 756
+ 757
+ 758
+ 759
+ 760
+ 761
+ 762
+ 763
+ 764
+ 765
+ 766
+ 767
+ 768
+ 769
+ 770
+ 771
+ 772
+ 773
+ 774
+ 775
+ 776
+ 777
+ 778
+ 779
+ 780
+ 781
+ 782
+ 783
+ 784
+ 785
+ 786
+ 787
+ 788
+ 789
+ 790
+ 791
+ 792
+ 793
+ 794
+ 795
+ 796
+ 797
+ 798
+ 799
+ 800
+ 801
+ 802
+ 803
+ 804
+ 805
+ 806
+ 807
+ 808
+ 809
+ 810
+ 811
+ 812
+ 813
+ 814
+ 815
+ 816
+ 817
+ 818
+ 819
+ 820
+ 821
+ 822
+ 823
+ 824
+ 825
+ 826
+ 827
+ 828
+ 829
+ 830
+ 831
+ 832
+ 833
+ 834
+ 835
+ 836
+ 837
+ 838
+ 839
+ 840
+ 841
+ 842
+ 843
+ 844
+ 845
+ 846
+ 847
+ 848
+ 849
+ 850
+ 851
+ 852
+ 853
+ 854
+ 855
+ 856
+ 857
+ 858
+ 859
+ 860
+ 861
+ 862
+ 863
+ 864
+ 865
+ 866
+ 867
+ 868
+ 869
+ 870
+ 871
+ 872
+ 873
+ 874
+ 875
+ 876
+ 877
+ 878
+ 879
+ 880
+ 881
+ 882
+ 883
+ 884
+ 885
+ 886
+ 887
+ 888
+ 889
+ 890
+ 891
+ 892
+ 893
+ 894
+ 895
+ 896
+ 897
+ 898
+ 899
+ 900
+ 901
+ 902
+ 903
+ 904
+ 905
+ 906
+ 907
+ 908
+ 909
+ 910
+ 911
+ 912
+ 913
+ 914
+ 915
+ 916
+ 917
+ 918
+ 919
+ 920
+ 921
+ 922
+ 923
+ 924
+ 925
+ 926
+ 927
+ 928
+ 929
+ 930
+ 931
+ 932
+ 933
+ 934
+ 935
+ 936
+ 937
+ 938
+ 939
+ 940
+ 941
+ 942
+ 943
+ 944
+ 945
+ 946
+ 947
+ 948
+ 949
+ 950
+ 951
+ 952
+ 953
+ 954
+ 955
+ 956
+ 957
+ 958
+ 959
+ 960
+ 961
+ 962
+ 963
+ 964
+ 965
+ 966
+ 967
+ 968
+ 969
+ 970
+ 971
+ 972
+ 973
+ 974
+ 975
+ 976
+ 977
+ 978
+ 979
+ 980
+ 981
+ 982
+ 983
+ 984
+ 985
+ 986
+ 987
+ 988
+ 989
+ 990
+ 991
+ 992
+ 993
+ 994
+ 995
+ 996
+ 997
+ 998
+ 999
+1000
+1001
+1002
+1003
+1004
+1005
+1006
+1007
+1008
+1009
+1010
+1011
+1012
+1013
+1014
+1015
+1016
+1017
+1018
+1019
+1020
+1021
+1022
+1023
+1024
+1025
+1026
+1027
+1028
+1029
+1030
+1031
+1032
+1033
+1034
+1035
+1036
+1037
+1038
+1039
+1040
+1041
+1042
+1043
+1044
+1045
+1046
+1047
+1048
+1049
+1050
+1051
+1052
+1053
+1054
+1055
+1056
+1057
+1058
+1059
+1060
+1061
+1062
+1063
+1064
+1065
+1066
+1067
+1068
+1069
+1070
+1071
+1072
+1073
+1074
+1075
+1076
+1077
+1078
+1079
+1080
+1081
+1082
+1083
+1084
+1085
+1086
+1087
+1088
+1089
+1090
+1091
+1092
+1093
+1094
+1095
+1096
+1097
+1098
+1099
+1100
+1101
+1102
+1103
+1104
+1105
+1106
+1107
+1108
+1109
+1110
+1111
+1112
+1113
+1114
+1115
+1116
+1117
+1118
+1119
+1120
+1121
+1122
+1123
+1124
+1125
+1126
+1127
+1128
+1129
+1130
+1131
+1132
+1133
+1134
+1135
+1136
+1137
+1138
+1139
+1140
+1141
+1142
+1143
+1144
+1145
+1146
+1147
+1148
+1149
+1150
+1151
+1152
+1153
+1154
+1155
+1156
+1157
+1158
+1159
+1160
+1161
+1162
+1163
+1164
+1165
+1166
+1167
+1168
+1169
+1170
+1171
+1172
+1173
+1174
+1175
+1176
+1177
+1178
+1179
+1180
+1181
+1182
+1183
+1184
+1185
+1186
+1187
+1188
+1189
+1190
+1191
+1192
+1193
+1194
+1195
+1196
+1197
+1198
+1199
+1200
+1201
+1202
+1203
+1204
+1205
+1206
+1207
+1208
+1209
+1210
+1211
+1212
+1213
+1214
+1215
+1216
+1217
+1218
+1219
+1220
+1221
+1222
+1223
+1224
+1225
+1226
+1227
+1228
+1229
+1230
+1231
+1232
+1233
+1234
+1235
+1236
+1237
+1238
+1239
+1240
+1241
+1242
+1243
+1244
+1245
+1246
+1247
+1248
+1249
+1250
+1251
+1252
+1253
+1254
+1255
+1256
+1257
+1258
+1259
+1260
+1261
+1262
+1263
+1264
+1265
+1266
+1267
+1268
+1269
+1270
+1271
+1272
+1273
+1274
+1275
+1276
+1277
+1278
+1279
+1280
+1281
+1282
+1283
+1284
+1285
+1286
+1287
+1288
+1289
+1290
+1291
+1292
+1293
+1294
+1295
+1296
+1297
+1298
+1299
+1300
+1301
+1302
+1303
+1304
+1305
+1306
+1307
+1308
+1309
+1310
+1311
+1312
+1313
+1314
+1315
+1316
+1317
+1318
+1319
+1320
+1321
+1322
+1323
+1324
+1325
+1326
+1327
+1328
+1329
+1330
+1331
+1332
+1333
+1334
+1335
+1336
+1337
+1338
+1339
+1340
+1341
+1342
+1343
+1344
+1345
+1346
+1347
+1348
+1349
+1350
+1351
+1352
+1353
+1354
+1355
+1356
+1357
+1358
+1359
+1360
+1361
+1362
+1363
+1364
+1365
+1366
+1367
+1368
+1369
+1370
+1371
+1372
+1373
+1374
+1375
+1376
+1377
+1378
+1379
+1380
+1381
+1382
+1383
+1384
+1385
+1386
+1387
+1388
+1389
+1390
+1391
+1392
+1393
+1394
+1395
+1396
+1397
+1398
+1399
+1400
+1401
+1402
+1403
+1404
+1405
+1406
+1407
+1408
+1409
+1410
+1411
+1412
+1413
+1414
+1415
+1416
+1417
+1418
+1419
+1420
+1421
+1422
+1423
+1424
+1425
+1426
+1427
+1428
+1429
+1430
+1431
+1432
+1433
+1434
+1435
+1436
+1437
+1438
+1439
+1440
+1441
+1442
+1443
+1444
+1445
+1446
+1447
+1448
+1449
+1450
+1451
+1452
+1453
+1454
+1455
+1456
+1457
+1458
+1459
+1460
+1461
+1462
+1463
+1464
+1465
+1466
+1467
+1468
+1469
+1470
+1471
+1472
+1473
+1474
+1475
+1476
+1477
+1478
+1479
+1480
+1481
+1482
+1483
+1484
+1485
+1486
+1487
+1488
+1489
+1490
+1491
+1492
+1493
+1494
+1495
+1496
+1497
+1498
+1499
+1500
+1501
+1502
+1503
+1504
+1505
+1506
+1507
+1508
+1509
+1510
+1511
+1512
+1513
+1514
+1515
+1516
+1517
+1518
+1519
+1520
+1521
+1522
+1523
+1524
+1525
+1526
+1527
+1528
+1529
+1530
+1531
+1532
+1533
+1534
+1535
+1536
+1537
+1538
+1539
+1540
+1541
+1542
+1543
+1544
+1545
+1546
+1547
+1548
+1549
+1550
+1551
+1552
+1553
+1554
+1555
+1556
+1557
+1558
+1559
+1560
+1561
+1562
+1563
+1564
+1565
+1566
+1567
+1568
+1569
+1570
+1571
+1572
+1573
+1574
+1575
+1576
+1577
+1578
+1579
+1580
+1581
+1582
+1583
+1584
+1585
+1586
+1587
+1588
+1589
+1590
+1591
+1592
+1593
+1594
+1595
+1596
+1597
+1598
+1599
+1600
+1601
+1602
+1603
+1604
+1605
+1606
+1607
+1608
+1609
+1610
+1611
+1612
+1613
+1614
+1615
+1616
+1617
+1618
+1619
+1620
+1621
+1622
+1623
+1624
+1625
+1626
+1627
+1628
+1629
+1630
+1631
+1632
+1633
+1634
+1635
+1636
+1637
+1638
+1639
+1640
+1641
+1642
+1643
+1644
+1645
+1646
+1647
+1648
+1649
+1650
+1651
+1652
+1653
+1654
+1655
+1656
+1657
+1658
+1659
+1660
+1661
+1662
+1663
+1664
+1665
+1666
+1667
+1668
+1669
+1670
+1671
+1672
+1673
+1674
+1675
+1676
+1677
+1678
+1679
+1680
+1681
+1682
+1683
+1684
+1685
+1686
+1687
+1688
+1689
+1690
+1691
+1692
+1693
+1694
+1695
+1696
+1697
+1698
+1699
+1700
+1701
+1702
+1703
+1704
+1705
+1706
+1707
+1708
+1709
+1710
+1711
+1712
+1713
+1714
+1715
+1716
+1717
+1718
+1719
+1720
+1721
+1722
+1723
+1724
+1725
+1726
+1727
+1728
+1729
+1730
+1731
+1732
+1733
+1734
+1735
+1736
+1737
+1738
+1739
+1740
+1741
+1742
+1743
+1744
+1745
+1746
+1747
+1748
+1749
+1750
+1751
+1752
+1753
+1754
+1755
+1756
+1757
+1758
+1759
+1760
+1761
+1762
+1763
+1764
+1765
+1766
+1767
+1768
+1769
+1770
+1771
+1772
+1773
+1774
+1775
+1776
+1777
+1778
+1779
+1780
+1781
+1782
+1783
+1784
+1785
+1786
+1787
+1788
+1789
+1790
+1791
+1792
+1793
+1794
+1795
+1796
+1797
+1798
+1799
+1800
+1801
+1802
+1803
+1804
+1805
+1806
+1807
+1808
+1809
+1810
+1811
+1812
+1813
+1814
+1815
+1816
+1817
+1818
+1819
+1820
+1821
+1822
+1823
+1824
+1825
+1826
+1827
+1828
+1829
+1830
+1831
+1832
+1833
+1834
+1835
+1836
+1837
+1838
+1839
+1840
+1841
+1842
+1843
+1844
+1845
+1846
+1847
+1848
+1849
+1850
+1851
+1852
+1853
+1854
+1855
+1856
+1857
+1858
+1859
+1860
+1861
+1862
+1863
+1864
+1865
+1866
+1867
+1868
+1869
+1870
+1871
+1872
+1873
+1874
+1875
+1876
+1877
+1878
+1879
+1880
+1881
+1882
+1883
+1884
+1885
+1886
+1887
+1888
+1889
+1890
+1891
+1892
+1893
+1894
+1895
+1896
+1897
+1898
+1899
+1900
+1901
+1902
+1903
+1904
+1905
+1906
+1907
+1908
+1909
+1910
+1911
+1912
+1913
+1914
+1915
+1916
+1917
+1918
+1919
+1920
+1921
+1922
+1923
+1924
+1925
+1926
+1927
+1928
+1929
+1930
+1931
+1932
+1933
+1934
+1935
+1936
+1937
+1938
+1939
+1940
+1941
+1942
+1943
+1944
+1945
+1946
+1947
+1948
+1949
+1950
+1951
+1952
+1953
+1954
+1955
+1956
+1957
+1958
+1959
+1960
+1961
+1962
+1963
+1964
+1965
+1966
+1967
+1968
+1969
+1970
+1971
+1972
+1973
+1974
+1975
+1976
+1977
+1978
+1979
+1980
+1981
+1982
+1983
+1984
+1985
+1986
+1987
+1988
+1989
+1990
+1991
+1992
+1993
+1994
+1995
+1996
+1997
+1998
+1999
+2000
+2001
+2002
+2003
+2004
+2005
+2006
+2007
+2008
+2009
+2010
+2011
+2012
+2013
+2014
+2015
+2016
+2017
+2018
+2019
+2020
+2021
+2022
+2023
+2024
+2025
+2026
+2027
+2028
+2029
+2030
+2031
+2032
+2033
+2034
+2035
+2036
+2037
+2038
+2039
+2040
+2041
+2042
+2043
+2044
+2045
+2046
+2047
+2048
+2049
+2050
+2051
+2052
+2053
+2054
+2055
+2056
+2057
+2058
+2059
+2060
+2061
+2062
+2063
+2064
+2065
+2066
+2067
+2068
+2069
+2070
+2071
+2072
+2073
+2074
+2075
+2076
+2077
+2078
+2079
+2080
+2081
+2082
+2083
+2084
+2085
+2086
+2087
+2088
+2089
+2090
+2091
+2092
+2093
+2094
+2095
+2096
+2097
+2098
+2099
+2100
+2101
+2102
+2103
+2104
+2105
+2106
+2107
+2108
+2109
+2110
+2111
+2112
+2113
+2114
+2115
+2116
+2117
+2118
+2119
+2120
+2121
+2122
+2123
+2124
+2125
+2126
+2127
+2128
+2129
+2130
+2131
+2132
+2133
+2134
+2135
+2136
+2137
+2138
+2139
+2140
+2141
+2142
+2143
+2144
+2145
+2146
+2147
+2148
+2149
+2150
+2151
+2152
+2153
+2154
+2155
+2156
+2157
+2158
+2159
+2160
+2161
+2162
+2163
+2164
+2165
+2166
+2167
+2168
+2169
+2170
+2171
+2172
+2173
+2174
+2175
+2176
+2177
+2178
+2179
+2180
+2181
+2182
+2183
+2184
+2185
+2186
+2187
+2188
+2189
+2190
+2191
+2192
+2193
+2194
+2195
+2196
+2197
+2198
+2199
+2200
+2201
+2202
+2203
+2204
+2205
+2206
+2207
+2208
+2209
+2210
+2211
+2212
+2213
+2214
+2215
+2216
+2217
+2218
+2219
+2220
+2221
+2222
+2223
+2224
+2225
+2226
+2227
+2228
+2229
+2230
+2231
+2232
+2233
+2234
+2235
+2236
+2237
+2238
+2239
+2240
+2241
+2242
+2243
+2244
+2245
+2246
+2247
+2248
+2249
+2250
+2251
+2252
+2253
+2254
+2255
+2256
+2257
+2258
+2259
+2260
+2261
+2262
+2263
+2264
+2265
+2266
+2267
+2268
+2269
+2270
+2271
+2272
+2273
+2274
+2275
+2276
+2277
+2278
+2279
+2280
+2281
+2282
+2283
+2284
+2285
+2286
+2287
+2288
+2289
+2290
+2291
+2292
+2293
+2294
+2295
+2296
+2297
+2298
+2299
+2300
+2301
+2302
+2303
+2304
+2305
+2306
+2307
+2308
+2309
+2310
+2311
+2312
+2313
+2314
+2315
+2316
+2317
+2318
+2319
+2320
+2321
+2322
+2323
+2324
+2325
+2326
+2327
+2328
+2329
+2330
+2331
+2332
+2333
+2334
+2335
+2336
+2337
+2338
+2339
+2340
+2341
+2342
+2343
+2344
+2345
+2346
+2347
+2348
+2349
+2350
+2351
+2352
+2353
+2354
+2355
+2356
+2357
+2358
+2359
+2360
+2361
+2362
+2363
+2364
+2365
+2366
+2367
+2368
+2369
+2370
+2371
+2372
+2373
+2374
+2375
+2376
+2377
+2378
+2379
+2380
+2381
+2382
+2383
+2384
+2385
+2386
+2387
+2388
+2389
+2390
+2391
+2392
+2393
+2394
+2395
+2396
+2397
+2398
+2399
+2400
+2401
+2402
+2403
+2404
+2405
+2406
+2407
+2408
+2409
+2410
+2411
+2412
+2413
+2414
+2415
+2416
+2417
+2418
+2419
+2420
+2421
+2422
+2423
+2424
+2425
+2426
+2427
+2428
+2429
+2430
+2431
+2432
+2433
+2434
+2435
+2436
+2437
+2438
+2439
+2440
+2441
+2442
+2443
+2444
+2445
+2446
+2447
+2448
+2449
+2450
+2451
+2452
+2453
+2454
+2455
+2456
+2457
+2458
+2459
+2460
+2461
+2462
+2463
+2464
+2465
+2466
+2467
+2468
+2469
+2470
+2471
+2472
+2473
+2474
+2475
+2476
+2477
+2478
+2479
+2480
+2481
+2482
+2483
+2484
+2485
+2486
+2487
+2488
+2489
+2490
+2491
+2492
+2493
+2494
+2495
+2496
+2497
+2498
+2499
+2500
+2501
+2502
+2503
+2504
+2505
+2506
+2507
+2508
+2509
+2510
+2511
+2512
+2513
+2514
+2515
+2516
+2517
+2518
+2519
+2520
+2521
+2522
+2523
+2524
+2525
+2526
+2527
+2528
+2529
+2530
+2531
+2532
+2533
+2534
+2535
+2536
+2537
+2538
+2539
+2540
+2541
+2542
+2543
+2544
+2545
+2546
+2547
+2548
+2549
+2550
+2551
+2552
+2553
+2554
+2555
+2556
+2557
+2558
+2559
+2560
+2561
+2562
+2563
+2564
+2565
+2566
+2567
+2568
+2569
+2570
+2571
+2572
+2573
+2574
+2575
+2576
+2577
+2578
+2579
+2580
+2581
+2582
+2583
+2584
+2585
+2586
+2587
+2588
+2589
+2590
+2591
+2592
+2593
+2594
+2595
+2596
+2597
+2598
+2599
+2600
+2601
+2602
+2603
+2604
+2605
+2606
+2607
+2608
+2609
+2610
+2611
+2612
+2613
+2614
+2615
+2616
+2617
+2618
+2619
+2620
+2621
+2622
+2623
+2624
+2625
+2626
+2627
+2628
+2629
+2630
+2631
+2632
+2633
+2634
+2635
+2636
+2637
+2638
+2639
+2640
+2641
+2642
+2643
+2644
+2645
+2646
+2647
+2648
+2649
+2650
+2651
+2652
+2653
+2654
+2655
+2656
+2657
+2658
+2659
+2660
+2661
+2662
+2663
+2664
+2665
+2666
+2667
+2668
+2669
+2670
+2671
+2672
+2673
+2674
+2675
+2676
+2677
+2678
+2679
+2680
+2681
+2682
+2683
+2684
+2685
+2686
+2687
+2688
+2689
+2690
+2691
+2692
+2693
+2694
+2695
+2696
+2697
+2698
+2699
+2700
+2701
+2702
+2703
+2704
+2705
+2706
+2707
+2708
+2709
+2710
+2711
+2712
+2713
+2714
+2715
+2716
+2717
+2718
+2719
+2720
+2721
+2722
+2723
+2724
+2725
+2726
+2727
+2728
+2729
+2730
+2731
+2732
+2733
+2734
+2735
+2736
+2737
+2738
+2739
+2740
+2741
+2742
+2743
+2744
+2745
+2746
+2747
+2748
+2749
+2750
+2751
+2752
+2753
+2754
+2755
+2756
+2757
+2758
+2759
+2760
+2761
+2762
+2763
+2764
+2765
+2766
+2767
+2768
+2769
+2770
+2771
+2772
+2773
+2774
+2775
+2776
+2777
+2778
+2779
+2780
+2781
+2782
+2783
+2784
+2785
+2786
+2787
+2788
+2789
+2790
+2791
+2792
+2793
+2794
+2795
+2796
+2797
+2798
+2799
+2800
+2801
+2802
+2803
+2804
+2805
+2806
+2807
+2808
+2809
+2810
+2811
+2812
+2813
+2814
+2815
+2816
+2817
+2818
+2819
+2820
+2821
+2822
+2823
+2824
+2825
+2826
+2827
+2828
+2829
+2830
+2831
+2832
+2833
+2834
+2835
+2836
+2837
+2838
+2839
+2840
+2841
+2842
+2843
+2844
+2845
+2846
+2847
+2848
+2849
+2850
+2851
+2852
+2853
+2854
+2855
+2856
+2857
+2858
+2859
+2860
+2861
+2862
+2863
+2864
+2865
+2866
+2867
+2868
+2869
+2870
+2871
+2872
+2873
+2874
+2875
+2876
+2877
+2878
+2879
+2880
+2881
+2882
+2883
+2884
+2885
+2886
+2887
+2888
+2889
+2890
+2891
+2892
+2893
+2894
+2895
+2896
+2897
+2898
+2899
+2900
+2901
+2902
+2903
+2904
+2905
+2906
+2907
+2908
+2909
+2910
+2911
+2912
+2913
+2914
+2915
+2916
+2917
+2918
+2919
+2920
+2921
+2922
+2923
+2924
+2925
+2926
+2927
+2928
+2929
+2930
+2931
+2932
+2933
+2934
+2935
+2936
+2937
+2938
+2939
+2940
+2941
+2942
+2943
+2944
+2945
+2946
+2947
+2948
+2949
+2950
+2951
+2952
+2953
+2954
+2955
+2956
+2957
+2958
+2959
+2960
+2961
+2962
+2963
+2964
+2965
+2966
+2967
+2968
+2969
+2970
+2971
+2972
+2973
+2974
+2975
+2976
+2977
+2978
+2979
+2980
+2981
+2982
+2983
+2984
+2985
+2986
+2987
+2988
+2989
+2990
+2991
+2992
+2993
+2994
+2995
+2996
+2997
+2998
+2999
+3000
+3001
+3002
+3003
+3004
+3005
+3006
+3007
+3008
+3009
+3010
+3011
+3012
+3013
+3014
+3015
+3016
+3017
+3018
+3019
+3020
+3021
+3022
+3023
+3024
+3025
+3026
+3027
+3028
+3029
+3030
+3031
+3032
+3033
+3034
+3035
+3036
+3037
+3038
+3039
+3040
+3041
+3042
+3043
+3044
+3045
+3046
+3047
+3048
+3049
+3050
+3051
+3052
+3053
+3054
+3055
+3056
+3057
+3058
+3059
+3060
+3061
+3062
+3063
+3064
+3065
+3066
+3067
+3068
+3069
+3070
+3071
+3072
+3073
+3074
+3075
+3076
+3077
+3078
+3079
+3080
+3081
+3082
+3083
+3084
+3085
+3086
+3087
+3088
+3089
+3090
+3091
+3092
+3093
+3094
+3095
+3096
+3097
+3098
+3099
+3100
+3101
+3102
+3103
+3104
+3105
+3106
+3107
+3108
+3109
+3110
+3111
+3112
+3113
+3114
+3115
+3116
+3117
+3118
+3119
+3120
+3121
+3122
+3123
+3124
+3125
+3126
+3127
+3128
+3129
+3130
+3131
+3132
+3133
+3134
+3135
+3136
+3137
+3138
+3139
+3140
+3141
+3142
+3143
+3144
+3145
+3146
+3147
+3148
+3149
+3150
+3151
+3152
+3153
+3154
+3155
+3156
+3157
+3158
+3159
+3160
+3161
+3162
+3163
+3164
+3165
+3166
+3167
+3168
+3169
+3170
+3171
+3172
+3173
+3174
+3175
+3176
+3177
+3178
+3179
+3180
+3181
+3182
+3183
+3184
+3185
+3186
+3187
+3188
+3189
+3190
+3191
+3192
+3193
+3194
+3195
+3196
+3197
+3198
+3199
+3200
+3201
+3202
+3203
+3204
+3205
+3206
+3207
+3208
+3209
+3210
+3211
+3212
+3213
+3214
+3215
+3216
+3217
+3218
+3219
+3220
+3221
+3222
+3223
+3224
+3225
+3226
+3227
+3228
+3229
+3230
+3231
+3232
+3233
+3234
+3235
+3236
+3237
+3238
+3239
+3240
+3241
+3242
+3243
+3244
+3245
+3246
+3247
+3248
+3249
+3250
+3251
+3252
+3253
+3254
+3255
+3256
+3257
+3258
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
+
+matebg.c: Object for the desktop background.
+
+Copyright (C) 2000 Eazel, Inc.
+Copyright (C) 2007-2008 Red Hat, Inc.
+Copyright (C) 2012 Jasmine Hassan <jasmine.aura@gmail.com>
+Copyright (C) 2012-2021 MATE Developers
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public License as
+published by the Free Software Foundation; either version 2 of the
+License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with this program; if not, write to the
+Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+Boston, MA 02110-1301, USA.
+
+Derived from eel-background.c and eel-gdk-pixbuf-extensions.c by
+Darin Adler <darin@eazel.com> and Ramiro Estrugo <ramiro@eazel.com>
+
+Authors: Soren Sandmann <sandmann@redhat.com>
+	 Jasmine Hassan <jasmine.aura@gmail.com>
+
+*/
+
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <math.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdarg.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib/gstdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gio/gio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <gdk/gdkx.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <X11/Xlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <X11/Xatom.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <cairo.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#define MATE_DESKTOP_USE_UNSTABLE_API
+#include <mate-bg.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <mate-bg-crossfade.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+# include <cairo-xlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#define MATE_BG_CACHE_DIR "mate/background"
+
+/* We keep the large pixbufs around if the next update
+   in the slideshow is less than 60 seconds away */
+#define KEEP_EXPENSIVE_CACHE_SECS 60
+
+typedef struct _SlideShow SlideShow;
+typedef struct _Slide Slide;
+
+struct _Slide {
+	double duration; /* in seconds */
+	gboolean fixed;
+
+	GSList* file1;
+	GSList* file2; /* NULL if fixed is TRUE */
+};
+
+typedef struct _FileSize FileSize;
+struct _FileSize {
+	gint width;
+	gint height;
+
+	char* file;
+};
+
+#define THUMBNAIL_SIZE 256
+
+typedef struct FileCacheEntry FileCacheEntry;
+#define CACHE_SIZE 4
+
+/*
+ *   Implementation of the MateBG class
+ */
+struct _MateBG {
+	GObject		 parent_instance;
+	char		*filename;
+	MateBGPlacement	 placement;
+	MateBGColorType	 color_type;
+	GdkRGBA	 	 primary;
+	GdkRGBA	 	 secondary;
+	gboolean	 is_enabled;
+
+	GFileMonitor* file_monitor;
+
+	guint changed_id;
+	guint transitioned_id;
+	guint blow_caches_id;
+
+	/* Cached information, only access through cache accessor functions */
+	SlideShow* slideshow;
+	gint64 file_mtime;
+	GdkPixbuf* pixbuf_cache;
+	int timeout_id;
+
+	GList* file_cache;
+};
+
+struct _MateBGClass {
+	GObjectClass parent_class;
+};
+
+enum {
+	CHANGED,
+	TRANSITIONED,
+	N_SIGNALS
+};
+
+static guint signals[N_SIGNALS] = {0};
+
+G_DEFINE_TYPE(MateBG, mate_bg, G_TYPE_OBJECT)<--- There is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE is a macro then please configure it.
+
+static cairo_surface_t *make_root_pixmap     (GdkWindow  *window,
+                                              gint        width,
+                                              gint        height);
+
+/* Pixbuf utils */
+static void       pixbuf_average_value (GdkPixbuf  *pixbuf,
+                                        GdkRGBA    *result);
+static GdkPixbuf *pixbuf_scale_to_fit  (GdkPixbuf  *src,
+					int         max_width,
+					int         max_height);
+static GdkPixbuf *pixbuf_scale_to_min  (GdkPixbuf  *src,
+					int         min_width,
+					int         min_height);
+
+static void       pixbuf_draw_gradient (GdkPixbuf    *pixbuf,
+					gboolean      horizontal,
+					GdkRGBA     *c1,
+					GdkRGBA     *c2,
+					GdkRectangle *rect);
+
+static void       pixbuf_tile          (GdkPixbuf  *src,
+					GdkPixbuf  *dest);
+static void       pixbuf_blend         (GdkPixbuf  *src,
+					GdkPixbuf  *dest,
+					int         src_x,
+					int         src_y,
+					int         width,
+					int         height,
+					int         dest_x,
+					int         dest_y,
+					double      alpha);
+
+/* Thumbnail utilities */
+static GdkPixbuf *create_thumbnail_for_filename (MateDesktopThumbnailFactory *factory,
+						 const char            *filename);
+static gboolean   get_thumb_annotations (GdkPixbuf             *thumb,
+					 int                   *orig_width,
+					 int                   *orig_height);
+
+/* Cache */
+static GdkPixbuf *get_pixbuf_for_size  (MateBG               *bg,
+					gint                  num_monitor,
+					int                   width,
+					int                   height);
+static void       clear_cache          (MateBG               *bg);
+static gboolean   is_different         (MateBG               *bg,
+					const char            *filename);
+static gint64     get_mtime            (const char            *filename);
+static GdkPixbuf *create_img_thumbnail (MateBG               *bg,
+					MateDesktopThumbnailFactory *factory,
+					GdkScreen             *screen,
+					int                    dest_width,
+					int                    dest_height,
+					int		       frame_num);
+static SlideShow * get_as_slideshow    (MateBG               *bg,
+					const char 	      *filename);
+static Slide *     get_current_slide   (SlideShow 	      *show,
+		   			double    	      *alpha);
+static gboolean    slideshow_has_multiple_sizes (SlideShow *show);
+
+static SlideShow *read_slideshow_file (const char *filename,
+				       GError     **err);
+static SlideShow *slideshow_ref       (SlideShow  *show);
+static void       slideshow_unref     (SlideShow  *show);
+
+static FileSize   *find_best_size      (GSList                *sizes,
+					gint                   width,
+					gint                   height);
+
+static void
+color_from_string (const char *string,
+                   GdkRGBA    *colorp)
+{
+	if (!string || *string == '\0' || !gdk_rgba_parse (colorp, string))
+		gdk_rgba_parse (colorp, "#000000"); /* If all else fails use black */
+}
+
+static char *
+color_to_string (const GdkRGBA *color)
+{
+	return g_strdup_printf ("#%02x%02x%02x",
+				((guint) (color->red * 65535)) >> 8,
+				((guint) (color->green * 65535)) >> 8,
+				((guint) (color->blue * 65535)) >> 8);
+}
+
+static gboolean
+do_changed (MateBG *bg)
+{
+	bg->changed_id = 0;
+
+	g_signal_emit (G_OBJECT (bg), signals[CHANGED], 0);
+
+	return FALSE;
+}
+
+static void
+queue_changed (MateBG *bg)
+{
+	if (bg->changed_id > 0) {
+		g_source_remove (bg->changed_id);
+	}
+
+	bg->changed_id = g_timeout_add_full (G_PRIORITY_LOW,
+					     100,
+					     (GSourceFunc)do_changed,
+					     bg,
+					     NULL);
+}
+
+static gboolean
+do_transitioned (MateBG *bg)
+{
+	bg->transitioned_id = 0;
+
+	if (bg->pixbuf_cache) {
+		g_object_unref (bg->pixbuf_cache);
+		bg->pixbuf_cache = NULL;
+	}
+
+	g_signal_emit (G_OBJECT (bg), signals[TRANSITIONED], 0);
+
+	return FALSE;
+}
+
+static void
+queue_transitioned (MateBG *bg)
+{
+	if (bg->transitioned_id > 0) {
+		g_source_remove (bg->transitioned_id);
+	}
+
+	bg->transitioned_id = g_timeout_add_full (G_PRIORITY_LOW,
+						  100,
+						  (GSourceFunc)do_transitioned,
+						  bg,
+						  NULL);
+}
+
+/* This function loads the user's preferences */
+void
+mate_bg_load_from_preferences (MateBG *bg)
+{
+	GSettings *settings;
+	settings = g_settings_new (MATE_BG_SCHEMA);
+
+	mate_bg_load_from_gsettings (bg, settings);
+	g_object_unref (settings);
+
+	/* Queue change to force background redraw */
+	queue_changed (bg);
+}
+
+/* This function loads default system settings */
+void
+mate_bg_load_from_system_preferences (MateBG *bg)
+{
+	GSettings *settings;
+
+	/* FIXME: we need to bind system settings instead of user but
+	* that's currently impossible, not implemented yet.
+	* Hence, reset to system default values.
+	*/
+	settings = g_settings_new (MATE_BG_SCHEMA);
+
+	mate_bg_load_from_system_gsettings (bg, settings, FALSE);
+
+	g_object_unref (settings);
+}
+
+/* This function loads (and optionally resets to) default system settings */
+void
+mate_bg_load_from_system_gsettings (MateBG    *bg,
+				    GSettings *settings,
+				    gboolean   reset_apply)
+{
+	GSettingsSchema *schema;
+	gchar **keys;
+	gchar **k;
+
+	g_return_if_fail (MATE_IS_BG (bg));
+	g_return_if_fail (G_IS_SETTINGS (settings));
+
+	g_settings_delay (settings);
+
+	g_object_get (settings, "settings-schema", &schema, NULL);
+	keys = g_settings_schema_list_keys (schema);
+	g_settings_schema_unref (schema);
+
+	for (k = keys; *k; k++) {
+		g_settings_reset (settings, *k);
+	}
+	g_strfreev (keys);
+
+	if (reset_apply) {
+		/* Apply changes atomically. */
+		g_settings_apply (settings);
+	} else {
+		mate_bg_load_from_gsettings (bg, settings);
+		g_settings_revert (settings);
+	}
+}
+
+void
+mate_bg_load_from_gsettings (MateBG    *bg,
+			     GSettings *settings)
+{
+	char    *tmp;
+	char    *filename;
+	MateBGColorType ctype;
+	GdkRGBA c1, c2;
+	MateBGPlacement placement;
+
+	g_return_if_fail (MATE_IS_BG (bg));
+	g_return_if_fail (G_IS_SETTINGS (settings));
+
+	bg->is_enabled = g_settings_get_boolean (settings, MATE_BG_KEY_DRAW_BACKGROUND);
+
+	/* Filename */
+	filename = NULL;
+	tmp = g_settings_get_string (settings, MATE_BG_KEY_PICTURE_FILENAME);
+	if (tmp && *tmp != '\0') {
+		/* FIXME: UTF-8 checks should go away.
+		 * picture-filename is of type string, which can only be used for
+		 * UTF-8 strings, and some filenames are not, dependending on the
+		 * locale used.
+		 * It would be better (and simpler) to change to a URI instead,
+		 * as URIs are UTF-8 encoded strings.
+		 */
+		if (g_utf8_validate (tmp, -1, NULL) &&
+		    g_file_test (tmp, G_FILE_TEST_EXISTS)) {
+			filename = g_strdup (tmp);
+		} else {
+			filename = g_filename_from_utf8 (tmp, -1, NULL, NULL, NULL);
+		}
+
+		/* Fallback to default BG if the filename set is non-existent */
+		if (filename != NULL && !g_file_test (filename, G_FILE_TEST_EXISTS)) {
+
+			g_free (filename);
+
+			g_settings_delay (settings);
+			g_settings_reset (settings, MATE_BG_KEY_PICTURE_FILENAME);
+			filename = g_settings_get_string (settings, MATE_BG_KEY_PICTURE_FILENAME);
+			g_settings_revert (settings);
+
+			//* Check if default background exists, also */
+			if (filename != NULL && !g_file_test (filename, G_FILE_TEST_EXISTS)) {
+				g_free (filename);
+				filename = NULL;
+			}
+		}
+	}
+	g_free (tmp);
+
+	/* Colors */
+	tmp = g_settings_get_string (settings, MATE_BG_KEY_PRIMARY_COLOR);
+	color_from_string (tmp, &c1);
+	g_free (tmp);
+
+	tmp = g_settings_get_string (settings, MATE_BG_KEY_SECONDARY_COLOR);
+	color_from_string (tmp, &c2);
+	g_free (tmp);
+
+	/* Color type */
+	ctype = g_settings_get_enum (settings, MATE_BG_KEY_COLOR_TYPE);
+
+	/* Placement */
+	placement = g_settings_get_enum (settings, MATE_BG_KEY_PICTURE_PLACEMENT);
+
+	mate_bg_set_color (bg, ctype, &c1, &c2);
+	mate_bg_set_placement (bg, placement);
+	mate_bg_set_filename (bg, filename);
+
+	g_free (filename);
+}
+
+void
+mate_bg_save_to_preferences (MateBG *bg)
+{
+	GSettings *settings;
+	settings = g_settings_new (MATE_BG_SCHEMA);
+
+	mate_bg_save_to_gsettings (bg, settings);
+	g_object_unref (settings);
+}
+
+void
+mate_bg_save_to_gsettings (MateBG    *bg,
+			   GSettings *settings)
+{
+	gchar *primary;
+	gchar *secondary;
+
+	g_return_if_fail (MATE_IS_BG (bg));
+	g_return_if_fail (G_IS_SETTINGS (settings));
+
+	primary = color_to_string (&bg->primary);
+	secondary = color_to_string (&bg->secondary);
+
+	g_settings_delay (settings);
+
+	g_settings_set_boolean (settings, MATE_BG_KEY_DRAW_BACKGROUND, bg->is_enabled);
+	g_settings_set_string (settings, MATE_BG_KEY_PICTURE_FILENAME, bg->filename);
+	g_settings_set_enum (settings, MATE_BG_KEY_PICTURE_PLACEMENT, bg->placement);
+	g_settings_set_string (settings, MATE_BG_KEY_PRIMARY_COLOR, primary);
+	g_settings_set_string (settings, MATE_BG_KEY_SECONDARY_COLOR, secondary);
+	g_settings_set_enum (settings, MATE_BG_KEY_COLOR_TYPE, bg->color_type);
+
+	/* Apply changes atomically. */
+	g_settings_apply (settings);
+
+	g_free (primary);
+	g_free (secondary);
+}
+
+static void
+mate_bg_init (MateBG *bg)
+{
+}
+
+static void
+mate_bg_dispose (GObject *object)
+{
+	MateBG *bg = MATE_BG (object);
+
+	if (bg->file_monitor) {
+		g_object_unref (bg->file_monitor);
+		bg->file_monitor = NULL;
+	}
+
+	clear_cache (bg);
+
+	G_OBJECT_CLASS (mate_bg_parent_class)->dispose (object);
+}
+
+static void
+mate_bg_finalize (GObject *object)
+{
+	MateBG *bg = MATE_BG (object);
+
+	if (bg->changed_id != 0) {
+		g_source_remove (bg->changed_id);
+		bg->changed_id = 0;
+	}
+
+	if (bg->transitioned_id != 0) {
+		g_source_remove (bg->transitioned_id);
+		bg->transitioned_id = 0;
+	}
+
+	if (bg->blow_caches_id != 0) {
+		g_source_remove (bg->blow_caches_id);
+		bg->blow_caches_id = 0;
+	}
+
+	g_free (bg->filename);
+	bg->filename = NULL;
+
+	G_OBJECT_CLASS (mate_bg_parent_class)->finalize (object);
+}
+
+static void
+mate_bg_class_init (MateBGClass *klass)
+{
+	GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+	object_class->dispose = mate_bg_dispose;
+	object_class->finalize = mate_bg_finalize;
+
+	signals[CHANGED] = g_signal_new ("changed",
+					 G_OBJECT_CLASS_TYPE (object_class),
+					 G_SIGNAL_RUN_LAST,
+					 0,
+					 NULL, NULL,
+					 g_cclosure_marshal_VOID__VOID,
+					 G_TYPE_NONE, 0);
+
+	signals[TRANSITIONED] = g_signal_new ("transitioned",
+					 G_OBJECT_CLASS_TYPE (object_class),
+					 G_SIGNAL_RUN_LAST,
+					 0,
+					 NULL, NULL,
+					 g_cclosure_marshal_VOID__VOID,
+					 G_TYPE_NONE, 0);
+}
+
+MateBG *
+mate_bg_new (void)
+{
+	return g_object_new (MATE_TYPE_BG, NULL);
+}
+
+void
+mate_bg_set_color (MateBG *bg,
+		    MateBGColorType type,
+		    GdkRGBA *primary,
+		    GdkRGBA *secondary)
+{
+	g_return_if_fail (bg != NULL);
+	g_return_if_fail (primary != NULL);
+
+	if (bg->color_type != type			||
+	    !gdk_rgba_equal (&bg->primary, primary)			||
+	    (secondary && !gdk_rgba_equal (&bg->secondary, secondary))) {
+		bg->color_type = type;
+		bg->primary = *primary;
+		if (secondary) {
+			bg->secondary = *secondary;
+		}
+
+		queue_changed (bg);
+	}
+}
+
+void
+mate_bg_set_placement (MateBG		*bg,
+		       MateBGPlacement	 placement)
+{
+	g_return_if_fail (bg != NULL);
+
+	if (bg->placement != placement) {
+		bg->placement = placement;
+
+		queue_changed (bg);
+	}
+}
+
+MateBGPlacement
+mate_bg_get_placement (MateBG *bg)
+{
+	g_return_val_if_fail (bg != NULL, -1);
+
+	return bg->placement;
+}
+
+void
+mate_bg_get_color (MateBG		*bg,
+		   MateBGColorType	*type,
+		   GdkRGBA		*primary,
+		   GdkRGBA		*secondary)
+{
+	g_return_if_fail (bg != NULL);
+
+	if (type)
+		*type = bg->color_type;
+
+	if (primary)
+		*primary = bg->primary;
+
+	if (secondary)
+		*secondary = bg->secondary;
+}
+
+void
+mate_bg_set_draw_background (MateBG	*bg,
+			     gboolean	 draw_background)
+{
+	g_return_if_fail (bg != NULL);
+
+	if (bg->is_enabled != draw_background) {
+		bg->is_enabled = draw_background;
+
+		queue_changed (bg);
+	}
+}
+
+gboolean
+mate_bg_get_draw_background (MateBG *bg)
+{
+	g_return_val_if_fail (bg != NULL, FALSE);
+
+	return bg->is_enabled;
+}
+
+const gchar *
+mate_bg_get_filename (MateBG *bg)
+{
+	g_return_val_if_fail (bg != NULL, NULL);
+
+	return bg->filename;
+}
+
+static inline gchar *
+get_wallpaper_cache_dir (void)
+{
+	return g_build_filename (g_get_user_cache_dir(), MATE_BG_CACHE_DIR, NULL);
+}
+
+static inline gchar *
+get_wallpaper_cache_prefix_name (gint                     num_monitor,
+				 MateBGPlacement          placement,
+				 gint                     width,
+				 gint                     height)
+{
+	return g_strdup_printf ("%i_%i_%i_%i", num_monitor, (gint) placement, width, height);
+}
+
+static char *
+get_wallpaper_cache_filename (const char              *filename,
+			      gint                     num_monitor,
+			      MateBGPlacement          placement,
+			      gint                     width,
+			      gint                     height)
+{
+	gchar *cache_filename;
+	gchar *cache_prefix_name;
+	gchar *md5_filename;
+	gchar *cache_basename;
+	gchar *cache_dir;
+
+	md5_filename = g_compute_checksum_for_data (G_CHECKSUM_MD5, (const guchar *) filename,
+						    strlen (filename));
+	cache_prefix_name = get_wallpaper_cache_prefix_name (num_monitor, placement, width, height);
+	cache_basename = g_strdup_printf ("%s_%s", cache_prefix_name, md5_filename);
+	cache_dir = get_wallpaper_cache_dir ();
+	cache_filename = g_build_filename (cache_dir, cache_basename, NULL);
+
+	g_free (cache_prefix_name);
+	g_free (md5_filename);
+	g_free (cache_basename);
+	g_free (cache_dir);
+
+	return cache_filename;
+}
+
+static void
+cleanup_cache_for_monitor (gchar *cache_dir,
+			   gint   num_monitor)
+{
+	GDir            *g_cache_dir;
+	gchar           *monitor_prefix;
+	const gchar     *file;
+
+	g_cache_dir = g_dir_open (cache_dir, 0, NULL);
+	monitor_prefix = g_strdup_printf ("%i_", num_monitor);
+
+	file = g_dir_read_name (g_cache_dir);
+	while (file != NULL) {
+		gchar *path = g_build_filename (cache_dir, file, NULL);
+
+		/* purge files with same monitor id */
+		if (g_str_has_prefix (file, monitor_prefix) &&
+		    g_file_test (path, G_FILE_TEST_IS_REGULAR))
+			g_unlink (path);
+
+		g_free (path);
+
+		file = g_dir_read_name (g_cache_dir);
+	}
+
+	g_free (monitor_prefix);
+	g_dir_close (g_cache_dir);
+}
+
+static gboolean
+cache_file_is_valid (const char *filename,
+		     const char *cache_filename)
+{
+	if (!g_file_test (cache_filename, G_FILE_TEST_IS_REGULAR))
+		return FALSE;
+
+	return (get_mtime (filename) < get_mtime (cache_filename));
+}
+
+static void
+refresh_cache_file (MateBG     *bg,
+		    GdkPixbuf  *new_pixbuf,
+		    gint        num_monitor,
+		    gint        width,
+		    gint        height)
+{
+	gchar           *cache_filename;
+	gchar           *cache_dir;
+	GdkPixbufFormat *format;
+	gchar           *format_name;
+
+	if ((num_monitor == -1) || (width <= 300) || (height <= 300))
+		return;
+
+	cache_filename = get_wallpaper_cache_filename (bg->filename, num_monitor,
+							bg->placement, width, height);
+	cache_dir = get_wallpaper_cache_dir ();
+
+	/* Only refresh scaled file on disk if useful (and don't cache slideshow) */
+	if (!cache_file_is_valid (bg->filename, cache_filename)) {
+		format = gdk_pixbuf_get_file_info (bg->filename, NULL, NULL);
+
+		if (format != NULL) {
+			if (!g_file_test (cache_dir, G_FILE_TEST_IS_DIR)) {
+				g_mkdir_with_parents (cache_dir, 0700);
+			} else {
+				cleanup_cache_for_monitor (cache_dir, num_monitor);
+			}
+
+			format_name = gdk_pixbuf_format_get_name (format);
+
+			if (strcmp (format_name, "jpeg") == 0)
+				gdk_pixbuf_save (new_pixbuf, cache_filename, format_name,
+						 NULL, "quality", "100", NULL);
+			else
+				gdk_pixbuf_save (new_pixbuf, cache_filename, format_name,
+						 NULL, NULL);
+
+			g_free (format_name);
+		}
+	}
+
+	g_free (cache_filename);
+	g_free (cache_dir);
+}
+
+static void
+file_changed (GFileMonitor     *file_monitor,
+	      GFile            *child,
+	      GFile            *other_file,
+	      GFileMonitorEvent event_type,
+	      gpointer          user_data)
+{
+	MateBG *bg = MATE_BG (user_data);
+
+	clear_cache (bg);
+	queue_changed (bg);
+}
+
+void
+mate_bg_set_filename (MateBG	 *bg,
+		      const char *filename)
+{
+	g_return_if_fail (bg != NULL);
+
+	if (is_different (bg, filename)) {
+		g_free (bg->filename);
+
+		bg->filename = g_strdup (filename);
+		bg->file_mtime = get_mtime (bg->filename);
+
+		if (bg->file_monitor) {
+			g_object_unref (bg->file_monitor);
+			bg->file_monitor = NULL;
+		}
+
+		if (bg->filename) {
+			GFile *f = g_file_new_for_path (bg->filename);
+
+			bg->file_monitor = g_file_monitor_file (f, 0, NULL, NULL);
+			g_signal_connect (bg->file_monitor, "changed",
+					  G_CALLBACK (file_changed), bg);
+
+			g_object_unref (f);
+		}
+
+		clear_cache (bg);
+
+		queue_changed (bg);
+	}
+}
+
+static void
+draw_color_area (MateBG       *bg,
+		 GdkPixbuf    *dest,
+		 GdkRectangle *rect)
+{
+	guint32 pixel;
+	GdkRectangle extent;
+
+        extent.x = 0;
+        extent.y = 0;
+        extent.width = gdk_pixbuf_get_width (dest);
+        extent.height = gdk_pixbuf_get_height (dest);
+
+	gdk_rectangle_intersect (rect, &extent, rect);
+
+	switch (bg->color_type) {
+	case MATE_BG_COLOR_SOLID:
+		/* not really a big deal to ignore the area of interest */
+		pixel = ((guint) (bg->primary.red * 0xff) << 24)   |
+			((guint) (bg->primary.green * 0xff) << 16) |
+			((guint) (bg->primary.blue * 0xff) << 8)   |
+			(0xff);
+
+		gdk_pixbuf_fill (dest, pixel);
+		break;
+
+	case MATE_BG_COLOR_H_GRADIENT:
+		pixbuf_draw_gradient (dest, TRUE, &(bg->primary), &(bg->secondary), rect);
+		break;
+
+	case MATE_BG_COLOR_V_GRADIENT:
+		pixbuf_draw_gradient (dest, FALSE, &(bg->primary), &(bg->secondary), rect);
+		break;
+
+	default:
+		break;
+	}
+}
+
+static void
+draw_color (MateBG    *bg,
+	    GdkPixbuf *dest)
+{
+	GdkRectangle rect;
+
+	rect.x = 0;
+	rect.y = 0;
+	rect.width = gdk_pixbuf_get_width (dest);
+	rect.height = gdk_pixbuf_get_height (dest);
+	draw_color_area (bg, dest, &rect);
+}
+
+static void
+draw_color_each_monitor (MateBG    *bg,
+			 GdkPixbuf *dest,
+			 GdkScreen *screen)
+{
+	GdkDisplay *display;
+	GdkRectangle rect;
+	gint num_monitors;
+	int monitor;
+
+	display = gdk_screen_get_display (screen);
+	num_monitors = gdk_display_get_n_monitors (display);
+	for (monitor = 0; monitor < num_monitors; monitor++) {
+		gdk_monitor_get_geometry (gdk_display_get_monitor (display, monitor), &rect);
+		draw_color_area (bg, dest, &rect);
+	}
+}
+
+static GdkPixbuf *
+pixbuf_clip_to_fit (GdkPixbuf *src,
+		    int        max_width,
+		    int        max_height)
+{
+	int src_width, src_height;
+	int w, h;
+	int src_x, src_y;
+	GdkPixbuf *pixbuf;
+
+	src_width = gdk_pixbuf_get_width (src);
+	src_height = gdk_pixbuf_get_height (src);
+
+	if (src_width < max_width && src_height < max_height)
+		return g_object_ref (src);
+
+	w = MIN(src_width, max_width);
+	h = MIN(src_height, max_height);
+
+	pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
+				 gdk_pixbuf_get_has_alpha (src),
+				 8, w, h);
+
+	src_x = (src_width - w) / 2;
+	src_y = (src_height - h) / 2;
+	gdk_pixbuf_copy_area (src,
+			      src_x, src_y,
+			      w, h,
+			      pixbuf,
+			      0, 0);
+	return pixbuf;
+}
+
+static GdkPixbuf *
+get_scaled_pixbuf (MateBGPlacement  placement,
+		   GdkPixbuf       *pixbuf,
+		   int width, int height,
+		   int *x, int *y,
+		   int *w, int *h)
+{
+	GdkPixbuf *new;
+
+#if 0
+	g_print ("original_width: %d %d\n",
+		 gdk_pixbuf_get_width (pixbuf),
+		 gdk_pixbuf_get_height (pixbuf));
+#endif
+
+	switch (placement) {
+	case MATE_BG_PLACEMENT_SPANNED:
+                new = pixbuf_scale_to_fit (pixbuf, width, height);
+		break;
+	case MATE_BG_PLACEMENT_ZOOMED:
+		new = pixbuf_scale_to_min (pixbuf, width, height);
+		break;
+
+	case MATE_BG_PLACEMENT_FILL_SCREEN:
+		new = gdk_pixbuf_scale_simple (pixbuf, width, height,
+					       GDK_INTERP_BILINEAR);
+		break;
+
+	case MATE_BG_PLACEMENT_SCALED:
+		new = pixbuf_scale_to_fit (pixbuf, width, height);
+		break;
+
+	case MATE_BG_PLACEMENT_CENTERED:
+	case MATE_BG_PLACEMENT_TILED:
+	default:
+		new = pixbuf_clip_to_fit (pixbuf, width, height);
+		break;
+	}
+
+	*w = gdk_pixbuf_get_width (new);
+	*h = gdk_pixbuf_get_height (new);
+	*x = (width - *w) / 2;
+	*y = (height - *h) / 2;
+
+	return new;
+}
+
+static void
+draw_image_area (MateBG        *bg,
+		 gint           num_monitor,
+		 GdkPixbuf     *pixbuf,
+		 GdkPixbuf     *dest,
+		 GdkRectangle  *area)
+{
+	int dest_width = area->width;
+	int dest_height = area->height;
+	int x, y, w, h;
+	GdkPixbuf *scaled;
+
+	if (!pixbuf)
+		return;
+
+	scaled = get_scaled_pixbuf (bg->placement, pixbuf, dest_width, dest_height, &x, &y, &w, &h);
+
+	switch (bg->placement) {
+	case MATE_BG_PLACEMENT_TILED:
+		pixbuf_tile (scaled, dest);
+		break;
+	case MATE_BG_PLACEMENT_ZOOMED:
+	case MATE_BG_PLACEMENT_CENTERED:
+	case MATE_BG_PLACEMENT_FILL_SCREEN:
+	case MATE_BG_PLACEMENT_SCALED:
+		pixbuf_blend (scaled, dest, 0, 0, w, h, x + area->x, y + area->y, 1.0);
+		break;
+	case MATE_BG_PLACEMENT_SPANNED:
+		pixbuf_blend (scaled, dest, 0, 0, w, h, x, y, 1.0);
+		break;
+	default:
+		g_assert_not_reached ();
+		break;
+	}
+
+	refresh_cache_file (bg, scaled, num_monitor, dest_width, dest_height);
+
+	g_object_unref (scaled);
+}
+
+static void
+draw_image_for_thumb (MateBG     *bg,
+		      GdkPixbuf  *pixbuf,
+		      GdkPixbuf  *dest)
+{
+	GdkRectangle rect;
+
+	rect.x = 0;
+	rect.y = 0;
+	rect.width = gdk_pixbuf_get_width (dest);
+	rect.height = gdk_pixbuf_get_height (dest);
+
+	draw_image_area (bg, -1, pixbuf, dest, &rect);
+}
+
+static void
+draw_once (MateBG    *bg,
+	   GdkPixbuf *dest,
+	   gboolean   is_root)
+{
+	GdkRectangle rect;
+	GdkPixbuf   *pixbuf;
+	gint         monitor;
+
+	/* whether we're drawing on root window or normal (Caja) window */
+	monitor = (is_root) ? 0 : -1;
+
+	rect.x = 0;
+	rect.y = 0;
+	rect.width = gdk_pixbuf_get_width (dest);
+	rect.height = gdk_pixbuf_get_height (dest);
+
+	pixbuf = get_pixbuf_for_size (bg, monitor, rect.width, rect.height);
+	if (pixbuf) {
+		draw_image_area (bg, monitor, pixbuf, dest, &rect);
+
+		g_object_unref (pixbuf);
+	}
+}
+
+static void
+draw_each_monitor (MateBG    *bg,
+		   GdkPixbuf *dest,
+		   GdkScreen *screen)
+{
+	GdkDisplay *display;
+
+	display = gdk_screen_get_display (screen);
+	gint num_monitors = gdk_display_get_n_monitors (display);
+	gint monitor = 0;
+
+	for (; monitor < num_monitors; monitor++) {
+		GdkRectangle rect;
+		GdkPixbuf *pixbuf;
+
+		gdk_monitor_get_geometry (gdk_display_get_monitor (display, monitor), &rect);
+
+		pixbuf = get_pixbuf_for_size (bg, monitor, rect.width, rect.height);
+		if (pixbuf) {
+			draw_image_area (bg, monitor, pixbuf, dest, &rect);
+
+			g_object_unref (pixbuf);
+		}
+	}
+}
+
+void
+mate_bg_draw (MateBG     *bg,
+	       GdkPixbuf *dest,
+	       GdkScreen *screen,
+	       gboolean   is_root)
+{
+	if (!bg)
+		return;
+
+	if (is_root && (bg->placement != MATE_BG_PLACEMENT_SPANNED)) {
+		draw_color_each_monitor (bg, dest, screen);
+		if (bg->filename) {
+			draw_each_monitor (bg, dest, screen);
+		}
+	} else {
+		draw_color (bg, dest);
+		if (bg->filename) {
+			draw_once (bg, dest, is_root);
+		}
+	}
+}
+
+gboolean
+mate_bg_has_multiple_sizes (MateBG *bg)
+{
+	SlideShow *show;
+	gboolean ret;
+
+	g_return_val_if_fail (bg != NULL, FALSE);
+
+	ret = FALSE;
+
+	show = get_as_slideshow (bg, bg->filename);
+	if (show) {
+		ret = slideshow_has_multiple_sizes (show);
+		slideshow_unref (show);
+	}
+
+	return ret;
+}
+
+static void
+mate_bg_get_pixmap_size (MateBG   *bg,
+			  int        width,
+			  int        height,
+			  int       *pixmap_width,
+			  int       *pixmap_height)
+{
+	int dummy;
+
+	if (!pixmap_width)
+		pixmap_width = &dummy;
+	if (!pixmap_height)
+		pixmap_height = &dummy;
+
+	*pixmap_width = width;
+	*pixmap_height = height;
+
+	if (!bg->filename) {
+		switch (bg->color_type) {
+		case MATE_BG_COLOR_SOLID:
+			*pixmap_width = 1;
+			*pixmap_height = 1;
+			break;
+
+		case MATE_BG_COLOR_H_GRADIENT:
+		case MATE_BG_COLOR_V_GRADIENT:
+			break;
+		}
+
+		return;
+	}
+}
+
+/**
+ * mate_bg_create_surface:
+ * @bg: MateBG
+ * @window:
+ * @width:
+ * @height:
+ * @root:
+ *
+ * Create a surface that can be set as background for @window. If @root is
+ * TRUE, the surface created will be created by a temporary X server connection
+ * so that if someone calls XKillClient on it, it won't affect the application
+ * who created it.
+ **/
+cairo_surface_t *
+mate_bg_create_surface (MateBG      *bg,
+		 	GdkWindow   *window,
+			int	     width,
+			int	     height,
+			gboolean     root)
+{
+	return mate_bg_create_surface_scale (bg,
+					     window,
+					     width,
+					     height,
+					     1,
+					     root);
+}
+
+/**
+ * mate_bg_create_surface_scale:
+ * @bg: MateBG
+ * @window:
+ * @width:
+ * @height:
+ * @scale:
+ * @root:
+ *
+ * Create a scaled surface that can be set as background for @window. If @root is
+ * TRUE, the surface created will be created by a temporary X server connection
+ * so that if someone calls XKillClient on it, it won't affect the application
+ * who created it.
+ **/
+cairo_surface_t *
+mate_bg_create_surface_scale (MateBG      *bg,
+			      GdkWindow   *window,
+			      int          width,
+			      int          height,
+			      int          scale,
+			      gboolean     root)
+{
+	int pm_width, pm_height;
+
+	cairo_surface_t *surface;
+	cairo_t *cr;
+
+	g_return_val_if_fail (bg != NULL, NULL);
+	g_return_val_if_fail (window != NULL, NULL);
+
+	if (bg->pixbuf_cache &&
+	    (gdk_pixbuf_get_width (bg->pixbuf_cache) != width ||
+	     gdk_pixbuf_get_height (bg->pixbuf_cache) != height))
+	{
+		g_object_unref (bg->pixbuf_cache);
+		bg->pixbuf_cache = NULL;
+	}
+
+	mate_bg_get_pixmap_size (bg, width, height, &pm_width, &pm_height);
+
+	if (root)
+	{
+		surface = make_root_pixmap (window, pm_width * scale, pm_height * scale);
+	}
+	else
+	{
+		surface = gdk_window_create_similar_surface (window, CAIRO_CONTENT_COLOR,
+							     pm_width, pm_height);
+	}
+
+	cr = cairo_create (surface);
+	cairo_scale (cr, (double)scale, (double)scale);
+
+	if (!bg->filename && bg->color_type == MATE_BG_COLOR_SOLID) {
+		gdk_cairo_set_source_rgba (cr, &(bg->primary));
+	}
+	else
+	{
+		GdkPixbuf *pixbuf;
+
+		pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8,
+					 width, height);
+		mate_bg_draw (bg, pixbuf, gdk_window_get_screen (window), root);
+		gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0);
+		g_object_unref (pixbuf);
+	}
+
+	cairo_paint (cr);
+
+	cairo_destroy (cr);
+
+	return surface;
+}
+
+/* determine if a background is darker or lighter than average, to help
+ * clients know what colors to draw on top with
+ */
+gboolean
+mate_bg_is_dark (MateBG *bg,
+		  int      width,
+		  int      height)
+{
+	GdkRGBA color;
+	int intensity;
+	GdkPixbuf *pixbuf;
+
+	g_return_val_if_fail (bg != NULL, FALSE);
+
+	if (bg->color_type == MATE_BG_COLOR_SOLID) {
+		color = bg->primary;
+	} else {
+		color.red = (bg->primary.red + bg->secondary.red) / 2;
+		color.green = (bg->primary.green + bg->secondary.green) / 2;
+		color.blue = (bg->primary.blue + bg->secondary.blue) / 2;
+	}
+	pixbuf = get_pixbuf_for_size (bg, -1, width, height);
+	if (pixbuf) {
+		GdkRGBA argb;
+		guchar a, r, g, b;
+
+		pixbuf_average_value (pixbuf, &argb);
+		a = argb.alpha * 0xff;
+		r = argb.red * 0xff;
+		g = argb.green * 0xff;
+		b = argb.blue * 0xff;
+
+		color.red = (color.red * (0xFF - a) + r * 0x101 * a) / 0xFF;
+		color.green = (color.green * (0xFF - a) + g * 0x101 * a) / 0xFF;
+		color.blue = (color.blue * (0xFF - a) + b * 0x101 * a) / 0xFF;
+		g_object_unref (pixbuf);
+	}
+
+	intensity = ((guint) (color.red * 65535) * 77 +
+		     (guint) (color.green * 65535) * 150 +
+		     (guint) (color.blue * 65535) * 28) >> 16;
+
+	return intensity < 160; /* biased slightly to be dark */
+}
+
+/*
+ * Create a persistent pixmap. We create a separate display
+ * and set the closedown mode on it to RetainPermanent.
+ */
+static cairo_surface_t *
+make_root_pixmap (GdkWindow *window, gint width, gint height)
+{
+	GdkScreen *screen = gdk_window_get_screen(window);
+	char *disp_name = DisplayString (GDK_WINDOW_XDISPLAY (window));
+	Display *display;
+	Pixmap xpixmap;
+	cairo_surface_t *surface;
+	int depth;
+
+	/* Desktop background pixmap should be created from dummy X client since most
+	 * applications will try to kill it with XKillClient later when changing pixmap
+	 */
+	display = XOpenDisplay (disp_name);
+
+	if (display == NULL) {
+		g_warning ("Unable to open display '%s' when setting background pixmap\n",
+		           (disp_name) ? disp_name : "NULL");
+		return NULL;
+	}
+
+	depth = DefaultDepth (display, gdk_x11_screen_get_screen_number (screen));
+	xpixmap = XCreatePixmap (display, GDK_WINDOW_XID (window), width, height, depth);
+
+	XFlush (display);
+	XSetCloseDownMode (display, RetainPermanent);
+	XCloseDisplay (display);
+
+	surface = cairo_xlib_surface_create (GDK_SCREEN_XDISPLAY (screen), xpixmap,
+                                             GDK_VISUAL_XVISUAL (gdk_screen_get_system_visual (screen)),
+        				     width, height);
+
+	return surface;
+}
+
+static gboolean
+get_original_size (const char *filename,
+		   int        *orig_width,
+		   int        *orig_height)
+{
+	gboolean result;
+
+        if (gdk_pixbuf_get_file_info (filename, orig_width, orig_height))
+		result = TRUE;
+	else
+		result = FALSE;
+
+	return result;
+}
+
+static const char *
+get_filename_for_size (MateBG *bg, gint best_width, gint best_height)
+{
+	SlideShow *show;
+	Slide *slide;
+	FileSize *size;
+
+	if (!bg->filename)
+		return NULL;
+
+	show = get_as_slideshow (bg, bg->filename);
+	if (!show) {
+		return bg->filename;
+	}
+
+	slide = get_current_slide (show, NULL);
+	slideshow_unref (show);
+	size = find_best_size (slide->file1, best_width, best_height);
+	return size->file;
+}
+
+gboolean
+mate_bg_get_image_size (MateBG	       *bg,
+			 MateDesktopThumbnailFactory *factory,
+			 int                    best_width,
+			 int                    best_height,
+			 int		       *width,
+			 int		       *height)
+{
+	GdkPixbuf *thumb;
+	gboolean result = FALSE;
+	const gchar *filename;
+
+	g_return_val_if_fail (bg != NULL, FALSE);
+	g_return_val_if_fail (factory != NULL, FALSE);
+
+	if (!bg->filename)
+		return FALSE;
+
+	filename = get_filename_for_size (bg, best_width, best_height);
+	thumb = create_thumbnail_for_filename (factory, filename);
+	if (thumb) {
+		if (get_thumb_annotations (thumb, width, height))
+			result = TRUE;
+
+		g_object_unref (thumb);
+	}
+
+	if (!result) {
+		if (get_original_size (filename, width, height))
+			result = TRUE;
+	}
+
+	return result;
+}
+
+static double
+fit_factor (int from_width, int from_height,
+	    int to_width,   int to_height)
+{
+	return MIN (to_width  / (double) from_width, to_height / (double) from_height);
+}
+
+/**
+ * mate_bg_create_thumbnail:
+ *
+ * Returns: (transfer full): a #GdkPixbuf showing the background as a thumbnail
+ */
+GdkPixbuf *
+mate_bg_create_thumbnail (MateBG               *bg,
+		           MateDesktopThumbnailFactory *factory,
+			   GdkScreen             *screen,
+			   int                    dest_width,
+			   int                    dest_height)
+{
+	GdkPixbuf *result;
+	GdkPixbuf *thumb;
+
+	g_return_val_if_fail (bg != NULL, NULL);
+
+	result = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, dest_width, dest_height);
+
+	draw_color (bg, result);
+
+	if (bg->filename) {
+		thumb = create_img_thumbnail (bg, factory, screen, dest_width, dest_height, -1);
+
+		if (thumb) {
+			draw_image_for_thumb (bg, thumb, result);
+			g_object_unref (thumb);
+		}
+	}
+
+	return result;
+}
+
+/**
+ * mate_bg_get_surface_from_root:
+ * @screen: a #GdkScreen
+ *
+ * This function queries the _XROOTPMAP_ID property from
+ * the root window associated with @screen to determine
+ * the current root window background surface and returns
+ * a copy of it. If the _XROOTPMAP_ID is not set, then
+ * a black surface is returned.
+ *
+ * Return value: a #cairo_surface_t if successful or %NULL
+ **/
+cairo_surface_t *
+mate_bg_get_surface_from_root (GdkScreen *screen)
+{
+	int result;
+	gint format;
+	gulong nitems;
+	gulong bytes_after;
+	guchar *data;
+	Atom type;
+	Display *display;
+	int screen_num;
+	cairo_surface_t *surface;
+	cairo_surface_t *source_pixmap;
+	GdkDisplay *gdkdisplay;
+	int width, height;
+	cairo_t *cr;
+
+	display = GDK_DISPLAY_XDISPLAY (gdk_screen_get_display (screen));
+	screen_num = gdk_x11_screen_get_screen_number (screen);
+
+	result = XGetWindowProperty (display,
+				     RootWindow (display, screen_num),
+				     gdk_x11_get_xatom_by_name ("_XROOTPMAP_ID"),
+				     0L, 1L, False, XA_PIXMAP,
+				     &type, &format, &nitems, &bytes_after,
+				     &data);
+	surface = NULL;
+	source_pixmap = NULL;
+
+	if (result != Success || type != XA_PIXMAP ||
+	    format != 32 || nitems != 1) {
+		XFree (data);
+		data = NULL;
+	}
+
+	if (data != NULL) {
+		gdkdisplay = gdk_screen_get_display (screen);
+		gdk_x11_display_error_trap_push (gdkdisplay);
+
+		Pixmap xpixmap = *(Pixmap *) data;
+		Window root_return;
+		int x_ret, y_ret;
+		unsigned int w_ret, h_ret, bw_ret, depth_ret;
+
+		if (XGetGeometry (GDK_SCREEN_XDISPLAY (screen),
+				  xpixmap,
+				  &root_return,
+				  &x_ret, &y_ret, &w_ret, &h_ret, &bw_ret, &depth_ret))
+		{
+			source_pixmap = cairo_xlib_surface_create (GDK_SCREEN_XDISPLAY (screen),
+								   xpixmap,
+								   GDK_VISUAL_XVISUAL (gdk_screen_get_system_visual (screen)),
+								   w_ret, h_ret);
+		}
+
+		gdk_x11_display_error_trap_pop_ignored (gdkdisplay);
+	}
+
+	width = WidthOfScreen (gdk_x11_screen_get_xscreen (screen));
+	height = HeightOfScreen (gdk_x11_screen_get_xscreen (screen));
+
+	if (source_pixmap) {
+		surface = cairo_surface_create_similar (source_pixmap,
+							CAIRO_CONTENT_COLOR,
+							width, height);
+
+		cr = cairo_create (surface);
+		cairo_set_source_surface (cr, source_pixmap, 0, 0);
+		cairo_paint (cr);
+
+		if (cairo_status (cr) != CAIRO_STATUS_SUCCESS) {
+			cairo_surface_destroy (surface);
+			surface = NULL;
+		}
+
+		cairo_destroy (cr);
+	}
+
+	if (surface == NULL) {
+		surface = gdk_window_create_similar_surface (gdk_screen_get_root_window (screen),
+							     CAIRO_CONTENT_COLOR,
+							     width, height);
+	}
+
+	if (source_pixmap != NULL)
+		cairo_surface_destroy (source_pixmap);
+
+	if (data != NULL)
+		XFree (data);
+
+	return surface;
+}
+
+/* Sets the "ESETROOT_PMAP_ID" property to later be used to free the pixmap,
+ */
+static void
+mate_bg_set_root_pixmap_id (GdkScreen       *screen,
+			    Display         *display,
+			    Pixmap           xpixmap)
+{
+	Window   xroot   = RootWindow (display, gdk_x11_screen_get_screen_number (screen));
+	char    *atom_names[] = {"_XROOTPMAP_ID", "ESETROOT_PMAP_ID"};
+	Atom     atoms[G_N_ELEMENTS(atom_names)] = {0};
+
+	Atom     type;
+	int      format, result;
+	unsigned long nitems, after;
+	unsigned char *data_root, *data_esetroot;
+	GdkDisplay *gdkdisplay;
+
+	/* Get atoms for both properties in an array, only if they exist.
+	 * This method is to avoid multiple round-trips to Xserver
+	 */
+	if (XInternAtoms (display, atom_names, G_N_ELEMENTS(atom_names), True, atoms) &&
+	    atoms[0] != None && atoms[1] != None) {
+		result = XGetWindowProperty (display, xroot, atoms[0], 0L, 1L,
+		                             False, AnyPropertyType,
+		                             &type, &format, &nitems, &after,
+		                             &data_root);
+
+		if (data_root != NULL && result == Success &&
+		    type == XA_PIXMAP && format == 32 && nitems == 1) {
+			result = XGetWindowProperty (display, xroot, atoms[1],
+			                             0L, 1L, False,
+			                             AnyPropertyType,
+			                             &type, &format, &nitems,
+			                             &after, &data_esetroot);
+
+			if (data_esetroot != NULL && result == Success &&
+			    type == XA_PIXMAP && format == 32 && nitems == 1) {
+				Pixmap xrootpmap = *((Pixmap *) data_root);
+				Pixmap esetrootpmap = *((Pixmap *) data_esetroot);
+
+				gdkdisplay = gdk_screen_get_display (screen);
+				gdk_x11_display_error_trap_push (gdkdisplay);
+				if (xrootpmap && xrootpmap == esetrootpmap) {
+					XKillClient (display, xrootpmap);
+				}
+				if (esetrootpmap && esetrootpmap != xrootpmap) {
+					XKillClient (display, esetrootpmap);
+				}
+				gdk_x11_display_error_trap_pop_ignored (gdkdisplay);
+			}
+			if (data_esetroot != NULL) {
+				XFree (data_esetroot);
+			}
+		}
+		if (data_root != NULL) {
+			XFree (data_root);
+		}
+	}
+
+	/* Get atoms for both properties in an array, create them if needed.
+	 * This method is to avoid multiple round-trips to Xserver
+	 */
+	if (!XInternAtoms (display, atom_names, G_N_ELEMENTS(atom_names), False, atoms) ||
+	    atoms[0] == None || atoms[1] == None) {
+	    g_warning ("Could not create atoms needed to set root pixmap id/properties.\n");
+	    return;
+	}
+
+	/* Set new _XROOTMAP_ID and ESETROOT_PMAP_ID properties */
+	XChangeProperty (display, xroot, atoms[0], XA_PIXMAP, 32,
+			 PropModeReplace, (unsigned char *) &xpixmap, 1);
+
+	XChangeProperty (display, xroot, atoms[1], XA_PIXMAP, 32,
+			 PropModeReplace, (unsigned char *) &xpixmap, 1);
+}
+
+/**
+ * mate_bg_set_surface_as_root:
+ * @screen: the #GdkScreen to change root background on
+ * @surface: the #cairo_surface_t to set root background from.
+ *   Must be an xlib surface backing a pixmap.
+ *
+ * Set the root pixmap, and properties pointing to it. We
+ * do this atomically with a server grab to make sure that
+ * we won't leak the pixmap if somebody else it setting
+ * it at the same time. (This assumes that they follow the
+ * same conventions we do).  @surface should come from a call
+ * to mate_bg_create_surface().
+ **/
+void
+mate_bg_set_surface_as_root (GdkScreen *screen, cairo_surface_t *surface)
+{
+	g_return_if_fail (screen != NULL);
+	g_return_if_fail (cairo_surface_get_type (surface) == CAIRO_SURFACE_TYPE_XLIB);
+
+	/* Desktop background pixmap should be created from dummy X client since most
+	 * applications will try to kill it with XKillClient later when changing pixmap
+	 */
+	Display    *display      = GDK_DISPLAY_XDISPLAY (gdk_screen_get_display (screen));
+	Pixmap      pixmap_id    = cairo_xlib_surface_get_drawable (surface);
+	Window      xroot        = RootWindow (display, gdk_x11_screen_get_screen_number (screen));
+
+	XGrabServer (display);
+	mate_bg_set_root_pixmap_id (screen, display, pixmap_id);
+
+	XSetWindowBackgroundPixmap (display, xroot, pixmap_id);
+	XClearWindow (display, xroot);
+
+	XFlush (display);
+	XUngrabServer (display);
+}
+
+/**
+ * mate_bg_set_surface_as_root_with_crossfade:
+ * @screen: the #GdkScreen to change root background on
+ * @surface: the cairo xlib surface to set root background from
+ *
+ * Set the root pixmap, and properties pointing to it.
+ * This function differs from mate_bg_set_surface_as_root()
+ * in that it adds a subtle crossfade animation from the
+ * current root pixmap to the new one.
+ *
+ * Return value: (transfer full): a #MateBGCrossfade object
+ **/
+MateBGCrossfade *
+mate_bg_set_surface_as_root_with_crossfade (GdkScreen       *screen,
+		 			    cairo_surface_t *surface)
+{
+	GdkWindow       *root_window;
+	int              width, height;
+	MateBGCrossfade *fade;
+	cairo_t         *cr;
+	cairo_surface_t *old_surface;
+
+	g_return_val_if_fail (screen != NULL, NULL);
+	g_return_val_if_fail (surface != NULL, NULL);
+
+	root_window = gdk_screen_get_root_window (screen);
+	width       = gdk_window_get_width (root_window);
+	height      = gdk_window_get_height (root_window);
+	fade        = mate_bg_crossfade_new (width, height);
+	old_surface = mate_bg_get_surface_from_root (screen);
+
+	mate_bg_crossfade_set_start_surface (fade, old_surface);
+	mate_bg_crossfade_set_end_surface (fade, surface);
+
+	/* Before setting the surface as a root pixmap, let's have it draw
+	 * the old stuff, just so it won't be noticable
+	 * (crossfade will later get it back)
+	 */
+	cr = cairo_create (surface);
+	cairo_set_source_surface (cr, old_surface, 0, 0);
+	cairo_pattern_set_extend (cairo_get_source (cr), CAIRO_EXTEND_REPEAT);
+	cairo_paint (cr);
+	cairo_destroy (cr);
+	cairo_surface_destroy (old_surface);
+
+	mate_bg_set_surface_as_root (screen, surface);
+	mate_bg_crossfade_start (fade, root_window);
+
+	return fade;
+}
+
+/* Implementation of the pixbuf cache */
+struct _SlideShow
+{
+	gint ref_count;
+	double start_time;
+	double total_duration;
+
+	GQueue *slides;
+
+	gboolean has_multiple_sizes;
+
+	/* used during parsing */
+	struct tm start_tm;
+	GQueue *stack;
+};
+
+#if GLIB_CHECK_VERSION(2,61,2)
+static double
+now (void)
+{
+	const double microseconds_per_second = (double) G_USEC_PER_SEC;
+	gint64 tv;
+
+	tv = g_get_real_time ();
+
+	return (double) (tv / microseconds_per_second);
+}
+#else
+static double
+now (void)
+{
+	const double microseconds_per_second = (double) G_USEC_PER_SEC;
+	GTimeVal tv;
+
+	g_get_current_time (&tv);
+
+	return (double)tv.tv_sec + (tv.tv_usec / microseconds_per_second);
+}
+#endif
+
+static Slide *
+get_current_slide (SlideShow *show,
+		   double    *alpha)
+{
+	double delta = fmod (now() - show->start_time, show->total_duration);
+	GList *list;
+	double elapsed;
+	int i;
+
+	if (delta < 0)
+		delta += show->total_duration;
+
+	elapsed = 0;
+	i = 0;
+	for (list = show->slides->head; list != NULL; list = list->next) {
+		Slide *slide = list->data;
+
+		if (elapsed + slide->duration > delta) {
+			if (alpha)
+				*alpha = (delta - elapsed) / (double)slide->duration;
+			return slide;
+		}
+
+		i++;
+		elapsed += slide->duration;
+	}
+
+	/* this should never happen since we have slides and we should always
+	 * find a current slide for the elapsed time since beginning -- we're
+	 * looping with fmod() */
+	g_assert_not_reached ();
+
+	return NULL;
+}
+
+static GdkPixbuf *
+blend (GdkPixbuf *p1,
+       GdkPixbuf *p2,
+       double alpha)
+{
+	GdkPixbuf *result = gdk_pixbuf_copy (p1);
+	GdkPixbuf *tmp;
+
+	if (gdk_pixbuf_get_width (p2) != gdk_pixbuf_get_width (p1) ||
+            gdk_pixbuf_get_height (p2) != gdk_pixbuf_get_height (p1)) {
+		tmp = gdk_pixbuf_scale_simple (p2,
+					       gdk_pixbuf_get_width (p1),
+					       gdk_pixbuf_get_height (p1),
+					       GDK_INTERP_BILINEAR);
+	}
+        else {
+		tmp = g_object_ref (p2);
+	}
+
+	pixbuf_blend (tmp, result, 0, 0, -1, -1, 0, 0, alpha);
+
+        g_object_unref (tmp);
+
+	return result;
+}
+
+typedef	enum {
+	PIXBUF,
+	SLIDESHOW,
+	THUMBNAIL
+} FileType;
+
+struct FileCacheEntry
+{
+	FileType type;
+	char *filename;
+	union {
+		GdkPixbuf *pixbuf;
+		SlideShow *slideshow;
+		GdkPixbuf *thumbnail;
+	} u;
+};
+
+static void
+file_cache_entry_delete (FileCacheEntry *ent)
+{
+	g_free (ent->filename);
+
+	switch (ent->type) {
+	case PIXBUF:
+		g_object_unref (ent->u.pixbuf);
+		break;
+	case SLIDESHOW:
+		slideshow_unref (ent->u.slideshow);
+		break;
+	case THUMBNAIL:
+		g_object_unref (ent->u.thumbnail);
+		break;
+	}
+
+	g_free (ent);
+}
+
+static void
+bound_cache (MateBG *bg)
+{
+      while (g_list_length (bg->file_cache) >= CACHE_SIZE) {
+	      GList *last_link = g_list_last (bg->file_cache);
+	      FileCacheEntry *ent = last_link->data;
+
+	      file_cache_entry_delete (ent);
+
+	      bg->file_cache = g_list_delete_link (bg->file_cache, last_link);
+      }
+}
+
+static const FileCacheEntry *
+file_cache_lookup (MateBG *bg, FileType type, const char *filename)
+{
+	GList *list;
+
+	for (list = bg->file_cache; list != NULL; list = list->next) {
+		FileCacheEntry *ent = list->data;
+
+		if (ent && ent->type == type &&
+		    strcmp (ent->filename, filename) == 0) {
+			return ent;
+		}
+	}
+
+	return NULL;
+}
+
+static FileCacheEntry *
+file_cache_entry_new (MateBG *bg,
+		      FileType type,
+		      const char *filename)
+{
+	FileCacheEntry *ent = g_new0 (FileCacheEntry, 1);
+
+	g_assert (!file_cache_lookup (bg, type, filename));
+
+	ent->type = type;
+	ent->filename = g_strdup (filename);
+
+	bg->file_cache = g_list_prepend (bg->file_cache, ent);
+
+	bound_cache (bg);
+
+	return ent;
+}
+
+static void
+file_cache_add_pixbuf (MateBG *bg,
+		       const char *filename,
+		       GdkPixbuf *pixbuf)
+{
+	FileCacheEntry *ent = file_cache_entry_new (bg, PIXBUF, filename);
+	ent->u.pixbuf = g_object_ref (pixbuf);
+}
+
+static void
+file_cache_add_thumbnail (MateBG *bg,
+			  const char *filename,
+			  GdkPixbuf *pixbuf)
+{
+	FileCacheEntry *ent = file_cache_entry_new (bg, THUMBNAIL, filename);
+	ent->u.thumbnail = g_object_ref (pixbuf);
+}
+
+static void
+file_cache_add_slide_show (MateBG *bg,
+			   const char *filename,
+			   SlideShow *show)
+{
+	FileCacheEntry *ent = file_cache_entry_new (bg, SLIDESHOW, filename);
+	ent->u.slideshow = slideshow_ref (show);
+}
+
+static GdkPixbuf *
+load_from_cache_file (MateBG     *bg,
+		      const char *filename,
+		      gint        num_monitor,
+		      gint        best_width,
+		      gint        best_height)
+{
+	GdkPixbuf *pixbuf = NULL;
+	gchar *cache_filename;
+
+	cache_filename = get_wallpaper_cache_filename (filename, num_monitor, bg->placement,
+							best_width, best_height);
+
+	if (cache_file_is_valid (filename, cache_filename))
+		pixbuf = gdk_pixbuf_new_from_file (cache_filename, NULL);
+
+	g_free (cache_filename);
+
+	return pixbuf;
+}
+
+static GdkPixbuf *
+get_as_pixbuf_for_size (MateBG    *bg,
+			const char *filename,
+			gint         monitor,
+			gint         best_width,
+			gint         best_height)
+{
+	const FileCacheEntry *ent;
+	if ((ent = file_cache_lookup (bg, PIXBUF, filename))) {
+		return g_object_ref (ent->u.pixbuf);
+	} else {
+		GdkPixbufFormat *format;
+		GdkPixbuf *pixbuf = NULL;
+		gchar *tmp = NULL;
+		GdkPixbuf *tmp_pixbuf;
+
+		/* Try to hit local cache first if relevant */
+		if (monitor != -1)
+			pixbuf = load_from_cache_file (bg, filename, monitor,
+							best_width, best_height);
+
+		if (!pixbuf) {
+			/* If scalable choose maximum size */
+			format = gdk_pixbuf_get_file_info (filename, NULL, NULL);
+			if (format != NULL)
+				tmp = gdk_pixbuf_format_get_name (format);
+
+			if (g_strcmp0 (tmp, "svg") == 0 &&
+			    (best_width > 0 && best_height > 0) &&
+			    (bg->placement == MATE_BG_PLACEMENT_FILL_SCREEN ||
+			     bg->placement == MATE_BG_PLACEMENT_SCALED ||
+			     bg->placement == MATE_BG_PLACEMENT_ZOOMED))
+			{
+				pixbuf = gdk_pixbuf_new_from_file_at_size (filename,
+									   best_width,
+									   best_height, NULL);
+			} else {
+				pixbuf = gdk_pixbuf_new_from_file (filename, NULL);
+			}
+
+			if (tmp != NULL)
+				g_free (tmp);
+		}
+
+		if (pixbuf) {
+			tmp_pixbuf = gdk_pixbuf_apply_embedded_orientation (pixbuf);
+			g_object_unref (pixbuf);
+			pixbuf = tmp_pixbuf;
+			file_cache_add_pixbuf (bg, filename, pixbuf);
+		}
+
+		return pixbuf;
+	}
+}
+
+static SlideShow *
+get_as_slideshow (MateBG *bg, const char *filename)
+{
+	const FileCacheEntry *ent;
+	if ((ent = file_cache_lookup (bg, SLIDESHOW, filename))) {
+		return slideshow_ref (ent->u.slideshow);
+	}
+	else {
+		SlideShow *show = read_slideshow_file (filename, NULL);
+
+		if (show)
+			file_cache_add_slide_show (bg, filename, show);
+
+		return show;
+	}
+}
+
+static GdkPixbuf *
+get_as_thumbnail (MateBG *bg, MateDesktopThumbnailFactory *factory, const char *filename)
+{
+	const FileCacheEntry *ent;
+	if ((ent = file_cache_lookup (bg, THUMBNAIL, filename))) {
+		return g_object_ref (ent->u.thumbnail);
+	}
+	else {
+		GdkPixbuf *thumb = create_thumbnail_for_filename (factory, filename);
+
+		if (thumb)
+			file_cache_add_thumbnail (bg, filename, thumb);
+
+		return thumb;
+	}
+}
+
+static gboolean
+blow_expensive_caches (gpointer data)
+{
+	MateBG *bg = data;
+	GList *list, *next;
+
+	bg->blow_caches_id = 0;
+
+	for (list = bg->file_cache; list != NULL; list = next) {
+		FileCacheEntry *ent = list->data;
+		next = list->next;
+
+		if (ent->type == PIXBUF) {
+			file_cache_entry_delete (ent);
+			bg->file_cache = g_list_delete_link (bg->file_cache,
+							     list);
+		}
+	}
+
+	if (bg->pixbuf_cache) {
+		g_object_unref (bg->pixbuf_cache);
+		bg->pixbuf_cache = NULL;
+	}
+
+	return FALSE;
+}
+
+static void
+blow_expensive_caches_in_idle (MateBG *bg)
+{
+	if (bg->blow_caches_id == 0) {
+		bg->blow_caches_id =
+			g_idle_add (blow_expensive_caches,
+				    bg);
+	}
+}
+
+static gboolean
+on_timeout (gpointer data)
+{
+	MateBG *bg = data;
+
+	bg->timeout_id = 0;
+
+	queue_transitioned (bg);
+
+	return FALSE;
+}
+
+static double
+get_slide_timeout (Slide   *slide)
+{
+	double timeout;
+	if (slide->fixed) {
+		timeout = slide->duration;
+	} else {
+		/* Maybe the number of steps should be configurable? */
+
+		/* In the worst case we will do a fade from 0 to 256, which mean
+		 * we will never use more than 255 steps, however in most cases
+		 * the first and last value are similar and users can't percieve
+		 * changes in pixel values as small as 1/255th. So, lets not waste
+		 * CPU cycles on transitioning to often.
+		 *
+		 * 64 steps is enough for each step to be just detectable in a 16bit
+		 * color mode in the worst case, so we'll use this as an approximation
+		 * of whats detectable.
+		 */
+		timeout = slide->duration / 64.0;
+	}
+	return timeout;
+}
+
+static void
+ensure_timeout (MateBG *bg,
+		Slide   *slide)
+{
+	if (!bg->timeout_id) {
+		double timeout = get_slide_timeout (slide);
+
+		/* G_MAXUINT means "only one slide" */
+		if (timeout < G_MAXUINT) {
+			bg->timeout_id = g_timeout_add_full (
+				G_PRIORITY_LOW,
+				timeout * 1000, on_timeout, bg, NULL);
+		}
+
+	}
+}
+
+static gint64
+get_mtime (const char *filename)
+{
+	GFile     *file;
+	GFileInfo *info;
+	gint64     mtime = (gint64)-1;
+
+	if (filename) {
+		file = g_file_new_for_path (filename);
+		info = g_file_query_info (file, G_FILE_ATTRIBUTE_TIME_MODIFIED,
+					  G_FILE_QUERY_INFO_NONE, NULL, NULL);
+		if (info) {
+			mtime = g_file_info_get_attribute_uint64 (info,
+								  G_FILE_ATTRIBUTE_TIME_MODIFIED);
+			g_object_unref (info);
+		}
+		g_object_unref (file);
+	}
+
+	return mtime;
+}
+
+static GdkPixbuf *
+scale_thumbnail (MateBGPlacement placement,
+		 const char *filename,
+		 GdkPixbuf *thumb,
+		 GdkScreen *screen,
+		 int	    dest_width,
+		 int	    dest_height)
+{
+	int o_width;
+	int o_height;
+
+	if (placement != MATE_BG_PLACEMENT_TILED &&
+	    placement != MATE_BG_PLACEMENT_CENTERED) {
+
+		/* In this case, the pixbuf will be scaled to fit the screen anyway,
+		 * so just return the pixbuf here
+		 */
+		return g_object_ref (thumb);
+	}
+
+	if (get_thumb_annotations (thumb, &o_width, &o_height)		||
+	    (filename && get_original_size (filename, &o_width, &o_height))) {
+
+		int scr_height = HeightOfScreen (gdk_x11_screen_get_xscreen (screen));
+		int scr_width = WidthOfScreen (gdk_x11_screen_get_xscreen (screen));
+		int thumb_width = gdk_pixbuf_get_width (thumb);
+		int thumb_height = gdk_pixbuf_get_height (thumb);
+		double screen_to_dest = fit_factor (scr_width, scr_height,
+						    dest_width, dest_height);
+		double thumb_to_orig  = fit_factor (thumb_width, thumb_height,
+						    o_width, o_height);
+		double f = thumb_to_orig * screen_to_dest;
+		int new_width, new_height;
+
+		new_width = floor (thumb_width * f + 0.5);
+		new_height = floor (thumb_height * f + 0.5);
+
+		if (placement == MATE_BG_PLACEMENT_TILED) {
+			/* Heuristic to make sure tiles don't become so small that
+			 * they turn into a blur.
+			 *
+			 * This is strictly speaking incorrect, but the resulting
+			 * thumbnail gives a much better idea what the background
+			 * will actually look like.
+			 */
+
+			if ((new_width < 32 || new_height < 32) &&
+			    (new_width < o_width / 4 || new_height < o_height / 4)) {
+				new_width = o_width / 4;
+				new_height = o_height / 4;
+			}
+		}
+
+		thumb = gdk_pixbuf_scale_simple (thumb, new_width, new_height,
+						 GDK_INTERP_BILINEAR);
+	}
+	else
+		g_object_ref (thumb);
+
+	return thumb;
+}
+
+/* frame_num determines which slide to thumbnail.
+ * -1 means 'current slide'.
+ */
+static GdkPixbuf *
+create_img_thumbnail (MateBG                      *bg,
+		      MateDesktopThumbnailFactory *factory,
+		      GdkScreen                    *screen,
+		      int                           dest_width,
+		      int                           dest_height,
+		      int                           frame_num)
+{
+	if (bg->filename) {
+		GdkPixbuf *thumb;
+
+		thumb = get_as_thumbnail (bg, factory, bg->filename);
+
+		if (thumb) {
+			GdkPixbuf *result;
+			result = scale_thumbnail (bg->placement,
+						  bg->filename,
+						  thumb,
+						  screen,
+						  dest_width,
+						  dest_height);
+			g_object_unref (thumb);
+			return result;
+		}
+		else {
+			SlideShow *show = get_as_slideshow (bg, bg->filename);
+
+			if (show) {
+				double alpha;
+				Slide *slide;
+
+				if (frame_num == -1)
+					slide = get_current_slide (show, &alpha);
+				else
+					slide = g_queue_peek_nth (show->slides, frame_num);
+
+				if (slide->fixed) {
+					GdkPixbuf *tmp;
+					FileSize *fs;
+					fs = find_best_size (slide->file1, dest_width, dest_height);
+					tmp = get_as_thumbnail (bg, factory, fs->file);
+					if (tmp) {
+						thumb = scale_thumbnail (bg->placement,
+									 fs->file,
+									 tmp,
+									 screen,
+									 dest_width,
+									 dest_height);
+						g_object_unref (tmp);
+					}
+				}
+				else {
+					FileSize *fs1, *fs2;
+					GdkPixbuf *p1, *p2;
+					fs1 = find_best_size (slide->file1, dest_width, dest_height);
+					p1 = get_as_thumbnail (bg, factory, fs1->file);
+
+					fs2 = find_best_size (slide->file2, dest_width, dest_height);
+					p2 = get_as_thumbnail (bg, factory, fs2->file);
+
+					if (p1 && p2) {
+						GdkPixbuf *thumb1, *thumb2;
+
+						thumb1 = scale_thumbnail (bg->placement,
+									  fs1->file,
+									  p1,
+									  screen,
+									  dest_width,
+									  dest_height);
+
+						thumb2 = scale_thumbnail (bg->placement,
+									  fs2->file,
+									  p2,
+									  screen,
+									  dest_width,
+									  dest_height);
+
+						thumb = blend (thumb1, thumb2, alpha);
+
+						g_object_unref (thumb1);
+						g_object_unref (thumb2);
+					}
+					if (p1)
+						g_object_unref (p1);
+					if (p2)
+						g_object_unref (p2);
+				}
+
+				ensure_timeout (bg, slide);
+
+				slideshow_unref (show);
+			}
+		}
+
+		return thumb;
+	}
+
+	return NULL;
+}
+
+/*
+ * Find the FileSize that best matches the given size.
+ * Do two passes; the first pass only considers FileSizes
+ * that are larger than the given size.
+ * We are looking for the image that best matches the aspect ratio.
+ * When two images have the same aspect ratio, prefer the one whose
+ * width is closer to the given width.
+ */
+static FileSize *
+find_best_size (GSList *sizes, gint width, gint height)
+{
+	GSList *s;
+	gdouble a, d, distance;
+	FileSize *best = NULL;
+	gint pass;
+
+	a = width/(gdouble)height;
+	distance = 10000.0;
+
+	for (pass = 0; pass < 2; pass++) {
+		for (s = sizes; s; s = s->next) {
+			FileSize *size = s->data;
+
+			if (pass == 0 && (size->width < width || size->height < height))
+				continue;
+
+			d = fabs (a - size->width/(gdouble)size->height);
+			if (d < distance) {
+				distance = d;
+				best = size;
+			}
+			else if (d == distance) {
+				if (best && (abs (size->width - width) < abs (best->width - width))) {
+					best = size;
+				}
+			}
+		}
+
+		if (best)
+			break;
+	}
+
+	return best;
+}
+
+static GdkPixbuf *
+get_pixbuf_for_size (MateBG *bg,
+		     gint monitor,
+		     gint best_width,
+		     gint best_height)
+{
+	guint time_until_next_change;
+	gboolean hit_cache = FALSE;
+
+	/* only hit the cache if the aspect ratio matches */
+	if (bg->pixbuf_cache) {
+		int width, height;
+		width = gdk_pixbuf_get_width (bg->pixbuf_cache);
+		height = gdk_pixbuf_get_height (bg->pixbuf_cache);
+		hit_cache = 0.2 > fabs ((best_width / (double)best_height) - (width / (double)height));
+		if (!hit_cache) {
+			g_object_unref (bg->pixbuf_cache);
+			bg->pixbuf_cache = NULL;
+		}
+	}
+
+	if (!hit_cache && bg->filename) {
+		bg->file_mtime = get_mtime (bg->filename);
+
+		bg->pixbuf_cache = get_as_pixbuf_for_size (bg, bg->filename, monitor,
+							   best_width, best_height);
+		time_until_next_change = G_MAXUINT;
+		if (!bg->pixbuf_cache) {
+			SlideShow *show = get_as_slideshow (bg, bg->filename);
+
+			if (show) {
+				double alpha;
+				double timeout;
+				Slide *slide;
+
+				slideshow_ref (show);
+
+				slide = get_current_slide (show, &alpha);
+				timeout = get_slide_timeout (slide);
+				time_until_next_change = (guint) timeout;
+				if (slide->fixed) {
+					FileSize *size = find_best_size (slide->file1,
+									 best_width, best_height);
+					bg->pixbuf_cache =
+						get_as_pixbuf_for_size (bg, size->file, monitor,
+									best_width, best_height);
+				} else {
+					FileSize *size;
+					GdkPixbuf *p1, *p2;
+
+					size = find_best_size (slide->file1,
+								best_width, best_height);
+					p1 = get_as_pixbuf_for_size (bg, size->file, monitor,
+								     best_width, best_height);
+
+					size = find_best_size (slide->file2,
+								best_width, best_height);
+					p2 = get_as_pixbuf_for_size (bg, size->file, monitor,
+								     best_width, best_height);
+
+					if (p1 && p2)
+						bg->pixbuf_cache = blend (p1, p2, alpha);
+					if (p1)
+						g_object_unref (p1);
+					if (p2)
+						g_object_unref (p2);
+				}
+
+				ensure_timeout (bg, slide);
+
+				slideshow_unref (show);
+			}
+		}
+
+		/* If the next slideshow step is a long time away then
+		   we blow away the expensive stuff (large pixbufs) from
+		   the cache */
+		if (time_until_next_change > KEEP_EXPENSIVE_CACHE_SECS)
+		    blow_expensive_caches_in_idle (bg);
+	}
+
+	if (bg->pixbuf_cache)
+		g_object_ref (bg->pixbuf_cache);
+
+	return bg->pixbuf_cache;
+}
+
+static gboolean
+is_different (MateBG    *bg,
+	      const char *filename)
+{
+	if (!filename && bg->filename) {
+		return TRUE;
+	}
+	else if (filename && !bg->filename) {
+		return TRUE;
+	}
+	else if (!filename && !bg->filename) {
+		return FALSE;
+	}
+	else {
+		if (get_mtime (filename) != bg->file_mtime)
+			return TRUE;
+
+		if (strcmp (filename, bg->filename) != 0)
+			return TRUE;
+
+		return FALSE;
+	}
+}
+
+static void
+clear_cache (MateBG *bg)
+{
+	GList *list;
+
+	if (bg->file_cache) {
+		for (list = bg->file_cache; list != NULL; list = list->next) {
+			FileCacheEntry *ent = list->data;
+
+			file_cache_entry_delete (ent);
+		}
+		g_list_free (bg->file_cache);
+		bg->file_cache = NULL;
+	}
+
+	if (bg->pixbuf_cache) {
+		g_object_unref (bg->pixbuf_cache);
+
+		bg->pixbuf_cache = NULL;
+	}
+
+	if (bg->timeout_id) {
+		g_source_remove (bg->timeout_id);
+
+		bg->timeout_id = 0;
+	}
+}
+
+/* Pixbuf utilities */
+static void
+pixbuf_average_value (GdkPixbuf *pixbuf,
+                      GdkRGBA   *result)
+{
+	guint64 a_total, r_total, g_total, b_total;
+	guint row, column;
+	int row_stride;
+	const guchar *pixels, *p;
+	int r, g, b, a;
+	guint64 dividend;
+	guint width, height;
+	gdouble dd;
+
+	width = gdk_pixbuf_get_width (pixbuf);
+	height = gdk_pixbuf_get_height (pixbuf);
+	row_stride = gdk_pixbuf_get_rowstride (pixbuf);
+	pixels = gdk_pixbuf_get_pixels (pixbuf);
+
+	/* iterate through the pixbuf, counting up each component */
+	a_total = 0;
+	r_total = 0;
+	g_total = 0;
+	b_total = 0;
+
+	if (gdk_pixbuf_get_has_alpha (pixbuf)) {
+		for (row = 0; row < height; row++) {
+			p = pixels + (row * row_stride);
+			for (column = 0; column < width; column++) {
+				r = *p++;
+				g = *p++;
+				b = *p++;
+				a = *p++;
+
+				a_total += a;
+				r_total += r * a;
+				g_total += g * a;
+				b_total += b * a;
+			}
+		}
+		dividend = height * width * 0xFF;
+		a_total *= 0xFF;
+	} else {
+		for (row = 0; row < height; row++) {
+			p = pixels + (row * row_stride);
+			for (column = 0; column < width; column++) {
+				r = *p++;
+				g = *p++;
+				b = *p++;
+
+				r_total += r;
+				g_total += g;
+				b_total += b;
+			}
+		}
+		dividend = height * width;
+		a_total = dividend * 0xFF;
+	}
+
+	dd = dividend * 0xFF;
+	result->alpha = a_total / dd;
+	result->red = r_total / dd;
+	result->green = g_total / dd;
+	result->blue = b_total / dd;
+}
+
+static GdkPixbuf *
+pixbuf_scale_to_fit (GdkPixbuf *src, int max_width, int max_height)
+{
+	double factor;
+	int src_width, src_height;
+	int new_width, new_height;
+
+	src_width = gdk_pixbuf_get_width (src);
+	src_height = gdk_pixbuf_get_height (src);
+
+	factor = MIN (max_width  / (double) src_width, max_height / (double) src_height);
+
+	new_width  = floor (src_width * factor + 0.5);
+	new_height = floor (src_height * factor + 0.5);
+
+	return gdk_pixbuf_scale_simple (src, new_width, new_height, GDK_INTERP_BILINEAR);
+}
+
+static GdkPixbuf *
+pixbuf_scale_to_min (GdkPixbuf *src, int min_width, int min_height)
+{
+	double factor;
+	int src_width, src_height;
+	int new_width, new_height;
+	GdkPixbuf *dest;
+
+	src_width = gdk_pixbuf_get_width (src);
+	src_height = gdk_pixbuf_get_height (src);
+
+	factor = MAX (min_width / (double) src_width, min_height / (double) src_height);
+
+	new_width = floor (src_width * factor + 0.5);
+	new_height = floor (src_height * factor + 0.5);
+
+	dest = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
+			       gdk_pixbuf_get_has_alpha (src),
+			       8, min_width, min_height);
+	if (!dest)
+		return NULL;
+
+	/* crop the result */
+	gdk_pixbuf_scale (src, dest,
+			  0, 0,
+			  min_width, min_height,
+			  (new_width - min_width) / -2,
+			  (new_height - min_height) / -2,
+			  factor,
+			  factor,
+			  GDK_INTERP_BILINEAR);
+	return dest;
+}
+
+static guchar *
+create_gradient (const GdkRGBA *primary,
+		 const GdkRGBA *secondary,
+		 int	         n_pixels)
+{
+	guchar *result = g_malloc (n_pixels * 3);
+	int i;
+
+	for (i = 0; i < n_pixels; ++i) {
+		double ratio = (i + 0.5) / n_pixels;
+
+		result[3 * i + 0] = (guchar) ((primary->red * (1 - ratio) + secondary->red * ratio) * 0x100);
+		result[3 * i + 1] = (guchar) ((primary->green * (1 - ratio) + secondary->green * ratio) * 0x100);
+		result[3 * i + 2] = (guchar) ((primary->blue * (1 - ratio) + secondary->blue * ratio) * 0x100);
+	}
+
+	return result;
+}
+
+static void
+pixbuf_draw_gradient (GdkPixbuf    *pixbuf,
+		      gboolean      horizontal,
+		      GdkRGBA      *primary,
+		      GdkRGBA      *secondary,
+		      GdkRectangle *rect)
+{
+	int width;
+	int height;
+	int rowstride;
+	guchar *dst;
+	int n_channels = 3;
+
+	rowstride = gdk_pixbuf_get_rowstride (pixbuf);
+	width = rect->width;
+	height = rect->height;
+	dst = gdk_pixbuf_get_pixels (pixbuf) + rect->x * n_channels + rowstride * rect->y;
+
+	if (horizontal) {
+		guchar *gradient = create_gradient (primary, secondary, width);
+		int copy_bytes_per_row = width * n_channels;
+		int i;
+
+		for (i = 0; i < height; i++) {
+			guchar *d;
+			d = dst + rowstride * i;
+			memcpy (d, gradient, copy_bytes_per_row);
+		}
+		g_free (gradient);
+	} else {
+		guchar *gb, *gradient;
+		int i;
+
+		gradient = create_gradient (primary, secondary, height);
+		for (i = 0; i < height; i++) {
+			int j;
+			guchar *d;
+
+			d = dst + rowstride * i;
+			gb = gradient + n_channels * i;
+			for (j = width; j > 0; j--) {
+				int k;
+
+				for (k = 0; k < n_channels; k++) {
+					*(d++) = gb[k];
+				}
+			}
+		}
+
+		g_free (gradient);
+	}
+}
+
+static void
+pixbuf_blend (GdkPixbuf *src,
+	      GdkPixbuf *dest,
+	      int	 src_x,
+	      int	 src_y,
+	      int	 src_width,
+	      int        src_height,
+	      int	 dest_x,
+	      int	 dest_y,
+	      double	 alpha)
+{
+	int dest_width = gdk_pixbuf_get_width (dest);
+	int dest_height = gdk_pixbuf_get_height (dest);
+	int offset_x = dest_x - src_x;
+	int offset_y = dest_y - src_y;
+
+	if (src_width < 0)
+		src_width = gdk_pixbuf_get_width (src);
+
+	if (src_height < 0)
+		src_height = gdk_pixbuf_get_height (src);
+
+	if (dest_x < 0)
+		dest_x = 0;
+
+	if (dest_y < 0)
+		dest_y = 0;
+
+	if (dest_x + src_width > dest_width) {
+		src_width = dest_width - dest_x;
+	}
+
+	if (dest_y + src_height > dest_height) {
+		src_height = dest_height - dest_y;
+	}
+
+	gdk_pixbuf_composite (src, dest,
+			      dest_x, dest_y,
+			      src_width, src_height,
+			      offset_x, offset_y,
+			      1, 1, GDK_INTERP_NEAREST,
+			      alpha * 0xFF + 0.5);
+}
+
+static void
+pixbuf_tile (GdkPixbuf *src, GdkPixbuf *dest)
+{
+	int x, y;
+	int tile_width, tile_height;
+	int dest_width = gdk_pixbuf_get_width (dest);
+	int dest_height = gdk_pixbuf_get_height (dest);
+
+	tile_width = gdk_pixbuf_get_width (src);
+	tile_height = gdk_pixbuf_get_height (src);
+
+	for (y = 0; y < dest_height; y += tile_height) {
+		for (x = 0; x < dest_width; x += tile_width) {
+			pixbuf_blend (src, dest, 0, 0,
+				      tile_width, tile_height, x, y, 1.0);
+		}
+	}
+}
+
+static gboolean stack_is (SlideShow *parser, const char *s1, ...);
+
+/* Parser for fading background */
+static void
+handle_start_element (GMarkupParseContext *context,
+		      const gchar         *name,
+		      const gchar        **attr_names,
+		      const gchar        **attr_values,
+		      gpointer             user_data,
+		      GError             **err)
+{
+	SlideShow *parser = user_data;
+	gint i;
+
+	if (strcmp (name, "static") == 0 || strcmp (name, "transition") == 0) {
+		Slide *slide = g_new0 (Slide, 1);
+
+		if (strcmp (name, "static") == 0)
+			slide->fixed = TRUE;
+
+		g_queue_push_tail (parser->slides, slide);
+	}
+	else if (strcmp (name, "size") == 0) {
+		Slide *slide = parser->slides->tail->data;
+		FileSize *size = g_new0 (FileSize, 1);
+		for (i = 0; attr_names[i]; i++) {
+			if (strcmp (attr_names[i], "width") == 0)
+				size->width = atoi (attr_values[i]);
+			else if (strcmp (attr_names[i], "height") == 0)
+				size->height = atoi (attr_values[i]);
+		}
+		if (parser->stack->tail &&
+		    (strcmp (parser->stack->tail->data, "file") == 0 ||
+		     strcmp (parser->stack->tail->data, "from") == 0)) {
+			slide->file1 = g_slist_prepend (slide->file1, size);
+		}
+		else if (parser->stack->tail &&
+			 strcmp (parser->stack->tail->data, "to") == 0) {
+			slide->file2 = g_slist_prepend (slide->file2, size);
+		}
+		else
+			g_free (size);
+	}
+	g_queue_push_tail (parser->stack, g_strdup (name));
+}
+
+static void
+handle_end_element (GMarkupParseContext *context,
+		    const gchar         *name,
+		    gpointer             user_data,
+		    GError             **err)
+{
+	SlideShow *parser = user_data;
+
+	g_free (g_queue_pop_tail (parser->stack));
+}
+
+static gboolean
+stack_is (SlideShow *parser,
+	  const char *s1,
+	  ...)
+{
+	GList *stack = NULL;
+	const char *s;
+	GList *l1, *l2;
+	va_list args;
+
+	stack = g_list_prepend (stack, (gpointer)s1);
+
+	va_start (args, s1);
+
+	s = va_arg (args, const char *);
+	while (s) {
+		stack = g_list_prepend (stack, (gpointer)s);
+		s = va_arg (args, const char *);
+	}
+
+	va_end (args);
+
+	l1 = stack;
+	l2 = parser->stack->head;
+
+	while (l1 && l2) {
+		if (strcmp (l1->data, l2->data) != 0) {
+			g_list_free (stack);
+			return FALSE;
+		}
+
+		l1 = l1->next;
+		l2 = l2->next;
+	}
+
+	g_list_free (stack);
+
+	return (!l1 && !l2);
+}
+
+static int
+parse_int (const char *text)
+{
+	return strtol (text, NULL, 0);
+}
+
+static void
+handle_text (GMarkupParseContext *context,
+	     const gchar         *text,
+	     gsize                text_len,
+	     gpointer             user_data,
+	     GError             **err)
+{
+	SlideShow *parser = user_data;
+	FileSize *fs;
+	gint i;
+
+	g_return_if_fail (parser != NULL);
+	g_return_if_fail (parser->slides != NULL);
+
+	Slide *slide = parser->slides->tail ? parser->slides->tail->data : NULL;
+
+	if (stack_is (parser, "year", "starttime", "background", NULL)) {
+		parser->start_tm.tm_year = parse_int (text) - 1900;
+	}
+	else if (stack_is (parser, "month", "starttime", "background", NULL)) {
+		parser->start_tm.tm_mon = parse_int (text) - 1;
+	}
+	else if (stack_is (parser, "day", "starttime", "background", NULL)) {
+		parser->start_tm.tm_mday = parse_int (text);
+	}
+	else if (stack_is (parser, "hour", "starttime", "background", NULL)) {
+		parser->start_tm.tm_hour = parse_int (text) - 1;
+	}
+	else if (stack_is (parser, "minute", "starttime", "background", NULL)) {
+		parser->start_tm.tm_min = parse_int (text);
+	}
+	else if (stack_is (parser, "second", "starttime", "background", NULL)) {
+		parser->start_tm.tm_sec = parse_int (text);
+	}
+	else if (stack_is (parser, "duration", "static", "background", NULL) ||
+		 stack_is (parser, "duration", "transition", "background", NULL)) {
+		g_return_if_fail (slide != NULL);
+
+		slide->duration = g_strtod (text, NULL);
+		parser->total_duration += slide->duration;
+	}
+	else if (stack_is (parser, "file", "static", "background", NULL) ||
+		 stack_is (parser, "from", "transition", "background", NULL)) {
+		g_return_if_fail (slide != NULL);
+
+		for (i = 0; text[i]; i++) {
+			if (!g_ascii_isspace (text[i]))
+				break;
+		}
+		if (text[i] == 0)
+			return;
+		fs = g_new (FileSize, 1);
+		fs->width = -1;
+		fs->height = -1;
+		fs->file = g_strdup (text);
+		slide->file1 = g_slist_prepend (slide->file1, fs);
+		if (slide->file1->next != NULL)
+			parser->has_multiple_sizes = TRUE;
+	}
+	else if (stack_is (parser, "size", "file", "static", "background", NULL) ||
+		 stack_is (parser, "size", "from", "transition", "background", NULL)) {
+		g_return_if_fail (slide != NULL);
+
+		fs = slide->file1->data;
+		fs->file = g_strdup (text);
+		if (slide->file1->next != NULL)
+			parser->has_multiple_sizes = TRUE;
+	}
+	else if (stack_is (parser, "to", "transition", "background", NULL)) {
+		g_return_if_fail (slide != NULL);
+
+		for (i = 0; text[i]; i++) {
+			if (!g_ascii_isspace (text[i]))
+				break;
+		}
+		if (text[i] == 0)
+			return;
+		fs = g_new (FileSize, 1);
+		fs->width = -1;
+		fs->height = -1;
+		fs->file = g_strdup (text);
+		slide->file2 = g_slist_prepend (slide->file2, fs);
+		if (slide->file2->next != NULL)
+			parser->has_multiple_sizes = TRUE;
+	}
+	else if (stack_is (parser, "size", "to", "transition", "background", NULL)) {
+		g_return_if_fail (slide != NULL);
+
+		fs = slide->file2->data;
+		fs->file = g_strdup (text);
+		if (slide->file2->next != NULL)
+			parser->has_multiple_sizes = TRUE;
+	}
+}
+
+static SlideShow *
+slideshow_ref (SlideShow *show)
+{
+	show->ref_count++;
+	return show;
+}
+
+static void
+slideshow_unref (SlideShow *show)
+{
+	GList *list;
+	GSList *slist;
+	FileSize *size;
+
+	show->ref_count--;
+	if (show->ref_count > 0)
+		return;
+
+	for (list = show->slides->head; list != NULL; list = list->next) {
+		Slide *slide = list->data;
+
+		for (slist = slide->file1; slist != NULL; slist = slist->next) {
+			size = slist->data;
+			g_free (size->file);
+			g_free (size);
+		}
+		g_slist_free (slide->file1);
+
+		for (slist = slide->file2; slist != NULL; slist = slist->next) {
+			size = slist->data;
+			g_free (size->file);
+			g_free (size);
+		}
+		g_slist_free (slide->file2);
+
+		g_free (slide);
+	}
+
+	g_queue_free (show->slides);
+	g_queue_free_full (show->stack, g_free);
+	g_free (show);
+}
+
+static void
+dump_bg (SlideShow *show)
+{
+#if 0
+	GList *list;
+	GSList *slist;
+
+	for (list = show->slides->head; list != NULL; list = list->next)
+	{
+		Slide *slide = list->data;
+
+		g_print ("\nSlide: %s\n", slide->fixed? "fixed" : "transition");
+		g_print ("duration: %f\n", slide->duration);
+		g_print ("File1:\n");
+		for (slist = slide->file1; slist != NULL; slist = slist->next) {
+			FileSize *size = slist->data;
+			g_print ("\t%s (%dx%d)\n",
+				 size->file, size->width, size->height);
+		}
+		g_print ("File2:\n");
+		for (slist = slide->file2; slist != NULL; slist = slist->next) {
+			FileSize *size = slist->data;
+			g_print ("\t%s (%dx%d)\n",
+				 size->file, size->width, size->height);
+		}
+	}
+#endif
+}
+
+static void
+threadsafe_localtime (time_t time, struct tm *tm)
+{
+	struct tm *res;
+
+	G_LOCK_DEFINE_STATIC (localtime_mutex);
+
+	G_LOCK (localtime_mutex);
+
+	res = localtime (&time);
+	if (tm) {
+		*tm = *res;
+	}
+
+	G_UNLOCK (localtime_mutex);
+}
+
+static SlideShow *
+read_slideshow_file (const char *filename,
+		     GError     **err)
+{
+	GMarkupParser parser = {
+		handle_start_element,
+		handle_end_element,
+		handle_text,
+		NULL, /* passthrough */
+		NULL, /* error */
+	};
+
+	GFile *file;
+	char *contents = NULL;
+	gsize len;
+	SlideShow *show = NULL;
+	GMarkupParseContext *context = NULL;
+	time_t t;
+
+	if (!filename)
+		return NULL;
+
+	file = g_file_new_for_path (filename);
+	if (!g_file_load_contents (file, NULL, &contents, &len, NULL, NULL)) {
+		g_object_unref (file);
+		return NULL;
+	}
+	g_object_unref (file);
+
+	show = g_new0 (SlideShow, 1);
+	show->ref_count = 1;
+	threadsafe_localtime ((time_t)0, &show->start_tm);
+	show->stack = g_queue_new ();
+	show->slides = g_queue_new ();
+
+	context = g_markup_parse_context_new (&parser, 0, show, NULL);
+
+	if (!g_markup_parse_context_parse (context, contents, len, err)) {
+		slideshow_unref (show);
+		show = NULL;
+	}
+
+	if (show) {
+		if (!g_markup_parse_context_end_parse (context, err)) {
+			slideshow_unref (show);
+			show = NULL;
+		}
+	}
+
+	g_markup_parse_context_free (context);
+
+	if (show) {
+		guint num_items;
+
+		t = mktime (&show->start_tm);
+
+		show->start_time = (double)t;
+
+		dump_bg (show);
+
+		num_items = g_queue_get_length (show->slides);
+
+		/* no slides, that's not a slideshow */
+		if (num_items == 0) {
+			slideshow_unref (show);
+			show = NULL;
+		/* one slide, there's no transition */
+		} else if (num_items == 1) {
+			Slide *slide = show->slides->head->data;
+			slide->duration = show->total_duration = G_MAXUINT;
+		}
+	}
+
+	g_free (contents);
+
+	return show;
+}
+
+/* Thumbnail utilities */
+static GdkPixbuf *
+create_thumbnail_for_filename (MateDesktopThumbnailFactory *factory,
+			       const char            *filename)
+{
+	char *thumb;
+	gint64 mtime;
+	GdkPixbuf *orig, *result = NULL;
+	char *uri;
+
+	mtime = get_mtime (filename);
+	if (mtime == (gint64)-1)
+		return NULL;
+
+	uri = g_filename_to_uri (filename, NULL, NULL);
+
+	if (uri == NULL)
+		return NULL;
+
+	thumb = mate_desktop_thumbnail_factory_lookup (factory, uri, mtime);
+
+	if (thumb) {
+		result = gdk_pixbuf_new_from_file (thumb, NULL);
+		g_free (thumb);
+	}
+	else {
+		orig = gdk_pixbuf_new_from_file (filename, NULL);
+		if (orig) {
+			int orig_width = gdk_pixbuf_get_width (orig);
+			int orig_height = gdk_pixbuf_get_height (orig);
+
+			result = pixbuf_scale_to_fit (orig, THUMBNAIL_SIZE, THUMBNAIL_SIZE);
+
+			g_object_set_data_full (G_OBJECT (result), "mate-thumbnail-height",
+						g_strdup_printf ("%d", orig_height), g_free);
+			g_object_set_data_full (G_OBJECT (result), "mate-thumbnail-width",
+						g_strdup_printf ("%d", orig_width), g_free);
+
+			g_object_unref (orig);
+
+			mate_desktop_thumbnail_factory_save_thumbnail (factory, result, uri, mtime);
+		}
+		else {
+			mate_desktop_thumbnail_factory_create_failed_thumbnail (factory, uri, mtime);
+		}
+	}
+
+	g_free (uri);
+
+	return result;
+}
+
+static gboolean
+get_thumb_annotations (GdkPixbuf *thumb,
+		       int	 *orig_width,
+		       int	 *orig_height)
+{
+	char *end;
+	const char *wstr, *hstr;
+
+	wstr = gdk_pixbuf_get_option (thumb, "tEXt::Thumb::Image::Width");
+	hstr = gdk_pixbuf_get_option (thumb, "tEXt::Thumb::Image::Height");
+
+	if (hstr && wstr) {
+		*orig_width = strtol (wstr, &end, 10);
+		if (*end != 0)
+			return FALSE;
+
+		*orig_height = strtol (hstr, &end, 10);
+		if (*end != 0)
+			return FALSE;
+
+		return TRUE;
+	}
+
+	return FALSE;
+}
+
+static gboolean
+slideshow_has_multiple_sizes (SlideShow *show)
+{
+	return show->has_multiple_sizes;
+}
+
+/*
+ * Returns whether the background is a slideshow.
+ */
+gboolean
+mate_bg_changes_with_time (MateBG *bg)
+{
+	SlideShow *show;
+
+	g_return_val_if_fail (bg != NULL, FALSE);
+
+	if (!bg->filename)
+		return FALSE;
+
+	if ((show = get_as_slideshow (bg, bg->filename)) != NULL) {
+		gboolean result;
+
+		result = (g_queue_get_length (show->slides) > 1) ? TRUE : FALSE;
+		slideshow_unref (show);
+		return result;
+	}
+
+	return FALSE;
+}
+
+/**
+ * mate_bg_create_frame_thumbnail:
+ *
+ * Creates a thumbnail for a certain frame, where 'frame' is somewhat
+ * vaguely defined as 'suitable point to show while single-stepping
+ * through the slideshow'.
+ *
+ * Returns: (transfer full): the newly created thumbnail or
+ * or NULL if frame_num is out of bounds.
+ */
+GdkPixbuf *
+mate_bg_create_frame_thumbnail (MateBG			*bg,
+				 MateDesktopThumbnailFactory	*factory,
+				 GdkScreen			*screen,
+				 int				 dest_width,
+				 int				 dest_height,
+				 int				 frame_num)
+{
+	SlideShow *show;
+	GdkPixbuf *result;
+	GdkPixbuf *thumb;
+        GList *l;
+        int i, skipped;
+        gboolean found;
+
+	g_return_val_if_fail (bg != NULL, FALSE);
+
+	show = get_as_slideshow (bg, bg->filename);
+
+	if (!show)
+		return NULL;
+
+	if (frame_num < 0 || (guint) frame_num >= g_queue_get_length (show->slides))
+		return NULL;
+
+	i = 0;
+	skipped = 0;
+	found = FALSE;
+	for (l = show->slides->head; l; l = l->next) {
+		Slide *slide = l->data;
+		if (!slide->fixed) {
+			skipped++;
+			continue;
+		}
+		if (i == frame_num) {
+			found = TRUE;
+			break;
+		}
+		i++;
+	}
+	if (!found)
+		return NULL;
+
+	result = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, dest_width, dest_height);
+
+	draw_color (bg, result);
+
+	if (bg->filename) {
+		thumb = create_img_thumbnail (bg, factory, screen,
+					      dest_width, dest_height,
+					      frame_num + skipped);
+
+		if (thumb) {
+			draw_image_for_thumb (bg, thumb, result);
+			g_object_unref (thumb);
+		}
+	}
+
+	return result;
+}
+
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/100.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/100.html new file mode 100644 index 0000000..fdaac10 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/100.html @@ -0,0 +1,365 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "gpm-point-obj.h"
+
+/**
+ * gpm_point_obj_copy:
+ **/
+GpmPointObj *
+gpm_point_obj_copy (const GpmPointObj *cobj)
+{
+	GpmPointObj *obj;
+	obj = g_new0 (GpmPointObj, 1);
+	obj->x = cobj->x;
+	obj->y = cobj->y;
+	obj->color = cobj->color;
+	return obj;
+}
+
+/**
+ * gpm_point_obj_new:
+ **/
+GpmPointObj *
+gpm_point_obj_new (void)
+{
+	GpmPointObj *obj;
+	obj = g_new0 (GpmPointObj, 1);
+	obj->x = 0.0f;
+	obj->y = 0.0f;
+	obj->color = 0x0;
+	return obj;
+}
+
+/**
+ * gpm_point_obj_free:
+ **/
+void
+gpm_point_obj_free (GpmPointObj *obj)
+{
+	if (obj == NULL)
+		return;
+	g_free (obj);
+}
+
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/101.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/101.html new file mode 100644 index 0000000..f7957a8 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/101.html @@ -0,0 +1,1947 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
+603
+604
+605
+606
+607
+608
+609
+610
+611
+612
+613
+614
+615
+616
+617
+618
+619
+620
+621
+622
+623
+624
+625
+626
+627
+628
+629
+630
+631
+632
+633
+634
+635
+636
+637
+638
+639
+640
+641
+642
+643
+644
+645
+646
+647
+648
+649
+650
+651
+652
+653
+654
+655
+656
+657
+658
+659
+660
+661
+662
+663
+664
+665
+666
+667
+668
+669
+670
+671
+672
+673
+674
+675
+676
+677
+678
+679
+680
+681
+682
+683
+684
+685
+686
+687
+688
+689
+690
+691
+692
+693
+694
+695
+696
+697
+698
+699
+700
+701
+702
+703
+704
+705
+706
+707
+708
+709
+710
+711
+712
+713
+714
+715
+716
+717
+718
+719
+720
+721
+722
+723
+724
+725
+726
+727
+728
+729
+730
+731
+732
+733
+734
+735
+736
+737
+738
+739
+740
+741
+742
+743
+744
+745
+746
+747
+748
+749
+750
+751
+752
+753
+754
+755
+756
+757
+758
+759
+760
+761
+762
+763
+764
+765
+766
+767
+768
+769
+770
+771
+772
+773
+774
+775
+776
+777
+778
+779
+780
+781
+782
+783
+784
+785
+786
+787
+788
+789
+790
+791
+792
+793
+794
+795
+796
+797
+798
+799
+800
+801
+802
+803
+804
+805
+806
+807
+808
+809
+810
+811
+812
+813
+814
+815
+816
+817
+818
+819
+820
+821
+822
+823
+824
+825
+826
+827
+828
+829
+830
+831
+832
+833
+834
+835
+836
+837
+838
+839
+840
+841
+842
+843
+844
+845
+846
+847
+848
+849
+850
+851
+852
+853
+854
+855
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2005 Jaap Haitsma <jaap@haitsma.org>
+ * Copyright (C) 2005 William Jon McCann <mccann@jhu.edu>
+ * Copyright (C) 2005-2009 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "config.h"<--- Include file: "config.h" not found.
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <math.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#define UPOWER_ENABLE_DEPRECATED
+#include <libupower-glib/upower.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "egg-console-kit.h"
+
+#include "gpm-tray-icon.h"
+#include "gpm-common.h"
+#include "gpm-prefs-core.h"
+#include "gpm-icon-names.h"
+#include "gpm-brightness.h"
+
+#define GET_WIDGET(x) (GTK_WIDGET (gtk_builder_get_object (prefs->priv->builder, (x))))
+#define GET_NOTEBOOK(x) (GTK_NOTEBOOK (gtk_builder_get_object (prefs->priv->builder, (x))))
+#define GET_WINDOW(x) (GTK_WINDOW (gtk_builder_get_object (prefs->priv->builder, (x))))
+
+static void gpm_prefs_finalize (GObject *object);
+
+struct GpmPrefsPrivate
+{
+	UpClient		*client;
+	GtkBuilder		*builder;
+	gboolean		 has_batteries;
+	gboolean		 has_lcd;
+	gboolean		 has_ups;
+	gboolean		 has_button_lid;
+	gboolean		 has_button_suspend;
+	gboolean		 can_shutdown;
+	gboolean		 can_suspend;
+	gboolean		 can_hibernate;
+	GSettings		*settings;
+	EggConsoleKit		*console;
+};
+
+enum {
+	ACTION_HELP,
+	ACTION_CLOSE,
+	LAST_SIGNAL
+};
+
+static guint signals [LAST_SIGNAL] = { 0 };
+
+G_DEFINE_TYPE_WITH_PRIVATE (GpmPrefs, gpm_prefs, G_TYPE_OBJECT)<--- There is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
+
+/**
+ * gpm_prefs_class_init:
+ * @klass: This prefs class instance
+ **/
+static void
+gpm_prefs_class_init (GpmPrefsClass *klass)
+{
+	GObjectClass *object_class = G_OBJECT_CLASS (klass);
+	object_class->finalize = gpm_prefs_finalize;
+
+	signals [ACTION_HELP] =
+		g_signal_new ("action-help",
+				  G_TYPE_FROM_CLASS (object_class),
+				  G_SIGNAL_RUN_LAST,
+				  G_STRUCT_OFFSET (GpmPrefsClass, action_help),
+				  NULL,
+				  NULL,
+				  g_cclosure_marshal_VOID__VOID,
+				  G_TYPE_NONE, 0);
+	signals [ACTION_CLOSE] =
+		g_signal_new ("action-close",
+				  G_TYPE_FROM_CLASS (object_class),
+				  G_SIGNAL_RUN_LAST,
+				  G_STRUCT_OFFSET (GpmPrefsClass, action_close),
+				  NULL,
+				  NULL,
+				  g_cclosure_marshal_VOID__VOID,
+				  G_TYPE_NONE, 0);
+}
+
+/**
+ * gpm_prefs_activate_window:
+ * @prefs: This prefs class instance
+ *
+ * Activates (shows) the window.
+ **/
+void
+gpm_prefs_activate_window (GtkApplication *app, GpmPrefs *prefs)
+{
+	GtkWindow *window;
+	window = GET_WINDOW ("dialog_preferences");
+	gtk_application_add_window (GTK_APPLICATION (app), window);
+	gtk_window_present (window);
+}
+
+/**
+ * gpm_prefs_help_cb:
+ * @widget: The GtkWidget object
+ * @prefs: This prefs class instance
+ **/
+static void
+gpm_prefs_help_cb (GtkWidget *widget, GpmPrefs *prefs)
+{
+	g_debug ("emitting action-help");
+	g_signal_emit (prefs, signals [ACTION_HELP], 0);
+}
+
+/**
+ * gpm_prefs_icon_radio_cb:
+ * @widget: The GtkWidget object
+ **/
+static void
+gpm_prefs_icon_radio_cb (GtkWidget *widget, GpmPrefs *prefs)
+{
+	gint policy;
+
+	policy = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "policy"));
+	g_settings_set_enum (prefs->priv->settings, GPM_SETTINGS_ICON_POLICY, policy);
+}
+
+/**
+ * gpm_prefs_format_percentage_cb:
+ * @scale: The GtkScale object
+ * @value: The value in %.
+ **/
+static gchar *
+gpm_prefs_format_percentage_cb (GtkScale *scale, gdouble value)
+{
+	return g_strdup_printf ("%.0f%%", value);
+}
+
+/**
+ * gpm_prefs_action_combo_changed_cb:
+ **/
+static void
+gpm_prefs_action_combo_changed_cb (GtkWidget *widget, GpmPrefs *prefs)
+{
+	GpmActionPolicy policy;
+	const GpmActionPolicy *actions;
+	const gchar *gpm_pref_key;
+	guint active;
+
+	actions = (const GpmActionPolicy *) g_object_get_data (G_OBJECT (widget), "actions");
+	gpm_pref_key = (const gchar *) g_object_get_data (G_OBJECT (widget), "settings_key");
+
+	active = gtk_combo_box_get_active (GTK_COMBO_BOX (widget));
+	policy = actions[active];
+	g_settings_set_enum (prefs->priv->settings, gpm_pref_key, policy);
+}
+
+/**
+ * gpm_prefs_action_time_changed_cb:
+ **/
+static void
+gpm_prefs_action_time_changed_cb (GtkWidget *widget, GpmPrefs *prefs)
+{
+	guint value;
+	const gint *values;
+	const gchar *gpm_pref_key;
+	guint active;
+
+	values = (const gint *) g_object_get_data (G_OBJECT (widget), "values");
+	gpm_pref_key = (const gchar *) g_object_get_data (G_OBJECT (widget), "settings_key");
+
+	active = gtk_combo_box_get_active (GTK_COMBO_BOX (widget));
+	value = values[active];
+
+	g_debug ("Changing %s to %u", gpm_pref_key, value);
+	g_settings_set_int (prefs->priv->settings, gpm_pref_key, value);
+}
+
+/**
+ * gpm_prefs_actions_destroy_cb:
+ **/
+static void
+gpm_prefs_actions_destroy_cb (GpmActionPolicy *array)
+{
+	g_free (array);
+}
+
+/**
+ * gpm_prefs_setup_action_combo:
+ * @prefs: This prefs class instance
+ * @widget_name: The GtkWidget name
+ * @gpm_pref_key: The settings key for this preference setting.
+ * @actions: The actions to associate in an array.
+ **/
+static void
+gpm_prefs_setup_action_combo (GpmPrefs *prefs, const gchar *widget_name,
+				  const gchar *gpm_pref_key, const GpmActionPolicy *actions)
+{
+	guint i;
+	gboolean is_writable;
+	GtkWidget *widget;
+	GpmActionPolicy policy;
+	GpmActionPolicy	value;
+	GPtrArray *array;
+	GpmActionPolicy *actions_added;
+
+	widget = GET_WIDGET (widget_name);
+
+	value = g_settings_get_enum (prefs->priv->settings, gpm_pref_key);
+	is_writable = g_settings_is_writable (prefs->priv->settings, gpm_pref_key);
+
+	gtk_widget_set_sensitive (widget, is_writable);
+
+	array = g_ptr_array_new ();
+	g_object_set_data (G_OBJECT (widget), "settings_key", (gpointer) gpm_pref_key);
+	g_signal_connect (G_OBJECT (widget), "changed",
+			  G_CALLBACK (gpm_prefs_action_combo_changed_cb), prefs);
+
+	for (i=0; (gint)actions[i] != -1; i++) {
+		policy = actions[i];
+		if (policy == GPM_ACTION_POLICY_SHUTDOWN && !prefs->priv->can_shutdown) {
+			g_debug ("Cannot add option, as cannot shutdown.");
+		} else if (policy == GPM_ACTION_POLICY_SHUTDOWN && prefs->priv->can_shutdown) {
+			gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT (widget), _("Shutdown"));
+			g_ptr_array_add(array, GINT_TO_POINTER (policy));
+		} else if (policy == GPM_ACTION_POLICY_SUSPEND && !prefs->priv->can_suspend) {
+			g_debug ("Cannot add option, as cannot suspend.");
+		} else if (policy == GPM_ACTION_POLICY_HIBERNATE && !prefs->priv->can_hibernate) {
+			g_debug ("Cannot add option, as cannot hibernate.");
+		} else if (policy == GPM_ACTION_POLICY_SUSPEND && prefs->priv->can_suspend) {
+			gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT (widget), _("Suspend"));
+			g_ptr_array_add (array, GINT_TO_POINTER (policy));
+		} else if (policy == GPM_ACTION_POLICY_HIBERNATE && prefs->priv->can_hibernate) {
+			gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT (widget), _("Hibernate"));
+			g_ptr_array_add(array, GINT_TO_POINTER (policy));
+		} else if (policy == GPM_ACTION_POLICY_BLANK) {
+			gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT (widget), _("Blank screen"));
+			g_ptr_array_add (array, GINT_TO_POINTER (policy));
+		} else if (policy == GPM_ACTION_POLICY_INTERACTIVE) {
+			gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT (widget), _("Ask me"));
+			g_ptr_array_add(array, GINT_TO_POINTER (policy));
+		} else if (policy == GPM_ACTION_POLICY_NOTHING) {
+			gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT (widget), _("Do nothing"));
+			g_ptr_array_add(array, GINT_TO_POINTER (policy));
+		} else {
+			g_warning ("Unknown action read from settings: %u", policy);
+		}
+	}
+
+	/* save as array _only_ the actions we could add */
+	actions_added = g_new0 (GpmActionPolicy, array->len+1);
+	for (i=0; i<array->len; i++)
+		actions_added[i] = GPOINTER_TO_INT (g_ptr_array_index (array, i));
+	actions_added[i] = -1;
+
+	g_object_set_data_full (G_OBJECT (widget), "actions", (gpointer) actions_added, (GDestroyNotify) gpm_prefs_actions_destroy_cb);
+
+	/* set what we have in the settings */
+	for (i=0; (gint)actions_added[i] != -1; i++) {
+		policy = actions_added[i];
+		if (value == policy)
+			 gtk_combo_box_set_active (GTK_COMBO_BOX (widget), i);
+	}
+
+	g_ptr_array_unref (array);
+}
+
+/**
+ * gpm_prefs_setup_time_combo:
+ * @prefs: This prefs class instance
+ * @widget_name: The GtkWidget name
+ * @gpm_pref_key: The settings key for this preference setting.
+ * @actions: The actions to associate in an array.
+ **/
+static void
+gpm_prefs_setup_time_combo (GpmPrefs *prefs, const gchar *widget_name,
+				const gchar *gpm_pref_key, const gint *values)
+{
+	guint value;
+	gchar *text;
+	guint i;
+	gboolean is_writable;
+	GtkWidget *widget;
+
+	widget = GET_WIDGET (widget_name);
+
+	value = g_settings_get_int (prefs->priv->settings, gpm_pref_key);
+	is_writable = g_settings_is_writable (prefs->priv->settings, gpm_pref_key);
+	gtk_widget_set_sensitive (widget, is_writable);
+
+	g_object_set_data (G_OBJECT (widget), "settings_key", (gpointer) gpm_pref_key);
+	g_object_set_data (G_OBJECT (widget), "values", (gpointer) values);
+
+	/* add each time */
+	for (i=0; values[i] != -1; i++) {
+
+		/* get translation for number of seconds */
+		if (values[i] != 0) {
+			text = gpm_get_timestring (values[i]);
+			gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT (widget), text);
+			g_free (text);
+		} else {
+			gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT (widget), _("Never"));
+		}
+
+		/* matches, so set default */
+		if ((gint)value == values[i])
+			 gtk_combo_box_set_active (GTK_COMBO_BOX (widget), i);
+	}
+
+	/* connect after set */
+	g_signal_connect (G_OBJECT (widget), "changed",
+			  G_CALLBACK (gpm_prefs_action_time_changed_cb), prefs);
+}
+
+/**
+ * gpm_prefs_close_cb:
+ * @widget: The GtkWidget object
+ * @prefs: This prefs class instance
+ **/
+static void
+gpm_prefs_close_cb (GtkWidget *widget, GpmPrefs *prefs)
+{
+	g_debug ("emitting action-close");
+	g_signal_emit (prefs, signals [ACTION_CLOSE], 0);
+}
+
+/**
+ * gpm_prefs_delete_event_cb:
+ * @widget: The GtkWidget object
+ * @event: The event type, unused.
+ * @prefs: This prefs class instance
+ **/
+static gboolean
+gpm_prefs_delete_event_cb (GtkWidget *widget, GdkEvent *event, GpmPrefs *prefs)
+{
+	gpm_prefs_close_cb (widget, prefs);
+	return FALSE;
+}
+
+static void
+prefs_setup_ac (GpmPrefs *prefs)
+{
+	GtkWidget *widget;
+	const GpmActionPolicy button_lid_actions[] =
+				{GPM_ACTION_POLICY_NOTHING,
+				 GPM_ACTION_POLICY_BLANK,
+				 GPM_ACTION_POLICY_SUSPEND,
+				 GPM_ACTION_POLICY_HIBERNATE,
+				 GPM_ACTION_POLICY_SHUTDOWN,
+				 -1};
+
+	static const gint computer_times[] =
+		{10*60,
+		 30*60,
+		 1*60*60,
+		 2*60*60,
+		 0, /* never */
+		 -1};
+	static const gint display_times[] =
+		{1*60,
+		 5*60,
+		 10*60,
+		 30*60,
+		 1*60*60,
+		 0, /* never */
+		 -1};
+
+	gpm_prefs_setup_time_combo (prefs, "combobox_ac_computer",
+					GPM_SETTINGS_SLEEP_COMPUTER_AC,
+					computer_times);
+	gpm_prefs_setup_time_combo (prefs, "combobox_ac_display",
+					GPM_SETTINGS_SLEEP_DISPLAY_AC,
+					display_times);
+
+	gpm_prefs_setup_action_combo (prefs, "combobox_ac_lid",
+					  GPM_SETTINGS_BUTTON_LID_AC,
+					  button_lid_actions);
+
+	/* setup brightness slider */
+	widget = GET_WIDGET ("hscale_ac_brightness");
+	g_settings_bind (prefs->priv->settings, GPM_SETTINGS_BRIGHTNESS_AC,
+			 gtk_range_get_adjustment (GTK_RANGE (widget)), "value",
+			 G_SETTINGS_BIND_DEFAULT);
+	g_signal_connect (G_OBJECT (widget), "format-value",
+			  G_CALLBACK (gpm_prefs_format_percentage_cb), NULL);
+
+	/* set up the checkboxes */
+	g_settings_bind (prefs->priv->settings, GPM_SETTINGS_IDLE_DIM_AC,
+			 GET_WIDGET ("checkbutton_ac_display_dim"), "active",
+			 G_SETTINGS_BIND_DEFAULT);
+
+	if (prefs->priv->has_button_lid == FALSE) {
+		gtk_widget_hide (GET_WIDGET ("box_ac_lid"));
+	}
+	if (prefs->priv->has_lcd == FALSE) {
+		gtk_widget_hide (GET_WIDGET ("box_ac_brightness"));
+		gtk_widget_hide (GET_WIDGET ("checkbutton_ac_display_dim"));
+	}
+}
+
+static void
+prefs_setup_battery (GpmPrefs *prefs)
+{
+	GtkNotebook *notebook;
+	gint page;
+
+	const GpmActionPolicy button_lid_actions[] =
+				{GPM_ACTION_POLICY_NOTHING,
+				 GPM_ACTION_POLICY_BLANK,
+				 GPM_ACTION_POLICY_SUSPEND,
+				 GPM_ACTION_POLICY_HIBERNATE,
+				 GPM_ACTION_POLICY_SHUTDOWN,
+				 -1};
+	const GpmActionPolicy battery_critical_actions[] =
+				{GPM_ACTION_POLICY_NOTHING,
+				 GPM_ACTION_POLICY_SUSPEND,
+				 GPM_ACTION_POLICY_HIBERNATE,
+				 GPM_ACTION_POLICY_SHUTDOWN,
+				 -1};
+
+	static const gint computer_times[] =
+		{10*60,
+		 30*60,
+		 1*60*60,
+		 2*60*60,
+		 0, /* never */
+		 -1};
+	static const gint display_times[] =
+		{1*60,
+		 5*60,
+		 10*60,
+		 30*60,
+		 1*60*60,
+		 0, /* never */
+		 -1};
+
+	gpm_prefs_setup_time_combo (prefs, "combobox_battery_computer",
+					GPM_SETTINGS_SLEEP_COMPUTER_BATT,
+					computer_times);
+	gpm_prefs_setup_time_combo (prefs, "combobox_battery_display",
+					GPM_SETTINGS_SLEEP_DISPLAY_BATT,
+					display_times);
+
+	if (prefs->priv->has_batteries == FALSE) {
+		notebook = GET_NOTEBOOK ("notebook_preferences");
+		page = gtk_notebook_page_num (notebook, GET_WIDGET ("box_battery"));
+		gtk_notebook_remove_page (notebook, page);
+		return;
+	}
+
+	gpm_prefs_setup_action_combo (prefs, "combobox_battery_lid",
+					  GPM_SETTINGS_BUTTON_LID_BATT,
+					  button_lid_actions);
+	gpm_prefs_setup_action_combo (prefs, "combobox_battery_critical",
+					  GPM_SETTINGS_ACTION_CRITICAL_BATT,
+					  battery_critical_actions);
+
+	/* set up the checkboxes */
+	g_settings_bind (prefs->priv->settings, GPM_SETTINGS_BACKLIGHT_BATTERY_REDUCE,
+			 GET_WIDGET ("checkbutton_battery_display_reduce"), "active",
+			 G_SETTINGS_BIND_DEFAULT);
+	g_settings_bind (prefs->priv->settings, GPM_SETTINGS_IDLE_DIM_BATT,
+			 GET_WIDGET ("checkbutton_battery_display_dim"), "active",
+			 G_SETTINGS_BIND_DEFAULT);
+	g_settings_bind (prefs->priv->settings, GPM_SETTINGS_KBD_BACKLIGHT_BATT_REDUCE,
+			 GET_WIDGET ("checkbutton_battery_keyboard_reduce"), "active",
+			 G_SETTINGS_BIND_DEFAULT);
+
+	if (prefs->priv->has_button_lid == FALSE)
+		gtk_widget_hide (GET_WIDGET ("box_battery_lid"));
+
+	if (prefs->priv->has_lcd == FALSE)
+		gtk_widget_hide (GET_WIDGET ("checkbutton_battery_display_dim"));
+}
+
+static void
+prefs_setup_ups (GpmPrefs *prefs)
+{
+	GtkWidget *notebook;
+	gint page;
+
+	const GpmActionPolicy ups_low_actions[] =
+				{GPM_ACTION_POLICY_NOTHING,
+				 GPM_ACTION_POLICY_HIBERNATE,
+				 GPM_ACTION_POLICY_SHUTDOWN,
+				 -1};
+
+	static const gint computer_times[] =
+		{10*60,
+		 30*60,
+		 1*60*60,
+		 2*60*60,
+		 0, /* never */
+		 -1};
+	static const gint display_times[] =
+		{1*60,
+		 5*60,
+		 10*60,
+		 30*60,
+		 1*60*60,
+		 0, /* never */
+		 -1};
+
+	gpm_prefs_setup_time_combo (prefs, "combobox_ups_computer",
+					GPM_SETTINGS_SLEEP_COMPUTER_UPS,
+					computer_times);
+	gpm_prefs_setup_time_combo (prefs, "combobox_ups_display",
+					GPM_SETTINGS_SLEEP_DISPLAY_UPS,
+					display_times);
+
+	notebook = GET_WIDGET ("notebook_preferences");
+	gtk_widget_add_events (notebook, GDK_SCROLL_MASK);
+	g_signal_connect (GTK_NOTEBOOK (notebook),
+	                  "scroll-event",
+			  G_CALLBACK (gpm_notebook_scroll_event_cb),
+			  NULL);
+
+	if (prefs->priv->has_ups == FALSE) {
+		page = gtk_notebook_page_num (GTK_NOTEBOOK (notebook), GET_WIDGET ("box_ups"));
+		gtk_notebook_remove_page (GTK_NOTEBOOK (notebook), page);
+		return;
+	}
+
+	gpm_prefs_setup_action_combo (prefs, "combobox_ups_low",
+					  GPM_SETTINGS_ACTION_LOW_UPS,
+					  ups_low_actions);
+	gpm_prefs_setup_action_combo (prefs, "combobox_ups_critical",
+					  GPM_SETTINGS_ACTION_CRITICAL_UPS,
+					  ups_low_actions);
+}
+
+static void
+prefs_setup_general (GpmPrefs *prefs)
+{
+	const GpmActionPolicy power_button_actions[] =
+				{GPM_ACTION_POLICY_INTERACTIVE,
+				 GPM_ACTION_POLICY_SUSPEND,
+				 GPM_ACTION_POLICY_HIBERNATE,
+				 GPM_ACTION_POLICY_SHUTDOWN,
+				 GPM_ACTION_POLICY_NOTHING,
+				 -1};
+	const GpmActionPolicy suspend_button_actions[] =
+				{GPM_ACTION_POLICY_NOTHING,
+				 GPM_ACTION_POLICY_SUSPEND,
+				 GPM_ACTION_POLICY_HIBERNATE,
+				 -1};
+
+	gpm_prefs_setup_action_combo (prefs, "combobox_general_power",
+					  GPM_SETTINGS_BUTTON_POWER,
+					  power_button_actions);
+	gpm_prefs_setup_action_combo (prefs, "combobox_general_suspend",
+					  GPM_SETTINGS_BUTTON_SUSPEND,
+					  suspend_button_actions);
+
+	if (prefs->priv->has_button_suspend == FALSE)
+		gtk_widget_hide (GET_WIDGET ("box_general_suspend"));
+}
+
+/**
+ * gpm_prefs_init:
+ * @prefs: This prefs class instance
+ **/
+static void
+gpm_prefs_init (GpmPrefs *prefs)
+{
+	GError *error = NULL;
+	GPtrArray *devices = NULL;
+	UpDevice *device;
+	UpDeviceKind kind;
+	GpmBrightness *brightness;
+	gint icon_policy;
+	/** setup the notification page */
+	GtkWidget *radiobutton_icon_always;
+	GtkWidget *radiobutton_icon_present;
+	GtkWidget *radiobutton_icon_charge;
+	GtkWidget *radiobutton_icon_low;
+	GtkWidget *radiobutton_icon_never;
+
+	guint i;
+
+	GDBusProxy *proxy;
+	GVariant *res, *inner;
+	gchar * r;
+
+	prefs->priv = gpm_prefs_get_instance_private (prefs);
+
+	prefs->priv->client = up_client_new ();
+	prefs->priv->console = egg_console_kit_new ();
+	prefs->priv->settings = g_settings_new (GPM_SETTINGS_SCHEMA);
+
+	prefs->priv->can_shutdown = FALSE;
+	prefs->priv->can_suspend = FALSE;
+	prefs->priv->can_hibernate = FALSE;
+
+	if (LOGIND_RUNNING()) {
+		/* get values from logind */
+
+		proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
+						       G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
+						       NULL,
+						       "org.freedesktop.login1",
+						       "/org/freedesktop/login1",
+						       "org.freedesktop.login1.Manager",
+						       NULL,
+						       &error );
+		if (proxy == NULL) {
+			g_error ("Error connecting to dbus - %s", error->message);
+			g_error_free (error);
+			return;
+		}
+
+		res = g_dbus_proxy_call_sync (proxy, "CanPowerOff",
+					      NULL,
+					      G_DBUS_CALL_FLAGS_NONE,
+					      -1,
+					      NULL,
+					      &error
+					      );
+		if (error == NULL && res != NULL) {
+			g_variant_get(res,"(&s)", &r);
+			prefs->priv->can_shutdown = g_strcmp0(r,"yes")==0?TRUE:FALSE;
+			g_variant_unref (res);
+		} else if (error != NULL ) {
+			g_error ("Error in dbus - %s", error->message);
+			g_error_free (error);
+		}
+
+		res = g_dbus_proxy_call_sync (proxy, "CanSuspend",
+					      NULL,
+					      G_DBUS_CALL_FLAGS_NONE,
+					      -1,
+					      NULL,
+					      &error
+					      );
+		if (error == NULL && res != NULL) {
+			g_variant_get(res,"(&s)", &r);
+			prefs->priv->can_suspend = g_strcmp0(r,"yes")==0?TRUE:FALSE;
+			g_variant_unref (res);
+		} else if (error != NULL ) {
+			g_error ("Error in dbus - %s", error->message);
+			g_error_free (error);
+		}
+
+		res = g_dbus_proxy_call_sync (proxy, "CanHibernate",
+					      NULL,
+					      G_DBUS_CALL_FLAGS_NONE,
+					      -1,
+					      NULL,
+					      &error
+					      );
+		if (error == NULL && res != NULL) {
+			g_variant_get(res,"(&s)", &r);
+			prefs->priv->can_hibernate = g_strcmp0(r,"yes")==0?TRUE:FALSE;
+			g_variant_unref (res);
+		} else if (error != NULL ) {
+			g_error ("Error in dbus - %s", error->message);
+			g_error_free (error);
+		}
+		g_object_unref(proxy);
+	}
+	else {
+		/* Get values from ConsoleKit */
+		egg_console_kit_can_stop (prefs->priv->console, &prefs->priv->can_shutdown, NULL);
+		egg_console_kit_can_suspend (prefs->priv->console, &prefs->priv->can_suspend, NULL);
+		egg_console_kit_can_hibernate (prefs->priv->console, &prefs->priv->can_hibernate, NULL);
+	}
+
+	if (LOGIND_RUNNING()) {
+		proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
+						       G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
+						       NULL,
+						       "org.freedesktop.UPower",
+						       "/org/freedesktop/UPower",
+						       "org.freedesktop.DBus.Properties",
+						       NULL,
+						       &error );
+		if (proxy == NULL) {
+			g_error ("Error connecting to dbus - %s", error->message);
+			g_error_free (error);
+			return;
+		}
+
+		res = g_dbus_proxy_call_sync (proxy, "Get",
+					      g_variant_new( "(ss)",
+							     "org.freedesktop.UPower",
+							     "LidIsPresent"),
+					      G_DBUS_CALL_FLAGS_NONE,
+					      -1,
+					      NULL,
+					      &error
+					      );
+		if (error == NULL && res != NULL) {
+			g_variant_get(res, "(v)", &inner );
+			prefs->priv->has_button_lid = g_variant_get_boolean(inner);
+			g_variant_unref (inner);
+			g_variant_unref (res);
+		} else if (error != NULL ) {
+			g_error ("Error in dbus - %s", error->message);
+			g_error_free (error);
+		}
+		g_object_unref(proxy);
+	}
+	else {
+		prefs->priv->has_button_lid = up_client_get_lid_is_present (prefs->priv->client);
+	}
+
+	prefs->priv->has_button_suspend = TRUE;
+
+	/* find if we have brightness hardware */
+	brightness = gpm_brightness_new ();
+	prefs->priv->has_lcd = gpm_brightness_has_hw (brightness);
+	g_object_unref (brightness);
+	devices = up_client_get_devices2 (prefs->priv->client);
+	for (i=0; i<devices->len; i++) {
+		device = g_ptr_array_index (devices, i);
+		g_object_get (device,
+			      "kind", &kind,
+			      NULL);
+		if (kind == UP_DEVICE_KIND_BATTERY)
+			prefs->priv->has_batteries = TRUE;
+		if (kind == UP_DEVICE_KIND_UPS)
+			prefs->priv->has_ups = TRUE;
+	}
+	g_ptr_array_unref (devices);
+
+	error = NULL;
+	prefs->priv->builder = gtk_builder_new ();
+	(void) gtk_builder_add_from_resource (prefs->priv->builder, "/org/mate/powermanager/preferences/gpm-prefs.ui", &error);
+
+	if (error) {
+		g_error ("failed to load ui: %s", error->message);
+	}
+
+	/* Hide window first so that the dialogue resizes itself without redrawing */
+	gtk_widget_hide (GET_WIDGET ("dialog_preferences"));
+
+	gtk_widget_hide (GET_WIDGET ("button_defaults"));
+
+	icon_policy = g_settings_get_enum (prefs->priv->settings, GPM_SETTINGS_ICON_POLICY);
+
+	radiobutton_icon_always = GET_WIDGET ("radiobutton_notification_always");
+	radiobutton_icon_present = GET_WIDGET ("radiobutton_notification_present");
+	radiobutton_icon_charge = GET_WIDGET ("radiobutton_notification_charge");
+	radiobutton_icon_low = GET_WIDGET ("radiobutton_notification_low");
+	radiobutton_icon_never = GET_WIDGET ("radiobutton_notification_never");
+
+	gtk_widget_set_sensitive (GET_WIDGET ("box_general_notification"),
+	                          g_settings_is_writable (prefs->priv->settings, GPM_SETTINGS_ICON_POLICY));
+
+	switch (icon_policy) {
+		case GPM_ICON_POLICY_ALWAYS:
+			gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton_icon_always), TRUE);
+			break;
+		case GPM_ICON_POLICY_PRESENT:
+			gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton_icon_present), TRUE);
+			break;
+		case GPM_ICON_POLICY_CHARGE:
+			gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton_icon_charge), TRUE);
+			break;
+		case GPM_ICON_POLICY_LOW:
+			gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton_icon_low), TRUE);
+			break;
+		case GPM_ICON_POLICY_NEVER:
+			gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton_icon_never), TRUE);
+			break;
+		default:
+			break;
+	}
+
+	g_object_set_data (G_OBJECT (radiobutton_icon_always), "policy", GINT_TO_POINTER (GPM_ICON_POLICY_ALWAYS));
+	g_object_set_data (G_OBJECT (radiobutton_icon_present), "policy", GINT_TO_POINTER (GPM_ICON_POLICY_PRESENT));
+	g_object_set_data (G_OBJECT (radiobutton_icon_charge), "policy", GINT_TO_POINTER (GPM_ICON_POLICY_CHARGE));
+	g_object_set_data (G_OBJECT (radiobutton_icon_low), "policy", GINT_TO_POINTER (GPM_ICON_POLICY_LOW));
+	g_object_set_data (G_OBJECT (radiobutton_icon_never), "policy", GINT_TO_POINTER (GPM_ICON_POLICY_NEVER));
+
+	gtk_builder_add_callback_symbols (prefs->priv->builder,
+	                                  "on_dialog_preferences_delete_event", G_CALLBACK (gpm_prefs_delete_event_cb),
+	                                  "on_button_help_clicked", G_CALLBACK (gpm_prefs_help_cb),
+	                                  "on_button_close_clicked", G_CALLBACK (gpm_prefs_close_cb),
+	                                  "on_radiobutton_notification_never_clicked", G_CALLBACK (gpm_prefs_icon_radio_cb),
+	                                  "on_radiobutton_notification_low_clicked", G_CALLBACK (gpm_prefs_icon_radio_cb),
+	                                  "on_radiobutton_notification_charge_clicked", G_CALLBACK (gpm_prefs_icon_radio_cb),
+	                                  "on_radiobutton_notification_present_clicked", G_CALLBACK (gpm_prefs_icon_radio_cb),
+	                                  "on_radiobutton_notification_always_clicked", G_CALLBACK (gpm_prefs_icon_radio_cb),
+	                                  NULL);
+	gtk_builder_connect_signals (prefs->priv->builder, prefs);
+
+	prefs_setup_ac (prefs);
+	prefs_setup_battery (prefs);
+	prefs_setup_ups (prefs);
+	prefs_setup_general (prefs);
+}
+
+/**
+ * gpm_prefs_finalize:
+ * @object: This prefs class instance
+ **/
+static void
+gpm_prefs_finalize (GObject *object)
+{
+	GpmPrefs *prefs;
+	g_return_if_fail (object != NULL);
+	g_return_if_fail (GPM_IS_PREFS (object));
+
+	prefs = GPM_PREFS (object);
+	prefs->priv = gpm_prefs_get_instance_private (prefs);
+
+	g_object_unref (prefs->priv->settings);
+	g_object_unref (prefs->priv->client);
+	g_object_unref (prefs->priv->console);
+	g_object_unref (prefs->priv->builder);
+
+	G_OBJECT_CLASS (gpm_prefs_parent_class)->finalize (object);
+}
+
+/**
+ * gpm_prefs_new:
+ * Return value: new GpmPrefs instance.
+ **/
+GpmPrefs *
+gpm_prefs_new (void)
+{
+	GpmPrefs *prefs;
+	prefs = g_object_new (GPM_TYPE_PREFS, NULL);
+	return GPM_PREFS (prefs);
+}
+
+/**
+ * gpm_window:
+ * Return value: Prefs window widget.
+ **/
+GtkWidget *
+gpm_window (GpmPrefs *prefs)
+{
+	return GET_WIDGET ("dialog_preferences");
+}
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/102.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/102.html new file mode 100644 index 0000000..42e25ff --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/102.html @@ -0,0 +1,355 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2005-2007 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __GPMPREFS_H
+#define __GPMPREFS_H
+
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+G_BEGIN_DECLS
+
+#define GPM_TYPE_PREFS		(gpm_prefs_get_type ())
+#define GPM_PREFS(o)		(G_TYPE_CHECK_INSTANCE_CAST ((o), GPM_TYPE_PREFS, GpmPrefs))
+#define GPM_PREFS_CLASS(k)	(G_TYPE_CHECK_CLASS_CAST((k), GPM_TYPE_PREFS, GpmPrefsClass))
+#define GPM_IS_PREFS(o)		(G_TYPE_CHECK_INSTANCE_TYPE ((o), GPM_TYPE_PREFS))
+#define GPM_IS_PREFS_CLASS(k)	(G_TYPE_CHECK_CLASS_TYPE ((k), GPM_TYPE_PREFS))
+#define GPM_PREFS_GET_CLASS(o)	(G_TYPE_INSTANCE_GET_CLASS ((o), GPM_TYPE_PREFS, GpmPrefsClass))
+
+typedef struct GpmPrefsPrivate GpmPrefsPrivate;
+
+typedef struct
+{
+	GObject		 parent;
+	GpmPrefsPrivate *priv;
+} GpmPrefs;
+
+typedef struct
+{
+	GObjectClass	parent_class;
+	void		(* action_help)			(GpmPrefs	*prefs);
+	void		(* action_close)		(GpmPrefs	*prefs);
+} GpmPrefsClass;
+
+GType		 gpm_prefs_get_type			(void);
+GpmPrefs	*gpm_prefs_new				(void);
+GtkWidget	*gpm_window				(GpmPrefs	*prefs);
+void		 gpm_prefs_activate_window		(GtkApplication *app, GpmPrefs	*prefs);
+
+G_END_DECLS
+
+#endif	/* __GPMPREFS_H */
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/103.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/103.html new file mode 100644 index 0000000..a8fbde1 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/103.html @@ -0,0 +1,453 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2005 Jaap Haitsma <jaap@haitsma.org>
+ * Copyright (C) 2005 William Jon McCann <mccann@jhu.edu>
+ * Copyright (C) 2005-2008 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#  include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+
+#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "gpm-common.h"
+#include "gpm-prefs-core.h"
+
+/**
+ * gpm_prefs_help_cb
+ * @prefs: This prefs class instance
+ *
+ * What to do when help is requested
+ **/
+static void
+gpm_prefs_help_cb (GpmPrefs *prefs)
+{
+	gpm_help_display ("preferences");
+}
+
+/**
+ * gpm_prefs_activated_cb
+ * @prefs: This prefs class instance
+ *
+ * We have been asked to show the window
+ **/
+static void
+gpm_prefs_activated_cb (GtkApplication *app, GpmPrefs *prefs)
+{
+	gpm_prefs_activate_window (app, prefs);
+}
+
+/**
+ * main:
+ **/
+int
+main (int argc, char **argv)
+{
+	GOptionContext *context;
+	GpmPrefs *prefs = NULL;
+	GtkApplication *app;
+	GtkWidget *window;
+	gint status;
+
+	const GOptionEntry options[] = {
+		{ NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL }
+	};
+
+	context = g_option_context_new (N_("MATE Power Preferences"));
+
+	bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR);
+	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+	textdomain (GETTEXT_PACKAGE);
+
+	g_option_context_set_translation_domain(context, GETTEXT_PACKAGE);
+	g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE);
+	g_option_context_add_group (context, gtk_get_option_group (FALSE));
+	g_option_context_parse (context, &argc, &argv, NULL);
+	g_option_context_free (context);
+
+	gdk_init (&argc, &argv);
+	app = gtk_application_new("org.mate.PowerManager.Preferences", 0);
+
+	prefs = gpm_prefs_new ();
+
+	window = gpm_window (prefs);
+	g_signal_connect (app, "activate",
+			  G_CALLBACK (gpm_prefs_activated_cb), prefs);
+	g_signal_connect (prefs, "action-help",
+			  G_CALLBACK (gpm_prefs_help_cb), prefs);
+	g_signal_connect_swapped (prefs, "action-close",
+			  G_CALLBACK (gtk_widget_destroy), window);
+
+	status = g_application_run (G_APPLICATION (app), argc, argv);
+	g_object_unref (prefs);
+
+	g_object_unref (app);
+
+	return status;
+}
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/104.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/104.html new file mode 100644 index 0000000..bf99402 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/104.html @@ -0,0 +1,887 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2006-2007 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "config.h"<--- Include file: "config.h" not found.
+
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <dbus/dbus-glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "gpm-screensaver.h"
+#include "gpm-common.h"
+
+static void     gpm_screensaver_finalize   (GObject		*object);
+
+#define GS_LISTENER_SERVICE	"org.mate.ScreenSaver"
+#define GS_LISTENER_PATH	"/"
+#define GS_LISTENER_INTERFACE	"org.mate.ScreenSaver"
+
+struct GpmScreensaverPrivate
+{
+	DBusGProxy		*proxy;
+};
+
+static gpointer gpm_screensaver_object = NULL;
+
+G_DEFINE_TYPE_WITH_PRIVATE (GpmScreensaver, gpm_screensaver, G_TYPE_OBJECT)<--- There is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
+
+/**
+ * gpm_screensaver_lock
+ * @screensaver: This class instance
+ * Return value: Success value
+ **/
+gboolean
+gpm_screensaver_lock (GpmScreensaver *screensaver)
+{
+	guint sleepcount = 0;
+
+	g_return_val_if_fail (GPM_IS_SCREENSAVER (screensaver), FALSE);
+
+	if (screensaver->priv->proxy == NULL) {
+		g_warning ("not connected");
+		return FALSE;
+	}
+
+	g_debug ("doing mate-screensaver lock");
+	dbus_g_proxy_call_no_reply (screensaver->priv->proxy,
+				    "Lock", G_TYPE_INVALID);
+
+	/* When we send the Lock signal to g-ss it takes maybe a second
+	   or so to fade the screen and lock. If we suspend mid fade then on
+	   resume the X display is still present for a split second
+	   (since fade is gamma) and as such it can leak information.
+	   Instead we wait until g-ss reports running and thus blanked
+	   solidly before we continue from the screensaver_lock action.
+	   The interior of g-ss is async, so we cannot get the dbus method
+	   to block until lock is complete. */
+	while (! gpm_screensaver_check_running (screensaver)) {
+		/* Sleep for 1/10s */
+		g_usleep (1000 * 100);
+		if (sleepcount++ > 50) {
+			g_debug ("timeout waiting for mate-screensaver");
+			break;
+		}
+	}
+
+	return TRUE;
+}
+
+/**
+ * gpm_screensaver_add_throttle:
+ * @screensaver: This class instance
+ * @reason:      The reason for throttling
+ * Return value: Success value, or zero for failure
+ **/
+guint
+gpm_screensaver_add_throttle (GpmScreensaver *screensaver,
+			      const char     *reason)
+{
+	GError  *error = NULL;
+	gboolean ret;
+	guint32  cookie;
+
+	g_return_val_if_fail (GPM_IS_SCREENSAVER (screensaver), 0);
+	g_return_val_if_fail (reason != NULL, 0);
+
+	if (screensaver->priv->proxy == NULL) {
+		g_warning ("not connected");
+		return 0;
+	}
+
+	ret = dbus_g_proxy_call (screensaver->priv->proxy,
+				 "Throttle", &error,
+				 G_TYPE_STRING, "Power screensaver",
+				 G_TYPE_STRING, reason,
+				 G_TYPE_INVALID,
+				 G_TYPE_UINT, &cookie,
+				 G_TYPE_INVALID);
+	if (error) {
+		g_debug ("ERROR: %s", error->message);
+		g_error_free (error);
+	}
+	if (!ret) {
+		/* abort as the DBUS method failed */
+		g_warning ("Throttle failed!");
+		return 0;
+	}
+
+	g_debug ("adding throttle reason: '%s': id %u", reason, cookie);
+	return cookie;
+}
+
+/**
+ * gpm_screensaver_remove_throttle:
+ **/
+gboolean
+gpm_screensaver_remove_throttle (GpmScreensaver *screensaver, guint cookie)
+{
+	gboolean ret;
+	GError *error = NULL;
+
+	g_return_val_if_fail (GPM_IS_SCREENSAVER (screensaver), FALSE);
+
+	if (screensaver->priv->proxy == NULL) {
+		g_warning ("not connected");
+		return FALSE;
+	}
+
+	g_debug ("removing throttle: id %u", cookie);
+	ret = dbus_g_proxy_call (screensaver->priv->proxy,
+				 "UnThrottle", &error,
+				 G_TYPE_UINT, cookie,
+				 G_TYPE_INVALID,
+				 G_TYPE_INVALID);
+	if (error) {
+		g_debug ("ERROR: %s", error->message);
+		g_error_free (error);
+	}
+	if (!ret) {
+		/* abort as the DBUS method failed */
+		g_warning ("UnThrottle failed!");
+		return FALSE;
+	}
+
+	return TRUE;
+}
+
+/**
+ * gpm_screensaver_check_running:
+ * @screensaver: This class instance
+ * Return value: TRUE if mate-screensaver is running
+ **/
+gboolean
+gpm_screensaver_check_running (GpmScreensaver *screensaver)
+{
+	gboolean ret;
+	gboolean temp = TRUE;
+	GError *error = NULL;
+
+	g_return_val_if_fail (GPM_IS_SCREENSAVER (screensaver), FALSE);
+
+	if (screensaver->priv->proxy == NULL) {
+		g_warning ("not connected");
+		return FALSE;
+	}
+
+	ret = dbus_g_proxy_call (screensaver->priv->proxy,
+				 "GetActive", &error,
+				 G_TYPE_INVALID,
+				 G_TYPE_BOOLEAN, &temp,
+				 G_TYPE_INVALID);
+	if (error) {
+		g_debug ("ERROR: %s", error->message);
+		g_error_free (error);
+	}
+
+	return ret;
+}
+
+/**
+ * gpm_screensaver_poke:
+ * @screensaver: This class instance
+ *
+ * Pokes MATE Screensaver simulating hardware events. This displays the unlock
+ * dialogue when we resume, so the user doesn't have to move the mouse or press
+ * any key before the window comes up.
+ **/
+gboolean
+gpm_screensaver_poke (GpmScreensaver *screensaver)
+{
+	g_return_val_if_fail (GPM_IS_SCREENSAVER (screensaver), FALSE);
+
+	if (screensaver->priv->proxy == NULL) {
+		g_warning ("not connected");
+		return FALSE;
+	}
+
+	g_debug ("poke");
+	dbus_g_proxy_call_no_reply (screensaver->priv->proxy,
+				    "SimulateUserActivity",
+				    G_TYPE_INVALID);
+	return TRUE;
+}
+
+/**
+ * gpm_screensaver_class_init:
+ * @klass: This class instance
+ **/
+static void
+gpm_screensaver_class_init (GpmScreensaverClass *klass)
+{
+	GObjectClass *object_class = G_OBJECT_CLASS (klass);
+	object_class->finalize = gpm_screensaver_finalize;
+}
+
+/**
+ * gpm_screensaver_init:
+ * @screensaver: This class instance
+ **/
+static void
+gpm_screensaver_init (GpmScreensaver *screensaver)
+{
+	DBusGConnection *connection;
+
+	screensaver->priv = gpm_screensaver_get_instance_private (screensaver);
+
+	connection = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
+	screensaver->priv->proxy = dbus_g_proxy_new_for_name (connection,
+							      GS_LISTENER_SERVICE,
+							      GS_LISTENER_PATH,
+							      GS_LISTENER_INTERFACE);
+}
+
+/**
+ * gpm_screensaver_finalize:
+ * @object: This class instance
+ **/
+static void
+gpm_screensaver_finalize (GObject *object)
+{
+	GpmScreensaver *screensaver;
+	g_return_if_fail (object != NULL);
+	g_return_if_fail (GPM_IS_SCREENSAVER (object));
+
+	screensaver = GPM_SCREENSAVER (object);
+	screensaver->priv = gpm_screensaver_get_instance_private (screensaver);
+
+	g_object_unref (screensaver->priv->proxy);
+
+	G_OBJECT_CLASS (gpm_screensaver_parent_class)->finalize (object);
+}
+
+/**
+ * gpm_screensaver_new:
+ * Return value: new GpmScreensaver instance.
+ **/
+GpmScreensaver *
+gpm_screensaver_new (void)
+{
+	if (gpm_screensaver_object != NULL) {
+		g_object_ref (gpm_screensaver_object);
+	} else {
+		gpm_screensaver_object = g_object_new (GPM_TYPE_SCREENSAVER, NULL);
+		g_object_add_weak_pointer (gpm_screensaver_object, &gpm_screensaver_object);
+	}
+	return GPM_SCREENSAVER (gpm_screensaver_object);
+}
+/***************************************************************************
+ ***                          MAKE CHECK TESTS                           ***
+ ***************************************************************************/
+#ifdef EGG_TEST
+#include "egg-test.h"
+
+void
+gpm_screensaver_test (gpointer data)
+{
+	GpmScreensaver *screensaver;
+//	guint value;
+	gboolean ret;
+	EggTest *test = (EggTest *) data;
+
+	if (egg_test_start (test, "GpmScreensaver") == FALSE)
+		return;
+
+	/************************************************************/
+	egg_test_title (test, "make sure we get a non null screensaver");
+	screensaver = gpm_screensaver_new ();
+	egg_test_assert (test, (screensaver != NULL));
+
+	/************************************************************/
+	egg_test_title (test, "lock screensaver");
+	ret = gpm_screensaver_lock (screensaver);
+	egg_test_assert (test, ret);
+
+	/************************************************************/
+	egg_test_title (test, "poke screensaver");
+	ret = gpm_screensaver_poke (screensaver);
+	egg_test_assert (test, ret);
+
+	g_object_unref (screensaver);
+
+	egg_test_end (test);
+}
+
+#endif
+
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/105.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/105.html new file mode 100644 index 0000000..ad8d9a7 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/105.html @@ -0,0 +1,401 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+82
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007-2008 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "config.h"<--- Include file: "config.h" not found.
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include "egg-test.h"
+
+#include "gpm-screensaver.h"
+
+/* prototypes */
+void egg_precision_test (EggTest *test);
+void egg_discrete_test (EggTest *test);
+void egg_color_test (EggTest *test);
+void egg_array_float_test (EggTest *test);
+void egg_idletime_test (EggTest *test);
+
+void gpm_common_test (EggTest *test);
+void gpm_idle_test (EggTest *test);
+void gpm_phone_test (EggTest *test);
+void gpm_dpms_test (EggTest *test);
+void gpm_graph_widget_test (EggTest *test);
+void gpm_proxy_test (EggTest *test);
+void gpm_hal_manager_test (EggTest *test);
+void gpm_device_test (EggTest *test);
+void gpm_device_teststore (EggTest *test);
+
+int
+main (int argc, char **argv)
+{
+	EggTest *test;
+
+	test = egg_test_init ();
+
+	/* needed for DPMS checks */
+	gtk_init (&argc, &argv);
+
+	/* tests go here */
+	egg_precision_test (test);
+	egg_discrete_test (test);
+	egg_color_test (test);
+	egg_array_float_test (test);
+//	egg_idletime_test (test);
+
+	gpm_common_test (test);
+//	gpm_idle_test (test);
+	gpm_phone_test (test);
+//	gpm_dpms_test (test);
+//	gpm_graph_widget_test (test);
+//	gpm_screensaver_test (test);
+
+#if 0
+	gpm_proxy_test (test);
+	gpm_hal_manager_test (test);
+	gpm_device_test (test);
+	gpm_device_teststore (test);
+#endif
+
+	return (egg_test_finish (test));
+}
+
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/106.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/106.html new file mode 100644 index 0000000..a73c6cb --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/106.html @@ -0,0 +1,1333 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008-2009 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "config.h"<--- Include file: "config.h" not found.
+
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <dbus/dbus-glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "gpm-session.h"
+#include "gpm-common.h"
+#include "gpm-marshal.h"
+
+static void     gpm_session_finalize   (GObject		*object);
+
+#define GPM_SESSION_MANAGER_SERVICE			"org.gnome.SessionManager"
+#define GPM_SESSION_MANAGER_PATH			"/org/gnome/SessionManager"
+#define GPM_SESSION_MANAGER_INTERFACE			"org.gnome.SessionManager"
+#define GPM_SESSION_MANAGER_PRESENCE_PATH		"/org/gnome/SessionManager/Presence"
+#define GPM_SESSION_MANAGER_PRESENCE_INTERFACE		"org.gnome.SessionManager.Presence"
+#define GPM_SESSION_MANAGER_CLIENT_PRIVATE_INTERFACE	"org.gnome.SessionManager.ClientPrivate"
+#define GPM_DBUS_PROPERTIES_INTERFACE			"org.freedesktop.DBus.Properties"
+
+typedef enum {
+	GPM_SESSION_STATUS_ENUM_AVAILABLE = 0,
+	GPM_SESSION_STATUS_ENUM_INVISIBLE,
+	GPM_SESSION_STATUS_ENUM_BUSY,
+	GPM_SESSION_STATUS_ENUM_IDLE,
+	GPM_SESSION_STATUS_ENUM_UNKNOWN
+} GpmSessionStatusEnum;
+
+typedef enum {
+	GPM_SESSION_INHIBIT_MASK_LOGOUT = 1,
+	GPM_SESSION_INHIBIT_MASK_SWITCH = 2,
+	GPM_SESSION_INHIBIT_MASK_SUSPEND = 4,
+	GPM_SESSION_INHIBIT_MASK_IDLE = 8
+} GpmSessionInhibitMask;
+
+struct GpmSessionPrivate
+{
+	DBusGProxy		*proxy;
+	DBusGProxy		*proxy_presence;
+	DBusGProxy		*proxy_client_private;
+	DBusGProxy		*proxy_prop;
+	gboolean		 is_idle_old;
+	gboolean		 is_idle_inhibited_old;
+	gboolean		 is_suspend_inhibited_old;
+};
+
+enum {
+	IDLE_CHANGED,
+	INHIBITED_CHANGED,
+	STOP,
+	QUERY_END_SESSION,
+	END_SESSION,
+	CANCEL_END_SESSION,
+	LAST_SIGNAL
+};
+
+static guint signals [LAST_SIGNAL] = { 0 };
+static gpointer gpm_session_object = NULL;
+
+G_DEFINE_TYPE_WITH_PRIVATE (GpmSession, gpm_session, G_TYPE_OBJECT)<--- There is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
+
+/**
+ * gpm_session_logout:
+ **/
+gboolean
+gpm_session_logout (GpmSession *session)
+{
+	g_return_val_if_fail (GPM_IS_SESSION (session), FALSE);
+
+	/* no mate-session */
+	if (session->priv->proxy == NULL) {
+		g_warning ("no mate-session");
+		return FALSE;
+	}
+
+	/* we have to use no reply, as the SM calls into g-p-m to get the can_suspend property */
+	dbus_g_proxy_call_no_reply (session->priv->proxy, "Shutdown", G_TYPE_INVALID);
+	return TRUE;
+}
+
+/**
+ * gpm_session_get_idle:
+ **/
+gboolean
+gpm_session_get_idle (GpmSession *session)
+{
+	g_return_val_if_fail (GPM_IS_SESSION (session), FALSE);
+	return session->priv->is_idle_old;
+}
+
+/**
+ * gpm_session_get_idle_inhibited:
+ **/
+gboolean
+gpm_session_get_idle_inhibited (GpmSession *session)
+{
+	g_return_val_if_fail (GPM_IS_SESSION (session), FALSE);
+	return session->priv->is_idle_inhibited_old;
+}
+
+/**
+ * gpm_session_get_suspend_inhibited:
+ **/
+gboolean
+gpm_session_get_suspend_inhibited (GpmSession *session)
+{
+	g_return_val_if_fail (GPM_IS_SESSION (session), FALSE);
+	return session->priv->is_suspend_inhibited_old;
+}
+
+/**
+ * gpm_session_presence_status_changed_cb:
+ **/
+static void
+gpm_session_presence_status_changed_cb (DBusGProxy *proxy, guint status, GpmSession *session)
+{
+	gboolean is_idle;
+	is_idle = (status == GPM_SESSION_STATUS_ENUM_IDLE);
+	if (is_idle != session->priv->is_idle_old) {
+		g_debug ("emitting idle-changed : (%i)", is_idle);
+		session->priv->is_idle_old = is_idle;
+		g_signal_emit (session, signals [IDLE_CHANGED], 0, is_idle);
+	}
+}
+
+/**
+ * gpm_session_is_idle:
+ **/
+static gboolean
+gpm_session_is_idle (GpmSession *session)
+{
+	gboolean ret;
+	gboolean is_idle = FALSE;
+	GError *error = NULL;
+	GValue *value;
+
+	/* no mate-session */
+	if (session->priv->proxy_prop == NULL) {
+		g_warning ("no mate-session");
+		goto out;
+	}
+
+	value = g_new0(GValue, 1);
+	/* find out if this change altered the inhibited state */
+	ret = dbus_g_proxy_call (session->priv->proxy_prop, "Get", &error,
+				 G_TYPE_STRING, GPM_SESSION_MANAGER_PRESENCE_INTERFACE,
+				 G_TYPE_STRING, "status",
+				 G_TYPE_INVALID,
+				 G_TYPE_VALUE, value,
+				 G_TYPE_INVALID);
+	if (!ret) {
+		g_warning ("failed to get idle status: %s", error->message);
+		g_error_free (error);
+		is_idle = FALSE;
+		goto out;
+	}
+	is_idle = (g_value_get_uint (value) == GPM_SESSION_STATUS_ENUM_IDLE);
+	g_free (value);
+out:
+	return is_idle;
+}
+
+/**
+ * gpm_session_is_idle_inhibited:
+ **/
+static gboolean
+gpm_session_is_idle_inhibited (GpmSession *session)
+{
+	gboolean ret;
+	gboolean is_inhibited = FALSE;
+	GError *error = NULL;
+
+	/* no mate-session */
+	if (session->priv->proxy == NULL) {
+		g_warning ("no mate-session");
+		goto out;
+	}
+
+	/* find out if this change altered the inhibited state */
+	ret = dbus_g_proxy_call (session->priv->proxy, "IsInhibited", &error,
+				 G_TYPE_UINT, GPM_SESSION_INHIBIT_MASK_IDLE,
+				 G_TYPE_INVALID,
+				 G_TYPE_BOOLEAN, &is_inhibited,
+				 G_TYPE_INVALID);
+	if (!ret) {
+		g_warning ("failed to get inhibit status: %s", error->message);
+		g_error_free (error);
+		is_inhibited = FALSE;
+	}
+out:
+	return is_inhibited;
+}
+
+/**
+ * gpm_session_is_suspend_inhibited:
+ **/
+static gboolean
+gpm_session_is_suspend_inhibited (GpmSession *session)
+{
+	gboolean ret;
+	gboolean is_inhibited = FALSE;
+	GError *error = NULL;
+
+	/* no mate-session */
+	if (session->priv->proxy == NULL) {
+		g_warning ("no mate-session");
+		goto out;
+	}
+
+	/* find out if this change altered the inhibited state */
+	ret = dbus_g_proxy_call (session->priv->proxy, "IsInhibited", &error,
+				 G_TYPE_UINT, GPM_SESSION_INHIBIT_MASK_SUSPEND,
+				 G_TYPE_INVALID,
+				 G_TYPE_BOOLEAN, &is_inhibited,
+				 G_TYPE_INVALID);
+	if (!ret) {
+		g_warning ("failed to get inhibit status: %s", error->message);
+		g_error_free (error);
+		is_inhibited = FALSE;
+	}
+out:
+	return is_inhibited;
+}
+
+/**
+ * gpm_session_stop_cb:
+ **/
+static void
+gpm_session_stop_cb (DBusGProxy *proxy, GpmSession *session)
+{
+	g_debug ("emitting ::stop()");
+	g_signal_emit (session, signals [STOP], 0);
+}
+
+/**
+ * gpm_session_query_end_session_cb:
+ **/
+static void
+gpm_session_query_end_session_cb (DBusGProxy *proxy, guint flags, GpmSession *session)
+{
+	g_debug ("emitting ::query-end-session(%u)", flags);
+	g_signal_emit (session, signals [QUERY_END_SESSION], 0, flags);
+}
+
+/**
+ * gpm_session_end_session_cb:
+ **/
+static void
+gpm_session_end_session_cb (DBusGProxy *proxy, guint flags, GpmSession *session)
+{
+	g_debug ("emitting ::end-session(%u)", flags);
+	g_signal_emit (session, signals [END_SESSION], 0, flags);
+}
+
+/**
+ * gpm_session_end_session_response:
+ **/
+gboolean
+gpm_session_end_session_response (GpmSession *session, gboolean is_okay, const gchar *reason)
+{
+	gboolean ret = FALSE;
+	GError *error = NULL;
+
+	g_return_val_if_fail (GPM_IS_SESSION (session), FALSE);
+	g_return_val_if_fail (session->priv->proxy_client_private != NULL, FALSE);
+
+	/* no mate-session */
+	if (session->priv->proxy_client_private == NULL) {
+		g_warning ("no mate-session proxy");
+		goto out;
+	}
+
+	/* send response */
+	ret = dbus_g_proxy_call (session->priv->proxy_client_private, "EndSessionResponse", &error,
+				 G_TYPE_BOOLEAN, is_okay,
+				 G_TYPE_STRING, reason,
+				 G_TYPE_INVALID,
+				 G_TYPE_INVALID);
+	if (!ret) {
+		g_warning ("failed to send session response: %s", error->message);
+		g_error_free (error);
+		goto out;
+	}
+out:
+	return ret;
+}
+
+/**
+ * gpm_session_register_client:
+ **/
+gboolean
+gpm_session_register_client (GpmSession *session, const gchar *app_id, const gchar *client_startup_id)
+{
+	gboolean ret = FALSE;
+	gchar *client_id = NULL;
+	GError *error = NULL;
+	DBusGConnection *connection;
+
+	g_return_val_if_fail (GPM_IS_SESSION (session), FALSE);
+
+	/* no mate-session */
+	if (session->priv->proxy == NULL) {
+		g_warning ("no mate-session");
+		goto out;
+	}
+
+	/* find out if this change altered the inhibited state */
+	ret = dbus_g_proxy_call (session->priv->proxy, "RegisterClient", &error,
+				 G_TYPE_STRING, app_id,
+				 G_TYPE_STRING, client_startup_id,
+				 G_TYPE_INVALID,
+				 DBUS_TYPE_G_OBJECT_PATH, &client_id,
+				 G_TYPE_INVALID);
+	if (!ret) {
+		g_warning ("failed to register client '%s': %s", client_startup_id, error->message);
+		g_error_free (error);
+		goto out;
+	}
+
+	/* get org.gnome.SessionManager.ClientPrivate interface */
+	connection = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
+	session->priv->proxy_client_private = dbus_g_proxy_new_for_name_owner (connection, GPM_SESSION_MANAGER_SERVICE,
+									       client_id, GPM_SESSION_MANAGER_CLIENT_PRIVATE_INTERFACE, &error);
+	if (session->priv->proxy_client_private == NULL) {
+		g_warning ("DBUS error: %s", error->message);
+		g_error_free (error);
+		goto out;
+	}
+
+	/* get Stop */
+	dbus_g_proxy_add_signal (session->priv->proxy_client_private, "Stop", G_TYPE_INVALID);
+	dbus_g_proxy_connect_signal (session->priv->proxy_client_private, "Stop", G_CALLBACK (gpm_session_stop_cb), session, NULL);
+
+	/* get QueryEndSession */
+	dbus_g_proxy_add_signal (session->priv->proxy_client_private, "QueryEndSession", G_TYPE_UINT, G_TYPE_INVALID);
+	dbus_g_proxy_connect_signal (session->priv->proxy_client_private, "QueryEndSession", G_CALLBACK (gpm_session_query_end_session_cb), session, NULL);
+
+	/* get EndSession */
+	dbus_g_proxy_add_signal (session->priv->proxy_client_private, "EndSession", G_TYPE_UINT, G_TYPE_INVALID);
+	dbus_g_proxy_connect_signal (session->priv->proxy_client_private, "EndSession", G_CALLBACK (gpm_session_end_session_cb), session, NULL);
+
+	g_debug ("registered startup '%s' to client id '%s'", client_startup_id, client_id);
+out:
+	g_free (client_id);
+	return ret;
+}
+
+/**
+ * gpm_session_inhibit_changed_cb:
+ **/
+static void
+gpm_session_inhibit_changed_cb (DBusGProxy *proxy, const gchar *id, GpmSession *session)
+{
+	gboolean is_idle_inhibited;
+	gboolean is_suspend_inhibited;
+
+	is_idle_inhibited = gpm_session_is_idle_inhibited (session);
+	is_suspend_inhibited = gpm_session_is_suspend_inhibited (session);
+	if (is_idle_inhibited != session->priv->is_idle_inhibited_old || is_suspend_inhibited != session->priv->is_suspend_inhibited_old) {
+		g_debug ("emitting inhibited-changed : idle=(%i), suspend=(%i)", is_idle_inhibited, is_suspend_inhibited);
+		session->priv->is_idle_inhibited_old = is_idle_inhibited;
+		session->priv->is_suspend_inhibited_old = is_suspend_inhibited;
+		g_signal_emit (session, signals [INHIBITED_CHANGED], 0, is_idle_inhibited, is_suspend_inhibited);
+	}
+}
+
+/**
+ * gpm_session_class_init:
+ * @klass: This class instance
+ **/
+static void
+gpm_session_class_init (GpmSessionClass *klass)
+{
+	GObjectClass *object_class = G_OBJECT_CLASS (klass);
+	object_class->finalize = gpm_session_finalize;
+
+	signals [IDLE_CHANGED] =
+		g_signal_new ("idle-changed",
+			      G_TYPE_FROM_CLASS (object_class),
+			      G_SIGNAL_RUN_LAST,
+			      G_STRUCT_OFFSET (GpmSessionClass, idle_changed),
+			      NULL, NULL, g_cclosure_marshal_VOID__BOOLEAN,
+			      G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
+	signals [INHIBITED_CHANGED] =
+		g_signal_new ("inhibited-changed",
+			      G_TYPE_FROM_CLASS (object_class),
+			      G_SIGNAL_RUN_LAST,
+			      G_STRUCT_OFFSET (GpmSessionClass, inhibited_changed),
+			      NULL, NULL, gpm_marshal_VOID__BOOLEAN_BOOLEAN,
+			      G_TYPE_NONE, 2, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN);
+	signals [STOP] =
+		g_signal_new ("stop",
+			      G_TYPE_FROM_CLASS (object_class),
+			      G_SIGNAL_RUN_LAST,
+			      G_STRUCT_OFFSET (GpmSessionClass, stop),
+			      NULL, NULL, g_cclosure_marshal_VOID__VOID,
+			      G_TYPE_NONE, 0);
+	signals [QUERY_END_SESSION] =
+		g_signal_new ("query-end-session",
+			      G_TYPE_FROM_CLASS (object_class),
+			      G_SIGNAL_RUN_LAST,
+			      G_STRUCT_OFFSET (GpmSessionClass, query_end_session),
+			      NULL, NULL, g_cclosure_marshal_VOID__UINT,
+			      G_TYPE_NONE, 1, G_TYPE_UINT);
+	signals [END_SESSION] =
+		g_signal_new ("end-session",
+			      G_TYPE_FROM_CLASS (object_class),
+			      G_SIGNAL_RUN_LAST,
+			      G_STRUCT_OFFSET (GpmSessionClass, end_session),
+			      NULL, NULL, g_cclosure_marshal_VOID__UINT,
+			      G_TYPE_NONE, 1, G_TYPE_UINT);
+	signals [CANCEL_END_SESSION] =
+		g_signal_new ("cancel-end-session",
+			      G_TYPE_FROM_CLASS (object_class),
+			      G_SIGNAL_RUN_LAST,
+			      G_STRUCT_OFFSET (GpmSessionClass, cancel_end_session),
+			      NULL, NULL, g_cclosure_marshal_VOID__VOID,
+			      G_TYPE_NONE, 0);
+}
+
+/**
+ * gpm_session_init:
+ * @session: This class instance
+ **/
+static void
+gpm_session_init (GpmSession *session)
+{
+	DBusGConnection *connection;
+	GError *error = NULL;
+
+	session->priv = gpm_session_get_instance_private (session);
+	session->priv->is_idle_old = FALSE;
+	session->priv->is_idle_inhibited_old = FALSE;
+	session->priv->is_suspend_inhibited_old = FALSE;
+	session->priv->proxy_client_private = NULL;
+
+	connection = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
+
+	/* get org.gnome.SessionManager interface */
+	session->priv->proxy = dbus_g_proxy_new_for_name_owner (connection, GPM_SESSION_MANAGER_SERVICE,
+								GPM_SESSION_MANAGER_PATH,
+								GPM_SESSION_MANAGER_INTERFACE, &error);
+	if (session->priv->proxy == NULL) {
+		g_warning ("DBUS error: %s", error->message);
+		g_error_free (error);
+		return;
+	}
+
+	/* get org.gnome.SessionManager.Presence interface */
+	session->priv->proxy_presence = dbus_g_proxy_new_for_name_owner (connection, GPM_SESSION_MANAGER_SERVICE,
+									 GPM_SESSION_MANAGER_PRESENCE_PATH,
+									 GPM_SESSION_MANAGER_PRESENCE_INTERFACE, &error);
+	if (session->priv->proxy_presence == NULL) {
+		g_warning ("DBUS error: %s", error->message);
+		g_error_free (error);
+		return;
+	}
+
+	/* get properties interface */
+	session->priv->proxy_prop = dbus_g_proxy_new_for_name_owner (connection, GPM_SESSION_MANAGER_SERVICE,
+								     GPM_SESSION_MANAGER_PRESENCE_PATH,
+								     GPM_DBUS_PROPERTIES_INTERFACE, &error);
+	if (session->priv->proxy_prop == NULL) {
+		g_warning ("DBUS error: %s", error->message);
+		g_error_free (error);
+		return;
+	}
+
+	/* get StatusChanged */
+	dbus_g_proxy_add_signal (session->priv->proxy_presence, "StatusChanged", G_TYPE_UINT, G_TYPE_INVALID);
+	dbus_g_proxy_connect_signal (session->priv->proxy_presence, "StatusChanged", G_CALLBACK (gpm_session_presence_status_changed_cb), session, NULL);
+
+	/* get InhibitorAdded */
+	dbus_g_proxy_add_signal (session->priv->proxy, "InhibitorAdded", DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID);
+	dbus_g_proxy_connect_signal (session->priv->proxy, "InhibitorAdded", G_CALLBACK (gpm_session_inhibit_changed_cb), session, NULL);
+
+	/* get InhibitorRemoved */
+	dbus_g_proxy_add_signal (session->priv->proxy, "InhibitorRemoved", DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID);
+	dbus_g_proxy_connect_signal (session->priv->proxy, "InhibitorRemoved", G_CALLBACK (gpm_session_inhibit_changed_cb), session, NULL);
+
+	/* coldplug */
+	session->priv->is_idle_inhibited_old = gpm_session_is_idle_inhibited (session);
+	session->priv->is_suspend_inhibited_old = gpm_session_is_suspend_inhibited (session);
+	session->priv->is_idle_old = gpm_session_is_idle (session);
+	g_debug ("idle: %i, idle_inhibited: %i, suspend_inhibited: %i", session->priv->is_idle_old, session->priv->is_idle_inhibited_old, session->priv->is_suspend_inhibited_old);
+}
+
+/**
+ * gpm_session_finalize:
+ * @object: This class instance
+ **/
+static void
+gpm_session_finalize (GObject *object)
+{
+	GpmSession *session;
+	g_return_if_fail (object != NULL);
+	g_return_if_fail (GPM_IS_SESSION (object));
+
+	session = GPM_SESSION (object);
+	session->priv = gpm_session_get_instance_private (session);
+
+	g_object_unref (session->priv->proxy);
+	g_object_unref (session->priv->proxy_presence);
+	if (session->priv->proxy_client_private != NULL)
+		g_object_unref (session->priv->proxy_client_private);
+	g_object_unref (session->priv->proxy_prop);
+
+	G_OBJECT_CLASS (gpm_session_parent_class)->finalize (object);
+}
+
+/**
+ * gpm_session_new:
+ * Return value: new GpmSession instance.
+ **/
+GpmSession *
+gpm_session_new (void)
+{
+	if (gpm_session_object != NULL) {
+		g_object_ref (gpm_session_object);
+	} else {
+		gpm_session_object = g_object_new (GPM_TYPE_SESSION, NULL);
+		g_object_add_weak_pointer (gpm_session_object, &gpm_session_object);
+	}
+	return GPM_SESSION (gpm_session_object);
+}
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/107.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/107.html new file mode 100644 index 0000000..c7c6bee --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/107.html @@ -0,0 +1,3313 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
   1
+   2
+   3
+   4
+   5
+   6
+   7
+   8
+   9
+  10
+  11
+  12
+  13
+  14
+  15
+  16
+  17
+  18
+  19
+  20
+  21
+  22
+  23
+  24
+  25
+  26
+  27
+  28
+  29
+  30
+  31
+  32
+  33
+  34
+  35
+  36
+  37
+  38
+  39
+  40
+  41
+  42
+  43
+  44
+  45
+  46
+  47
+  48
+  49
+  50
+  51
+  52
+  53
+  54
+  55
+  56
+  57
+  58
+  59
+  60
+  61
+  62
+  63
+  64
+  65
+  66
+  67
+  68
+  69
+  70
+  71
+  72
+  73
+  74
+  75
+  76
+  77
+  78
+  79
+  80
+  81
+  82
+  83
+  84
+  85
+  86
+  87
+  88
+  89
+  90
+  91
+  92
+  93
+  94
+  95
+  96
+  97
+  98
+  99
+ 100
+ 101
+ 102
+ 103
+ 104
+ 105
+ 106
+ 107
+ 108
+ 109
+ 110
+ 111
+ 112
+ 113
+ 114
+ 115
+ 116
+ 117
+ 118
+ 119
+ 120
+ 121
+ 122
+ 123
+ 124
+ 125
+ 126
+ 127
+ 128
+ 129
+ 130
+ 131
+ 132
+ 133
+ 134
+ 135
+ 136
+ 137
+ 138
+ 139
+ 140
+ 141
+ 142
+ 143
+ 144
+ 145
+ 146
+ 147
+ 148
+ 149
+ 150
+ 151
+ 152
+ 153
+ 154
+ 155
+ 156
+ 157
+ 158
+ 159
+ 160
+ 161
+ 162
+ 163
+ 164
+ 165
+ 166
+ 167
+ 168
+ 169
+ 170
+ 171
+ 172
+ 173
+ 174
+ 175
+ 176
+ 177
+ 178
+ 179
+ 180
+ 181
+ 182
+ 183
+ 184
+ 185
+ 186
+ 187
+ 188
+ 189
+ 190
+ 191
+ 192
+ 193
+ 194
+ 195
+ 196
+ 197
+ 198
+ 199
+ 200
+ 201
+ 202
+ 203
+ 204
+ 205
+ 206
+ 207
+ 208
+ 209
+ 210
+ 211
+ 212
+ 213
+ 214
+ 215
+ 216
+ 217
+ 218
+ 219
+ 220
+ 221
+ 222
+ 223
+ 224
+ 225
+ 226
+ 227
+ 228
+ 229
+ 230
+ 231
+ 232
+ 233
+ 234
+ 235
+ 236
+ 237
+ 238
+ 239
+ 240
+ 241
+ 242
+ 243
+ 244
+ 245
+ 246
+ 247
+ 248
+ 249
+ 250
+ 251
+ 252
+ 253
+ 254
+ 255
+ 256
+ 257
+ 258
+ 259
+ 260
+ 261
+ 262
+ 263
+ 264
+ 265
+ 266
+ 267
+ 268
+ 269
+ 270
+ 271
+ 272
+ 273
+ 274
+ 275
+ 276
+ 277
+ 278
+ 279
+ 280
+ 281
+ 282
+ 283
+ 284
+ 285
+ 286
+ 287
+ 288
+ 289
+ 290
+ 291
+ 292
+ 293
+ 294
+ 295
+ 296
+ 297
+ 298
+ 299
+ 300
+ 301
+ 302
+ 303
+ 304
+ 305
+ 306
+ 307
+ 308
+ 309
+ 310
+ 311
+ 312
+ 313
+ 314
+ 315
+ 316
+ 317
+ 318
+ 319
+ 320
+ 321
+ 322
+ 323
+ 324
+ 325
+ 326
+ 327
+ 328
+ 329
+ 330
+ 331
+ 332
+ 333
+ 334
+ 335
+ 336
+ 337
+ 338
+ 339
+ 340
+ 341
+ 342
+ 343
+ 344
+ 345
+ 346
+ 347
+ 348
+ 349
+ 350
+ 351
+ 352
+ 353
+ 354
+ 355
+ 356
+ 357
+ 358
+ 359
+ 360
+ 361
+ 362
+ 363
+ 364
+ 365
+ 366
+ 367
+ 368
+ 369
+ 370
+ 371
+ 372
+ 373
+ 374
+ 375
+ 376
+ 377
+ 378
+ 379
+ 380
+ 381
+ 382
+ 383
+ 384
+ 385
+ 386
+ 387
+ 388
+ 389
+ 390
+ 391
+ 392
+ 393
+ 394
+ 395
+ 396
+ 397
+ 398
+ 399
+ 400
+ 401
+ 402
+ 403
+ 404
+ 405
+ 406
+ 407
+ 408
+ 409
+ 410
+ 411
+ 412
+ 413
+ 414
+ 415
+ 416
+ 417
+ 418
+ 419
+ 420
+ 421
+ 422
+ 423
+ 424
+ 425
+ 426
+ 427
+ 428
+ 429
+ 430
+ 431
+ 432
+ 433
+ 434
+ 435
+ 436
+ 437
+ 438
+ 439
+ 440
+ 441
+ 442
+ 443
+ 444
+ 445
+ 446
+ 447
+ 448
+ 449
+ 450
+ 451
+ 452
+ 453
+ 454
+ 455
+ 456
+ 457
+ 458
+ 459
+ 460
+ 461
+ 462
+ 463
+ 464
+ 465
+ 466
+ 467
+ 468
+ 469
+ 470
+ 471
+ 472
+ 473
+ 474
+ 475
+ 476
+ 477
+ 478
+ 479
+ 480
+ 481
+ 482
+ 483
+ 484
+ 485
+ 486
+ 487
+ 488
+ 489
+ 490
+ 491
+ 492
+ 493
+ 494
+ 495
+ 496
+ 497
+ 498
+ 499
+ 500
+ 501
+ 502
+ 503
+ 504
+ 505
+ 506
+ 507
+ 508
+ 509
+ 510
+ 511
+ 512
+ 513
+ 514
+ 515
+ 516
+ 517
+ 518
+ 519
+ 520
+ 521
+ 522
+ 523
+ 524
+ 525
+ 526
+ 527
+ 528
+ 529
+ 530
+ 531
+ 532
+ 533
+ 534
+ 535
+ 536
+ 537
+ 538
+ 539
+ 540
+ 541
+ 542
+ 543
+ 544
+ 545
+ 546
+ 547
+ 548
+ 549
+ 550
+ 551
+ 552
+ 553
+ 554
+ 555
+ 556
+ 557
+ 558
+ 559
+ 560
+ 561
+ 562
+ 563
+ 564
+ 565
+ 566
+ 567
+ 568
+ 569
+ 570
+ 571
+ 572
+ 573
+ 574
+ 575
+ 576
+ 577
+ 578
+ 579
+ 580
+ 581
+ 582
+ 583
+ 584
+ 585
+ 586
+ 587
+ 588
+ 589
+ 590
+ 591
+ 592
+ 593
+ 594
+ 595
+ 596
+ 597
+ 598
+ 599
+ 600
+ 601
+ 602
+ 603
+ 604
+ 605
+ 606
+ 607
+ 608
+ 609
+ 610
+ 611
+ 612
+ 613
+ 614
+ 615
+ 616
+ 617
+ 618
+ 619
+ 620
+ 621
+ 622
+ 623
+ 624
+ 625
+ 626
+ 627
+ 628
+ 629
+ 630
+ 631
+ 632
+ 633
+ 634
+ 635
+ 636
+ 637
+ 638
+ 639
+ 640
+ 641
+ 642
+ 643
+ 644
+ 645
+ 646
+ 647
+ 648
+ 649
+ 650
+ 651
+ 652
+ 653
+ 654
+ 655
+ 656
+ 657
+ 658
+ 659
+ 660
+ 661
+ 662
+ 663
+ 664
+ 665
+ 666
+ 667
+ 668
+ 669
+ 670
+ 671
+ 672
+ 673
+ 674
+ 675
+ 676
+ 677
+ 678
+ 679
+ 680
+ 681
+ 682
+ 683
+ 684
+ 685
+ 686
+ 687
+ 688
+ 689
+ 690
+ 691
+ 692
+ 693
+ 694
+ 695
+ 696
+ 697
+ 698
+ 699
+ 700
+ 701
+ 702
+ 703
+ 704
+ 705
+ 706
+ 707
+ 708
+ 709
+ 710
+ 711
+ 712
+ 713
+ 714
+ 715
+ 716
+ 717
+ 718
+ 719
+ 720
+ 721
+ 722
+ 723
+ 724
+ 725
+ 726
+ 727
+ 728
+ 729
+ 730
+ 731
+ 732
+ 733
+ 734
+ 735
+ 736
+ 737
+ 738
+ 739
+ 740
+ 741
+ 742
+ 743
+ 744
+ 745
+ 746
+ 747
+ 748
+ 749
+ 750
+ 751
+ 752
+ 753
+ 754
+ 755
+ 756
+ 757
+ 758
+ 759
+ 760
+ 761
+ 762
+ 763
+ 764
+ 765
+ 766
+ 767
+ 768
+ 769
+ 770
+ 771
+ 772
+ 773
+ 774
+ 775
+ 776
+ 777
+ 778
+ 779
+ 780
+ 781
+ 782
+ 783
+ 784
+ 785
+ 786
+ 787
+ 788
+ 789
+ 790
+ 791
+ 792
+ 793
+ 794
+ 795
+ 796
+ 797
+ 798
+ 799
+ 800
+ 801
+ 802
+ 803
+ 804
+ 805
+ 806
+ 807
+ 808
+ 809
+ 810
+ 811
+ 812
+ 813
+ 814
+ 815
+ 816
+ 817
+ 818
+ 819
+ 820
+ 821
+ 822
+ 823
+ 824
+ 825
+ 826
+ 827
+ 828
+ 829
+ 830
+ 831
+ 832
+ 833
+ 834
+ 835
+ 836
+ 837
+ 838
+ 839
+ 840
+ 841
+ 842
+ 843
+ 844
+ 845
+ 846
+ 847
+ 848
+ 849
+ 850
+ 851
+ 852
+ 853
+ 854
+ 855
+ 856
+ 857
+ 858
+ 859
+ 860
+ 861
+ 862
+ 863
+ 864
+ 865
+ 866
+ 867
+ 868
+ 869
+ 870
+ 871
+ 872
+ 873
+ 874
+ 875
+ 876
+ 877
+ 878
+ 879
+ 880
+ 881
+ 882
+ 883
+ 884
+ 885
+ 886
+ 887
+ 888
+ 889
+ 890
+ 891
+ 892
+ 893
+ 894
+ 895
+ 896
+ 897
+ 898
+ 899
+ 900
+ 901
+ 902
+ 903
+ 904
+ 905
+ 906
+ 907
+ 908
+ 909
+ 910
+ 911
+ 912
+ 913
+ 914
+ 915
+ 916
+ 917
+ 918
+ 919
+ 920
+ 921
+ 922
+ 923
+ 924
+ 925
+ 926
+ 927
+ 928
+ 929
+ 930
+ 931
+ 932
+ 933
+ 934
+ 935
+ 936
+ 937
+ 938
+ 939
+ 940
+ 941
+ 942
+ 943
+ 944
+ 945
+ 946
+ 947
+ 948
+ 949
+ 950
+ 951
+ 952
+ 953
+ 954
+ 955
+ 956
+ 957
+ 958
+ 959
+ 960
+ 961
+ 962
+ 963
+ 964
+ 965
+ 966
+ 967
+ 968
+ 969
+ 970
+ 971
+ 972
+ 973
+ 974
+ 975
+ 976
+ 977
+ 978
+ 979
+ 980
+ 981
+ 982
+ 983
+ 984
+ 985
+ 986
+ 987
+ 988
+ 989
+ 990
+ 991
+ 992
+ 993
+ 994
+ 995
+ 996
+ 997
+ 998
+ 999
+1000
+1001
+1002
+1003
+1004
+1005
+1006
+1007
+1008
+1009
+1010
+1011
+1012
+1013
+1014
+1015
+1016
+1017
+1018
+1019
+1020
+1021
+1022
+1023
+1024
+1025
+1026
+1027
+1028
+1029
+1030
+1031
+1032
+1033
+1034
+1035
+1036
+1037
+1038
+1039
+1040
+1041
+1042
+1043
+1044
+1045
+1046
+1047
+1048
+1049
+1050
+1051
+1052
+1053
+1054
+1055
+1056
+1057
+1058
+1059
+1060
+1061
+1062
+1063
+1064
+1065
+1066
+1067
+1068
+1069
+1070
+1071
+1072
+1073
+1074
+1075
+1076
+1077
+1078
+1079
+1080
+1081
+1082
+1083
+1084
+1085
+1086
+1087
+1088
+1089
+1090
+1091
+1092
+1093
+1094
+1095
+1096
+1097
+1098
+1099
+1100
+1101
+1102
+1103
+1104
+1105
+1106
+1107
+1108
+1109
+1110
+1111
+1112
+1113
+1114
+1115
+1116
+1117
+1118
+1119
+1120
+1121
+1122
+1123
+1124
+1125
+1126
+1127
+1128
+1129
+1130
+1131
+1132
+1133
+1134
+1135
+1136
+1137
+1138
+1139
+1140
+1141
+1142
+1143
+1144
+1145
+1146
+1147
+1148
+1149
+1150
+1151
+1152
+1153
+1154
+1155
+1156
+1157
+1158
+1159
+1160
+1161
+1162
+1163
+1164
+1165
+1166
+1167
+1168
+1169
+1170
+1171
+1172
+1173
+1174
+1175
+1176
+1177
+1178
+1179
+1180
+1181
+1182
+1183
+1184
+1185
+1186
+1187
+1188
+1189
+1190
+1191
+1192
+1193
+1194
+1195
+1196
+1197
+1198
+1199
+1200
+1201
+1202
+1203
+1204
+1205
+1206
+1207
+1208
+1209
+1210
+1211
+1212
+1213
+1214
+1215
+1216
+1217
+1218
+1219
+1220
+1221
+1222
+1223
+1224
+1225
+1226
+1227
+1228
+1229
+1230
+1231
+1232
+1233
+1234
+1235
+1236
+1237
+1238
+1239
+1240
+1241
+1242
+1243
+1244
+1245
+1246
+1247
+1248
+1249
+1250
+1251
+1252
+1253
+1254
+1255
+1256
+1257
+1258
+1259
+1260
+1261
+1262
+1263
+1264
+1265
+1266
+1267
+1268
+1269
+1270
+1271
+1272
+1273
+1274
+1275
+1276
+1277
+1278
+1279
+1280
+1281
+1282
+1283
+1284
+1285
+1286
+1287
+1288
+1289
+1290
+1291
+1292
+1293
+1294
+1295
+1296
+1297
+1298
+1299
+1300
+1301
+1302
+1303
+1304
+1305
+1306
+1307
+1308
+1309
+1310
+1311
+1312
+1313
+1314
+1315
+1316
+1317
+1318
+1319
+1320
+1321
+1322
+1323
+1324
+1325
+1326
+1327
+1328
+1329
+1330
+1331
+1332
+1333
+1334
+1335
+1336
+1337
+1338
+1339
+1340
+1341
+1342
+1343
+1344
+1345
+1346
+1347
+1348
+1349
+1350
+1351
+1352
+1353
+1354
+1355
+1356
+1357
+1358
+1359
+1360
+1361
+1362
+1363
+1364
+1365
+1366
+1367
+1368
+1369
+1370
+1371
+1372
+1373
+1374
+1375
+1376
+1377
+1378
+1379
+1380
+1381
+1382
+1383
+1384
+1385
+1386
+1387
+1388
+1389
+1390
+1391
+1392
+1393
+1394
+1395
+1396
+1397
+1398
+1399
+1400
+1401
+1402
+1403
+1404
+1405
+1406
+1407
+1408
+1409
+1410
+1411
+1412
+1413
+1414
+1415
+1416
+1417
+1418
+1419
+1420
+1421
+1422
+1423
+1424
+1425
+1426
+1427
+1428
+1429
+1430
+1431
+1432
+1433
+1434
+1435
+1436
+1437
+1438
+1439
+1440
+1441
+1442
+1443
+1444
+1445
+1446
+1447
+1448
+1449
+1450
+1451
+1452
+1453
+1454
+1455
+1456
+1457
+1458
+1459
+1460
+1461
+1462
+1463
+1464
+1465
+1466
+1467
+1468
+1469
+1470
+1471
+1472
+1473
+1474
+1475
+1476
+1477
+1478
+1479
+1480
+1481
+1482
+1483
+1484
+1485
+1486
+1487
+1488
+1489
+1490
+1491
+1492
+1493
+1494
+1495
+1496
+1497
+1498
+1499
+1500
+1501
+1502
+1503
+1504
+1505
+1506
+1507
+1508
+1509
+1510
+1511
+1512
+1513
+1514
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "config.h"<--- Include file: "config.h" not found.
+
+#include <locale.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <dbus/dbus-glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <libupower-glib/upower.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "egg-color.h"
+#include "egg-array-float.h"
+
+#include "gpm-common.h"
+#include "gpm-icon-names.h"
+#include "gpm-upower.h"
+#include "gpm-graph-widget.h"
+
+static GtkBuilder *builder = NULL;
+static GtkListStore *list_store_info = NULL;
+static GtkListStore *list_store_devices = NULL;
+gchar *current_device = NULL;
+static guint history_time;
+static GSettings *settings;
+static gfloat sigma_smoothing = 0.0f;
+static GtkWidget *graph_history = NULL;
+static GtkWidget *graph_statistics = NULL;
+
+enum {
+	GPM_INFO_COLUMN_TEXT,
+	GPM_INFO_COLUMN_VALUE,
+	GPM_INFO_COLUMN_LAST
+};
+
+enum {
+	GPM_DEVICES_COLUMN_ICON,
+	GPM_DEVICES_COLUMN_TEXT,
+	GPM_DEVICES_COLUMN_ID,
+	GPM_DEVICES_COLUMN_LAST
+};
+
+#define GPM_STATS_CHARGE_DATA_VALUE             "charge-data"
+#define GPM_STATS_CHARGE_ACCURACY_VALUE         "charge-accuracy"
+#define GPM_STATS_DISCHARGE_DATA_VALUE          "discharge-data"
+#define GPM_STATS_DISCHARGE_ACCURACY_VALUE      "discharge-accuracy"
+
+/* TRANSLATORS: what we've observed about the device */
+#define GPM_STATS_CHARGE_DATA_TEXT              _("Charge profile")
+#define GPM_STATS_DISCHARGE_DATA_TEXT           _("Discharge profile")
+/* TRANSLATORS: how accurately we can predict the time remaining of the battery */
+#define GPM_STATS_CHARGE_ACCURACY_TEXT          _("Charge accuracy")
+#define GPM_STATS_DISCHARGE_ACCURACY_TEXT       _("Discharge accuracy")
+
+#define GPM_HISTORY_RATE_TEXT			_("Rate")
+#define GPM_HISTORY_CHARGE_TEXT			_("Charge")
+#define GPM_HISTORY_TIME_FULL_TEXT		_("Time to full")
+#define GPM_HISTORY_TIME_EMPTY_TEXT		_("Time to empty")
+
+#define GPM_HISTORY_POWER_VALUE                 "power"
+#define GPM_HISTORY_RATE_VALUE			"rate"
+#define GPM_HISTORY_CHARGE_VALUE		"charge"
+#define GPM_HISTORY_TIME_FULL_VALUE		"time-full"
+#define GPM_HISTORY_TIME_EMPTY_VALUE		"time-empty"
+
+#define GPM_HISTORY_MINUTE_TEXT			_("10 minutes")
+#define GPM_HISTORY_HOUR_TEXT			_("2 hours")
+#define GPM_HISTORY_HOURS_TEXT			_("6 hours")
+#define GPM_HISTORY_DAY_TEXT			_("1 day")
+#define GPM_HISTORY_WEEK_TEXT			_("1 week")
+
+#define GPM_HISTORY_MINUTE_VALUE		10*60
+#define GPM_HISTORY_HOUR_VALUE			2*60*60
+#define GPM_HISTORY_HOURS_VALUE			6*60*60
+#define GPM_HISTORY_DAY_VALUE			24*60*60
+#define GPM_HISTORY_WEEK_VALUE			7*24*60*60
+
+enum stats_type_enum {
+	GPM_STATS_CHARGE_TYPE = 0,
+	GPM_STATS_DISCHARGE_TYPE,
+	GPM_STATS_CHARGE_ACCURACY_TYPE,
+	GPM_STATS_DISCHARGE_ACCURACY_TYPE,
+	GPM_STATS_LAST_TYPE
+};
+static enum stats_type_enum stats_type;
+
+enum history_type_enum {
+	GPM_HISTORY_RATE_TYPE = 0,
+	GPM_HISTORY_CHARGE_TYPE,
+	GPM_HISTORY_TIME_FULL_TYPE,
+	GPM_HISTORY_TIME_EMPTY_TYPE,
+	GPM_HISTORY_POWER_TYPE,
+	GPM_HISTORY_LAST_TYPE
+};
+static enum history_type_enum history_type;
+static const char *history_types [GPM_HISTORY_LAST_TYPE] = {
+	[GPM_HISTORY_RATE_TYPE] = GPM_HISTORY_RATE_VALUE,
+	[GPM_HISTORY_CHARGE_TYPE] = GPM_HISTORY_CHARGE_VALUE,
+	[GPM_HISTORY_TIME_FULL_TYPE] = GPM_HISTORY_TIME_FULL_VALUE,
+	[GPM_HISTORY_TIME_EMPTY_TYPE] = GPM_HISTORY_TIME_EMPTY_VALUE,
+	[GPM_HISTORY_POWER_TYPE] = GPM_HISTORY_POWER_VALUE
+};
+
+/**
+ * gpm_stats_button_help_cb:
+ **/
+static void
+gpm_stats_button_help_cb (GtkWidget *widget, gboolean data)
+{
+	gpm_help_display ("statistics");
+}
+
+/**
+ * gpm_stats_add_info_columns:
+ **/
+static void
+gpm_stats_add_info_columns (GtkTreeView *treeview)
+{
+	GtkCellRenderer *renderer;
+	GtkTreeViewColumn *column;
+
+	/* image */
+	renderer = gtk_cell_renderer_text_new ();
+	column = gtk_tree_view_column_new_with_attributes (_("Attribute"), renderer,
+							   "markup", GPM_INFO_COLUMN_TEXT, NULL);
+	gtk_tree_view_column_set_sort_column_id (column, GPM_INFO_COLUMN_TEXT);
+	gtk_tree_view_append_column (treeview, column);
+
+	/* column for text */
+	renderer = gtk_cell_renderer_text_new ();
+	column = gtk_tree_view_column_new_with_attributes (_("Value"), renderer,
+							   "markup", GPM_INFO_COLUMN_VALUE, NULL);
+	gtk_tree_view_append_column (treeview, column);
+}
+
+/**
+ * gpm_stats_add_devices_columns:
+ **/
+static void
+gpm_stats_add_devices_columns (GtkTreeView *treeview)
+{
+	GtkCellRenderer *renderer;
+	GtkTreeViewColumn *column;
+
+	/* image */
+	renderer = gtk_cell_renderer_pixbuf_new ();
+	g_object_set (renderer, "stock-size", GTK_ICON_SIZE_DIALOG, NULL);
+	column = gtk_tree_view_column_new_with_attributes (_("Image"), renderer,
+							   "icon-name", GPM_DEVICES_COLUMN_ICON, NULL);
+	gtk_tree_view_append_column (treeview, column);
+
+	/* column for text */
+	renderer = gtk_cell_renderer_text_new ();
+	column = gtk_tree_view_column_new_with_attributes (_("Description"), renderer,
+							   "markup", GPM_DEVICES_COLUMN_TEXT, NULL);
+	gtk_tree_view_column_set_sort_column_id (column, GPM_INFO_COLUMN_TEXT);
+	gtk_tree_view_append_column (treeview, column);
+	gtk_tree_view_column_set_expand (column, TRUE);
+}
+
+/**
+ * gpm_stats_add_info_data:
+ **/
+static void
+gpm_stats_add_info_data (const gchar *attr, const gchar *text)
+{
+	GtkTreeIter iter;
+	gtk_list_store_append (list_store_info, &iter);
+	gtk_list_store_set (list_store_info, &iter,
+			    GPM_INFO_COLUMN_TEXT, attr,
+			    GPM_INFO_COLUMN_VALUE, text, -1);
+}
+
+/**
+ * gpm_stats_update_smooth_data:
+ **/
+static GPtrArray *
+gpm_stats_update_smooth_data (GPtrArray *list)
+{
+	guint i;
+	GpmPointObj *point;
+	GpmPointObj *point_new;
+	GPtrArray *new;
+	EggArrayFloat *raw;
+	EggArrayFloat *convolved;
+	EggArrayFloat *outliers;
+	EggArrayFloat *gaussian = NULL;
+
+	/* convert the y data to a EggArrayFloat array */
+	raw = egg_array_float_new (list->len);
+	for (i=0; i<list->len; i++) {
+		point = (GpmPointObj *) g_ptr_array_index (list, i);
+		egg_array_float_set (raw, i, point->y);
+	}
+
+	/* remove any outliers */
+	outliers = egg_array_float_remove_outliers (raw, 3, 0.1);
+
+	/* convolve with gaussian */
+	gaussian = egg_array_float_compute_gaussian (15, sigma_smoothing);
+	convolved = egg_array_float_convolve (outliers, gaussian);
+
+	/* add the smoothed data back into a new array */
+	new = g_ptr_array_new_with_free_func ((GDestroyNotify) gpm_point_obj_free);
+	for (i=0; i<list->len; i++) {
+		point = (GpmPointObj *) g_ptr_array_index (list, i);
+		point_new = g_new0 (GpmPointObj, 1);
+		point_new->color = point->color;
+		point_new->x = point->x;
+		point_new->y = egg_array_float_get (convolved, i);
+		g_ptr_array_add (new, point_new);
+	}
+
+	/* free data */
+	egg_array_float_free (gaussian);
+	egg_array_float_free (raw);
+	egg_array_float_free (convolved);
+	egg_array_float_free (outliers);
+
+	return new;
+}
+
+/**
+ * gpm_stats_time_to_string:
+ **/
+static gchar *
+gpm_stats_time_to_string (gint seconds)
+{
+	gfloat value = seconds;
+
+	if (value < 0) {
+		/* TRANSLATORS: this is when the stats time is not known */
+		return g_strdup (_("Unknown"));
+	}
+	if (value < 60) {
+		/* TRANSLATORS: this is a time value, usually to show on a graph */
+		return g_strdup_printf (ngettext ("%.0f second", "%.0f seconds", value), value);
+	}
+	value /= 60.0;
+	if (value < 60) {
+		/* TRANSLATORS: this is a time value, usually to show on a graph */
+		return g_strdup_printf (ngettext ("%.1f minute", "%.1f minutes", value), value);
+	}
+	value /= 60.0;
+	if (value < 60) {
+		/* TRANSLATORS: this is a time value, usually to show on a graph */
+		return g_strdup_printf (ngettext ("%.1f hour", "%.1f hours", value), value);
+	}
+	value /= 24.0;
+	/* TRANSLATORS: this is a time value, usually to show on a graph */
+	return g_strdup_printf (ngettext ("%.1f day", "%.1f days", value), value);
+}
+
+/**
+ * gpm_stats_bool_to_string:
+ **/
+static const gchar *
+gpm_stats_bool_to_string (gboolean ret)
+{
+	return ret ? _("Yes") : _("No");
+}
+
+/**
+ * gpm_stats_get_printable_device_path:
+ **/
+static gchar *
+gpm_stats_get_printable_device_path (UpDevice *device)
+{
+	const gchar *object_path;
+	gchar *device_path = NULL;
+
+	/* get object path */
+	object_path = up_device_get_object_path (device);
+	if (object_path != NULL)
+		device_path = g_filename_display_basename (object_path);
+
+	return device_path;
+}
+
+/**
+ * gpm_stats_update_info_page_details:
+ **/
+static void
+gpm_stats_update_info_page_details (UpDevice *device)
+{
+	struct tm *time_tm;<--- Variable 'time_tm' can be declared as pointer to const
+	time_t t;
+	gchar time_buf[256];
+	gchar *text;
+	guint refreshed;
+	UpDeviceKind kind;
+	UpDeviceState state;
+	UpDeviceTechnology technology;
+	gdouble percentage;
+	gdouble capacity;
+	gdouble energy;
+	gdouble energy_empty;
+	gdouble energy_full;
+	gdouble energy_full_design;
+	gdouble energy_rate;
+	gdouble voltage;
+	gboolean online;
+	gboolean is_present;
+	gboolean power_supply;
+	gboolean is_rechargeable;
+	guint64 update_time;
+	gint64 time_to_full;
+	gint64 time_to_empty;
+	gchar *vendor = NULL;
+	gchar *serial = NULL;
+	gchar *model = NULL;
+	gchar *device_path = NULL;
+
+	gtk_list_store_clear (list_store_info);
+
+	/* get device properties */
+	g_object_get (device,
+		      "kind", &kind,
+		      "state", &state,
+		      "percentage", &percentage,
+		      "online", &online,
+		      "update_time", &update_time,
+		      "power_supply", &power_supply,
+		      "is_rechargeable", &is_rechargeable,
+		      "is-present", &is_present,
+		      "time-to-full", &time_to_full,
+		      "time-to-empty", &time_to_empty,
+		      "technology", &technology,
+		      "capacity", &capacity,
+		      "energy", &energy,
+		      "energy-empty", &energy_empty,
+		      "energy-full", &energy_full,
+		      "energy-full-design", &energy_full_design,
+		      "energy-rate", &energy_rate,
+		      "voltage", &voltage,
+		      "vendor", &vendor,
+		      "serial", &serial,
+		      "model", &model,
+		      NULL);
+
+	/* get a human readable time */
+	t = (time_t) update_time;
+	time_tm = localtime (&t);
+	strftime (time_buf, sizeof time_buf, "%c", time_tm);
+
+	/* remove prefix */
+	device_path = gpm_stats_get_printable_device_path (device);
+	/* TRANSLATORS: the device ID of the current device, e.g. "battery0" */
+	gpm_stats_add_info_data (_("Device"), device_path);
+	g_free (device_path);
+
+	gpm_stats_add_info_data (_("Type"), gpm_device_kind_to_localised_string (kind, 1));
+	if (vendor != NULL && vendor[0] != '\0')
+		gpm_stats_add_info_data (_("Vendor"), vendor);
+	if (model != NULL && model[0] != '\0')
+		gpm_stats_add_info_data (_("Model"), model);
+	if (serial != NULL && serial[0] != '\0')
+		gpm_stats_add_info_data (_("Serial number"), serial);
+
+	/* TRANSLATORS: a boolean attribute that means if the device is supplying the
+	 * main power for the computer. For instance, an AC adapter or laptop battery
+	 * would be TRUE,  but a mobile phone or mouse taking power is FALSE */
+	gpm_stats_add_info_data (_("Supply"), gpm_stats_bool_to_string (power_supply));
+
+	refreshed = (int) (time (NULL) - update_time);
+	text = g_strdup_printf (ngettext ("%u second", "%u seconds", refreshed), refreshed);
+
+	/* TRANSLATORS: when the device was last updated with new data. It's
+	* usually a few seconds when a device is discharging or charging. */
+	gpm_stats_add_info_data (_("Refreshed"), text);
+	g_free (text);
+
+	if (kind == UP_DEVICE_KIND_BATTERY ||
+	    kind == UP_DEVICE_KIND_MOUSE ||
+	    kind == UP_DEVICE_KIND_KEYBOARD ||
+	    kind == UP_DEVICE_KIND_UPS) {
+		/* TRANSLATORS: Present is whether the device is currently attached
+		 * to the computer, as some devices (e.g. laptop batteries) can
+		 * be removed, but still observed as devices on the system */
+		gpm_stats_add_info_data (_("Present"), gpm_stats_bool_to_string (is_present));
+	}
+	if (kind == UP_DEVICE_KIND_BATTERY ||
+	    kind == UP_DEVICE_KIND_MOUSE ||
+	    kind == UP_DEVICE_KIND_KEYBOARD) {
+		/* TRANSLATORS: If the device can be recharged, e.g. lithium
+		 * batteries rather than alkaline ones */
+		gpm_stats_add_info_data (_("Rechargeable"), gpm_stats_bool_to_string (is_rechargeable));
+	}
+	if (kind == UP_DEVICE_KIND_BATTERY ||
+	    kind == UP_DEVICE_KIND_MOUSE ||
+	    kind == UP_DEVICE_KIND_KEYBOARD) {
+		/* TRANSLATORS: The state of the device, e.g. "Changing" or "Fully charged" */
+		gpm_stats_add_info_data (_("State"), gpm_device_state_to_localised_string (state));
+	}
+	if (kind == UP_DEVICE_KIND_BATTERY) {
+		text = g_strdup_printf ("%.1f Wh", energy);
+		gpm_stats_add_info_data (_("Energy"), text);
+		g_free (text);
+		text = g_strdup_printf ("%.1f Wh", energy_empty);
+		gpm_stats_add_info_data (_("Energy when empty"), text);
+		g_free (text);
+		text = g_strdup_printf ("%.1f Wh", energy_full);
+		gpm_stats_add_info_data (_("Energy when full"), text);
+		g_free (text);
+		text = g_strdup_printf ("%.1f Wh", energy_full_design);
+		gpm_stats_add_info_data (_("Energy (design)"), text);
+		g_free (text);
+	}
+	if (kind == UP_DEVICE_KIND_BATTERY ||
+	    kind == UP_DEVICE_KIND_MONITOR) {
+		text = g_strdup_printf ("%.1f W", energy_rate);
+		/* TRANSLATORS: the rate of discharge for the device */
+		gpm_stats_add_info_data (_("Rate"), text);
+		g_free (text);
+	}
+	if (kind == UP_DEVICE_KIND_UPS ||
+	    kind == UP_DEVICE_KIND_BATTERY ||
+	    kind == UP_DEVICE_KIND_MONITOR) {
+		text = g_strdup_printf ("%.1f V", voltage);
+		gpm_stats_add_info_data (_("Voltage"), text);
+		g_free (text);
+	}
+	if (kind == UP_DEVICE_KIND_BATTERY ||
+	    kind == UP_DEVICE_KIND_UPS) {
+		if (time_to_full >= 0) {
+			text = gpm_stats_time_to_string (time_to_full);
+			gpm_stats_add_info_data (_("Time to full"), text);
+			g_free (text);
+		}
+		if (time_to_empty >= 0) {
+			text = gpm_stats_time_to_string (time_to_empty);
+			gpm_stats_add_info_data (_("Time to empty"), text);
+			g_free (text);
+		}
+	}
+	if (kind == UP_DEVICE_KIND_BATTERY ||
+	    kind == UP_DEVICE_KIND_MOUSE ||
+	    kind == UP_DEVICE_KIND_KEYBOARD ||
+	    kind == UP_DEVICE_KIND_UPS) {
+		text = g_strdup_printf ("%.1f%%", percentage);
+		/* TRANSLATORS: the amount of charge the cell contains */
+		gpm_stats_add_info_data (_("Percentage"), text);
+		g_free (text);
+	}
+	if (kind == UP_DEVICE_KIND_BATTERY) {
+		text = g_strdup_printf ("%.1f%%", capacity);
+		/* TRANSLATORS: the capacity of the device, which is basically a measure
+		 * of how full it can get, relative to the design capacity */
+		gpm_stats_add_info_data (_("Capacity"), text);
+		g_free (text);
+	}
+	if (kind == UP_DEVICE_KIND_BATTERY) {
+		/* TRANSLATORS: the type of battery, e.g. lithium or nikel metal hydroxide */
+		gpm_stats_add_info_data (_("Technology"), gpm_device_technology_to_localised_string (technology));
+	}
+	if (kind == UP_DEVICE_KIND_LINE_POWER) {
+		/* TRANSLATORS: this is when the device is plugged in, typically
+		 * only shown for the ac adaptor device */
+		gpm_stats_add_info_data (_("Online"), gpm_stats_bool_to_string (online));
+	}
+
+	g_free (vendor);
+	g_free (serial);
+	g_free (model);
+}
+
+/**
+ * gpm_stats_set_graph_data:
+ **/
+static void
+gpm_stats_set_graph_data (GtkWidget *widget, GPtrArray *data, gboolean use_smoothed, gboolean use_points)
+{
+	GPtrArray *smoothed;
+
+	gpm_graph_widget_data_clear (GPM_GRAPH_WIDGET (widget));
+
+	/* add correct data */
+	if (!use_smoothed) {
+		if (use_points)
+			gpm_graph_widget_data_assign (GPM_GRAPH_WIDGET (widget), GPM_GRAPH_WIDGET_PLOT_BOTH, data);
+		else
+			gpm_graph_widget_data_assign (GPM_GRAPH_WIDGET (widget), GPM_GRAPH_WIDGET_PLOT_LINE, data);
+	} else {
+		smoothed = gpm_stats_update_smooth_data (data);
+		if (use_points)
+			gpm_graph_widget_data_assign (GPM_GRAPH_WIDGET (widget), GPM_GRAPH_WIDGET_PLOT_POINTS, data);
+		gpm_graph_widget_data_assign (GPM_GRAPH_WIDGET (widget), GPM_GRAPH_WIDGET_PLOT_LINE, smoothed);
+		g_ptr_array_unref (smoothed);
+	}
+
+	/* show */
+	gtk_widget_show (widget);
+}
+
+/**
+ * gpm_stats_update_info_page_history:
+ **/
+static void
+gpm_stats_update_info_page_history (UpDevice *device)
+{
+	GPtrArray *array;
+	guint i;
+	UpHistoryItem *item;
+	GtkWidget *widget;
+	gboolean checked;
+	gboolean points;
+	GpmPointObj *point;
+	GPtrArray *new;
+	gint32 offset;
+
+	new = g_ptr_array_new_with_free_func ((GDestroyNotify) gpm_point_obj_free);
+	if (history_type == GPM_HISTORY_CHARGE_TYPE) {
+		g_object_set (graph_history,
+			      "type-x", GPM_GRAPH_WIDGET_TYPE_TIME,
+			      "type-y", GPM_GRAPH_WIDGET_TYPE_PERCENTAGE,
+			      "autorange-x", FALSE,
+			      "start-x", -history_time,
+			      "stop-x", 0,
+			      "autorange-y", FALSE,
+			      "start-y", 0,
+			      "stop-y", 100,
+			      NULL);
+	} else if (history_type == GPM_HISTORY_RATE_TYPE) {
+		g_object_set (graph_history,
+			      "type-x", GPM_GRAPH_WIDGET_TYPE_TIME,
+			      "type-y", GPM_GRAPH_WIDGET_TYPE_POWER,
+			      "autorange-x", FALSE,
+			      "start-x", -history_time,
+			      "stop-x", 0,
+			      "autorange-y", TRUE,
+			      NULL);
+	} else {
+		g_object_set (graph_history,
+			      "type-x", GPM_GRAPH_WIDGET_TYPE_TIME,
+			      "type-y", GPM_GRAPH_WIDGET_TYPE_TIME,
+			      "autorange-x", FALSE,
+			      "start-x", -history_time,
+			      "stop-x", 0,
+			      "autorange-y", TRUE,
+			      NULL);
+	}
+
+	widget = GTK_WIDGET (gtk_builder_get_object (builder, "label_history_nodata"));
+	/* The type of history, history_types [history_type], known values are "rate" and "charge". */
+	array = up_device_get_history_sync (device, history_types [history_type], history_time, 150, NULL, NULL);
+	if (array == NULL) {
+		/* show no data label and hide graph */
+		gtk_widget_hide (graph_history);
+		gtk_widget_show (widget);
+		goto out;
+	}
+
+	/* hide no data and show graph */
+	gtk_widget_hide (widget);
+	gtk_widget_show (graph_history);
+
+	offset = (gint32) (g_get_real_time () / G_USEC_PER_SEC);
+
+	for (i=0; i<array->len; i++) {
+		item = (UpHistoryItem *) g_ptr_array_index (array, i);
+
+		/* abandon this point */
+		if (up_history_item_get_state (item) == UP_DEVICE_STATE_UNKNOWN)
+			continue;
+
+		point = gpm_point_obj_new ();
+		point->x = ((gint32) up_history_item_get_time (item)) - offset;
+		point->y = up_history_item_get_value (item);
+		if (up_history_item_get_state (item) == UP_DEVICE_STATE_CHARGING)
+			point->color = egg_color_from_rgb (255, 0, 0);
+		else if (up_history_item_get_state (item) == UP_DEVICE_STATE_DISCHARGING)
+			point->color = egg_color_from_rgb (0, 0, 255);
+		else if (up_history_item_get_state (item) == UP_DEVICE_STATE_PENDING_CHARGE)
+			point->color = egg_color_from_rgb (200, 0, 0);
+		else if (up_history_item_get_state (item) == UP_DEVICE_STATE_PENDING_DISCHARGE)
+			point->color = egg_color_from_rgb (0, 0, 200);
+		else {
+			if (history_type == GPM_HISTORY_RATE_TYPE)
+				point->color = egg_color_from_rgb (255, 255, 255);
+			else
+				point->color = egg_color_from_rgb (0, 255, 0);
+		}
+		g_ptr_array_add (new, point);
+	}
+
+	/* render */
+	sigma_smoothing = 2.0;
+	widget = GTK_WIDGET (gtk_builder_get_object (builder, "checkbutton_smooth_history"));
+	checked = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
+	widget = GTK_WIDGET (gtk_builder_get_object (builder, "checkbutton_points_history"));
+	points = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
+
+	/* present data to graph */
+	gpm_stats_set_graph_data (graph_history, new, checked, points);
+
+	g_ptr_array_unref (array);
+	g_ptr_array_unref (new);
+out:
+	return;
+}
+
+/**
+ * gpm_stats_update_info_page_stats:
+ **/
+static void
+gpm_stats_update_info_page_stats (UpDevice *device)
+{
+	GPtrArray *array;
+	guint i;
+	UpStatsItem *item;
+	GtkWidget *widget;
+	gboolean checked;
+	gboolean points;
+	GpmPointObj *point;
+	GPtrArray *new;
+	gboolean use_data = FALSE;
+	const gchar *type = NULL;
+
+	new = g_ptr_array_new_with_free_func ((GDestroyNotify) gpm_point_obj_free);
+	if (stats_type == GPM_STATS_CHARGE_TYPE) {
+		type = "charging";
+		use_data = TRUE;
+	} else if (stats_type == GPM_STATS_DISCHARGE_TYPE) {
+		type = "discharging";
+		use_data = TRUE;
+	} else if (stats_type == GPM_STATS_CHARGE_ACCURACY_TYPE) {
+		type = "charging";
+		use_data = FALSE;
+	} else if (stats_type == GPM_STATS_DISCHARGE_ACCURACY_TYPE) {
+		type = "discharging";
+		use_data = FALSE;
+	} else {
+		g_assert_not_reached ();
+	}
+
+	if (use_data) {
+		g_object_set (graph_statistics,
+			      "type-x", GPM_GRAPH_WIDGET_TYPE_PERCENTAGE,
+			      "type-y", GPM_GRAPH_WIDGET_TYPE_FACTOR,
+			      "autorange-x", TRUE,
+			      "autorange-y", TRUE,
+			      NULL);
+	} else {
+		g_object_set (graph_statistics,
+			      "type-x", GPM_GRAPH_WIDGET_TYPE_PERCENTAGE,
+			      "type-y", GPM_GRAPH_WIDGET_TYPE_PERCENTAGE,
+			      "autorange-x", TRUE,
+			      "autorange-y", TRUE,
+			      NULL);
+	}
+
+	widget = GTK_WIDGET (gtk_builder_get_object (builder, "label_stats_nodata"));
+	array = up_device_get_statistics_sync (device, type, NULL, NULL);
+	if (array == NULL) {
+		/* show no data label and hide graph */
+		gtk_widget_hide (graph_statistics);
+		gtk_widget_show (widget);
+		goto out;
+	}
+
+	/* hide no data and show graph */
+	gtk_widget_hide (widget);
+	gtk_widget_show (graph_statistics);
+
+	for (i=0; i<array->len; i++) {
+		item = (UpStatsItem *) g_ptr_array_index (array, i);
+		point = gpm_point_obj_new ();
+		point->x = i;
+		if (use_data)
+			point->y = up_stats_item_get_value (item);
+		else
+			point->y = up_stats_item_get_accuracy (item);
+		point->color = egg_color_from_rgb (255, 0, 0);
+		g_ptr_array_add (new, point);
+	}
+
+	/* render */
+	sigma_smoothing = 1.1;
+	widget = GTK_WIDGET (gtk_builder_get_object (builder, "checkbutton_smooth_stats"));
+	checked = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
+	widget = GTK_WIDGET (gtk_builder_get_object (builder, "checkbutton_points_stats"));
+	points = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
+
+	/* present data to graph */
+	gpm_stats_set_graph_data (graph_statistics, new, checked, points);
+
+	g_ptr_array_unref (array);
+	g_ptr_array_unref (new);
+out:
+	return;
+}
+
+/**
+ * gpm_stats_update_info_data_page:
+ **/
+static void
+gpm_stats_update_info_data_page (UpDevice *device, gint page)
+{
+	if (page == 0)
+		gpm_stats_update_info_page_details (device);
+	else if (page == 1)
+		gpm_stats_update_info_page_history (device);
+	else if (page == 2)
+		gpm_stats_update_info_page_stats (device);
+}
+
+/**
+ * gpm_stats_update_info_data:
+ **/
+static void
+gpm_stats_update_info_data (UpDevice *device)
+{
+	gint page;
+	GtkNotebook *notebook;
+	GtkWidget *page_widget;
+	gboolean has_history;
+	gboolean has_statistics;
+
+	/* get properties */
+	g_object_get (device,
+		      "has-history", &has_history,
+		      "has-statistics", &has_statistics,
+		      NULL);
+
+	notebook = GTK_NOTEBOOK (gtk_builder_get_object (builder, "notebook1"));
+
+	/* show info page */
+	page_widget = gtk_notebook_get_nth_page (notebook, 0);
+	gtk_widget_show (page_widget);
+
+	/* hide history if no support */
+	page_widget = gtk_notebook_get_nth_page (notebook, 1);
+	if (has_history)
+		gtk_widget_show (page_widget);
+	else
+		gtk_widget_hide (page_widget);
+
+	/* hide statistics if no support */
+	page_widget = gtk_notebook_get_nth_page (notebook, 2);
+	if (has_statistics)
+		gtk_widget_show (page_widget);
+	else
+		gtk_widget_hide (page_widget);
+
+	page = gtk_notebook_get_current_page (notebook);
+	gpm_stats_update_info_data_page (device, page);
+
+	return;
+}
+
+static void
+gpm_stats_set_title (GtkWindow *window, gint page_num)
+{
+	gchar *title;
+	const gchar * const page_titles[] = {
+		/* TRANSLATORS: shown on the titlebar */
+		N_("Device Information"),
+		/* TRANSLATORS: shown on the titlebar */
+		N_("Device History"),
+		/* TRANSLATORS: shown on the titlebar */
+		N_("Device Profile"),
+	};
+
+	/* TRANSLATORS: shown on the titlebar */
+	title = g_strdup_printf ("%s - %s", _("Power Statistics"), _(page_titles[page_num]));
+	gtk_window_set_title (window, title);
+	g_free (title);
+}
+
+/**
+ * gpm_stats_notebook_changed_cb:
+ **/
+static void
+gpm_stats_notebook_changed_cb (GtkNotebook *notebook, gpointer page, gint page_num, gpointer user_data)
+{
+	UpDevice *device;
+	GtkWidget *widget;
+
+	/* set the window title depending on the mode */
+	widget = GTK_WIDGET (gtk_builder_get_object (builder, "dialog_stats"));
+	gpm_stats_set_title (GTK_WINDOW (widget), page_num);
+
+	/* save page in gsettings */
+	g_settings_set_int (settings, GPM_SETTINGS_INFO_PAGE_NUMBER, page_num);
+
+	if (current_device == NULL)
+		return;
+
+	device = up_device_new ();
+	up_device_set_object_path_sync (device, current_device, NULL, NULL);
+	gpm_stats_update_info_data_page (device, page_num);
+	gpm_stats_update_info_data (device);
+	g_object_unref (device);
+}
+
+/**
+ * gpm_stats_button_update_ui:
+ **/
+static void
+gpm_stats_button_update_ui (void)
+{
+	UpDevice *device;
+
+	if (current_device == NULL)
+		return;
+
+	device = up_device_new ();
+	up_device_set_object_path_sync (device, current_device, NULL, NULL);
+	gpm_stats_update_info_data (device);
+	g_object_unref (device);
+}
+
+/**
+ * gpm_stats_devices_treeview_clicked_cb:
+ **/
+static void
+gpm_stats_devices_treeview_clicked_cb (GtkTreeSelection *selection, gboolean data)
+{
+	GtkTreeModel *model;
+	GtkTreeIter iter;
+	UpDevice *device;
+
+	/* This will only work in single or browse selection mode! */
+	if (gtk_tree_selection_get_selected (selection, &model, &iter)) {
+		g_free (current_device);
+		gtk_tree_model_get (model, &iter, GPM_DEVICES_COLUMN_ID, &current_device, -1);
+
+		/* save device in gsettings */
+		g_settings_set_string (settings, GPM_SETTINGS_INFO_LAST_DEVICE, current_device);
+
+		/* show transaction_id */
+		g_debug ("selected row is: %s", current_device);
+
+		/* is special device */
+		device = up_device_new ();
+		up_device_set_object_path_sync (device, current_device, NULL, NULL);
+		gpm_stats_update_info_data (device);
+		g_object_unref (device);
+
+	} else {
+		g_debug ("no row selected");
+	}
+}
+
+/**
+ * gpm_stats_window_activated_cb
+ **/
+static void
+gpm_stats_window_activated_cb (GtkApplication *app, gpointer data)
+{
+	GtkWidget *widget;
+	widget = GTK_WIDGET (gtk_builder_get_object (builder, "dialog_stats"));
+	gtk_application_add_window (GTK_APPLICATION (app), GTK_WINDOW (widget));
+	gtk_window_present (GTK_WINDOW (widget));
+}
+
+/**
+ * gpm_stats_device_changed_cb:
+ **/
+static void
+gpm_stats_device_changed_cb (UpDevice *device, GParamSpec *pspec, gpointer user_data)
+{
+	const gchar *object_path;
+	object_path = up_device_get_object_path (device);
+	if (object_path == NULL || current_device == NULL)
+		return;
+	g_debug ("changed:   %s", object_path);
+	if (g_strcmp0 (current_device, object_path) == 0)
+		gpm_stats_update_info_data (device);
+}
+
+/**
+ * gpm_stats_add_device:
+ **/
+static void
+gpm_stats_add_device (UpDevice *device, GPtrArray *devices)
+{
+	const gchar *id;
+	GtkTreeIter iter;
+	char *icon;
+	UpDeviceKind kind;
+	gchar *label, *vendor, *model;
+
+	if (devices != NULL)
+		g_ptr_array_add (devices, device);
+
+	g_signal_connect (device, "notify",
+	                  G_CALLBACK (gpm_stats_device_changed_cb), NULL);
+
+	/* get device properties */
+	g_object_get (device,
+		      "kind", &kind,
+		      "vendor", &vendor,
+		      "model", &model,
+		      NULL);
+
+	id = up_device_get_object_path (device);
+	if ((vendor != NULL && strlen(vendor) != 0) && (model != NULL && strlen(model) != 0)) {
+		label = g_strdup_printf ("%s %s", vendor, model);
+	}
+	else if((vendor == NULL || strlen(vendor) == 0) && (model != NULL && strlen(model) != 0)) {
+		label = g_strdup_printf ("%s", model);
+	}
+	else {
+		label = g_strdup_printf ("%s", gpm_device_kind_to_localised_string (kind, 1));
+	}
+	icon = gpm_upower_get_device_icon (device);
+
+	gtk_list_store_append (list_store_devices, &iter);
+	gtk_list_store_set (list_store_devices, &iter,
+			    GPM_DEVICES_COLUMN_ID, id,
+			    GPM_DEVICES_COLUMN_TEXT, label,
+			    GPM_DEVICES_COLUMN_ICON, icon, -1);
+	g_free (icon);
+	g_free (label);
+	g_free (vendor);
+	g_free (model);
+}
+
+/**
+ * gpm_stats_device_added_cb:
+ **/
+static void
+gpm_stats_device_added_cb (UpClient *client, UpDevice *device, GPtrArray *devices)
+{
+	const gchar *object_path;
+	object_path = up_device_get_object_path (device);
+	g_debug ("added:     %s", object_path);
+
+	gpm_stats_add_device (device, devices);
+}
+
+/**
+ * gpm_stats_device_removed_cb:
+ **/
+static void
+gpm_stats_device_removed_cb (UpClient *client, const gchar *object_path, GPtrArray *devices)
+{
+	GtkTreeIter iter;
+	gchar *id = NULL;
+	gboolean ret;
+
+	UpDevice *device_tmp;
+	guint i;
+
+	for (i = 0; i < devices->len; i++) {
+		device_tmp = g_ptr_array_index (devices, i);
+		if (g_strcmp0 (up_device_get_object_path (device_tmp), object_path) == 0) {
+			g_ptr_array_remove_index_fast (devices, i);
+			break;
+		}
+	}
+	g_debug ("removed:   %s", object_path);
+	if (g_strcmp0 (current_device, object_path) == 0) {
+		gtk_list_store_clear (list_store_info);
+	}
+
+	/* search the list and remove the object path entry */
+	ret = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (list_store_devices), &iter);
+	while (ret) {
+		gtk_tree_model_get (GTK_TREE_MODEL (list_store_devices), &iter, GPM_DEVICES_COLUMN_ID, &id, -1);
+		if (g_strcmp0 (id, object_path) == 0) {
+			gtk_list_store_remove (list_store_devices, &iter);
+			break;
+		}
+		g_free (id);
+		ret = gtk_tree_model_iter_next (GTK_TREE_MODEL (list_store_devices), &iter);
+	};
+}
+
+/**
+ * gpm_stats_history_type_combo_changed_cb:
+ **/
+static void
+gpm_stats_history_type_combo_changed_cb (GtkWidget *widget, gpointer data)
+{
+	guint active;
+	const gchar *axis_x = NULL;
+	const gchar *axis_y = NULL;
+
+	active = gtk_combo_box_get_active (GTK_COMBO_BOX (widget));
+
+	if (active == 0) {
+		history_type = GPM_HISTORY_RATE_TYPE;
+		/* TRANSLATORS: this is the X axis on the graph */
+		axis_x = _("Time elapsed");
+		/* TRANSLATORS: this is the Y axis on the graph */
+		axis_y = _("Power");
+	} else if (active == 1) {
+		history_type = GPM_HISTORY_CHARGE_TYPE;
+		/* TRANSLATORS: this is the X axis on the graph */
+		axis_x = _("Time elapsed");
+		/* TRANSLATORS: this is the Y axis on the graph for the whole battery device */
+		axis_y = _("Cell charge");
+	} else if (active == 2) {
+		history_type = GPM_HISTORY_TIME_FULL_TYPE;
+		/* TRANSLATORS: this is the X axis on the graph */
+		axis_x = _("Time elapsed");
+		/* TRANSLATORS: this is the Y axis on the graph */
+		axis_y = _("Predicted time");
+	} else if (active == 3) {
+		history_type = GPM_HISTORY_TIME_EMPTY_TYPE;
+		/* TRANSLATORS: this is the X axis on the graph */
+		axis_x = _("Time elapsed");
+		/* TRANSLATORS: this is the Y axis on the graph */
+		axis_y = _("Predicted time");
+	} else {
+		g_assert (FALSE);
+	}
+
+	/* set axis */
+	widget = GTK_WIDGET (gtk_builder_get_object (builder, "label_axis_history_x"));
+	gtk_label_set_label (GTK_LABEL(widget), axis_x);
+	widget = GTK_WIDGET (gtk_builder_get_object (builder, "label_axis_history_y"));
+	gtk_label_set_label (GTK_LABEL(widget), axis_y);
+
+	gpm_stats_button_update_ui ();
+
+	/* save to gsettings */
+	g_settings_set_string (settings, GPM_SETTINGS_INFO_HISTORY_TYPE, history_types [history_type]);
+}
+
+/**
+ * gpm_stats_type_combo_changed_cb:
+ **/
+static void
+gpm_stats_type_combo_changed_cb (GtkWidget *widget, gpointer data)
+{
+	guint active;
+	const gchar *axis_x = NULL;
+	const gchar *axis_y = NULL;
+	const char *stats_types [GPM_STATS_LAST_TYPE] = {
+		[GPM_STATS_CHARGE_TYPE] = GPM_STATS_CHARGE_DATA_VALUE,
+		[GPM_STATS_DISCHARGE_TYPE] = GPM_STATS_CHARGE_ACCURACY_VALUE,
+		[GPM_STATS_CHARGE_ACCURACY_TYPE] = GPM_STATS_DISCHARGE_DATA_VALUE,
+		[GPM_STATS_DISCHARGE_ACCURACY_TYPE] = GPM_STATS_DISCHARGE_ACCURACY_VALUE
+	};
+
+	active = gtk_combo_box_get_active (GTK_COMBO_BOX (widget));
+
+	if (active == 0) {
+		stats_type = GPM_STATS_CHARGE_TYPE;
+		/* TRANSLATORS: this is the X axis on the graph for the whole battery device */
+		axis_x = _("Cell charge");
+		/* TRANSLATORS: this is the Y axis on the graph */
+		axis_y = _("Correction factor");
+	} else if (active == 1) {
+		stats_type = GPM_STATS_CHARGE_ACCURACY_TYPE;
+		/* TRANSLATORS: this is the X axis on the graph for the whole battery device */
+		axis_x = _("Cell charge");
+		/* TRANSLATORS: this is the Y axis on the graph */
+		axis_y = _("Prediction accuracy");
+	} else if (active == 2) {
+		stats_type = GPM_STATS_DISCHARGE_TYPE;
+		/* TRANSLATORS: this is the X axis on the graph for the whole battery device */
+		axis_x = _("Cell charge");
+		/* TRANSLATORS: this is the Y axis on the graph */
+		axis_y = _("Correction factor");
+	} else if (active == 3) {
+		stats_type = GPM_STATS_DISCHARGE_ACCURACY_TYPE;
+		/* TRANSLATORS: this is the X axis on the graph for the whole battery device */
+		axis_x = _("Cell charge");
+		/* TRANSLATORS: this is the Y axis on the graph */
+		axis_y = _("Prediction accuracy");
+	} else {
+		g_assert (FALSE);
+	}
+
+	/* set axis */
+	widget = GTK_WIDGET (gtk_builder_get_object (builder, "label_axis_stats_x"));
+	gtk_label_set_label (GTK_LABEL(widget), axis_x);
+	widget = GTK_WIDGET (gtk_builder_get_object (builder, "label_axis_stats_y"));
+	gtk_label_set_label (GTK_LABEL(widget), axis_y);
+
+	gpm_stats_button_update_ui ();
+
+	/* save to gsettings */
+	g_settings_set_string (settings, GPM_SETTINGS_INFO_STATS_TYPE, stats_types[stats_type]);
+}
+
+/**
+ * gpm_stats_range_combo_changed:
+ **/
+static void
+gpm_stats_range_combo_changed (GtkWidget *widget, gpointer data)
+{
+	guint active;
+
+	active = gtk_combo_box_get_active (GTK_COMBO_BOX (widget));
+
+	if (active == 0)
+		history_time = GPM_HISTORY_MINUTE_VALUE;
+	else if (active == 1)
+		history_time = GPM_HISTORY_HOUR_VALUE;
+	else if (active == 2)
+		history_time = GPM_HISTORY_HOURS_VALUE;
+	else if (active == 3)
+		history_time = GPM_HISTORY_DAY_VALUE;
+	else if (active == 4)
+		history_time = GPM_HISTORY_WEEK_VALUE;
+	else
+		g_assert (FALSE);
+
+	/* save to gsettings */
+	g_settings_set_int (settings, GPM_SETTINGS_INFO_HISTORY_TIME, history_time);
+
+	gpm_stats_button_update_ui ();
+}
+
+/**
+ * gpm_stats_smooth_checkbox_history_cb:
+ * @widget: The GtkWidget object
+ **/
+static void
+gpm_stats_smooth_checkbox_history_cb (GtkWidget *widget, gpointer data)
+{
+	gboolean checked;
+	checked = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
+	g_settings_set_boolean (settings, GPM_SETTINGS_INFO_HISTORY_GRAPH_SMOOTH, checked);
+	gpm_stats_button_update_ui ();
+}
+
+/**
+ * gpm_stats_smooth_checkbox_stats_cb:
+ * @widget: The GtkWidget object
+ **/
+static void
+gpm_stats_smooth_checkbox_stats_cb (GtkWidget *widget, gpointer data)
+{
+	gboolean checked;
+	checked = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
+	g_settings_set_boolean (settings, GPM_SETTINGS_INFO_STATS_GRAPH_SMOOTH, checked);
+	gpm_stats_button_update_ui ();
+}
+
+/**
+ * gpm_stats_points_checkbox_history_cb:
+ * @widget: The GtkWidget object
+ **/
+static void
+gpm_stats_points_checkbox_history_cb (GtkWidget *widget, gpointer data)
+{
+	gboolean checked;
+	checked = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
+	g_settings_set_boolean (settings, GPM_SETTINGS_INFO_HISTORY_GRAPH_POINTS, checked);
+	gpm_stats_button_update_ui ();
+}
+
+/**
+ * gpm_stats_points_checkbox_stats_cb:
+ * @widget: The GtkWidget object
+ **/
+static void
+gpm_stats_points_checkbox_stats_cb (GtkWidget *widget, gpointer data)
+{
+	gboolean checked;
+	checked = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
+	g_settings_set_boolean (settings, GPM_SETTINGS_INFO_STATS_GRAPH_POINTS, checked);
+	gpm_stats_button_update_ui ();
+}
+
+/**
+ * gpm_stats_highlight_device:
+ **/
+static void
+gpm_stats_highlight_device (const gchar *object_path)
+{
+	gboolean ret;
+	gchar *id = NULL;
+	gchar *path_str;
+	guint i;
+	GtkTreeIter iter;
+	GtkTreePath *path;
+	GtkWidget *widget;
+
+	/* check valid */
+	if (!g_str_has_prefix (object_path, "/"))
+		return;
+
+	/* we have to reuse the treeview data as it may be sorted */
+	ret = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (list_store_devices), &iter);
+	for (i=0; ret; i++) {
+		gtk_tree_model_get (GTK_TREE_MODEL (list_store_devices), &iter,
+				    GPM_DEVICES_COLUMN_ID, &id,
+				    -1);
+		if (g_strcmp0 (id, object_path) == 0) {
+			path_str = g_strdup_printf ("%u", i);
+			path = gtk_tree_path_new_from_string (path_str);
+			widget = GTK_WIDGET (gtk_builder_get_object (builder, "treeview_devices"));
+			gtk_tree_view_set_cursor_on_cell (GTK_TREE_VIEW (widget), path, NULL, NULL, FALSE);
+			g_free (path_str);
+			gtk_tree_path_free (path);
+		}
+		g_free (id);
+		ret = gtk_tree_model_iter_next (GTK_TREE_MODEL (list_store_devices), &iter);
+	}
+}
+
+/**
+ * main:
+ **/
+int
+main (int argc, char *argv[])
+{
+	GOptionContext *context;
+	GtkBox *box;
+	GtkWidget *widget, *window;
+	GtkTreeSelection *selection;
+	GtkApplication *app;
+	gint status;
+	UpClient *client;
+	GPtrArray *devices = NULL;
+	UpDevice *device;
+	UpDeviceKind kind;
+	guint i, j;
+	gint page;
+	gboolean checked;
+	gchar *last_device = NULL;
+	char  *history_type_str;
+	char  *stats_type_str;
+
+	const char *history_text [GPM_HISTORY_LAST_TYPE - 1] = {
+		[GPM_HISTORY_RATE_TYPE] = GPM_HISTORY_RATE_TEXT,
+		[GPM_HISTORY_CHARGE_TYPE] = GPM_HISTORY_CHARGE_TEXT,
+		[GPM_HISTORY_TIME_FULL_TYPE] = GPM_HISTORY_TIME_FULL_TEXT,
+		[GPM_HISTORY_TIME_EMPTY_TYPE] = GPM_HISTORY_TIME_EMPTY_TEXT
+	};
+	const char *stats_text [GPM_STATS_LAST_TYPE] = {
+		[GPM_STATS_CHARGE_TYPE] = GPM_STATS_CHARGE_DATA_TEXT,
+		[GPM_STATS_DISCHARGE_TYPE] = GPM_STATS_DISCHARGE_DATA_TEXT,
+		[GPM_STATS_CHARGE_ACCURACY_TYPE] = GPM_STATS_CHARGE_ACCURACY_TEXT,
+		[GPM_STATS_DISCHARGE_ACCURACY_TYPE] = GPM_STATS_DISCHARGE_ACCURACY_TEXT
+	};
+	const GOptionEntry options[] = {
+		{ "device", '\0', 0, G_OPTION_ARG_STRING, &last_device,
+		  /* TRANSLATORS: show a device by default */
+		  N_("Select this device at startup"), NULL },
+		{ NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL }
+	};
+
+	setlocale (LC_ALL, "");
+
+	bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR);
+	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+	textdomain (GETTEXT_PACKAGE);
+
+	dbus_g_thread_init ();
+
+	context = g_option_context_new (NULL);
+	/* TRANSLATORS: the program name */
+	g_option_context_set_summary (context, _("Power Statistics"));
+	g_option_context_add_main_entries (context, options, NULL);
+	g_option_context_parse (context, &argc, &argv, NULL);
+	g_option_context_free (context);
+
+	gtk_init (&argc, &argv);
+
+	app = gtk_application_new ("org.mate.PowerManager.Statistics", 0);
+
+	g_signal_connect (app, "activate",
+			  G_CALLBACK (gpm_stats_window_activated_cb), NULL);
+
+	/* add application specific icons to search path */
+	gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (),
+                                           GPM_ICONS_DATA);
+
+	/* get data from the settings */
+	settings = g_settings_new (GPM_SETTINGS_SCHEMA);
+
+	/* get UI */
+	builder = gtk_builder_new_from_resource ("/org/mate/powermanager/statistics/gpm-statistics.ui");
+
+	/* add history graph */
+	box = GTK_BOX (gtk_builder_get_object (builder, "hbox_history"));
+	graph_history = gpm_graph_widget_new ();
+	gtk_box_pack_start (box, graph_history, TRUE, TRUE, 0);
+	gtk_widget_set_size_request (graph_history, 400, 250);
+	gtk_widget_show (graph_history);
+
+	/* add statistics graph */
+	box = GTK_BOX (gtk_builder_get_object (builder, "hbox_statistics"));
+	graph_statistics = gpm_graph_widget_new ();
+	gtk_box_pack_start (box, graph_statistics, TRUE, TRUE, 0);
+	gtk_widget_set_size_request (graph_statistics, 400, 250);
+	gtk_widget_show (graph_statistics);
+
+	window = GTK_WIDGET (gtk_builder_get_object (builder, "dialog_stats"));
+	gtk_window_set_default_size (GTK_WINDOW(window), 800, 500);
+	gtk_window_set_default_icon_name (GPM_ICON_APP_ICON);
+
+	/* Get the main window quit */
+	widget = GTK_WIDGET (gtk_builder_get_object (builder, "button_close"));
+	g_signal_connect_swapped (window, "delete_event", G_CALLBACK (gtk_widget_destroy), window);
+	g_signal_connect_swapped (widget, "clicked", G_CALLBACK (gtk_widget_destroy), window);
+	gtk_widget_grab_default (widget);
+
+	widget = GTK_WIDGET (gtk_builder_get_object (builder, "button_help"));
+	g_signal_connect (widget, "clicked",
+			  G_CALLBACK (gpm_stats_button_help_cb), NULL);
+
+	widget = GTK_WIDGET (gtk_builder_get_object (builder, "checkbutton_smooth_history"));
+	checked = g_settings_get_boolean (settings, GPM_SETTINGS_INFO_HISTORY_GRAPH_SMOOTH);
+	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), checked);
+	g_signal_connect (widget, "clicked",
+			  G_CALLBACK (gpm_stats_smooth_checkbox_history_cb), NULL);
+
+	widget = GTK_WIDGET (gtk_builder_get_object (builder, "checkbutton_smooth_stats"));
+	checked = g_settings_get_boolean (settings, GPM_SETTINGS_INFO_STATS_GRAPH_SMOOTH);
+	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), checked);
+	g_signal_connect (widget, "clicked",
+			  G_CALLBACK (gpm_stats_smooth_checkbox_stats_cb), NULL);
+
+	widget = GTK_WIDGET (gtk_builder_get_object (builder, "checkbutton_points_history"));
+	checked = g_settings_get_boolean (settings, GPM_SETTINGS_INFO_HISTORY_GRAPH_POINTS);
+	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), checked);
+	g_signal_connect (widget, "clicked",
+			  G_CALLBACK (gpm_stats_points_checkbox_history_cb), NULL);
+
+	widget = GTK_WIDGET (gtk_builder_get_object (builder, "checkbutton_points_stats"));
+	checked = g_settings_get_boolean (settings, GPM_SETTINGS_INFO_STATS_GRAPH_POINTS);
+	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), checked);
+	g_signal_connect (widget, "clicked",
+			  G_CALLBACK (gpm_stats_points_checkbox_stats_cb), NULL);
+
+	widget = GTK_WIDGET (gtk_builder_get_object (builder, "notebook1"));
+
+	gtk_widget_add_events (widget, GDK_SCROLL_MASK);
+	g_signal_connect (widget,
+	                  "scroll-event",
+	                  G_CALLBACK (gpm_notebook_scroll_event_cb),
+	                  NULL);
+
+	page = g_settings_get_int (settings, GPM_SETTINGS_INFO_PAGE_NUMBER);
+	gtk_notebook_set_current_page (GTK_NOTEBOOK (widget), page);
+	g_signal_connect (widget, "switch-page",
+			  G_CALLBACK (gpm_stats_notebook_changed_cb), NULL);
+
+	/* create list stores */
+	list_store_info = gtk_list_store_new (GPM_INFO_COLUMN_LAST, G_TYPE_STRING, G_TYPE_STRING);
+	list_store_devices = gtk_list_store_new (GPM_DEVICES_COLUMN_LAST, G_TYPE_STRING,
+						 G_TYPE_STRING, G_TYPE_STRING);
+
+	/* create transaction_id tree view */
+	widget = GTK_WIDGET (gtk_builder_get_object (builder, "treeview_info"));
+	gtk_tree_view_set_model (GTK_TREE_VIEW (widget),
+				 GTK_TREE_MODEL (list_store_info));
+
+	/* add columns to the tree view */
+	gpm_stats_add_info_columns (GTK_TREE_VIEW (widget));
+	gtk_tree_view_columns_autosize (GTK_TREE_VIEW (widget)); /* show */
+
+	/* create transaction_id tree view */
+	widget = GTK_WIDGET (gtk_builder_get_object (builder, "treeview_devices"));
+	gtk_tree_view_set_model (GTK_TREE_VIEW (widget),
+				 GTK_TREE_MODEL (list_store_devices));
+	selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (widget));
+	g_signal_connect (selection, "changed",
+			  G_CALLBACK (gpm_stats_devices_treeview_clicked_cb), NULL);
+
+	/* add columns to the tree view */
+	gpm_stats_add_devices_columns (GTK_TREE_VIEW (widget));
+	gtk_tree_view_columns_autosize (GTK_TREE_VIEW (widget)); /* show */
+
+	history_type_str = g_settings_get_string (settings, GPM_SETTINGS_INFO_HISTORY_TYPE);
+	if ((history_type_str == NULL) || (strcmp (history_type_str, GPM_HISTORY_CHARGE_VALUE) == 0)) {
+		history_type = GPM_HISTORY_CHARGE_TYPE;
+	} else if (strcmp (history_type_str, GPM_HISTORY_RATE_VALUE) == 0) {
+		history_type = GPM_HISTORY_RATE_TYPE;
+	} else if (strcmp (history_type_str, GPM_HISTORY_TIME_FULL_VALUE) == 0) {
+		history_type = GPM_HISTORY_TIME_FULL_TYPE;
+	} else if (strcmp (history_type_str, GPM_HISTORY_TIME_EMPTY_VALUE) == 0) {
+		history_type = GPM_HISTORY_TIME_EMPTY_TYPE;
+	} else if (strcmp (history_type_str, GPM_HISTORY_POWER_VALUE) == 0) {
+		history_type = GPM_HISTORY_POWER_TYPE;
+	} else {
+		history_type = GPM_HISTORY_CHARGE_TYPE;
+	}
+	g_free (history_type_str);
+
+	history_time = g_settings_get_int (settings, GPM_SETTINGS_INFO_HISTORY_TIME);
+	if (history_time == 0)
+		history_time = GPM_HISTORY_HOUR_VALUE;
+
+	stats_type_str = g_settings_get_string (settings, GPM_SETTINGS_INFO_STATS_TYPE);
+	if ((stats_type_str == NULL) || (strcmp (stats_type_str, GPM_STATS_CHARGE_DATA_VALUE) == 0)) {
+		stats_type = GPM_STATS_CHARGE_TYPE;
+	} else if (strcmp (stats_type_str, GPM_STATS_DISCHARGE_DATA_VALUE) == 0) {
+		stats_type = GPM_STATS_DISCHARGE_TYPE;
+	} else if (strcmp (stats_type_str, GPM_STATS_CHARGE_ACCURACY_VALUE) == 0) {
+		stats_type = GPM_STATS_CHARGE_ACCURACY_TYPE;
+	} else if (strcmp (stats_type_str, GPM_STATS_DISCHARGE_ACCURACY_VALUE) == 0) {
+		stats_type = GPM_STATS_DISCHARGE_ACCURACY_TYPE;
+	} else {
+		stats_type = GPM_STATS_CHARGE_TYPE;
+	}
+	g_free (stats_type_str);
+
+	widget = GTK_WIDGET (gtk_builder_get_object (builder, "combobox_history_type"));
+	for (i = 0; i < GPM_HISTORY_LAST_TYPE - 1; i++)
+		gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), history_text[i]);
+	if (history_type == GPM_HISTORY_RATE_TYPE)
+		gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0);
+	else
+		gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 1);
+	g_signal_connect (G_OBJECT (widget), "changed",
+			  G_CALLBACK (gpm_stats_history_type_combo_changed_cb), NULL);
+
+	widget = GTK_WIDGET (gtk_builder_get_object (builder, "combobox_stats_type"));
+	for (i = 0; i < GPM_STATS_LAST_TYPE; i++)
+		gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), stats_text[i]);
+	if (stats_type == GPM_STATS_CHARGE_TYPE)
+		gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0);
+	else if (stats_type == GPM_STATS_CHARGE_TYPE)<--- Condition 'stats_type==GPM_STATS_CHARGE_TYPE' is always false
+		gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 1);
+	else if (stats_type == GPM_STATS_CHARGE_TYPE)<--- Condition 'stats_type==GPM_STATS_CHARGE_TYPE' is always false
+		gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 2);
+	else if (stats_type == GPM_STATS_CHARGE_TYPE)<--- Condition 'stats_type==GPM_STATS_CHARGE_TYPE' is always false
+		gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0);
+	else
+		gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 3);
+	g_signal_connect (G_OBJECT (widget), "changed",
+			  G_CALLBACK (gpm_stats_type_combo_changed_cb), NULL);
+
+	widget = GTK_WIDGET (gtk_builder_get_object (builder, "combobox_history_time"));
+	gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), GPM_HISTORY_MINUTE_TEXT);
+	gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), GPM_HISTORY_HOUR_TEXT);
+	gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), GPM_HISTORY_HOURS_TEXT);
+	gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), GPM_HISTORY_DAY_TEXT);
+	gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), GPM_HISTORY_WEEK_TEXT);
+	gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 1);
+	if (history_time == GPM_HISTORY_MINUTE_VALUE)
+		gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0);
+	else if (history_time == GPM_HISTORY_HOUR_VALUE)
+		gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 1);
+	else
+		gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 2);
+	g_signal_connect (G_OBJECT (widget), "changed",
+			  G_CALLBACK (gpm_stats_range_combo_changed), NULL);
+
+	client = up_client_new ();
+
+	devices = up_client_get_devices2 (client);
+
+	/* add devices in visually pleasing order */
+	for (j=0; j<UP_DEVICE_KIND_LAST; j++) {
+		for (i=0; i < devices->len; i++) {
+			device = g_ptr_array_index (devices, i);
+			g_object_get (device, "kind", &kind, NULL);
+			if (kind == j)
+				/* NULL == do not add it to ptr array */
+				gpm_stats_add_device (device, NULL);
+		}
+	}
+
+	/* connect now the coldplug is done */
+	g_signal_connect (client, "device-added", G_CALLBACK (gpm_stats_device_added_cb), devices);
+	g_signal_connect (client, "device-removed", G_CALLBACK (gpm_stats_device_removed_cb), devices);
+
+	/* set current device */
+	if (devices->len > 0) {
+		device = g_ptr_array_index (devices, 0);
+		gpm_stats_update_info_data (device);
+		current_device = g_strdup (up_device_get_object_path (device));
+	}
+
+	if (last_device == NULL)
+		last_device = g_settings_get_string (settings, GPM_SETTINGS_INFO_LAST_DEVICE);
+
+	/* set the correct focus on the last device */
+	if (last_device != NULL)
+		gpm_stats_highlight_device (last_device);
+
+	/* set axis */
+	widget = GTK_WIDGET (gtk_builder_get_object (builder, "combobox_history_type"));
+	gpm_stats_history_type_combo_changed_cb (widget, NULL);
+	widget = GTK_WIDGET (gtk_builder_get_object (builder, "combobox_stats_type"));
+	gpm_stats_type_combo_changed_cb (widget, NULL);
+
+	widget = GTK_WIDGET (gtk_builder_get_object (builder, "dialog_stats"));
+
+	status = g_application_run (G_APPLICATION (app), argc, argv);
+	if (devices != NULL)
+		g_ptr_array_unref (devices);
+
+	g_object_unref (settings);
+	g_object_unref (client);
+	g_object_unref (builder);
+	g_object_unref (list_store_info);
+	g_object_unref (app);
+	g_free (last_device);
+	return status;
+}
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/108.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/108.html new file mode 100644 index 0000000..5e6de12 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/108.html @@ -0,0 +1,1345 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2005 William Jon McCann <mccann@jhu.edu>
+ * Copyright (C) 2005-2009 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+
+#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <time.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <errno.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/time.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/types.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#ifdef HAVE_UNISTD_H
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif /* HAVE_UNISTD_H */
+
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <libupower-glib/upower.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <libmate-desktop/mate-image-menu-item.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "gpm-upower.h"
+#include "gpm-engine.h"
+#include "gpm-common.h"
+#include "gpm-icon-names.h"
+#include "gpm-tray-icon.h"
+
+static void     gpm_tray_icon_finalize   (GObject	   *object);
+
+struct GpmTrayIconPrivate
+{
+	GSettings		*settings;
+	GpmEngine		*engine;
+	GtkStatusIcon		*status_icon;
+	gboolean		 show_actions;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (GpmTrayIcon, gpm_tray_icon, G_TYPE_OBJECT)<--- There is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
+
+/**
+ * gpm_tray_icon_enable_actions:
+ **/
+static void
+gpm_tray_icon_enable_actions (GpmTrayIcon *icon, gboolean enabled)
+{
+	g_return_if_fail (GPM_IS_TRAY_ICON (icon));
+	icon->priv->show_actions = enabled;
+}
+
+/**
+ * gpm_tray_icon_show:
+ * @enabled: If we should show the tray
+ **/
+static void
+gpm_tray_icon_show (GpmTrayIcon *icon, gboolean enabled)
+{
+	g_return_if_fail (GPM_IS_TRAY_ICON (icon));
+	gtk_status_icon_set_visible (icon->priv->status_icon, enabled);
+}
+
+/**
+ * gpm_tray_icon_set_tooltip:
+ * @tooltip: The tooltip text, e.g. "Batteries charged"
+ **/
+gboolean
+gpm_tray_icon_set_tooltip (GpmTrayIcon *icon, const gchar *tooltip)
+{
+	g_return_val_if_fail (icon != NULL, FALSE);
+	g_return_val_if_fail (GPM_IS_TRAY_ICON (icon), FALSE);
+	g_return_val_if_fail (tooltip != NULL, FALSE);
+
+	gtk_status_icon_set_tooltip_text (icon->priv->status_icon, tooltip);
+
+	return TRUE;
+}
+
+/**
+ * gpm_tray_icon_get_status_icon:
+ **/
+GtkStatusIcon *
+gpm_tray_icon_get_status_icon (GpmTrayIcon *icon)
+{
+	g_return_val_if_fail (GPM_IS_TRAY_ICON (icon), NULL);
+	return g_object_ref (icon->priv->status_icon);
+}
+
+/**
+ * gpm_tray_icon_set_icon:
+ * @icon_name: The icon name, e.g. GPM_ICON_APP_ICON, or NULL to remove.
+ *
+ * Loads a pixmap from disk, and sets as the tooltip icon.
+ **/
+gboolean
+gpm_tray_icon_set_icon (GpmTrayIcon *icon, const gchar *icon_name)
+{
+	g_return_val_if_fail (icon != NULL, FALSE);
+	g_return_val_if_fail (GPM_IS_TRAY_ICON (icon), FALSE);
+
+	if (icon_name != NULL) {
+		g_debug ("Setting icon to %s", icon_name);
+		gtk_status_icon_set_from_icon_name (icon->priv->status_icon,
+		                                    icon_name);
+
+		/* make sure that we are visible */
+		gpm_tray_icon_show (icon, TRUE);
+	} else {
+		/* remove icon */
+		g_debug ("no icon will be displayed");
+
+		/* make sure that we are hidden */
+		gpm_tray_icon_show (icon, FALSE);
+	}
+	return TRUE;
+}
+
+/**
+ * gpm_tray_icon_show_info_cb:
+ **/
+static void
+gpm_tray_icon_show_info_cb (GtkMenuItem *item, gpointer data)
+{
+	gchar *path;
+	const gchar *object_path;
+
+	object_path = g_object_get_data (G_OBJECT (item), "object-path");
+	path = g_strdup_printf ("%s/mate-power-statistics --device %s", BINDIR, object_path);
+	if (!g_spawn_command_line_async (path, NULL))
+		g_warning ("Couldn't execute command: %s", path);
+	g_free (path);
+}
+
+/**
+ * gpm_tray_icon_show_preferences_cb:
+ * @action: A valid GtkAction
+ **/
+static void
+gpm_tray_icon_show_preferences_cb (GtkMenuItem *item, gpointer data)
+{
+	const gchar *command = "mate-power-preferences";
+
+	if (g_spawn_command_line_async (command, NULL) == FALSE)
+		g_warning ("Couldn't execute command: %s", command);
+}
+
+#define ABOUT_GROUP "About"
+#define EMAILIFY(string) (g_strdelimit ((string), "%", '@'))
+
+/**
+ * gpm_tray_icon_show_about_cb:
+ * @action: A valid GtkAction
+ **/
+static void
+gpm_tray_icon_show_about_cb (GtkMenuItem *item, gpointer data)
+{
+	GKeyFile *key_file;
+	GBytes *bytes;
+	const guint8 *data_resource;
+	gsize data_resource_len;
+	GError *error = NULL;
+	char **authors;
+	gsize n_authors = 0, i;
+
+	bytes = g_resources_lookup_data ("/org/mate/powermanager/manager/mate-power-manager.about",
+	                                 G_RESOURCE_LOOKUP_FLAGS_NONE, &error);
+	g_assert_no_error (error);
+
+	data_resource = g_bytes_get_data (bytes, &data_resource_len);
+	key_file = g_key_file_new ();
+	g_key_file_load_from_data (key_file, (const char *) data_resource, data_resource_len, 0, &error);
+	g_assert_no_error (error);
+
+	authors = g_key_file_get_string_list (key_file, ABOUT_GROUP, "Authors", &n_authors, NULL);
+
+	g_key_file_free (key_file);
+	g_bytes_unref (bytes);
+
+	for (i = 0; i < n_authors; ++i)
+		authors[i] = EMAILIFY (authors[i]);
+
+	gtk_show_about_dialog (NULL,
+				"program-name", _("Power Manager"),
+				"version", VERSION,
+				"comments", _("Power management daemon"),
+				"copyright", _("Copyright \xC2\xA9 2011-2021 MATE developers"),
+				"authors", authors,
+				/* Translators should localize the following string
+				* which will be displayed at the bottom of the about
+				* box to give credit to the translator(s).
+				*/
+				"translator-credits", _("translator-credits"),
+				"icon-name", "mate-power-manager",
+				"logo-icon-name", "mate-power-manager",
+				"website", PACKAGE_URL,
+				NULL);
+
+	g_strfreev (authors);
+}
+
+/**
+ * gpm_tray_icon_class_init:
+ **/
+static void
+gpm_tray_icon_class_init (GpmTrayIconClass *klass)
+{
+	GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+	object_class->finalize = gpm_tray_icon_finalize;
+}
+
+/**
+ * gpm_tray_icon_add_device:
+ **/
+static guint
+gpm_tray_icon_add_device (GpmTrayIcon *icon, GtkMenu *menu, const GPtrArray *array, UpDeviceKind kind)
+{
+	guint i;
+	guint added = 0;
+	gchar *icon_name;
+	gchar *label, *vendor, *model;
+	GtkWidget *item;
+	GtkWidget *image;
+	const gchar *object_path;
+	UpDevice *device;
+	UpDeviceKind kind_tmp;
+	gdouble percentage;
+
+	/* find type */
+	for (i=0;i<array->len;i++) {
+		device = g_ptr_array_index (array, i);
+
+		/* get device properties */
+		g_object_get (device,
+			      "kind", &kind_tmp,
+			      "percentage", &percentage,
+			      "vendor", &vendor,
+			      "model", &model,
+			      NULL);
+
+		if (kind != kind_tmp)
+			continue;
+
+		object_path = up_device_get_object_path (device);
+		g_debug ("adding device %s", object_path);
+		added++;
+
+		/* generate the label */
+		if ((vendor != NULL && strlen(vendor) != 0) && (model != NULL && strlen(model) != 0)) {
+			label = g_strdup_printf ("%s %s (%.1f%%)", vendor, model, percentage);
+		}
+		else if((vendor == NULL || strlen(vendor) == 0) && (model != NULL && strlen(model) != 0)) {
+			label = g_strdup_printf ("%s (%.1f%%)", model, percentage);
+		}
+		else {
+			label = g_strdup_printf ("%s (%.1f%%)", gpm_device_kind_to_localised_string (kind, 1), percentage);
+		}
+		item = mate_image_menu_item_new_with_label (label);
+
+		/* generate the image */
+		icon_name = gpm_upower_get_device_icon (device);
+		image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU);
+		mate_image_menu_item_set_image (MATE_IMAGE_MENU_ITEM (item), image);
+
+		/* set callback and add the menu */
+		g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (gpm_tray_icon_show_info_cb), icon);
+		g_object_set_data (G_OBJECT (item), "object-path", (gpointer) object_path);
+		gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+
+		g_free (icon_name);
+		g_free (label);
+		g_free (vendor);
+		g_free (model);
+	}
+	return added;
+}
+
+/**
+ * gpm_tray_icon_add_primary_device:
+ **/
+static void
+gpm_tray_icon_add_primary_device (GpmTrayIcon *icon, GtkMenu *menu, UpDevice *device)
+{
+	GtkWidget *item;
+	gchar *time_str;
+	gchar *string;
+	gint64 time_to_empty = 0;
+
+	/* get details */
+	g_object_get (device,
+		      "time-to-empty", &time_to_empty,
+		      NULL);
+
+	/* convert time to string */
+	time_str = gpm_get_timestring (time_to_empty);
+
+	/* TRANSLATORS: % is a timestring, e.g. "6 hours 10 minutes" */
+	string = g_strdup_printf (_("%s remaining"), time_str);
+	item = mate_image_menu_item_new_with_label (string);
+	gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+	g_free (time_str);
+	g_free (string);
+}
+
+/**
+ * gpm_tray_icon_create_menu:
+ *
+ * Create the popup menu.
+ **/
+static GtkMenu *
+gpm_tray_icon_create_menu (GpmTrayIcon *icon)
+{
+	GtkMenu *menu = (GtkMenu*) gtk_menu_new ();
+	GtkWidget *item;
+	GtkWidget *image;
+	guint dev_cnt = 0;
+	GPtrArray *array;
+	UpDevice *device = NULL;
+	GtkStyleContext *context;
+	GtkWidget       *toplevel;
+	GdkScreen       *screen;
+	GdkVisual       *visual;
+
+	/* show the primary device time remaining */
+	device = gpm_engine_get_primary_device (icon->priv->engine);
+	if (device != NULL) {
+		gpm_tray_icon_add_primary_device (icon, menu, device);
+		item = gtk_separator_menu_item_new ();
+		gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+	}
+
+	/* add all device types to the drop down menu */
+	array = gpm_engine_get_devices (icon->priv->engine);
+	dev_cnt += gpm_tray_icon_add_device (icon, menu, array, UP_DEVICE_KIND_BATTERY);
+	dev_cnt += gpm_tray_icon_add_device (icon, menu, array, UP_DEVICE_KIND_UPS);
+	dev_cnt += gpm_tray_icon_add_device (icon, menu, array, UP_DEVICE_KIND_MOUSE);
+	dev_cnt += gpm_tray_icon_add_device (icon, menu, array, UP_DEVICE_KIND_KEYBOARD);
+	dev_cnt += gpm_tray_icon_add_device (icon, menu, array, UP_DEVICE_KIND_PDA);
+	dev_cnt += gpm_tray_icon_add_device (icon, menu, array, UP_DEVICE_KIND_PHONE);
+	dev_cnt += gpm_tray_icon_add_device (icon, menu, array, UP_DEVICE_KIND_MEDIA_PLAYER);
+	dev_cnt += gpm_tray_icon_add_device (icon, menu, array, UP_DEVICE_KIND_TABLET);
+	dev_cnt += gpm_tray_icon_add_device (icon, menu, array, UP_DEVICE_KIND_COMPUTER);
+	dev_cnt += gpm_tray_icon_add_device (icon, menu, array, UP_DEVICE_KIND_GAMING_INPUT);
+	g_ptr_array_unref (array);
+
+	/* skip for things like live-cd's and GDM */
+	if (!icon->priv->show_actions)
+		goto skip_prefs;
+
+	/* only do the separator if we have at least one device */
+	if (dev_cnt != 0) {
+		item = gtk_separator_menu_item_new ();
+		gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+	}
+
+	/* preferences */
+	item = mate_image_menu_item_new_with_mnemonic (_("_Preferences"));
+	image = gtk_image_new_from_icon_name ("preferences-system", GTK_ICON_SIZE_MENU);
+	mate_image_menu_item_set_image (MATE_IMAGE_MENU_ITEM (item), image);
+	g_signal_connect (G_OBJECT (item), "activate",
+			  G_CALLBACK (gpm_tray_icon_show_preferences_cb), icon);
+	gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+
+	/*Set up custom panel menu theme support-gtk3 only */
+	toplevel = gtk_widget_get_toplevel (GTK_WIDGET (menu));
+	/* Fix any failures of compiz/other wm's to communicate with gtk for transparency in menu theme */
+	screen = gtk_widget_get_screen(GTK_WIDGET(toplevel));
+	visual = gdk_screen_get_rgba_visual(screen);
+	gtk_widget_set_visual(GTK_WIDGET(toplevel), visual);
+	/* Set menu and its toplevel window to follow panel theme */
+	context = gtk_widget_get_style_context (GTK_WIDGET(toplevel));
+	gtk_style_context_add_class(context,"gnome-panel-menu-bar");
+	gtk_style_context_add_class(context,"mate-panel-menu-bar");
+
+	/* about */
+	item = mate_image_menu_item_new_with_mnemonic (_("_About"));
+	image = gtk_image_new_from_icon_name ("help-about", GTK_ICON_SIZE_MENU);
+	mate_image_menu_item_set_image (MATE_IMAGE_MENU_ITEM (item), image);
+	g_signal_connect (G_OBJECT (item), "activate",
+			  G_CALLBACK (gpm_tray_icon_show_about_cb), icon);
+	gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+
+skip_prefs:
+	if (device != NULL)
+		g_object_unref (device);
+	return menu;
+}
+
+/**
+ * gpm_tray_icon_popup_cleared_cd:
+ * @widget: The popup Gtkwidget
+ *
+ * We have to re-enable the tooltip when the popup is removed
+ **/
+static void
+gpm_tray_icon_popup_cleared_cd (GtkWidget *widget, GpmTrayIcon *icon)
+{
+	g_return_if_fail (GPM_IS_TRAY_ICON (icon));
+	g_debug ("clear tray");
+	g_object_ref_sink (widget);
+	g_object_unref (widget);
+}
+
+/**
+ * gpm_tray_icon_popup_menu:
+ *
+ * Display the popup menu.
+ **/
+static void
+gpm_tray_icon_popup_menu (GpmTrayIcon *icon, guint32 timestamp)
+{
+	GtkMenu *menu;
+
+	menu = gpm_tray_icon_create_menu (icon);
+
+	/* show the menu */
+	gtk_widget_show_all (GTK_WIDGET (menu));
+	gtk_menu_popup (GTK_MENU (menu), NULL, NULL,
+			gtk_status_icon_position_menu, icon->priv->status_icon,
+			1, timestamp);
+
+	g_signal_connect (GTK_WIDGET (menu), "hide",
+			  G_CALLBACK (gpm_tray_icon_popup_cleared_cd), icon);
+}
+
+/**
+ * gpm_tray_icon_popup_menu_cb:
+ *
+ * Display the popup menu.
+ **/
+static void
+gpm_tray_icon_popup_menu_cb (GtkStatusIcon *status_icon, guint button, guint32 timestamp, GpmTrayIcon *icon)
+{
+	g_debug ("icon right clicked");
+	gpm_tray_icon_popup_menu (icon, timestamp);
+}
+
+/**
+ * gpm_tray_icon_activate_cb:
+ * @button: Which buttons are pressed
+ *
+ * Callback when the icon is clicked
+ **/
+static void
+gpm_tray_icon_activate_cb (GtkStatusIcon *status_icon, GpmTrayIcon *icon)
+{
+	g_debug ("icon left clicked");
+	gpm_tray_icon_popup_menu (icon, gtk_get_current_event_time());
+}
+
+/**
+ * gpm_tray_icon_settings_changed_cb:
+ *
+ * We might have to do things when the settings change; do them here.
+ **/
+static void
+gpm_tray_icon_settings_changed_cb (GSettings *settings, const gchar *key, GpmTrayIcon *icon)
+{
+	gboolean allowed_in_menu;
+
+	if (g_strcmp0 (key, GPM_SETTINGS_SHOW_ACTIONS) == 0) {
+		allowed_in_menu = g_settings_get_boolean (settings, key);
+		gpm_tray_icon_enable_actions (icon, allowed_in_menu);
+	}
+}
+
+/**
+ * gpm_tray_icon_init:
+ *
+ * Initialise the tray object
+ **/
+static void
+gpm_tray_icon_init (GpmTrayIcon *icon)
+{
+	gboolean allowed_in_menu;
+
+	icon->priv = gpm_tray_icon_get_instance_private (icon);
+
+	icon->priv->engine = gpm_engine_new ();
+
+	icon->priv->settings = g_settings_new (GPM_SETTINGS_SCHEMA);
+	g_signal_connect (icon->priv->settings, "changed",
+			  G_CALLBACK (gpm_tray_icon_settings_changed_cb), icon);
+
+	icon->priv->status_icon = gtk_status_icon_new ();
+	gpm_tray_icon_show (icon, FALSE);
+	g_signal_connect_object (G_OBJECT (icon->priv->status_icon),
+				 "popup_menu",
+				 G_CALLBACK (gpm_tray_icon_popup_menu_cb),
+				 icon, 0);
+	g_signal_connect_object (G_OBJECT (icon->priv->status_icon),
+				 "activate",
+				 G_CALLBACK (gpm_tray_icon_activate_cb),
+				 icon, 0);
+
+	allowed_in_menu = g_settings_get_boolean (icon->priv->settings, GPM_SETTINGS_SHOW_ACTIONS);
+	gpm_tray_icon_enable_actions (icon, allowed_in_menu);
+}
+
+/**
+ * gpm_tray_icon_finalize:
+ * @object: This TrayIcon class instance
+ **/
+static void
+gpm_tray_icon_finalize (GObject *object)
+{
+	GpmTrayIcon *tray_icon;
+
+	g_return_if_fail (object != NULL);
+	g_return_if_fail (GPM_IS_TRAY_ICON (object));
+
+	tray_icon = GPM_TRAY_ICON (object);
+
+	g_object_unref (tray_icon->priv->status_icon);
+	g_object_unref (tray_icon->priv->engine);
+	g_return_if_fail (tray_icon->priv != NULL);
+
+	G_OBJECT_CLASS (gpm_tray_icon_parent_class)->finalize (object);
+}
+
+/**
+ * gpm_tray_icon_new:
+ * Return value: A new TrayIcon object.
+ **/
+GpmTrayIcon *
+gpm_tray_icon_new (void)
+{
+	GpmTrayIcon *tray_icon;
+	tray_icon = g_object_new (GPM_TYPE_TRAY_ICON, NULL);
+	return GPM_TRAY_ICON (tray_icon);
+}
+
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/109.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/109.html new file mode 100644 index 0000000..8ad67d0 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/109.html @@ -0,0 +1,1591 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
+603
+604
+605
+606
+607
+608
+609
+610
+611
+612
+613
+614
+615
+616
+617
+618
+619
+620
+621
+622
+623
+624
+625
+626
+627
+628
+629
+630
+631
+632
+633
+634
+635
+636
+637
+638
+639
+640
+641
+642
+643
+644
+645
+646
+647
+648
+649
+650
+651
+652
+653
+654
+655
+656
+657
+658
+659
+660
+661
+662
+663
+664
+665
+666
+667
+668
+669
+670
+671
+672
+673
+674
+675
+676
+677
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "config.h"<--- Include file: "config.h" not found.
+
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <libupower-glib/upower.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "egg-precision.h"
+
+#include "gpm-upower.h"
+#include "gpm-common.h"
+
+#define GPM_UP_TIME_PRECISION			5*60
+#define GPM_UP_TEXT_MIN_TIME			120
+
+/**
+ * gpm_upower_get_device_icon_index:
+ * @percent: The charge of the device
+ *
+ * The index value depends on the percentage charge:
+ *	00-10  = 000
+ *	10-30  = 020
+ *	30-50  = 040
+ *	50-70  = 060
+ *	70-90  = 080
+ *	90-100 = 100
+ *
+ * Return value: The character string for the filename suffix.
+ **/
+static const gchar *
+gpm_upower_get_device_icon_index (UpDevice *device)
+{
+	gdouble percentage;
+	/* get device properties */
+	g_object_get (device, "percentage", &percentage, NULL);
+	if (percentage < 10)
+		return "000";
+	else if (percentage < 30)
+		return "020";
+	else if (percentage < 50)
+		return "040";
+	else if (percentage < 70)
+		return "060";
+	else if (percentage < 90)
+		return "080";
+	return "100";
+}
+
+/**
+ * gpm_upower_get_device_icon:
+ *
+ * Need to free the return value
+ *
+ **/
+gchar *
+gpm_upower_get_device_icon (UpDevice *device)
+{
+	gchar *filename = NULL;
+	const gchar *prefix = NULL;
+	const gchar *index_str;
+	UpDeviceKind kind;
+	UpDeviceState state;
+	gboolean is_present;
+	gdouble percentage;
+
+	g_return_val_if_fail (device != NULL, NULL);
+
+	/* get device properties */
+	g_object_get (device,
+		      "kind", &kind,
+		      "state", &state,
+		      "percentage", &percentage,
+		      "is-present", &is_present,
+		      NULL);
+
+	/* get correct icon prefix */
+	prefix = up_device_kind_to_string (kind);
+
+	/* get the icon from some simple rules */
+	if (kind == UP_DEVICE_KIND_LINE_POWER) {
+		filename = g_strdup ("gpm-ac-adapter");
+	} else if (kind == UP_DEVICE_KIND_MONITOR) {
+		filename = g_strdup ("gpm-monitor");
+	} else if (kind == UP_DEVICE_KIND_UPS) {
+		if (!is_present) {
+			/* battery missing */
+			filename = g_strdup_printf ("gpm-%s-missing", prefix);
+
+		} else if (state == UP_DEVICE_STATE_FULLY_CHARGED) {
+			filename = g_strdup_printf ("gpm-%s-100", prefix);
+
+		} else if (state == UP_DEVICE_STATE_CHARGING) {
+			index_str = gpm_upower_get_device_icon_index (device);
+			filename = g_strdup_printf ("gpm-%s-%s-charging", prefix, index_str);
+
+		} else if (state == UP_DEVICE_STATE_DISCHARGING) {
+			index_str = gpm_upower_get_device_icon_index (device);
+			filename = g_strdup_printf ("gpm-%s-%s", prefix, index_str);
+		}
+	} else if (kind == UP_DEVICE_KIND_BATTERY) {
+		if (!is_present) {
+			/* battery missing */
+			filename = g_strdup_printf ("gpm-%s-missing", prefix);
+
+		} else if (state == UP_DEVICE_STATE_EMPTY) {
+			filename = g_strdup_printf ("gpm-%s-empty", prefix);
+
+		} else if (state == UP_DEVICE_STATE_FULLY_CHARGED) {
+			filename = g_strdup_printf ("gpm-%s-charged", prefix);
+
+		} else if (state == UP_DEVICE_STATE_CHARGING) {
+			index_str = gpm_upower_get_device_icon_index (device);
+			filename = g_strdup_printf ("gpm-%s-%s-charging", prefix, index_str);
+
+		} else if (state == UP_DEVICE_STATE_DISCHARGING) {
+			index_str = gpm_upower_get_device_icon_index (device);
+			filename = g_strdup_printf ("gpm-%s-%s", prefix, index_str);
+
+		} else if (state == UP_DEVICE_STATE_PENDING_CHARGE) {
+			index_str = gpm_upower_get_device_icon_index (device);
+			/* FIXME: do new grey icons */
+			filename = g_strdup_printf ("gpm-%s-%s-charging", prefix, index_str);
+
+		} else if (state == UP_DEVICE_STATE_PENDING_DISCHARGE) {
+			index_str = gpm_upower_get_device_icon_index (device);
+			filename = g_strdup_printf ("gpm-%s-%s", prefix, index_str);
+		} else {
+			filename = g_strdup ("gpm-battery-missing");
+		}
+
+	} else if (kind == UP_DEVICE_KIND_MOUSE ||
+		   kind == UP_DEVICE_KIND_KEYBOARD ||
+		   kind == UP_DEVICE_KIND_PHONE) {
+		if (!is_present) {
+			/* battery missing */
+			filename = g_strdup_printf ("gpm-%s-000", prefix);
+
+		} else if (state == UP_DEVICE_STATE_FULLY_CHARGED) {
+			filename = g_strdup_printf ("gpm-%s-100", prefix);
+
+		} else if (state == UP_DEVICE_STATE_DISCHARGING) {
+			index_str = gpm_upower_get_device_icon_index (device);
+			filename = g_strdup_printf ("gpm-%s-%s", prefix, index_str);
+		}
+	} else if (kind == UP_DEVICE_KIND_GAMING_INPUT) {
+		index_str = gpm_upower_get_device_icon_index (device);
+		filename = g_strdup_printf ("gpm-%s-%s", prefix, index_str);
+	}
+
+	/* nothing matched */
+	if (filename == NULL) {
+		g_warning ("nothing matched, falling back to default icon");
+		filename = g_strdup ("dialog-warning");
+	}
+
+	g_debug ("got filename: %s", filename);
+	return filename;
+}
+
+/**
+ * gpm_upower_get_device_summary:
+ **/
+gchar *
+gpm_upower_get_device_summary (UpDevice *device)
+{
+	const gchar *kind_desc = NULL;
+	gchar *description = NULL;
+	guint time_to_full_round;
+	guint time_to_empty_round;
+	gchar *time_to_full_str;
+	gchar *time_to_empty_str;
+	UpDeviceKind kind;
+	UpDeviceState state;
+	gdouble percentage;
+	gboolean is_present;
+	gint64 time_to_full;
+	gint64 time_to_empty;
+
+	/* get device properties */
+	g_object_get (device,
+		      "kind", &kind,
+		      "state", &state,
+		      "percentage", &percentage,
+		      "is-present", &is_present,
+		      "time-to-full", &time_to_full,
+		      "time-to-empty", &time_to_empty,
+		      NULL);
+
+	kind_desc = gpm_device_kind_to_localised_string (kind, 1);
+
+	/* not installed */
+	if (!is_present) {
+		/* TRANSLATORS: device not present */
+		return g_strdup_printf (_("%s not present"), kind_desc);
+	}
+
+	/* don't display all the extra stuff for keyboards and mice */
+	if (kind == UP_DEVICE_KIND_MOUSE ||
+	    kind == UP_DEVICE_KIND_KEYBOARD ||
+	    kind == UP_DEVICE_KIND_PDA)
+		return g_strdup_printf ("%s (%.1f%%)", kind_desc, percentage);
+
+	/* we care if we are on AC */
+	if (kind == UP_DEVICE_KIND_PHONE) {
+		if (state == UP_DEVICE_STATE_CHARGING || !(state == UP_DEVICE_STATE_DISCHARGING)) {
+			/* TRANSLATORS: a phone is charging */
+			return g_strdup_printf (_("%s charging (%.1f%%)"), kind_desc, percentage);
+		}
+		return g_strdup_printf ("%s (%.1f%%)", kind_desc, percentage);
+	}
+
+	/* precalculate so we don't get Unknown time remaining */
+	time_to_full_round = egg_precision_round_down (time_to_full, GPM_UP_TIME_PRECISION);
+	time_to_empty_round = egg_precision_round_down (time_to_empty, GPM_UP_TIME_PRECISION);
+
+	/* we always display "Laptop battery 16 minutes remaining" as we need to clarify what device we are refering to */
+	if (state == UP_DEVICE_STATE_FULLY_CHARGED) {
+
+		if (kind == UP_DEVICE_KIND_BATTERY && time_to_empty_round > GPM_UP_TEXT_MIN_TIME) {
+			time_to_empty_str = gpm_get_timestring (time_to_empty_round);
+			/* TRANSLATORS: The laptop battery is fully charged, and we know a time */
+			description = g_strdup_printf (_("Battery is fully charged.\nProvides %s laptop runtime"),
+							time_to_empty_str);
+			g_free (time_to_empty_str);
+		} else {
+			/* TRANSLATORS: the device is fully charged */
+			description = g_strdup_printf (_("%s is fully charged"), kind_desc);
+		}
+
+	} else if (state == UP_DEVICE_STATE_DISCHARGING) {
+
+		if (time_to_empty_round > GPM_UP_TEXT_MIN_TIME) {
+			time_to_empty_str = gpm_get_timestring (time_to_empty_round);
+			/* TRANSLATORS: the device is discharging, and we have a time remaining */
+			description = g_strdup_printf (_("%s %s remaining (%.1f%%)"),
+							kind_desc, time_to_empty_str, percentage);
+			g_free (time_to_empty_str);
+		} else {
+			/* TRANSLATORS: the device is discharging, but we only have a percentage */
+			description = g_strdup_printf (_("%s discharging (%.1f%%)"),
+							kind_desc, percentage);
+		}
+
+	} else if (state == UP_DEVICE_STATE_CHARGING) {
+
+		if (time_to_full_round > GPM_UP_TEXT_MIN_TIME &&
+		    time_to_empty_round > GPM_UP_TEXT_MIN_TIME) {
+
+			/* display both discharge and charge time */
+			time_to_full_str = gpm_get_timestring (time_to_full_round);
+			time_to_empty_str = gpm_get_timestring (time_to_empty_round);
+
+			/* TRANSLATORS: the device is charging, and we have a time to full and empty */
+			description = g_strdup_printf (_("%s %s until charged (%.1f%%)\nProvides %s battery runtime"),
+							kind_desc, time_to_full_str, percentage, time_to_empty_str);
+			g_free (time_to_full_str);
+			g_free (time_to_empty_str);
+
+		} else if (time_to_full_round > GPM_UP_TEXT_MIN_TIME) {
+
+			/* display only charge time */
+			time_to_full_str = gpm_get_timestring (time_to_full_round);
+
+			/* TRANSLATORS: device is charging, and we have a time to full and a percentage */
+			description = g_strdup_printf (_("%s %s until charged (%.1f%%)"),
+						kind_desc, time_to_full_str, percentage);
+			g_free (time_to_full_str);
+		} else {
+
+			/* TRANSLATORS: device is charging, but we only have a percentage */
+			description = g_strdup_printf (_("%s charging (%.1f%%)"),
+						kind_desc, percentage);
+		}
+
+	} else if (state == UP_DEVICE_STATE_PENDING_DISCHARGE) {
+
+		/* TRANSLATORS: this is only shown for laptops with multiple batteries */
+		description = g_strdup_printf (_("%s waiting to discharge (%.1f%%)"),
+						kind_desc, percentage);
+
+	} else if (state == UP_DEVICE_STATE_PENDING_CHARGE) {
+
+		/* TRANSLATORS: this is only shown for laptops with multiple batteries */
+		description = g_strdup_printf (_("%s waiting to charge (%.1f%%)"), kind_desc, percentage);
+
+	} else if (state == UP_DEVICE_STATE_EMPTY) {
+
+		/* TRANSLATORS: when the device has no charge left */
+		description = g_strdup_printf (_("%s empty"), kind_desc);
+
+	} else {
+		g_warning ("in an undefined state we are not charging or "
+			     "discharging and the batteries are also not charged");
+		description = g_strdup_printf ("%s (%.1f%%)", kind_desc, percentage);
+	}
+
+	return description;
+}
+
+/**
+ * gpm_upower_get_device_description:
+ **/
+gchar *
+gpm_upower_get_device_description (UpDevice *device)
+{
+	GString	*details;
+	const gchar *text;
+	gchar *time_str;
+	UpDeviceKind kind;
+	UpDeviceState state;
+	UpDeviceTechnology technology;
+	gdouble percentage;
+	gdouble capacity;
+	gdouble energy;
+	gdouble energy_full;
+	gdouble energy_full_design;
+	gdouble energy_rate;
+	gboolean is_present;
+	gint64 time_to_full;
+	gint64 time_to_empty;
+	gchar *vendor = NULL;
+	gchar *serial = NULL;
+	gchar *model = NULL;
+
+	g_return_val_if_fail (device != NULL, NULL);
+
+	/* get device properties */
+	g_object_get (device,
+		      "kind", &kind,
+		      "state", &state,
+		      "percentage", &percentage,
+		      "is-present", &is_present,
+		      "time-to-full", &time_to_full,
+		      "time-to-empty", &time_to_empty,
+		      "technology", &technology,
+		      "capacity", &capacity,
+		      "energy", &energy,
+		      "energy-full", &energy_full,
+		      "energy-full-design", &energy_full_design,
+		      "energy-rate", &energy_rate,
+		      "vendor", &vendor,
+		      "serial", &serial,
+		      "model", &model,
+		      NULL);
+
+	details = g_string_new ("");
+	text = gpm_device_kind_to_localised_string (kind, 1);
+	/* TRANSLATORS: the type of data, e.g. Laptop battery */
+	g_string_append_printf (details, "<b>%s</b> %s\n", _("Product:"), text);
+
+	if (!is_present) {
+		/* TRANSLATORS: device is missing */
+		g_string_append_printf (details, "<b>%s</b> %s\n", _("Status:"), _("Missing"));
+	} else if (state == UP_DEVICE_STATE_FULLY_CHARGED) {
+		/* TRANSLATORS: device is charged */
+		g_string_append_printf (details, "<b>%s</b> %s\n", _("Status:"), _("Charged"));
+	} else if (state == UP_DEVICE_STATE_CHARGING) {
+		/* TRANSLATORS: device is charging */
+		g_string_append_printf (details, "<b>%s</b> %s\n", _("Status:"), _("Charging"));
+	} else if (state == UP_DEVICE_STATE_DISCHARGING) {
+		/* TRANSLATORS: device is discharging */
+		g_string_append_printf (details, "<b>%s</b> %s\n", _("Status:"), _("Discharging"));
+	}
+
+	if (percentage >= 0) {
+		/* TRANSLATORS: percentage */
+		g_string_append_printf (details, "<b>%s</b> %.1f%%\n", _("Percentage charge:"), percentage);
+	}
+	if (vendor) {
+		/* TRANSLATORS: manufacturer */
+		g_string_append_printf (details, "<b>%s</b> %s\n", _("Vendor:"), vendor);
+	}
+	if (technology != UP_DEVICE_TECHNOLOGY_UNKNOWN) {
+		text = gpm_device_technology_to_localised_string (technology);
+		/* TRANSLATORS: how the battery is made, e.g. Lithium Ion */
+		g_string_append_printf (details, "<b>%s</b> %s\n", _("Technology:"), text);
+	}
+	if (serial) {
+		/* TRANSLATORS: serial number of the battery */
+		g_string_append_printf (details, "<b>%s</b> %s\n", _("Serial number:"), serial);
+	}
+	if (model) {
+		/* TRANSLATORS: model number of the battery */
+		g_string_append_printf (details, "<b>%s</b> %s\n", _("Model:"), model);
+	}
+	if (time_to_full > 0) {
+		time_str = gpm_get_timestring (time_to_full);
+		/* TRANSLATORS: time to fully charged */
+		g_string_append_printf (details, "<b>%s</b> %s\n", _("Charge time:"), time_str);
+		g_free (time_str);
+	}
+	if (time_to_empty > 0) {
+		time_str = gpm_get_timestring (time_to_empty);
+		/* TRANSLATORS: time to empty */
+		g_string_append_printf (details, "<b>%s</b> %s\n", _("Discharge time:"), time_str);
+		g_free (time_str);
+	}
+	if (capacity > 0) {
+		const gchar *condition;
+		if (capacity > 99) {
+			/* TRANSLATORS: Excellent, Good, Fair and Poor are all related to battery Capacity */
+			condition = _("Excellent");
+		} else if (capacity > 90) {
+			condition = _("Good");
+		} else if (capacity > 70) {
+			condition = _("Fair");
+		} else {
+			condition = _("Poor");
+		}
+		/* TRANSLATORS: %.1f is a percentage and %s the condition (Excellent, Good, ...) */
+		g_string_append_printf (details, "<b>%s</b> %.1f%% (%s)\n",
+					_("Capacity:"), capacity, condition);
+	}
+	if (kind == UP_DEVICE_KIND_BATTERY) {
+		if (energy > 0) {
+			/* TRANSLATORS: current charge */
+			g_string_append_printf (details, "<b>%s</b> %.1f Wh\n",
+						_("Current charge:"), energy);
+		}
+		if (energy_full > 0 &&
+		    energy_full_design != energy_full) {
+			/* TRANSLATORS: last full is the charge the battery was seen to charge to */
+			g_string_append_printf (details, "<b>%s</b> %.1f Wh\n",
+						_("Last full charge:"), energy_full);
+		}
+		if (energy_full_design > 0) {
+			/* Translators:  */
+			/* TRANSLATORS: Design charge is the amount of charge the battery is designed to have when brand new */
+			g_string_append_printf (details, "<b>%s</b> %.1f Wh\n",
+						_("Design charge:"), energy_full_design);
+		}
+		if (energy_rate > 0) {
+			/* TRANSLATORS: the charge or discharge rate */
+			g_string_append_printf (details, "<b>%s</b> %.1f W\n",
+						_("Charge rate:"), energy_rate);
+		}
+	}
+	if (kind == UP_DEVICE_KIND_MOUSE ||
+	    kind == UP_DEVICE_KIND_KEYBOARD) {
+		if (energy > 0) {
+			/* TRANSLATORS: the current charge for CSR devices */
+			g_string_append_printf (details, "<b>%s</b> %.0f/7\n",
+						_("Current charge:"), energy);
+		}
+		if (energy_full_design > 0) {
+			/* TRANSLATORS: the design charge for CSR devices */
+			g_string_append_printf (details, "<b>%s</b> %.0f/7\n",
+						_("Design charge:"), energy_full_design);
+		}
+	}
+	/* remove the last \n */
+	g_string_truncate (details, details->len-1);
+
+	g_free (vendor);
+	g_free (serial);
+	g_free (model);
+	return g_string_free (details, FALSE);
+}
+
+/**
+ * gpm_device_kind_to_localised_string:
+ **/
+const gchar *
+gpm_device_kind_to_localised_string (UpDeviceKind kind, guint number)
+{
+	const gchar *text = NULL;
+	switch (kind) {
+	case UP_DEVICE_KIND_LINE_POWER:
+		/* TRANSLATORS: system power cord */
+		text = ngettext ("AC adapter", "AC adapters", number);
+		break;
+	case UP_DEVICE_KIND_BATTERY:
+		/* TRANSLATORS: laptop primary battery */
+		text = ngettext ("Laptop battery", "Laptop batteries", number);
+		break;
+	case UP_DEVICE_KIND_UPS:
+		/* TRANSLATORS: battery-backed AC power source */
+		text = ngettext ("UPS", "UPSs", number);
+		break;
+	case UP_DEVICE_KIND_MONITOR:
+		/* TRANSLATORS: a monitor is a device to measure voltage and current */
+		text = ngettext ("Monitor", "Monitors", number);
+		break;
+	case UP_DEVICE_KIND_MOUSE:
+		/* TRANSLATORS: wireless mice with internal batteries */
+		text = ngettext ("Mouse", "Mice", number);
+		break;
+	case UP_DEVICE_KIND_KEYBOARD:
+		/* TRANSLATORS: wireless keyboard with internal battery */
+		text = ngettext ("Keyboard", "Keyboards", number);
+		break;
+	case UP_DEVICE_KIND_PDA:
+		/* TRANSLATORS: portable device */
+		text = ngettext ("PDA", "PDAs", number);
+		break;
+	case UP_DEVICE_KIND_PHONE:
+		/* TRANSLATORS: cell phone (mobile...) */
+		text = ngettext ("Cell phone", "Cell phones", number);
+		break;
+	case UP_DEVICE_KIND_MEDIA_PLAYER:
+		/* TRANSLATORS: media player, mp3 etc */
+		text = ngettext ("Media player", "Media players", number);
+		break;
+	case UP_DEVICE_KIND_TABLET:
+		/* TRANSLATORS: tablet device */
+		text = ngettext ("Tablet", "Tablets", number);
+		break;
+	case UP_DEVICE_KIND_COMPUTER:
+		/* TRANSLATORS: tablet device */
+		text = ngettext ("Computer", "Computers", number);
+		break;
+	case UP_DEVICE_KIND_GAMING_INPUT:
+		/* TRANSLATORS: wireless gamepad, joystick etc */
+		text = ngettext ("Gaming input", "Gaming inputs", number);
+		break;
+	default:
+		g_warning ("enum unrecognised: %u", kind);
+		text = up_device_kind_to_string (kind);
+	}
+	return text;
+}
+
+/**
+ * gpm_device_kind_to_icon:
+ **/
+const gchar *
+gpm_device_kind_to_icon (UpDeviceKind kind)
+{
+	const gchar *icon = NULL;
+	switch (kind) {
+	case UP_DEVICE_KIND_LINE_POWER:
+		icon = "gpm-ac-adapter";
+		break;
+	case UP_DEVICE_KIND_BATTERY:
+		icon = "battery";
+		break;
+	case UP_DEVICE_KIND_UPS:
+		icon = "network-wired";
+		break;
+	case UP_DEVICE_KIND_MONITOR:
+		icon = "application-certificate";
+		break;
+	case UP_DEVICE_KIND_MOUSE:
+		icon = "input-mouse";
+		break;
+	case UP_DEVICE_KIND_KEYBOARD:
+		icon = "input-keyboard";
+		break;
+	case UP_DEVICE_KIND_PDA:
+		icon = "pda";
+		break;
+	case UP_DEVICE_KIND_PHONE:
+		icon = "phone";
+		break;
+	case UP_DEVICE_KIND_MEDIA_PLAYER:
+		icon = "multimedia-player";
+		break;
+	case UP_DEVICE_KIND_TABLET:
+		icon = "input-tablet";
+		break;
+	case UP_DEVICE_KIND_COMPUTER:
+		icon = "computer-apple-ipad";
+		break;
+	default:
+		g_warning ("enum unrecognised: %u", kind);
+		icon = "gtk-help";
+	}
+	return icon;
+}
+
+/**
+ * gpm_device_technology_to_localised_string:
+ **/
+const gchar *
+gpm_device_technology_to_localised_string (UpDeviceTechnology technology_enum)
+{
+	const gchar *technology = NULL;
+	switch (technology_enum) {
+	case UP_DEVICE_TECHNOLOGY_LITHIUM_ION:
+		/* TRANSLATORS: battery technology */
+		technology = _("Lithium Ion");
+		break;
+	case UP_DEVICE_TECHNOLOGY_LITHIUM_POLYMER:
+		/* TRANSLATORS: battery technology */
+		technology = _("Lithium Polymer");
+		break;
+	case UP_DEVICE_TECHNOLOGY_LITHIUM_IRON_PHOSPHATE:
+		/* TRANSLATORS: battery technology */
+		technology = _("Lithium Iron Phosphate");
+		break;
+	case UP_DEVICE_TECHNOLOGY_LEAD_ACID:
+		/* TRANSLATORS: battery technology */
+		technology = _("Lead acid");
+		break;
+	case UP_DEVICE_TECHNOLOGY_NICKEL_CADMIUM:
+		/* TRANSLATORS: battery technology */
+		technology = _("Nickel Cadmium");
+		break;
+	case UP_DEVICE_TECHNOLOGY_NICKEL_METAL_HYDRIDE:
+		/* TRANSLATORS: battery technology */
+		technology = _("Nickel metal hydride");
+		break;
+	case UP_DEVICE_TECHNOLOGY_UNKNOWN:
+		/* TRANSLATORS: battery technology */
+		technology = _("Unknown technology");
+		break;
+	default:
+		g_assert_not_reached ();
+		break;
+	}
+	return technology;
+}
+
+/**
+ * gpm_device_state_to_localised_string:
+ **/
+const gchar *
+gpm_device_state_to_localised_string (UpDeviceState state)
+{
+	const gchar *state_string = NULL;
+
+	switch (state) {
+	case UP_DEVICE_STATE_CHARGING:
+		/* TRANSLATORS: battery state */
+		state_string = _("Charging");
+		break;
+	case UP_DEVICE_STATE_DISCHARGING:
+		/* TRANSLATORS: battery state */
+		state_string = _("Discharging");
+		break;
+	case UP_DEVICE_STATE_EMPTY:
+		/* TRANSLATORS: battery state */
+		state_string = _("Empty");
+		break;
+	case UP_DEVICE_STATE_FULLY_CHARGED:
+		/* TRANSLATORS: battery state */
+		state_string = _("Charged");
+		break;
+	case UP_DEVICE_STATE_PENDING_CHARGE:
+		/* TRANSLATORS: battery state */
+		state_string = _("Waiting to charge");
+		break;
+	case UP_DEVICE_STATE_PENDING_DISCHARGE:
+		/* TRANSLATORS: battery state */
+		state_string = _("Waiting to discharge");
+		break;
+	case UP_DEVICE_STATE_UNKNOWN:
+		/* TRANSLATORS: battery state */
+		state_string = _("Unknown state");
+		break;
+	default:
+		g_assert_not_reached ();
+		break;
+	}
+	return state_string;
+}
+
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/11.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/11.html new file mode 100644 index 0000000..4113cb0 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/11.html @@ -0,0 +1,2025 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
+603
+604
+605
+606
+607
+608
+609
+610
+611
+612
+613
+614
+615
+616
+617
+618
+619
+620
+621
+622
+623
+624
+625
+626
+627
+628
+629
+630
+631
+632
+633
+634
+635
+636
+637
+638
+639
+640
+641
+642
+643
+644
+645
+646
+647
+648
+649
+650
+651
+652
+653
+654
+655
+656
+657
+658
+659
+660
+661
+662
+663
+664
+665
+666
+667
+668
+669
+670
+671
+672
+673
+674
+675
+676
+677
+678
+679
+680
+681
+682
+683
+684
+685
+686
+687
+688
+689
+690
+691
+692
+693
+694
+695
+696
+697
+698
+699
+700
+701
+702
+703
+704
+705
+706
+707
+708
+709
+710
+711
+712
+713
+714
+715
+716
+717
+718
+719
+720
+721
+722
+723
+724
+725
+726
+727
+728
+729
+730
+731
+732
+733
+734
+735
+736
+737
+738
+739
+740
+741
+742
+743
+744
+745
+746
+747
+748
+749
+750
+751
+752
+753
+754
+755
+756
+757
+758
+759
+760
+761
+762
+763
+764
+765
+766
+767
+768
+769
+770
+771
+772
+773
+774
+775
+776
+777
+778
+779
+780
+781
+782
+783
+784
+785
+786
+787
+788
+789
+790
+791
+792
+793
+794
+795
+796
+797
+798
+799
+800
+801
+802
+803
+804
+805
+806
+807
+808
+809
+810
+811
+812
+813
+814
+815
+816
+817
+818
+819
+820
+821
+822
+823
+824
+825
+826
+827
+828
+829
+830
+831
+832
+833
+834
+835
+836
+837
+838
+839
+840
+841
+842
+843
+844
+845
+846
+847
+848
+849
+850
+851
+852
+853
+854
+855
+856
+857
+858
+859
+860
+861
+862
+863
+864
+865
+866
+867
+868
+869
+870
+871
+872
+873
+874
+875
+876
+877
+878
+879
+880
+881
+882
+883
+884
+885
+886
+887
+888
+889
+890
+891
+892
+893
+894
/*
+ * GTK - The GIMP Toolkit
+ * Copyright (C) 1998, 1999 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This Library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This Library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with the Gnome Library; see the file COPYING.LIB.  If not,
+ * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+/* Color picker button for GNOME
+ *
+ * Author: Federico Mena <federico@nuclecu.unam.mx>
+ *
+ * Modified by the GTK+ Team and others 2003.  See the AUTHORS
+ * file for a list of people on the GTK+ Team.  See the ChangeLog
+ * files for a list of changes.  These files are distributed with
+ * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
+ */
+
+#include "config.h"<--- Include file: "config.h" not found.
+#include "private.h"
+
+#include "mate-colorbutton.h"
+#include "mate-colorsel.h"
+#include "mate-colorseldialog.h"
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdk/gdkkeysyms.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdk-pixbuf/gdk-pixbuf.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n-lib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+/* Size of checks and gray levels for alpha compositing checkerboard */
+#define CHECK_SIZE  4
+#define CHECK_DARK  (1.0 / 3.0)
+#define CHECK_LIGHT (2.0 / 3.0)
+
+struct _MateColorButtonPrivate
+{
+  GtkWidget *draw_area; /* Widget where we draw the color sample */
+  GtkWidget *cs_dialog; /* Color selection dialog */
+
+  gchar *title;         /* Title for the color selection window */
+
+  GdkColor color;
+  guint16 alpha;
+
+  guint use_alpha : 1;  /* Use alpha or not */
+};
+
+/* Properties */
+enum
+{
+  PROP_0,
+  PROP_USE_ALPHA,
+  PROP_TITLE,
+  PROP_COLOR,
+  PROP_ALPHA
+};
+
+/* Signals */
+enum
+{
+  COLOR_SET,
+  LAST_SIGNAL
+};
+
+/* gobject signals */
+static void mate_color_button_finalize      (GObject             *object);
+static void mate_color_button_set_property  (GObject        *object,
+					    guint           param_id,
+					    const GValue   *value,
+					    GParamSpec     *pspec);
+static void mate_color_button_get_property  (GObject        *object,
+					    guint           param_id,
+					    GValue         *value,
+					    GParamSpec     *pspec);
+
+/* gtkwidget signals */
+static void mate_color_button_state_changed (GtkWidget           *widget,
+					    GtkStateType         previous_state);
+
+/* gtkbutton signals */
+static void mate_color_button_clicked       (GtkButton           *button);
+
+/* source side drag signals */
+static void mate_color_button_drag_begin (GtkWidget        *widget,
+					 GdkDragContext   *context,
+					 gpointer          data);
+static void mate_color_button_drag_data_get (GtkWidget        *widget,
+                                            GdkDragContext   *context,
+                                            GtkSelectionData *selection_data,
+                                            guint             info,
+                                            guint             time,
+                                            MateColorButton   *color_button);
+
+/* target side drag signals */
+static void mate_color_button_drag_data_received (GtkWidget        *widget,
+						 GdkDragContext   *context,
+						 gint              x,
+						 gint              y,
+						 GtkSelectionData *selection_data,
+						 guint             info,
+						 guint32           time,
+						 MateColorButton   *color_button);
+
+static guint color_button_signals[LAST_SIGNAL] = { 0 };
+
+static const GtkTargetEntry drop_types[] = { { "application/x-color", 0, 0 } };
+
+G_DEFINE_TYPE_WITH_PRIVATE (MateColorButton, mate_color_button, GTK_TYPE_BUTTON)<--- There is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
+
+static void
+mate_color_button_class_init (MateColorButtonClass *klass)
+{
+  GObjectClass *gobject_class;
+  GtkWidgetClass *widget_class;
+  GtkButtonClass *button_class;
+
+  gobject_class = G_OBJECT_CLASS (klass);
+  widget_class = GTK_WIDGET_CLASS (klass);
+  button_class = GTK_BUTTON_CLASS (klass);
+
+  gobject_class->get_property = mate_color_button_get_property;
+  gobject_class->set_property = mate_color_button_set_property;
+  gobject_class->finalize = mate_color_button_finalize;
+  widget_class->state_changed = mate_color_button_state_changed;
+  button_class->clicked = mate_color_button_clicked;
+  klass->color_set = NULL;
+
+  /**
+   * MateColorButton:use-alpha:
+   *
+   * If this property is set to %TRUE, the color swatch on the button is rendered against a
+   * checkerboard background to show its opacity and the opacity slider is displayed in the
+   * color selection dialog.
+   *
+   * Since: 1.9.1
+   */
+  g_object_class_install_property (gobject_class,
+                                   PROP_USE_ALPHA,
+                                   g_param_spec_boolean ("use-alpha", _("Use alpha"),
+                                                         _("Whether or not to give the color an alpha value"),
+                                                         FALSE,
+                                                         G_PARAM_READWRITE));
+
+  /**
+   * MateColorButton:title:
+   *
+   * The title of the color selection dialog
+   *
+   * Since: 1.9.1
+   */
+  g_object_class_install_property (gobject_class,
+                                   PROP_TITLE,
+                                   g_param_spec_string ("title",
+							_("Title"),
+                                                        _("The title of the color selection dialog"),
+                                                        _("Pick a Color"),
+                                                        G_PARAM_READWRITE));
+
+  /**
+   * MateColorButton:color:
+   *
+   * The selected color.
+   *
+   * Since: 1.9.1
+   */
+  g_object_class_install_property (gobject_class,
+                                   PROP_COLOR,
+                                   g_param_spec_boxed ("color",
+                                                       _("Current Color"),
+                                                       _("The selected color"),
+                                                       GDK_TYPE_COLOR,
+                                                       G_PARAM_READWRITE));
+
+  /**
+   * MateColorButton:alpha:
+   *
+   * The selected opacity value (0 fully transparent, 65535 fully opaque).
+   *
+   * Since: 1.9.1
+   */
+  g_object_class_install_property (gobject_class,
+                                   PROP_ALPHA,
+                                   g_param_spec_uint ("alpha",
+                                                      _("Current Alpha"),
+                                                      _("The selected opacity value (0 fully transparent, 65535 fully opaque)"),
+                                                      0, 65535, 65535,
+                                                      G_PARAM_READWRITE));
+
+  /**
+   * MateColorButton::color-set:
+   * @widget: the object which received the signal.
+   *
+   * The ::color-set signal is emitted when the user selects a color.
+   * When handling this signal, use mate_color_button_get_color() and
+   * mate_color_button_get_alpha() to find out which color was just selected.
+   *
+   * Note that this signal is only emitted when the <emphasis>user</emphasis>
+   * changes the color. If you need to react to programmatic color changes
+   * as well, use the notify::color signal.
+   *
+   * Since: 1.9.1
+   */
+  color_button_signals[COLOR_SET] = g_signal_new ("color-set",
+						  G_TYPE_FROM_CLASS (gobject_class),
+						  G_SIGNAL_RUN_FIRST,
+						  G_STRUCT_OFFSET (MateColorButtonClass, color_set),
+						  NULL, NULL,
+						  g_cclosure_marshal_VOID__VOID,
+						  G_TYPE_NONE, 0);
+}
+
+static gboolean
+mate_color_button_has_alpha (MateColorButton *color_button)
+{
+  return color_button->priv->use_alpha &&
+      color_button->priv->alpha < 65535;
+}
+
+static cairo_pattern_t *
+mate_color_button_get_checkered (void)
+{
+  /* need to respect pixman's stride being a multiple of 4 */
+  static unsigned char data[8] = { 0xFF, 0x00, 0x00, 0x00,
+                                   0x00, 0xFF, 0x00, 0x00 };
+  static cairo_surface_t *checkered = NULL;
+  cairo_pattern_t *pattern;
+
+  if (checkered == NULL)
+    {
+      checkered = cairo_image_surface_create_for_data (data,
+                                                       CAIRO_FORMAT_A8,
+                                                       2, 2, 4);
+    }
+
+  pattern = cairo_pattern_create_for_surface (checkered);
+  cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT);
+  cairo_pattern_set_filter (pattern, CAIRO_FILTER_NEAREST);
+
+  return pattern;
+}
+
+/* Handle exposure events for the color picker's drawing area */
+static gboolean
+draw (GtkWidget      *widget,
+      cairo_t        *cr,
+      gpointer        data)
+{
+  MateColorButton *color_button = MATE_COLOR_BUTTON (data);
+  cairo_pattern_t *checkered;
+  GtkStyleContext *context;
+  GdkRGBA  rgba;
+
+  mate_color_button_get_rgba (color_button, &rgba);
+  if (mate_color_button_has_alpha (color_button))
+    {
+      cairo_save (cr);
+
+      cairo_set_source_rgb (cr, CHECK_DARK, CHECK_DARK, CHECK_DARK);
+      cairo_paint (cr);
+
+      cairo_set_source_rgb (cr, CHECK_LIGHT, CHECK_LIGHT, CHECK_LIGHT);
+      cairo_scale (cr, CHECK_SIZE, CHECK_SIZE);
+
+      checkered = mate_color_button_get_checkered ();
+      cairo_mask (cr, checkered);
+      cairo_pattern_destroy (checkered);
+
+      cairo_restore (cr);
+
+      cairo_set_source_rgba (cr,
+                             rgba.red,
+                             rgba.green,
+                             rgba.blue,
+                             rgba.alpha);
+    }
+  else
+    {
+      gdk_cairo_set_source_rgba (cr, &rgba);
+    }
+
+  cairo_paint (cr);
+
+  if (!gtk_widget_is_sensitive (GTK_WIDGET (color_button)))
+    {
+      context = gtk_widget_get_style_context (widget);
+      gtk_style_context_get_color (context, GTK_STATE_FLAG_INSENSITIVE, &rgba);
+      gdk_cairo_set_source_rgba (cr, &rgba);
+      checkered = mate_color_button_get_checkered ();
+      cairo_mask (cr, checkered);
+      cairo_pattern_destroy (checkered);
+    }
+
+  return FALSE;
+}
+
+static void
+mate_color_button_state_changed (GtkWidget   *widget,
+                                GtkStateType previous_state)
+{
+  gtk_widget_queue_draw (widget);
+}
+
+static void
+mate_color_button_drag_data_received (GtkWidget        *widget,
+				     GdkDragContext   *context,
+				     gint              x,
+				     gint              y,
+				     GtkSelectionData *selection_data,
+				     guint             info,
+				     guint32           time,
+				     MateColorButton   *color_button)
+{
+  guint16 *dropped;
+
+  if (gtk_selection_data_get_length (selection_data) < 0)
+    return;
+
+  /* We accept drops with the wrong format, since the KDE color
+   * chooser incorrectly drops application/x-color with format 8.
+   */
+  if (gtk_selection_data_get_length (selection_data) != 8)
+    {
+      g_warning (_("Received invalid color data\n"));
+      return;
+    }
+
+  dropped = (guint16 *)gtk_selection_data_get_data (selection_data);
+
+  color_button->priv->color.red = dropped[0];
+  color_button->priv->color.green = dropped[1];
+  color_button->priv->color.blue = dropped[2];
+  color_button->priv->alpha = dropped[3];
+
+  gtk_widget_queue_draw (color_button->priv->draw_area);
+
+  g_signal_emit (color_button, color_button_signals[COLOR_SET], 0);
+
+  g_object_freeze_notify (G_OBJECT (color_button));
+  g_object_notify (G_OBJECT (color_button), "color");
+  g_object_notify (G_OBJECT (color_button), "alpha");
+  g_object_thaw_notify (G_OBJECT (color_button));
+}
+
+static void
+set_color_icon (GdkDragContext *context,
+		GdkColor       *color)
+{
+  GdkPixbuf *pixbuf;
+  guint32 pixel;
+
+  pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE,
+			   8, 48, 32);
+
+  pixel = ((color->red & 0xff00) << 16) |
+          ((color->green & 0xff00) << 8) |
+           (color->blue & 0xff00);
+
+  gdk_pixbuf_fill (pixbuf, pixel);
+
+  gtk_drag_set_icon_pixbuf (context, pixbuf, -2, -2);
+  g_object_unref (pixbuf);
+}
+
+static void
+mate_color_button_drag_begin (GtkWidget      *widget,
+			     GdkDragContext *context,
+			     gpointer        data)
+{
+  MateColorButton *color_button = data;
+
+  set_color_icon (context, &color_button->priv->color);
+}
+
+static void
+mate_color_button_drag_data_get (GtkWidget        *widget,
+				GdkDragContext   *context,
+				GtkSelectionData *selection_data,
+				guint             info,
+				guint             time,
+				MateColorButton   *color_button)
+{
+  guint16 dropped[4];
+
+  dropped[0] = color_button->priv->color.red;
+  dropped[1] = color_button->priv->color.green;
+  dropped[2] = color_button->priv->color.blue;
+  dropped[3] = color_button->priv->alpha;
+
+  gtk_selection_data_set (selection_data, gtk_selection_data_get_target (selection_data),
+			  16, (guchar *)dropped, 8);
+}
+
+static void
+mate_color_button_init (MateColorButton *color_button)
+{
+  GtkWidget *frame;
+  PangoLayout *layout;
+  PangoRectangle rect;
+
+  _mate_desktop_init_i18n ();
+
+  /* Create the widgets */
+  color_button->priv = mate_color_button_get_instance_private (color_button);
+
+  frame = gtk_frame_new (NULL);
+  gtk_widget_set_valign (frame, GTK_ALIGN_CENTER);
+  gtk_widget_set_halign (frame, GTK_ALIGN_CENTER);
+  gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_OUT);
+  gtk_container_add (GTK_CONTAINER (color_button), frame);
+  gtk_widget_show (frame);
+
+  /* Just some widget we can hook to expose-event on */
+  color_button->priv->draw_area = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
+  gtk_widget_set_valign (color_button->priv->draw_area, GTK_ALIGN_CENTER);
+  gtk_widget_set_halign (color_button->priv->draw_area, GTK_ALIGN_CENTER);
+
+  layout = gtk_widget_create_pango_layout (GTK_WIDGET (color_button), "Black");
+  pango_layout_get_pixel_extents (layout, NULL, &rect);
+  g_object_unref (layout);
+
+  gtk_widget_set_size_request (color_button->priv->draw_area, rect.width - 2, rect.height - 2);
+  g_signal_connect (color_button->priv->draw_area, "draw",
+                    G_CALLBACK (draw), color_button);
+  gtk_container_add (GTK_CONTAINER (frame), color_button->priv->draw_area);
+  gtk_widget_show (color_button->priv->draw_area);
+
+  color_button->priv->title = g_strdup (_("Pick a Color")); /* default title */
+
+  /* Start with opaque black, alpha disabled */
+
+  color_button->priv->color.red = 0;
+  color_button->priv->color.green = 0;
+  color_button->priv->color.blue = 0;
+  color_button->priv->alpha = 65535;
+  color_button->priv->use_alpha = FALSE;
+
+  gtk_drag_dest_set (GTK_WIDGET (color_button),
+                     GTK_DEST_DEFAULT_MOTION |
+                     GTK_DEST_DEFAULT_HIGHLIGHT |
+                     GTK_DEST_DEFAULT_DROP,
+                     drop_types, 1, GDK_ACTION_COPY);
+  gtk_drag_source_set (GTK_WIDGET(color_button),
+                       GDK_BUTTON1_MASK|GDK_BUTTON3_MASK,
+                       drop_types, 1,
+                       GDK_ACTION_COPY);
+  g_signal_connect (color_button, "drag-begin",
+		    G_CALLBACK (mate_color_button_drag_begin), color_button);
+  g_signal_connect (color_button, "drag-data-received",
+                    G_CALLBACK (mate_color_button_drag_data_received), color_button);
+  g_signal_connect (color_button, "drag-data-get",
+                    G_CALLBACK (mate_color_button_drag_data_get), color_button);
+}
+
+static void
+mate_color_button_finalize (GObject *object)
+{
+  MateColorButton *color_button = MATE_COLOR_BUTTON (object);
+
+  if (color_button->priv->cs_dialog != NULL)
+    gtk_widget_destroy (color_button->priv->cs_dialog);
+  color_button->priv->cs_dialog = NULL;
+
+  g_free (color_button->priv->title);
+  color_button->priv->title = NULL;
+
+  G_OBJECT_CLASS (mate_color_button_parent_class)->finalize (object);
+}
+
+/**
+ * mate_color_button_new:
+ *
+ * Creates a new color button. This returns a widget in the form of
+ * a small button containing a swatch representing the current selected
+ * color. When the button is clicked, a color-selection dialog will open,
+ * allowing the user to select a color. The swatch will be updated to reflect
+ * the new color when the user finishes.
+ *
+ * Returns: a new color button.
+ *
+ * Since: 1.9.1
+ */
+GtkWidget *
+mate_color_button_new (void)
+{
+  return g_object_new (MATE_TYPE_COLOR_BUTTON, NULL);
+}
+
+/**
+ * mate_color_button_new_with_color:
+ * @color: A #GdkColor to set the current color with.
+ *
+ * Creates a new color button.
+ *
+ * Returns: a new color button.
+ *
+ * Since: 1.9.1
+ */
+GtkWidget *
+mate_color_button_new_with_color (const GdkColor *color)
+{
+  return g_object_new (MATE_TYPE_COLOR_BUTTON, "color", color, NULL);
+}
+
+static void
+dialog_ok_clicked (GtkWidget *widget,
+		   gpointer   data)
+{
+  MateColorButton *color_button = MATE_COLOR_BUTTON (data);
+  MateColorSelection *color_selection;
+
+  color_selection = MATE_COLOR_SELECTION (MATE_COLOR_SELECTION_DIALOG (color_button->priv->cs_dialog)->colorsel);
+
+  mate_color_selection_get_current_color (color_selection, &color_button->priv->color);
+  color_button->priv->alpha = mate_color_selection_get_current_alpha (color_selection);
+
+  gtk_widget_hide (color_button->priv->cs_dialog);
+
+  gtk_widget_queue_draw (color_button->priv->draw_area);
+
+  g_signal_emit (color_button, color_button_signals[COLOR_SET], 0);
+
+  g_object_freeze_notify (G_OBJECT (color_button));
+  g_object_notify (G_OBJECT (color_button), "color");
+  g_object_notify (G_OBJECT (color_button), "alpha");
+  g_object_thaw_notify (G_OBJECT (color_button));
+}
+
+static gboolean
+dialog_destroy (GtkWidget *widget,
+		gpointer   data)
+{
+  MateColorButton *color_button = MATE_COLOR_BUTTON (data);
+
+  color_button->priv->cs_dialog = NULL;
+
+  return FALSE;
+}
+
+static void
+dialog_cancel_clicked (GtkWidget *widget,
+		       gpointer   data)
+{
+  MateColorButton *color_button = MATE_COLOR_BUTTON (data);
+
+  gtk_widget_hide (color_button->priv->cs_dialog);
+}
+
+static void
+mate_color_button_clicked (GtkButton *button)
+{
+  MateColorButton *color_button = MATE_COLOR_BUTTON (button);
+  MateColorSelectionDialog *color_dialog;
+
+  /* if dialog already exists, make sure it's shown and raised */
+  if (!color_button->priv->cs_dialog)
+    {
+      /* Create the dialog and connects its buttons */
+      GtkWidget *parent;
+
+      parent = gtk_widget_get_toplevel (GTK_WIDGET (color_button));
+
+      color_button->priv->cs_dialog = mate_color_selection_dialog_new (color_button->priv->title);
+
+      color_dialog = MATE_COLOR_SELECTION_DIALOG (color_button->priv->cs_dialog);
+
+      if (gtk_widget_is_toplevel (parent) && GTK_IS_WINDOW (parent))
+        {
+          if (GTK_WINDOW (parent) != gtk_window_get_transient_for (GTK_WINDOW (color_dialog)))
+ 	    gtk_window_set_transient_for (GTK_WINDOW (color_dialog), GTK_WINDOW (parent));
+
+	  gtk_window_set_modal (GTK_WINDOW (color_dialog),
+				gtk_window_get_modal (GTK_WINDOW (parent)));
+	}
+
+      g_signal_connect (color_dialog->ok_button, "clicked",
+                        G_CALLBACK (dialog_ok_clicked), color_button);
+      g_signal_connect (color_dialog->cancel_button, "clicked",
+			G_CALLBACK (dialog_cancel_clicked), color_button);
+      g_signal_connect (color_dialog, "destroy",
+                        G_CALLBACK (dialog_destroy), color_button);
+    }
+
+  color_dialog = MATE_COLOR_SELECTION_DIALOG (color_button->priv->cs_dialog);
+
+  mate_color_selection_set_has_opacity_control (MATE_COLOR_SELECTION (color_dialog->colorsel),
+                                               color_button->priv->use_alpha);
+
+  mate_color_selection_set_has_palette (MATE_COLOR_SELECTION (color_dialog->colorsel), TRUE);
+
+  mate_color_selection_set_previous_color (MATE_COLOR_SELECTION (color_dialog->colorsel),
+					  &color_button->priv->color);
+  mate_color_selection_set_previous_alpha (MATE_COLOR_SELECTION (color_dialog->colorsel),
+					  color_button->priv->alpha);
+
+  mate_color_selection_set_current_color (MATE_COLOR_SELECTION (color_dialog->colorsel),
+					 &color_button->priv->color);
+  mate_color_selection_set_current_alpha (MATE_COLOR_SELECTION (color_dialog->colorsel),
+					 color_button->priv->alpha);
+
+  gtk_window_present (GTK_WINDOW (color_button->priv->cs_dialog));
+}
+
+/**
+ * mate_color_button_set_color:
+ * @color_button: a #MateColorButton.
+ * @color: A #GdkColor to set the current color with.
+ *
+ * Sets the current color to be @color.
+ *
+ * Since: 1.9.1
+ **/
+void
+mate_color_button_set_color (MateColorButton *color_button,
+			    const GdkColor *color)
+{
+  g_return_if_fail (MATE_IS_COLOR_BUTTON (color_button));
+  g_return_if_fail (color != NULL);
+
+  color_button->priv->color.red = color->red;
+  color_button->priv->color.green = color->green;
+  color_button->priv->color.blue = color->blue;
+
+  gtk_widget_queue_draw (color_button->priv->draw_area);
+
+  g_object_notify (G_OBJECT (color_button), "color");
+}
+
+/**
+ * mate_color_button_set_rgba:
+ * @color_button: a #MateColorButton.
+ * @color: A #GdkRGBA to set the current color with.
+ *
+ * Sets the current color to be @color.
+ *
+ * Since: 1.9.1
+ **/
+void
+mate_color_button_set_rgba (MateColorButton *color_button,
+			    const GdkRGBA *color)
+{
+  g_return_if_fail (MATE_IS_COLOR_BUTTON (color_button));
+  g_return_if_fail (color != NULL);
+
+  color_button->priv->color.red = color->red * 65535;
+  color_button->priv->color.green = color->green * 65535;
+  color_button->priv->color.blue = color->blue * 65535;
+  color_button->priv->alpha = color->alpha * 65535;
+
+  gtk_widget_queue_draw (color_button->priv->draw_area);
+
+  g_object_notify (G_OBJECT (color_button), "color");
+}
+
+/**
+ * mate_color_button_set_alpha:
+ * @color_button: a #MateColorButton.
+ * @alpha: an integer between 0 and 65535.
+ *
+ * Sets the current opacity to be @alpha.
+ *
+ * Since: 1.9.1
+ **/
+void
+mate_color_button_set_alpha (MateColorButton *color_button,
+			    guint16         alpha)
+{
+  g_return_if_fail (MATE_IS_COLOR_BUTTON (color_button));
+
+  color_button->priv->alpha = alpha;
+
+  gtk_widget_queue_draw (color_button->priv->draw_area);
+
+  g_object_notify (G_OBJECT (color_button), "alpha");
+}
+
+/**
+ * mate_color_button_get_color:
+ * @color_button: a #MateColorButton.
+ * @color: a #GdkColor to fill in with the current color.
+ *
+ * Sets @color to be the current color in the #MateColorButton widget.
+ *
+ * Since: 1.9.1
+ **/
+void
+mate_color_button_get_color (MateColorButton *color_button,
+			    GdkColor       *color)
+{
+  g_return_if_fail (MATE_IS_COLOR_BUTTON (color_button));
+
+  color->red = color_button->priv->color.red;
+  color->green = color_button->priv->color.green;
+  color->blue = color_button->priv->color.blue;
+}
+
+/**
+ * mate_color_button_get_rgba:
+ * @color_button: a #MateColorButton.
+ * @color: a #GdkRGBA to fill in with the current color.
+ *
+ * Sets @color to be the current color in the #MateColorButton widget.
+ *
+ * Since: 1.9.1
+ **/
+void
+mate_color_button_get_rgba (MateColorButton *color_button,
+			                      GdkRGBA         *color)
+{
+  g_return_if_fail (MATE_IS_COLOR_BUTTON (color_button));
+
+  color->red = color_button->priv->color.red / 65535.;
+  color->green = color_button->priv->color.green / 65535.;
+  color->blue = color_button->priv->color.blue / 65535.;
+  color->alpha = color_button->priv->alpha / 65535.;
+}
+
+/**
+ * mate_color_button_get_alpha:
+ * @color_button: a #MateColorButton.
+ *
+ * Returns the current alpha value.
+ *
+ * Return value: an integer between 0 and 65535.
+ *
+ * Since: 1.9.1
+ **/
+guint16
+mate_color_button_get_alpha (MateColorButton *color_button)
+{
+  g_return_val_if_fail (MATE_IS_COLOR_BUTTON (color_button), 0);
+
+  return color_button->priv->alpha;
+}
+
+/**
+ * mate_color_button_set_use_alpha:
+ * @color_button: a #MateColorButton.
+ * @use_alpha: %TRUE if color button should use alpha channel, %FALSE if not.
+ *
+ * Sets whether or not the color button should use the alpha channel.
+ *
+ * Since: 1.9.1
+ */
+void
+mate_color_button_set_use_alpha (MateColorButton *color_button,
+				gboolean        use_alpha)
+{
+  g_return_if_fail (MATE_IS_COLOR_BUTTON (color_button));
+
+  use_alpha = (use_alpha != FALSE);
+
+  if (color_button->priv->use_alpha != use_alpha)
+    {
+      color_button->priv->use_alpha = (use_alpha != FALSE);
+
+      gtk_widget_queue_draw (color_button->priv->draw_area);
+
+      g_object_notify (G_OBJECT (color_button), "use-alpha");
+    }
+}
+
+/**
+ * mate_color_button_get_use_alpha:
+ * @color_button: a #MateColorButton.
+ *
+ * Does the color selection dialog use the alpha channel?
+ *
+ * Returns: %TRUE if the color sample uses alpha channel, %FALSE if not.
+ *
+ * Since: 1.9.1
+ */
+gboolean
+mate_color_button_get_use_alpha (MateColorButton *color_button)
+{
+  g_return_val_if_fail (MATE_IS_COLOR_BUTTON (color_button), FALSE);
+
+  return color_button->priv->use_alpha;
+}
+
+/**
+ * mate_color_button_set_title:
+ * @color_button: a #MateColorButton
+ * @title: String containing new window title.
+ *
+ * Sets the title for the color selection dialog.
+ *
+ * Since: 1.9.1
+ */
+void
+mate_color_button_set_title (MateColorButton *color_button,
+			    const gchar    *title)
+{
+  gchar *old_title;
+
+  g_return_if_fail (MATE_IS_COLOR_BUTTON (color_button));
+
+  old_title = color_button->priv->title;
+  color_button->priv->title = g_strdup (title);
+  g_free (old_title);
+
+  if (color_button->priv->cs_dialog)
+    gtk_window_set_title (GTK_WINDOW (color_button->priv->cs_dialog),
+			  color_button->priv->title);
+
+  g_object_notify (G_OBJECT (color_button), "title");
+}
+
+/**
+ * mate_color_button_get_title:
+ * @color_button: a #MateColorButton
+ *
+ * Gets the title of the color selection dialog.
+ *
+ * Returns: An internal string, do not free the return value
+ *
+ * Since: 1.9.1
+ */
+const gchar *
+mate_color_button_get_title (MateColorButton *color_button)
+{
+  g_return_val_if_fail (MATE_IS_COLOR_BUTTON (color_button), NULL);
+
+  return color_button->priv->title;
+}
+
+static void
+mate_color_button_set_property (GObject      *object,
+			       guint         param_id,
+			       const GValue *value,
+			       GParamSpec   *pspec)
+{
+  MateColorButton *color_button = MATE_COLOR_BUTTON (object);
+
+  switch (param_id)
+    {
+    case PROP_USE_ALPHA:
+      mate_color_button_set_use_alpha (color_button, g_value_get_boolean (value));
+      break;
+    case PROP_TITLE:
+      mate_color_button_set_title (color_button, g_value_get_string (value));
+      break;
+    case PROP_COLOR:
+      mate_color_button_set_color (color_button, g_value_get_boxed (value));
+      break;
+    case PROP_ALPHA:
+      mate_color_button_set_alpha (color_button, g_value_get_uint (value));
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+      break;
+    }
+}
+
+static void
+mate_color_button_get_property (GObject    *object,
+			       guint       param_id,
+			       GValue     *value,
+			       GParamSpec *pspec)
+{
+  MateColorButton *color_button = MATE_COLOR_BUTTON (object);
+  GdkColor color;
+
+  switch (param_id)
+    {
+    case PROP_USE_ALPHA:
+      g_value_set_boolean (value, mate_color_button_get_use_alpha (color_button));
+      break;
+    case PROP_TITLE:
+      g_value_set_string (value, mate_color_button_get_title (color_button));
+      break;
+    case PROP_COLOR:
+      mate_color_button_get_color (color_button, &color);
+      g_value_set_boxed (value, &color);
+      break;
+    case PROP_ALPHA:
+      g_value_set_uint (value, mate_color_button_get_alpha (color_button));
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+      break;
+    }
+}
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/110.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/110.html new file mode 100644 index 0000000..7a81ff3 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/110.html @@ -0,0 +1,1603 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
+603
+604
+605
+606
+607
+608
+609
+610
+611
+612
+613
+614
+615
+616
+617
+618
+619
+620
+621
+622
+623
+624
+625
+626
+627
+628
+629
+630
+631
+632
+633
+634
+635
+636
+637
+638
+639
+640
+641
+642
+643
+644
+645
+646
+647
+648
+649
+650
+651
+652
+653
+654
+655
+656
+657
+658
+659
+660
+661
+662
+663
+664
+665
+666
+667
+668
+669
+670
+671
+672
+673
+674
+675
+676
+677
+678
+679
+680
+681
+682
+683
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2006-2007 William Jon McCann <mccann@jhu.edu>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be
+ * useful, but WITHOUT ANY WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE.  See the GNU Lesser General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "config.h"<--- Include file: "config.h" not found.
+
+#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <math.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "gsd-media-keys-window.h"
+
+#define ICON_SCALE 0.55           /* size of the icon compared to the whole OSD */
+
+struct MsdMediaKeysWindowPrivate
+{
+        MsdMediaKeysWindowAction action;
+        char                    *icon_name;
+        gboolean                 show_level;
+
+        guint                    volume_muted : 1;
+        int                      volume_level;
+
+        GtkImage                *image;
+        GtkWidget               *progress;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (MsdMediaKeysWindow, msd_media_keys_window, MSD_TYPE_OSD_WINDOW)<--- There is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
+
+static void
+volume_controls_set_visible (MsdMediaKeysWindow *window,
+                             gboolean            visible)
+{
+        if (window->priv->progress == NULL)
+                return;
+
+        if (visible) {
+                gtk_widget_show (window->priv->progress);
+        } else {
+                gtk_widget_hide (window->priv->progress);
+        }
+}
+
+static void
+window_set_icon_name (MsdMediaKeysWindow *window,
+                      const char         *name)
+{
+        if (window->priv->image == NULL)
+                return;
+
+        gtk_image_set_from_icon_name (window->priv->image,
+                                      name, GTK_ICON_SIZE_DIALOG);
+}
+
+static void
+action_changed (MsdMediaKeysWindow *window)
+{
+        if (!msd_osd_window_is_composited (MSD_OSD_WINDOW (window))) {
+                switch (window->priv->action) {
+                case MSD_MEDIA_KEYS_WINDOW_ACTION_VOLUME:
+                        volume_controls_set_visible (window, TRUE);
+
+                        if (window->priv->volume_muted) {
+                                window_set_icon_name (window, "audio-volume-muted");
+                        } else {
+                                window_set_icon_name (window, "audio-volume-high");
+                        }
+
+                        break;
+                case MSD_MEDIA_KEYS_WINDOW_ACTION_CUSTOM:
+                        volume_controls_set_visible (window, window->priv->show_level);
+                        window_set_icon_name (window, window->priv->icon_name);
+                        break;
+                default:
+                        g_assert_not_reached ();
+                        break;
+                }
+        }
+
+        msd_osd_window_update_and_hide (MSD_OSD_WINDOW (window));
+}
+
+static void
+volume_level_changed (MsdMediaKeysWindow *window)
+{
+        msd_osd_window_update_and_hide (MSD_OSD_WINDOW (window));
+
+        if (!msd_osd_window_is_composited (MSD_OSD_WINDOW (window)) && window->priv->progress != NULL) {
+                double fraction;
+
+                fraction = (double) window->priv->volume_level / 100.0;
+
+                gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (window->priv->progress),
+                                               fraction);
+        }
+}
+
+static void
+volume_muted_changed (MsdMediaKeysWindow *window)
+{
+        msd_osd_window_update_and_hide (MSD_OSD_WINDOW (window));
+
+        if (!msd_osd_window_is_composited (MSD_OSD_WINDOW (window))) {
+                if (window->priv->volume_muted) {
+                        window_set_icon_name (window, "audio-volume-muted");
+                } else {
+                        window_set_icon_name (window, "audio-volume-high");
+                }
+        }
+}
+
+void
+msd_media_keys_window_set_action (MsdMediaKeysWindow      *window,
+                                  MsdMediaKeysWindowAction action)
+{
+        g_return_if_fail (MSD_IS_MEDIA_KEYS_WINDOW (window));
+        g_return_if_fail (action == MSD_MEDIA_KEYS_WINDOW_ACTION_VOLUME);
+
+        if (window->priv->action != action) {
+                window->priv->action = action;
+                action_changed (window);
+        } else {
+                msd_osd_window_update_and_hide (MSD_OSD_WINDOW (window));
+        }
+}
+
+void
+msd_media_keys_window_set_action_custom (MsdMediaKeysWindow      *window,
+                                         const char              *icon_name,
+                                         gboolean                 show_level)
+{
+        g_return_if_fail (MSD_IS_MEDIA_KEYS_WINDOW (window));
+        g_return_if_fail (icon_name != NULL);
+
+        if (window->priv->action != MSD_MEDIA_KEYS_WINDOW_ACTION_CUSTOM ||
+            g_strcmp0 (window->priv->icon_name, icon_name) != 0 ||
+            window->priv->show_level != show_level) {
+                window->priv->action = MSD_MEDIA_KEYS_WINDOW_ACTION_CUSTOM;
+                g_free (window->priv->icon_name);
+                window->priv->icon_name = g_strdup (icon_name);
+                window->priv->show_level = show_level;
+                action_changed (window);
+        } else {
+                msd_osd_window_update_and_hide (MSD_OSD_WINDOW (window));
+        }
+}
+
+void
+msd_media_keys_window_set_volume_muted (MsdMediaKeysWindow *window,
+                                        gboolean            muted)
+{
+        g_return_if_fail (MSD_IS_MEDIA_KEYS_WINDOW (window));
+
+        if (window->priv->volume_muted != muted) {
+                window->priv->volume_muted = (muted != FALSE);
+                volume_muted_changed (window);
+        }
+}
+
+void
+msd_media_keys_window_set_volume_level (MsdMediaKeysWindow *window,
+                                        int                 level)
+{
+        g_return_if_fail (MSD_IS_MEDIA_KEYS_WINDOW (window));
+
+        if (window->priv->volume_level != level) {
+                window->priv->volume_level = level;
+                volume_level_changed (window);
+        }
+}
+
+static GdkPixbuf *
+load_pixbuf (MsdMediaKeysWindow *window,
+             const char         *name,
+             int                 icon_size)
+{
+        GtkIconTheme *theme;
+        GdkPixbuf    *pixbuf;
+
+        if (window != NULL && gtk_widget_has_screen (GTK_WIDGET (window))) {
+                theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (window)));
+        } else {
+                theme = gtk_icon_theme_get_default ();
+        }
+
+        pixbuf = gtk_icon_theme_load_icon (theme,
+                                           name,
+                                           icon_size,
+                                           GTK_ICON_LOOKUP_FORCE_SIZE,
+                                           NULL);
+
+        return pixbuf;
+}
+
+static void
+draw_eject (cairo_t *cr,
+            double   _x0,
+            double   _y0,
+            double   width,
+            double   height)
+{
+        int box_height;
+        int tri_height;
+        int separation;
+
+        box_height = height * 0.2;
+        separation = box_height / 3;
+        tri_height = height - box_height - separation;
+
+        cairo_rectangle (cr, _x0, _y0 + height - box_height, width, box_height);
+
+        cairo_move_to (cr, _x0, _y0 + tri_height);
+        cairo_rel_line_to (cr, width, 0);
+        cairo_rel_line_to (cr, -width / 2, -tri_height);
+        cairo_rel_line_to (cr, -width / 2, tri_height);
+        cairo_close_path (cr);
+        cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, MSD_OSD_WINDOW_FG_ALPHA);
+        cairo_fill_preserve (cr);
+
+        cairo_set_source_rgba (cr, 0.6, 0.6, 0.6, MSD_OSD_WINDOW_FG_ALPHA / 2);
+        cairo_set_line_width (cr, 2);
+        cairo_stroke (cr);
+}
+
+static void
+draw_waves (cairo_t *cr,
+            double   cx,
+            double   cy,
+            double   max_radius,
+            int      volume_level)
+{
+        const int n_waves = 3;
+        int last_wave;
+        int i;
+
+        last_wave = n_waves * volume_level / 100;
+
+        for (i = 0; i < n_waves; i++) {
+                double angle1;
+                double angle2;
+                double radius;
+                double alpha;
+
+                angle1 = -M_PI / 4;
+                angle2 = M_PI / 4;
+
+                if (i < last_wave)
+                        alpha = 1.0;
+                else if (i > last_wave)
+                        alpha = 0.1;
+                else alpha = 0.1 + 0.9 * (n_waves * volume_level % 100) / 100.0;
+
+                radius = (i + 1) * (max_radius / n_waves);
+                cairo_arc (cr, cx, cy, radius, angle1, angle2);
+                cairo_set_source_rgba (cr, 0.6, 0.6, 0.6, alpha / 2);
+                cairo_set_line_width (cr, 14);
+                cairo_set_line_cap  (cr, CAIRO_LINE_CAP_ROUND);
+                cairo_stroke_preserve (cr);
+
+                cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, alpha);
+                cairo_set_line_width (cr, 10);
+                cairo_set_line_cap  (cr, CAIRO_LINE_CAP_ROUND);
+                cairo_stroke (cr);
+        }
+}
+
+static void
+draw_cross (cairo_t *cr,
+            double   cx,
+            double   cy,
+            double   size)
+{
+        cairo_move_to (cr, cx, cy - size/2.0);
+        cairo_rel_line_to (cr, size, size);
+
+        cairo_move_to (cr, cx, cy + size/2.0);
+        cairo_rel_line_to (cr, size, -size);
+
+        cairo_set_source_rgba (cr, 0.6, 0.6, 0.6, MSD_OSD_WINDOW_FG_ALPHA / 2);
+        cairo_set_line_width (cr, 14);
+        cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
+        cairo_stroke_preserve (cr);
+
+        cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, MSD_OSD_WINDOW_FG_ALPHA);
+        cairo_set_line_width (cr, 10);
+        cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
+        cairo_stroke (cr);
+}
+
+static void
+draw_speaker (cairo_t *cr,
+              double   cx,
+              double   cy,
+              double   width,
+              double   height)
+{
+        double box_width;
+        double box_height;
+        double _x0;
+        double _y0;
+
+        box_width = width / 3;
+        box_height = height / 3;
+
+        _x0 = cx - (width / 2) + box_width;
+        _y0 = cy - box_height / 2;
+
+        cairo_move_to (cr, _x0, _y0);
+        cairo_rel_line_to (cr, - box_width, 0);
+        cairo_rel_line_to (cr, 0, box_height);
+        cairo_rel_line_to (cr, box_width, 0);
+
+        cairo_line_to (cr, cx + box_width, cy + height / 2);
+        cairo_rel_line_to (cr, 0, -height);
+        cairo_line_to (cr, _x0, _y0);
+        cairo_close_path (cr);
+
+        cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, MSD_OSD_WINDOW_FG_ALPHA);
+        cairo_fill_preserve (cr);
+
+        cairo_set_source_rgba (cr, 0.6, 0.6, 0.6, MSD_OSD_WINDOW_FG_ALPHA / 2);
+        cairo_set_line_width (cr, 2);
+        cairo_stroke (cr);
+}
+
+static gboolean
+render_speaker (MsdMediaKeysWindow *window,
+                cairo_t            *cr,
+                double              _x0,
+                double              _y0,
+                double              width,
+                double              height)
+{
+        GdkPixbuf         *pixbuf;
+        int                icon_size;
+        int                n;
+        static const char *icon_names[] = {
+                "audio-volume-muted",
+                "audio-volume-low",
+                "audio-volume-medium",
+                "audio-volume-high",
+                NULL
+        };
+
+        if (window->priv->volume_muted) {
+                n = 0;
+        } else {
+                /* select image */
+                n = 3 * window->priv->volume_level / 100 + 1;
+                if (n < 1) {
+                        n = 1;
+                } else if (n > 3) {
+                        n = 3;
+                }
+        }
+
+        icon_size = (int)width;
+
+        pixbuf = load_pixbuf (window, icon_names[n], icon_size);
+
+        if (pixbuf == NULL) {
+                return FALSE;
+        }
+
+        gdk_cairo_set_source_pixbuf (cr, pixbuf, _x0, _y0);
+        cairo_paint_with_alpha (cr, MSD_OSD_WINDOW_FG_ALPHA);
+
+        g_object_unref (pixbuf);
+
+        return TRUE;
+}
+
+static void
+draw_volume_boxes (MsdMediaKeysWindow *window,
+                   cairo_t            *cr,
+                   double              percentage,
+                   double              _x0,
+                   double              _y0,
+                   double              width,
+                   double              height)
+{
+        gdouble   x1;
+        GtkStyleContext *context;
+
+        height = round (height) - 1;
+        width = round (width) - 1;
+        x1 = round ((width - 1) * percentage);
+        context = gtk_widget_get_style_context (GTK_WIDGET (window));
+
+        /* bar background */
+        gtk_style_context_save (context);
+        gtk_style_context_add_class (context, GTK_STYLE_CLASS_TROUGH);
+
+        gtk_render_background (context, cr, _x0, _y0, width, height);
+        gtk_render_frame (context, cr, _x0, _y0, width, height);
+
+        gtk_style_context_restore (context);
+
+        /* bar progress */
+        if (percentage < 0.01)
+                return;
+
+        gtk_style_context_save (context);
+        gtk_style_context_add_class (context, GTK_STYLE_CLASS_PROGRESSBAR);
+
+        gtk_render_background (context, cr, _x0 + 0.5, _y0 + 0.5, x1, height -1 );
+        gtk_render_frame (context, cr, _x0 + 0.5, _y0 + 0.5, x1, height -1 );
+
+        gtk_style_context_restore (context);
+}
+
+static void
+draw_action_volume (MsdMediaKeysWindow *window,
+                    cairo_t            *cr)
+{
+        int window_width;
+        int window_height;
+        double icon_box_width;
+        double icon_box_height;
+        double icon_box_x0;
+        double icon_box_y0;
+        double volume_box_x0;
+        double volume_box_y0;
+        double volume_box_width;
+        double volume_box_height;
+        gboolean res;
+
+        gtk_window_get_size (GTK_WINDOW (window), &window_width, &window_height);
+
+        icon_box_width = round (window_width * ICON_SCALE);
+        icon_box_height = round (window_height * ICON_SCALE);
+        volume_box_width = icon_box_width;
+        volume_box_height = round (window_height * 0.05);
+
+        icon_box_x0 = round ((window_width - icon_box_width) / 2);
+        icon_box_y0 = round ((window_height - icon_box_height) / 2);
+        volume_box_x0 = round (icon_box_x0);
+        volume_box_y0 = round (window_height - icon_box_y0 / 2 - volume_box_height);
+
+        res = render_speaker (window,
+                              cr,
+                              icon_box_x0, icon_box_y0,
+                              icon_box_width, icon_box_height);
+        if (! res) {
+                double speaker_width;
+                double speaker_height;
+                double speaker_cx;
+                double speaker_cy;
+
+                speaker_width = icon_box_width * 0.5;
+                speaker_height = icon_box_height * 0.75;
+                speaker_cx = icon_box_x0 + speaker_width / 2;
+                speaker_cy = icon_box_y0 + speaker_height / 2;
+
+#if 0
+                g_message ("speaker box: w=%f h=%f cx=%f cy=%f",
+                           speaker_width,
+                           speaker_height,
+                           speaker_cx,
+                           speaker_cy);
+#endif
+
+                /* draw speaker symbol */
+                draw_speaker (cr, speaker_cx, speaker_cy, speaker_width, speaker_height);
+
+                if (! window->priv->volume_muted) {
+                        /* draw sound waves */
+                        double wave_x0;
+                        double wave_y0;
+                        double wave_radius;
+
+                        wave_x0 = window_width / 2;
+                        wave_y0 = speaker_cy;
+                        wave_radius = icon_box_width / 2;
+
+                        draw_waves (cr, wave_x0, wave_y0, wave_radius, window->priv->volume_level);
+                } else {
+                        /* draw 'mute' cross */
+                        double cross_x0;
+                        double cross_y0;
+                        double cross_size;
+
+                        cross_size = speaker_width * 3 / 4;
+                        cross_x0 = icon_box_x0 + icon_box_width - cross_size;
+                        cross_y0 = speaker_cy;
+
+                        draw_cross (cr, cross_x0, cross_y0, cross_size);
+                }
+        }
+
+        /* draw volume meter */
+        draw_volume_boxes (window,
+                           cr,
+                           (double)window->priv->volume_level / 100.0,
+                           volume_box_x0,
+                           volume_box_y0,
+                           volume_box_width,
+                           volume_box_height);
+}
+
+static gboolean
+render_custom (MsdMediaKeysWindow *window,
+               cairo_t            *cr,
+               double              _x0,
+               double              _y0,
+               double              width,
+               double              height)
+{
+        GdkPixbuf         *pixbuf;
+        int                icon_size;
+
+        icon_size = (int)width;
+
+        pixbuf = load_pixbuf (window, window->priv->icon_name, icon_size);
+
+        if (pixbuf == NULL) {
+                char *name;
+                if (gtk_widget_get_direction (GTK_WIDGET (window)) == GTK_TEXT_DIR_RTL)
+                        name = g_strdup_printf ("%s-rtl", window->priv->icon_name);
+                else
+                        name = g_strdup_printf ("%s-ltr", window->priv->icon_name);
+                pixbuf = load_pixbuf (window, name, icon_size);
+                g_free (name);
+                if (pixbuf == NULL)
+                        return FALSE;
+        }
+
+        gdk_cairo_set_source_pixbuf (cr, pixbuf, _x0, _y0);
+        cairo_paint_with_alpha (cr, MSD_OSD_WINDOW_FG_ALPHA);
+
+        g_object_unref (pixbuf);
+
+        return TRUE;
+}
+
+static void
+draw_action_custom (MsdMediaKeysWindow *window,
+                    cairo_t            *cr)
+{
+        int window_width;
+        int window_height;
+        double icon_box_width;
+        double icon_box_height;
+        double icon_box_x0;
+        double icon_box_y0;
+        double bright_box_x0;
+        double bright_box_y0;
+        double bright_box_width;
+        double bright_box_height;
+        gboolean res;
+
+        gtk_window_get_size (GTK_WINDOW (window), &window_width, &window_height);
+
+        icon_box_width = round (window_width * ICON_SCALE);
+        icon_box_height = round (window_height * ICON_SCALE);
+        bright_box_width = round (icon_box_width);
+        bright_box_height = round (window_height * 0.05);
+
+        icon_box_x0 = round ((window_width - icon_box_width) / 2);
+        icon_box_y0 = round ((window_height - icon_box_height) / 2);
+        bright_box_x0 = round (icon_box_x0);
+        bright_box_y0 = round (window_height - icon_box_y0 / 2 - bright_box_height);
+
+#if 0
+        g_message ("icon box: w=%f h=%f _x0=%f _y0=%f",
+                   icon_box_width,
+                   icon_box_height,
+                   icon_box_x0,
+                   icon_box_y0);
+        g_message ("brightness box: w=%f h=%f _x0=%f _y0=%f",
+                   bright_box_width,
+                   bright_box_height,
+                   bright_box_x0,
+                   bright_box_y0);
+#endif
+
+        res = render_custom (window,
+                             cr,
+                             icon_box_x0, icon_box_y0,
+                             icon_box_width, icon_box_height);
+        if (! res && g_strcmp0 (window->priv->icon_name, "media-eject") == 0) {
+                /* draw eject symbol */
+                draw_eject (cr,
+                            icon_box_x0, icon_box_y0,
+                            icon_box_width, icon_box_height);
+        }
+
+        if (window->priv->show_level != FALSE) {
+                /* draw volume meter */
+                draw_volume_boxes (window,
+                                   cr,
+                                   (double)window->priv->volume_level / 100.0,
+                                   bright_box_x0,
+                                   bright_box_y0,
+                                   bright_box_width,
+                                   bright_box_height);
+        }
+}
+
+static void
+msd_media_keys_window_draw_when_composited (MsdOsdWindow *osd_window,
+                                              cairo_t      *cr)
+{
+        MsdMediaKeysWindow *window = MSD_MEDIA_KEYS_WINDOW (osd_window);
+
+        switch (window->priv->action) {
+        case MSD_MEDIA_KEYS_WINDOW_ACTION_VOLUME:
+                draw_action_volume (window, cr);
+                break;
+        case MSD_MEDIA_KEYS_WINDOW_ACTION_CUSTOM:
+                draw_action_custom (window, cr);
+                break;
+        default:
+                break;
+        }
+}
+
+static void
+msd_media_keys_window_class_init (MsdMediaKeysWindowClass *klass)
+{
+        MsdOsdWindowClass *osd_window_class = MSD_OSD_WINDOW_CLASS (klass);
+
+        osd_window_class->draw_when_composited = msd_media_keys_window_draw_when_composited;
+}
+
+static void
+msd_media_keys_window_init (MsdMediaKeysWindow *window)
+{
+        window->priv = msd_media_keys_window_get_instance_private (window);
+        if (!msd_osd_window_is_composited (MSD_OSD_WINDOW (window))) {
+                GtkBuilder *builder;
+                const gchar *objects[] = {"acme_box", NULL};
+                GtkWidget *box;
+
+                builder = gtk_builder_new ();
+                gtk_builder_add_objects_from_file (builder,
+                                                   GTKBUILDERDIR "/acme.ui",
+                                                   (char **) objects,
+                                                   NULL);
+
+                window->priv->image = GTK_IMAGE (gtk_builder_get_object (builder, "acme_image"));
+                window->priv->progress = GTK_WIDGET (gtk_builder_get_object (builder, "acme_volume_progressbar"));
+                box = GTK_WIDGET (gtk_builder_get_object (builder, "acme_box"));
+
+                if (box != NULL) {
+                        gtk_container_add (GTK_CONTAINER (window), box);
+                        gtk_widget_show_all (box);
+                }
+
+                /* The builder needs to stay alive until the window
+                   takes ownership of the box (and its children)  */
+                g_object_unref (builder);
+        }
+}
+
+GtkWidget *
+msd_media_keys_window_new (void)
+{
+        return g_object_new (MSD_TYPE_MEDIA_KEYS_WINDOW, NULL);
+}
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/111.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/111.html new file mode 100644 index 0000000..868e663 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/111.html @@ -0,0 +1,807 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
#include <gio/gio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#if defined (__ELF__) && ( __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 6))
+# define SECTION __attribute__ ((section (".gresource.preferences"), aligned (8)))
+#else
+# define SECTION
+#endif
+
+static const SECTION union { const guint8 data[1237]; const double alignment; void * const ptr;}  preferences_resource_data = { {<--- union member 'Anonymous0::alignment' is never used.<--- union member 'Anonymous0::ptr' is never used.
+  0107, 0126, 0141, 0162, 0151, 0141, 0156, 0164, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 
+  0030, 0000, 0000, 0000, 0310, 0000, 0000, 0000, 0000, 0000, 0000, 0050, 0006, 0000, 0000, 0000, 
+  0000, 0000, 0000, 0000, 0001, 0000, 0000, 0000, 0002, 0000, 0000, 0000, 0005, 0000, 0000, 0000, 
+  0005, 0000, 0000, 0000, 0005, 0000, 0000, 0000, 0330, 0224, 0326, 0152, 0005, 0000, 0000, 0000, 
+  0310, 0000, 0000, 0000, 0015, 0000, 0114, 0000, 0330, 0000, 0000, 0000, 0334, 0000, 0000, 0000, 
+  0113, 0120, 0220, 0013, 0003, 0000, 0000, 0000, 0334, 0000, 0000, 0000, 0004, 0000, 0114, 0000, 
+  0340, 0000, 0000, 0000, 0344, 0000, 0000, 0000, 0142, 0213, 0257, 0345, 0000, 0000, 0000, 0000, 
+  0344, 0000, 0000, 0000, 0010, 0000, 0114, 0000, 0354, 0000, 0000, 0000, 0360, 0000, 0000, 0000, 
+  0324, 0265, 0002, 0000, 0377, 0377, 0377, 0377, 0360, 0000, 0000, 0000, 0001, 0000, 0114, 0000, 
+  0364, 0000, 0000, 0000, 0370, 0000, 0000, 0000, 0124, 0167, 0271, 0114, 0002, 0000, 0000, 0000, 
+  0370, 0000, 0000, 0000, 0030, 0000, 0166, 0000, 0020, 0001, 0000, 0000, 0310, 0004, 0000, 0000, 
+  0201, 0321, 0040, 0031, 0001, 0000, 0000, 0000, 0310, 0004, 0000, 0000, 0005, 0000, 0114, 0000, 
+  0320, 0004, 0000, 0000, 0324, 0004, 0000, 0000, 0160, 0157, 0167, 0145, 0162, 0155, 0141, 0156, 
+  0141, 0147, 0145, 0162, 0057, 0000, 0000, 0000, 0002, 0000, 0000, 0000, 0157, 0162, 0147, 0057, 
+  0005, 0000, 0000, 0000, 0155, 0141, 0156, 0141, 0147, 0145, 0162, 0057, 0004, 0000, 0000, 0000, 
+  0057, 0000, 0000, 0000, 0001, 0000, 0000, 0000, 0155, 0141, 0164, 0145, 0055, 0160, 0157, 0167, 
+  0145, 0162, 0055, 0155, 0141, 0156, 0141, 0147, 0145, 0162, 0056, 0141, 0142, 0157, 0165, 0164, 
+  0167, 0006, 0000, 0000, 0001, 0000, 0000, 0000, 0170, 0332, 0155, 0124, 0315, 0156, 0334, 0066, 
+  0020, 0276, 0347, 0051, 0170, 0341, 0251, 0260, 0154, 0007, 0106, 0341, 0164, 0325, 0005, 0274, 
+  0265, 0353, 0042, 0161, 0034, 0303, 0213, 0332, 0155, 0212, 0036, 0106, 0342, 0110, 0242, 0105, 
+  0221, 0052, 0071, 0134, 0131, 0173, 0357, 0233, 0364, 0015, 0012, 0364, 0005, 0334, 0007, 0353, 
+  0120, 0332, 0070, 0273, 0100, 0117, 0234, 0031, 0175, 0342, 0374, 0174, 0337, 0360, 0267, 0213, 
+  0302, 0105, 0372, 0375, 0315, 0105, 0244, 0306, 0371, 0360, 0375, 0205, 0045, 0247, 0055, 0212, 
+  0367, 0120, 0162, 0334, 0221, 0310, 0341, 0151, 0147, 0112, 0327, 0243, 0055, 0202, 0312, 0234, 
+  0257, 0227, 0213, 0004, 0264, 0342, 0041, 0023, 0053, 0067, 0202, 0017, 0215, 0266, 0156, 0043, 
+  0362, 0142, 0166, 0044, 0030, 0062, 0332, 0306, 0347, 0031, 0273, 0362, 0150, 0111, 0374, 0024, 
+  0215, 0141, 0104, 0303, 0307, 0333, 0223, 0323, 0023, 0151, 0364, 0006, 0263, 0322, 0165, 0313, 
+  0305, 0017, 0006, 0273, 0204, 0270, 0301, 0012, 0213, 0215, 0107, 0221, 0227, 0163, 0044, 0063, 
+  0273, 0210, 0234, 0156, 0353, 0064, 0207, 0346, 0077, 0234, 0161, 0135, 0001, 0126, 0074, 0242, 
+  0125, 0374, 0255, 0346, 0137, 0206, 0235, 0051, 0233, 0261, 0367, 0220, 0125, 0176, 0271, 0270, 
+  0144, 0304, 0107, 0010, 0015, 0160, 0142, 0005, 0066, 0353, 0046, 0133, 0126, 0250, 0234, 0207, 
+  0336, 0273, 0047, 0054, 0151, 0056, 0361, 0022, 0255, 0016, 0342, 0332, 0171, 0247, 0254, 0056, 
+  0033, 0344, 0136, 0124, 0012, 0145, 0365, 0327, 0220, 0254, 0073, 0320, 0146, 0056, 0340, 0112, 
+  0015, 0340, 0225, 0130, 0041, 0121, 0020, 0071, 0116, 0236, 0074, 0003, 0133, 0233, 0135, 0117, 
+  0127, 0206, 0163, 0337, 0307, 0030, 0240, 0173, 0371, 0213, 0073, 0342, 0017, 0126, 0052, 0064, 
+  0225, 0316, 0020, 0227, 0213, 0037, 0241, 0320, 0116, 0134, 0371, 0062, 0032, 0015, 0126, 0213, 
+  0334, 0074, 0133, 0030, 0145, 0200, 0002, 0106, 0147, 0347, 0232, 0256, 0307, 0227, 0177, 0174, 
+  0075, 0212, 0025, 0030, 0363, 0362, 0067, 0217, 0216, 0117, 0127, 0217, 0316, 0357, 0027, 0302, 
+  0104, 0265, 0142, 0115, 0210, 0206, 0223, 0060, 0125, 0155, 0070, 0073, 0177, 0367, 0156, 0037, 
+  0161, 0003, 0211, 0320, 0107, 0060, 0055, 0372, 0243, 0213, 0215, 0266, 0300, 0331, 0206, 0311, 
+  0005, 0251, 0021, 0161, 0316, 0166, 0003, 0161, 0242, 0351, 0026, 0172, 0015, 0334, 0023, 0101, 
+  0327, 0163, 0017, 0262, 0362, 0214, 0110, 0303, 0374, 0010, 0276, 0104, 0043, 0056, 0365, 0123, 
+  0033, 0310, 0363, 0045, 0335, 0024, 0310, 0324, 0070, 0371, 0373, 0051, 0031, 0112, 0232, 0311, 
+  0321, 0135, 0357, 0061, 0204, 0011, 0312, 0001, 0331, 0001, 0341, 0221, 0302, 0320, 0222, 0353, 
+  0347, 0254, 0037, 0201, 0110, 0254, 0173, 0210, 0106, 0115, 0054, 0166, 0341, 0213, 0175, 0362, 
+  0355, 0341, 0215, 0104, 0015, 0016, 0342, 0316, 0021, 0101, 0215, 0351, 0306, 0051, 0320, 0317, 
+  0276, 0324, 0226, 0033, 0053, 0065, 0141, 0331, 0354, 0176, 0320, 0055, 0212, 0153, 0050, 0274, 
+  0346, 0232, 0363, 0216, 0275, 0254, 0236, 0075, 0251, 0040, 0034, 0131, 0244, 0355, 0200, 0276, 
+  0045, 0204, 0056, 0123, 0070, 0341, 0033, 0316, 0046, 0326, 0114, 0064, 0205, 0244, 0345, 0016, 
+  0203, 0213, 0261, 0336, 0257, 0342, 0026, 0115, 0160, 0111, 0122, 0376, 0217, 0210, 0334, 0226, 
+  0355, 0034, 0153, 0152, 0162, 0016, 0140, 0221, 0312, 0006, 0254, 0113, 0362, 0114, 0126, 0320, 
+  0044, 0032, 0242, 0076, 0174, 0167, 0174, 0134, 0153, 0152, 0142, 0221, 0160, 0307, 0026, 0146, 
+  0324, 0342, 0016, 0012, 0343, 0230, 0146, 0137, 0162, 0171, 0074, 0330, 0120, 0272, 0101, 0172, 
+  0035, 0060, 0366, 0031, 0027, 0272, 0134, 0334, 0241, 0362, 0116, 0314, 0123, 0305, 0355, 0321, 
+  0373, 0044, 0032, 0221, 0367, 0051, 0332, 0075, 0311, 0330, 0145, 0030, 0030, 0244, 0035, 0171, 
+  0161, 0351, 0377, 0375, 0223, 0347, 0330, 0047, 0107, 0171, 0070, 0050, 0377, 0336, 0025, 0350, 
+  0111, 0254, 0342, 0223, 0310, 0375, 0144, 0147, 0105, 0174, 0372, 0037, 0304, 0055, 0260, 0354, 
+  0166, 0220, 0303, 0265, 0277, 0167, 0243, 0370, 0314, 0125, 0247, 0024, 0121, 0065, 0147, 0147, 
+  0247, 0347, 0373, 0377, 0257, 0301, 0052, 0364, 0142, 0075, 0040, 0172, 0236, 0217, 0266, 0225, 
+  0366, 0232, 0016, 0020, 0274, 0117, 0055, 0153, 0343, 0302, 0340, 0063, 0262, 0356, 0203, 0363, 
+  0031, 0114, 0266, 0354, 0320, 0015, 0076, 0363, 0221, 0101, 0204, 0025, 0257, 0317, 0032, 0307, 
+  0212, 0031, 0123, 0214, 0102, 0135, 0341, 0067, 0212, 0167, 0260, 0070, 0075, 0012, 0143, 0040, 
+  0354, 0302, 0356, 0276, 0011, 0352, 0304, 0007, 0340, 0215, 0106, 0012, 0111, 0272, 0141, 0216, 
+  0311, 0366, 0065, 0366, 0212, 0355, 0033, 0264, 0342, 0103, 0322, 0171, 0036, 0272, 0226, 0117, 
+  0071, 0037, 0363, 0234, 0031, 0260, 0101, 0361, 0031, 0103, 0331, 0114, 0267, 0154, 0160, 0233, 
+  0354, 0267, 0373, 0015, 0074, 0350, 0222, 0234, 0117, 0371, 0220, 0101, 0233, 0066, 0235, 0322, 
+  0243, 0152, 0140, 0367, 0066, 0075, 0030, 0120, 0342, 0223, 0067, 0223, 0206, 0234, 0015, 0304, 
+  0133, 0146, 0013, 0367, 0074, 0165, 0366, 0250, 0015, 0163, 0327, 0211, 0225, 0167, 0203, 0025, 
+  0371, 0060, 0273, 0222, 0307, 0024, 0150, 0104, 0360, 0231, 0126, 0031, 0044, 0234, 0063, 0125, 
+  0235, 0306, 0374, 0263, 0141, 0321, 0246, 0162, 0322, 0356, 0110, 0017, 0033, 0324, 0064, 0011, 
+  0366, 0061, 0212, 0137, 0064, 0070, 0342, 0347, 0103, 0344, 0043, 0222, 0016, 0007, 0163, 0376, 
+  0025, 0240, 0345, 0012, 0326, 0150, 0132, 0067, 0150, 0332, 0062, 0046, 0174, 0261, 0145, 0014, 
+  0114, 0117, 0306, 0362, 0346, 0005, 0256, 0230, 0127, 0234, 0333, 0237, 0211, 0345, 0133, 0355, 
+  0220, 0250, 0331, 0046, 0067, 0173, 0236, 0335, 0163, 0271, 0245, 0351, 0151, 0313, 0112, 0273, 
+  0134, 0124, 0115, 0054, 0033, 0047, 0362, 0371, 0334, 0317, 0153, 0142, 0213, 0025, 0313, 0122, 
+  0225, 0374, 0312, 0274, 0332, 0262, 0211, 0241, 0371, 0012, 0172, 0363, 0037, 0300, 0316, 0135, 
+  0234, 0000, 0050, 0165, 0165, 0141, 0171, 0051, 0155, 0141, 0164, 0145, 0057, 0000, 0000, 0000, 
+  0000, 0000, 0000, 0000
+} };
+
+static GStaticResource static_resource = { preferences_resource_data.data, sizeof (preferences_resource_data.data) - 1 /* nul terminator */, NULL, NULL, NULL };
+
+G_MODULE_EXPORT
+GResource *preferences_get_resource (void);
+GResource *preferences_get_resource (void)
+{
+  return g_static_resource_get_resource (&static_resource);
+}
+/* GLIB - Library of useful routines for C programming
+ * Copyright (C) 1995-1997  Peter Mattis, Spencer Kimball and Josh MacDonald
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * Modified by the GLib Team and others 1997-2000.  See the AUTHORS
+ * file for a list of people on the GLib Team.  See the ChangeLog
+ * files for a list of changes.  These files are distributed with
+ * GLib at ftp://ftp.gtk.org/pub/gtk/.
+ */
+
+#ifndef __G_CONSTRUCTOR_H__
+#define __G_CONSTRUCTOR_H__
+
+/*
+  If G_HAS_CONSTRUCTORS is true then the compiler support *both* constructors and
+  destructors, in a usable way, including e.g. on library unload. If not you're on
+  your own.
+
+  Some compilers need #pragma to handle this, which does not work with macros,
+  so the way you need to use this is (for constructors):
+
+  #ifdef G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA
+  #pragma G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(my_constructor)
+  #endif
+  G_DEFINE_CONSTRUCTOR(my_constructor)
+  static void my_constructor(void) {
+   ...
+  }
+
+*/
+
+#ifndef __GTK_DOC_IGNORE__
+
+#if  __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
+
+#define G_HAS_CONSTRUCTORS 1
+
+#define G_DEFINE_CONSTRUCTOR(_func) static void __attribute__((constructor)) _func (void);
+#define G_DEFINE_DESTRUCTOR(_func) static void __attribute__((destructor)) _func (void);
+
+#elif defined (_MSC_VER) && (_MSC_VER >= 1500)
+/* Visual studio 2008 and later has _Pragma */
+
+/*
+ * Only try to include gslist.h if not already included via glib.h,
+ * so that items using gconstructor.h outside of GLib (such as
+ * GResources) continue to build properly.
+ */
+#ifndef __G_LIB_H__
+#include "gslist.h"
+#endif
+
+#include <stdlib.h>
+
+#define G_HAS_CONSTRUCTORS 1
+
+/* We do some weird things to avoid the constructors being optimized
+ * away on VS2015 if WholeProgramOptimization is enabled. First we
+ * make a reference to the array from the wrapper to make sure its
+ * references. Then we use a pragma to make sure the wrapper function
+ * symbol is always included at the link stage. Also, the symbols
+ * need to be extern (but not dllexport), even though they are not
+ * really used from another object file.
+ */
+
+/* We need to account for differences between the mangling of symbols
+ * for x86 and x64/ARM/ARM64 programs, as symbols on x86 are prefixed
+ * with an underscore but symbols on x64/ARM/ARM64 are not.
+ */
+#ifdef _M_IX86
+#define G_MSVC_SYMBOL_PREFIX "_"
+#else
+#define G_MSVC_SYMBOL_PREFIX ""
+#endif
+
+#define G_DEFINE_CONSTRUCTOR(_func) G_MSVC_CTOR (_func, G_MSVC_SYMBOL_PREFIX)
+#define G_DEFINE_DESTRUCTOR(_func) G_MSVC_DTOR (_func, G_MSVC_SYMBOL_PREFIX)
+
+#define G_MSVC_CTOR(_func,_sym_prefix) \
+  static void _func(void); \
+  extern int (* _array ## _func)(void);              \
+  int _func ## _wrapper(void);              \
+  int _func ## _wrapper(void) { _func(); g_slist_find (NULL,  _array ## _func); return 0; } \
+  __pragma(comment(linker,"/include:" _sym_prefix # _func "_wrapper")) \
+  __pragma(section(".CRT$XCU",read)) \
+  __declspec(allocate(".CRT$XCU")) int (* _array ## _func)(void) = _func ## _wrapper;
+
+#define G_MSVC_DTOR(_func,_sym_prefix) \
+  static void _func(void); \
+  extern int (* _array ## _func)(void);              \
+  int _func ## _constructor(void);              \
+  int _func ## _constructor(void) { atexit (_func); g_slist_find (NULL,  _array ## _func); return 0; } \
+   __pragma(comment(linker,"/include:" _sym_prefix # _func "_constructor")) \
+  __pragma(section(".CRT$XCU",read)) \
+  __declspec(allocate(".CRT$XCU")) int (* _array ## _func)(void) = _func ## _constructor;
+
+#elif defined (_MSC_VER)
+
+#define G_HAS_CONSTRUCTORS 1
+
+/* Pre Visual studio 2008 must use #pragma section */
+#define G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA 1
+#define G_DEFINE_DESTRUCTOR_NEEDS_PRAGMA 1
+
+#define G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(_func) \
+  section(".CRT$XCU",read)
+#define G_DEFINE_CONSTRUCTOR(_func) \
+  static void _func(void); \
+  static int _func ## _wrapper(void) { _func(); return 0; } \
+  __declspec(allocate(".CRT$XCU")) static int (*p)(void) = _func ## _wrapper;
+
+#define G_DEFINE_DESTRUCTOR_PRAGMA_ARGS(_func) \
+  section(".CRT$XCU",read)
+#define G_DEFINE_DESTRUCTOR(_func) \
+  static void _func(void); \
+  static int _func ## _constructor(void) { atexit (_func); return 0; } \
+  __declspec(allocate(".CRT$XCU")) static int (* _array ## _func)(void) = _func ## _constructor;
+
+#elif defined(__SUNPRO_C)
+
+/* This is not tested, but i believe it should work, based on:
+ * http://opensource.apple.com/source/OpenSSL098/OpenSSL098-35/src/fips/fips_premain.c
+ */
+
+#define G_HAS_CONSTRUCTORS 1
+
+#define G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA 1
+#define G_DEFINE_DESTRUCTOR_NEEDS_PRAGMA 1
+
+#define G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(_func) \
+  init(_func)
+#define G_DEFINE_CONSTRUCTOR(_func) \
+  static void _func(void);
+
+#define G_DEFINE_DESTRUCTOR_PRAGMA_ARGS(_func) \
+  fini(_func)
+#define G_DEFINE_DESTRUCTOR(_func) \
+  static void _func(void);
+
+#else
+
+/* constructors not supported for this compiler */
+
+#endif
+
+#endif /* __GTK_DOC_IGNORE__ */
+#endif /* __G_CONSTRUCTOR_H__ */
+
+#ifdef G_HAS_CONSTRUCTORS
+
+#ifdef G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA
+#pragma G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(preferencesresource_constructor)
+#endif
+G_DEFINE_CONSTRUCTOR(preferencesresource_constructor)
+#ifdef G_DEFINE_DESTRUCTOR_NEEDS_PRAGMA
+#pragma G_DEFINE_DESTRUCTOR_PRAGMA_ARGS(preferencesresource_destructor)
+#endif
+G_DEFINE_DESTRUCTOR(preferencesresource_destructor)
+
+#else
+#warning "Constructor not supported on this compiler, linking in resources will not work"
+#endif
+
+static void preferencesresource_constructor (void)
+{
+  g_static_resource_init (&static_resource);
+}
+
+static void preferencesresource_destructor (void)
+{
+  g_static_resource_fini (&static_resource);
+}
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/112.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/112.html new file mode 100644 index 0000000..4835e55 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/112.html @@ -0,0 +1,1047 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
#include <gio/gio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#if defined (__ELF__) && ( __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 6))
+# define SECTION __attribute__ ((section (".gresource.preferences"), aligned (8)))
+#else
+# define SECTION
+#endif
+
+static const SECTION union { const guint8 data[3161]; const double alignment; void * const ptr;}  preferences_resource_data = { {<--- union member 'Anonymous0::alignment' is never used.<--- union member 'Anonymous0::ptr' is never used.
+  0107, 0126, 0141, 0162, 0151, 0141, 0156, 0164, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 
+  0030, 0000, 0000, 0000, 0310, 0000, 0000, 0000, 0000, 0000, 0000, 0050, 0006, 0000, 0000, 0000, 
+  0000, 0000, 0000, 0000, 0001, 0000, 0000, 0000, 0002, 0000, 0000, 0000, 0004, 0000, 0000, 0000, 
+  0005, 0000, 0000, 0000, 0005, 0000, 0000, 0000, 0330, 0224, 0326, 0152, 0005, 0000, 0000, 0000, 
+  0310, 0000, 0000, 0000, 0015, 0000, 0114, 0000, 0330, 0000, 0000, 0000, 0334, 0000, 0000, 0000, 
+  0113, 0120, 0220, 0013, 0002, 0000, 0000, 0000, 0334, 0000, 0000, 0000, 0004, 0000, 0114, 0000, 
+  0340, 0000, 0000, 0000, 0344, 0000, 0000, 0000, 0324, 0265, 0002, 0000, 0377, 0377, 0377, 0377, 
+  0344, 0000, 0000, 0000, 0001, 0000, 0114, 0000, 0350, 0000, 0000, 0000, 0354, 0000, 0000, 0000, 
+  0266, 0364, 0300, 0305, 0004, 0000, 0000, 0000, 0354, 0000, 0000, 0000, 0014, 0000, 0166, 0000, 
+  0370, 0000, 0000, 0000, 0073, 0014, 0000, 0000, 0171, 0022, 0006, 0206, 0000, 0000, 0000, 0000, 
+  0073, 0014, 0000, 0000, 0014, 0000, 0114, 0000, 0110, 0014, 0000, 0000, 0114, 0014, 0000, 0000, 
+  0201, 0321, 0040, 0031, 0001, 0000, 0000, 0000, 0114, 0014, 0000, 0000, 0005, 0000, 0114, 0000, 
+  0124, 0014, 0000, 0000, 0130, 0014, 0000, 0000, 0160, 0157, 0167, 0145, 0162, 0155, 0141, 0156, 
+  0141, 0147, 0145, 0162, 0057, 0000, 0000, 0000, 0004, 0000, 0000, 0000, 0157, 0162, 0147, 0057, 
+  0005, 0000, 0000, 0000, 0057, 0000, 0000, 0000, 0001, 0000, 0000, 0000, 0147, 0160, 0155, 0055, 
+  0160, 0162, 0145, 0146, 0163, 0056, 0165, 0151, 0134, 0021, 0001, 0000, 0001, 0000, 0000, 0000, 
+  0170, 0332, 0355, 0135, 0155, 0163, 0342, 0070, 0022, 0376, 0076, 0277, 0102, 0347, 0257, 0127, 
+  0114, 0002, 0331, 0173, 0251, 0255, 0204, 0255, 0354, 0114, 0315, 0334, 0325, 0335, 0316, 0116, 
+  0355, 0314, 0326, 0176, 0164, 0011, 0133, 0200, 0026, 0041, 0371, 0044, 0023, 0302, 0277, 0077, 
+  0311, 0066, 0304, 0200, 0261, 0345, 0067, 0300, 0246, 0077, 0005, 0202, 0045, 0253, 0133, 0352, 
+  0307, 0217, 0272, 0133, 0355, 0307, 0237, 0136, 0227, 0014, 0275, 0020, 0251, 0250, 0340, 0117, 
+  0316, 0360, 0375, 0275, 0203, 0010, 0367, 0204, 0117, 0371, 0354, 0311, 0371, 0375, 0373, 0247, 
+  0301, 0077, 0235, 0237, 0306, 0357, 0036, 0377, 0062, 0030, 0240, 0317, 0204, 0023, 0211, 0103, 
+  0342, 0243, 0065, 0015, 0347, 0150, 0306, 0260, 0117, 0320, 0303, 0373, 0321, 0350, 0375, 0020, 
+  0015, 0006, 0372, 0042, 0312, 0103, 0042, 0247, 0330, 0043, 0343, 0167, 0010, 0075, 0112, 0362, 
+  0277, 0025, 0225, 0104, 0041, 0106, 0047, 0117, 0316, 0054, 0134, 0374, 0325, 0171, 0273, 0221, 
+  0151, 0346, 0334, 0105, 0327, 0211, 0311, 0237, 0304, 0013, 0221, 0307, 0260, 0122, 0117, 0316, 
+  0347, 0160, 0361, 0354, 0377, 0271, 0122, 0341, 0222, 0360, 0320, 0101, 0324, 0177, 0162, 0360, 
+  0356, 0373, 0203, 0143, 0132, 0350, 0066, 0201, 0024, 0001, 0221, 0341, 0006, 0161, 0274, 0044, 
+  0117, 0316, 0052, 0320, 0337, 0234, 0361, 0360, 0376, 0376, 0361, 0156, 0373, 0123, 0366, 0225, 
+  0057, 0230, 0255, 0210, 0063, 0376, 0141, 0130, 0164, 0241, 0012, 0111, 0340, 0122, 0356, 0111, 
+  0022, 0015, 0144, 0134, 0330, 0040, 0300, 0063, 0222, 0156, 0360, 0267, 0303, 0301, 0074, 0336, 
+  0305, 0222, 0146, 0013, 0375, 0357, 0245, 0156, 0037, 0313, 0113, 0315, 0107, 0327, 0143, 0102, 
+  0221, 0023, 0362, 0276, 0120, 0105, 0047, 0114, 0377, 0372, 0135, 0256, 0110, 0321, 0300, 0074, 
+  0314, 0335, 0251, 0360, 0126, 0312, 0031, 0177, 0302, 0114, 0025, 0136, 0117, 0075, 0301, 0135, 
+  0363, 0321, 0031, 0257, 0051, 0367, 0305, 0172, 0020, 0015, 0245, 0226, 0060, 0163, 0302, 0202, 
+  0013, 0313, 0142, 0206, 0060, 0230, 0110, 0261, 0126, 0104, 0226, 0221, 0345, 0043, 0305, 0114, 
+  0314, 0142, 0141, 0374, 0350, 0263, 0033, 0110, 0062, 0045, 0122, 0233, 0011, 0121, 0116, 0063, 
+  0343, 0014, 0151, 0250, 0125, 0200, 0102, 0211, 0271, 0142, 0070, 0304, 0132, 0041, 0117, 0316, 
+  0306, 0164, 0377, 0125, 0254, 0211, 0104, 0277, 0140, 0256, 0325, 0150, 0026, 0026, 0372, 0372, 
+  0166, 0363, 0022, 0322, 0057, 0265, 0335, 0016, 0002, 0323, 0327, 0140, 0031, 0365, 0045, 0013, 
+  0207, 0264, 0011, 0364, 0274, 0121, 0263, 0224, 0143, 0261, 0217, 0032, 0050, 0072, 0343, 0230, 
+  0045, 0227, 0373, 0204, 0021, 0175, 0013, 0362, 0022, 0231, 0355, 0034, 0163, 0237, 0021, 0371, 
+  0344, 0350, 0001, 0034, 0053, 0315, 0215, 0057, 0166, 0223, 0213, 0325, 0032, 0153, 0373, 0325, 
+  0352, 0345, 0042, 0206, 0004, 0335, 0267, 0067, 0247, 0314, 0217, 0077, 0233, 0241, 0061, 0015, 
+  0052, 0163, 0301, 0174, 0042, 0267, 0027, 0334, 0245, 0256, 0210, 0257, 0106, 0021, 0374, 0350, 
+  0021, 0015, 0242, 0257, 0172, 0145, 0115, 0304, 0253, 0263, 0353, 0343, 0150, 0142, 0177, 0116, 
+  0375, 0132, 0176, 0006, 0263, 0332, 0010, 0111, 0265, 0100, 0070, 0324, 0010, 0347, 0214, 0065, 
+  0324, 0205, 0324, 0303, 0314, 0246, 0241, 0012, 0260, 0247, 0001, 0327, 0031, 0217, 0062, 0257, 
+  0316, 0026, 0017, 0173, 0346, 0106, 0056, 0226, 0004, 0247, 0344, 0310, 0224, 0164, 0025, 0206, 
+  0202, 0357, 0313, 0133, 0125, 0346, 0254, 0166, 0014, 0157, 0304, 0052, 0164, 0125, 0270, 0061, 
+  0166, 0114, 0270, 0177, 0262, 0341, 0336, 0264, 0026, 0015, 0070, 0266, 0271, 0111, 0364, 0071, 
+  0215, 0040, 0371, 0103, 0231, 0020, 0226, 0151, 0110, 0356, 0277, 0164, 0017, 0247, 0006, 0126, 
+  0032, 0230, 0054, 0325, 0130, 0266, 0251, 0044, 0036, 0241, 0057, 0221, 0205, 0114, 0361, 0212, 
+  0205, 0345, 0173, 0210, 0360, 0326, 0031, 0277, 0301, 0156, 0231, 0306, 0053, 0105, 0334, 0025, 
+  0327, 0126, 0306, 0050, 0257, 0040, 0070, 0146, 0153, 0274, 0121, 0256, 0232, 0213, 0265, 0233, 
+  0214, 0243, 0260, 0213, 0075, 0020, 0361, 0030, 0365, 0026, 0304, 0337, 0307, 0217, 0324, 0002, 
+  0160, 0167, 0027, 0144, 0140, 0106, 0252, 0323, 0024, 0240, 0357, 0217, 0027, 0173, 0013, 0155, 
+  0147, 0305, 0222, 0220, 0327, 0100, 0217, 0240, 0274, 0006, 0246, 0224, 0261, 0362, 0255, 0002, 
+  0241, 0150, 0014, 0032, 0367, 0247, 0233, 0351, 0137, 0262, 0106, 0277, 0007, 0204, 0015, 0330, 
+  0131, 0262, 0360, 0124, 0055, 0133, 0373, 0005, 0057, 0010, 0372, 0030, 0367, 0324, 0067, 0223, 
+  0353, 0356, 0342, 0032, 0136, 0174, 0161, 0245, 0071, 0155, 0105, 0024, 0377, 0160, 0314, 0105, 
+  0173, 0017, 0343, 0136, 0131, 0231, 0257, 0031, 0307, 0043, 0141, 0172, 0017, 0344, 0243, 0046, 
+  0154, 0055, 0113, 0374, 0154, 0321, 0117, 0211, 0135, 0212, 0306, 0305, 0062, 0227, 0152, 0122, 
+  0370, 0344, 0312, 0020, 0366, 0110, 0320, 0143, 0100, 0071, 0006, 0223, 0057, 0042, 0044, 0023, 
+  0041, 0026, 0061, 0234, 0360, 0344, 0133, 0306, 0116, 0254, 0026, 0014, 0124, 0204, 0200, 0303, 
+  0146, 0113, 0054, 0147, 0224, 0273, 0214, 0114, 0215, 0343, 0140, 0124, 0262, 0231, 0244, 0263, 
+  0171, 0225, 0166, 0241, 0010, 0052, 0264, 0232, 0010, 0155, 0225, 0313, 0334, 0206, 0266, 0170, 
+  0257, 0367, 0027, 0061, 0330, 0213, 0127, 0027, 0173, 0316, 0171, 0240, 0071, 0167, 0271, 0326, 
+  0230, 0234, 0072, 0023, 0124, 0175, 0222, 0152, 0115, 0124, 0255, 0055, 0151, 0376, 0154, 0147, 
+  0317, 0370, 0047, 0151, 0174, 0013, 0321, 0234, 0117, 0315, 0107, 0075, 0353, 0156, 0274, 0053, 
+  0315, 0242, 0217, 0265, 0126, 0100, 0335, 0125, 0160, 0222, 0145, 0270, 0257, 0230, 0351, 0107, 
+  0127, 0056, 0365, 0076, 0261, 0151, 0237, 0143, 0137, 0077, 0040, 0215, 0237, 0304, 0031, 0163, 
+  0301, 0213, 0357, 0177, 0122, 0265, 0331, 0352, 0175, 0066, 0003, 0213, 0235, 0211, 0047, 0332, 
+  0324, 0124, 0150, 0023, 0112, 0315, 0124, 0254, 0266, 0055, 0067, 0300, 0276, 0037, 0371, 0064, 
+  0362, 0027, 0254, 0235, 0162, 0154, 0074, 0070, 0255, 0250, 0247, 0051, 0025, 0025, 0101, 0302, 
+  0337, 0153, 0166, 0262, 0105, 0207, 0312, 0375, 0224, 0006, 0212, 0134, 0323, 0330, 0372, 0263, 
+  0354, 0207, 0123, 0070, 0375, 0126, 0017, 0035, 0327, 0023, 0313, 0140, 0025, 0232, 0140, 0100, 
+  0101, 0127, 0015, 0255, 0215, 0046, 0327, 0107, 0256, 0046, 0355, 0254, 0250, 0234, 0072, 0263, 
+  0125, 0372, 0337, 0170, 0363, 0145, 0224, 0032, 0043, 0144, 0071, 0265, 0066, 0252, 0332, 0246, 
+  0325, 0133, 0156, 0263, 0371, 0165, 0245, 0365, 0222, 0110, 0216, 0102, 0201, 0134, 0305, 0010, 
+  0011, 0320, 0172, 0116, 0070, 0242, 0334, 0074, 0351, 0136, 0010, 0232, 0012, 0371, 0143, 0335, 
+  0041, 0224, 0334, 0257, 0131, 0341, 0002, 0047, 0113, 0301, 0251, 0347, 0256, 0251, 0077, 0043, 
+  0372, 0021, 0242, 0005, 0231, 0210, 0003, 0053, 0251, 0173, 0023, 0353, 0147, 0247, 0335, 0266, 
+  0056, 0373, 0226, 0247, 0266, 0172, 0066, 0003, 0264, 0332, 0007, 0331, 0166, 0146, 0267, 0047, 
+  0264, 0351, 0311, 0312, 0341, 0227, 0255, 0071, 0153, 0165, 0144, 0372, 0156, 0232, 0306, 0212, 
+  0017, 0146, 0121, 0151, 0014, 0376, 0116, 0136, 0223, 0140, 0155, 0326, 0062, 0353, 0076, 0152, 
+  0234, 0177, 0305, 0066, 0041, 0163, 0033, 0013, 0166, 0170, 0351, 0005, 0153, 0073, 0025, 0366, 
+  0323, 0320, 0030, 0150, 0064, 0243, 0377, 0106, 0300, 0302, 0122, 0357, 0126, 0072, 0157, 0212, 
+  0233, 0061, 0352, 0003, 0055, 0153, 0224, 0226, 0331, 0151, 0264, 0107, 0214, 0354, 0017, 0103, 
+  0275, 0030, 0016, 0364, 0236, 0011, 0151, 0341, 0021, 0125, 0132, 0103, 0256, 0120, 0304, 0357, 
+  0034, 0007, 0323, 0303, 0007, 0372, 0005, 0364, 0253, 0105, 0372, 0325, 0013, 0164, 0000, 0346, 
+  0005, 0314, 0353, 0362, 0314, 0153, 0170, 0011, 0346, 0125, 0254, 0357, 0202, 0116, 0362, 0073, 
+  0310, 0155, 0234, 0344, 0234, 0031, 0347, 0366, 0366, 0171, 0154, 0357, 0270, 0316, 0242, 0052, 
+  0111, 0134, 0300, 0125, 0372, 0322, 0316, 0371, 0263, 0117, 0362, 0221, 0347, 0130, 0052, 0253, 
+  0116, 0161, 0030, 0112, 0072, 0321, 0373, 0141, 0225, 0073, 0351, 0273, 0313, 0222, 0233, 0257, 
+  0111, 0024, 0156, 0102, 0121, 0346, 0262, 0341, 0322, 0314, 0077, 0016, 0224, 0247, 0147, 0265, 
+  0370, 0076, 0225, 0327, 0105, 0136, 0303, 0174, 0253, 0257, 0145, 0351, 0325, 0255, 0273, 0362, 
+  0223, 0077, 0307, 0212, 0117, 0352, 0247, 0156, 0350, 0314, 0247, 0052, 0140, 0170, 0003, 0241, 
+  0063, 0010, 0235, 0101, 0350, 0354, 0046, 0242, 0125, 0371, 0026, 0017, 0136, 0221, 0152, 0124, 
+  0303, 0136, 0253, 0075, 0213, 0125, 0155, 0045, 0067, 0261, 0252, 0276, 0204, 0252, 0022, 0221, 
+  0300, 0125, 0002, 0256, 0222, 0026, 0135, 0045, 0275, 0201, 0014, 0160, 0227, 0200, 0273, 0004, 
+  0002, 0125, 0065, 0151, 0331, 0044, 0312, 0360, 0344, 0104, 0251, 0316, 0062, 0263, 0206, 0051, 
+  0125, 0051, 0215, 0364, 0210, 0125, 0175, 0043, 0041, 0332, 0222, 0252, 0224, 0022, 0064, 0301, 
+  0352, 0004, 0221, 0232, 0053, 0275, 0055, 0042, 0373, 0023, 0010, 0114, 0012, 0230, 0124, 0055, 
+  0174, 0370, 0146, 0326, 0124, 0214, 0017, 0131, 0353, 0353, 0312, 0000, 0242, 0211, 0356, 0336, 
+  0012, 0120, 0070, 0343, 0124, 0061, 0212, 0272, 0335, 0112, 0241, 0355, 0137, 0123, 0317, 0031, 
+  0065, 0307, 0055, 0207, 0100, 0364, 0200, 0350, 0101, 0134, 0254, 0125, 0242, 0367, 0141, 0116, 
+  0274, 0275, 0163, 0251, 0236, 0371, 0107, 0162, 0060, 0361, 0155, 0033, 0250, 0377, 0056, 0053, 
+  0060, 0277, 0323, 0064, 0342, 0043, 0165, 0227, 0073, 0036, 0021, 0373, 0144, 0174, 0126, 0153, 
+  0012, 0332, 0140, 0231, 0165, 0273, 0072, 0076, 0365, 0132, 0173, 0275, 0316, 0023, 0262, 0241, 
+  0102, 0054, 0303, 0072, 0035, 0325, 0144, 0133, 0207, 0335, 0371, 0022, 0257, 0135, 0312, 0175, 
+  0352, 0341, 0120, 0310, 0262, 0375, 0165, 0016, 0060, 0152, 0167, 0143, 0165, 0060, 0026, 0042, 
+  0351, 0145, 0334, 0333, 0075, 0213, 0244, 0177, 0264, 0367, 0363, 0102, 0044, 0375, 0252, 0042, 
+  0351, 0303, 0246, 0043, 0351, 0331, 0272, 0311, 0251, 0105, 0221, 0030, 0227, 0136, 0116, 0116, 
+  0361, 0061, 0345, 0043, 0223, 0322, 0315, 0256, 0370, 0270, 0362, 0151, 0213, 0371, 0225, 0243, 
+  0347, 0017, 0050, 0252, 0017, 0326, 0146, 0265, 0022, 0243, 0036, 0253, 0247, 0100, 0053, 0065, 
+  0104, 0322, 0236, 0271, 0211, 0266, 0107, 0042, 0067, 0160, 0260, 0374, 0366, 0016, 0226, 0047, 
+  0123, 0017, 0247, 0313, 0041, 0105, 0006, 0122, 0144, 0054, 0235, 0301, 0160, 0272, 0274, 0331, 
+  0300, 0320, 0026, 0203, 0340, 0210, 0171, 0363, 0041, 0246, 0012, 0272, 0355, 0131, 0356, 0116, 
+  0377, 0316, 0231, 0037, 0316, 0051, 0004, 0236, 0040, 0360, 0324, 0126, 0012, 0117, 0377, 0360, 
+  0003, 0342, 0073, 0020, 0337, 0201, 0104, 0236, 0046, 0370, 0032, 0034, 0073, 0157, 0205, 0252, 
+  0301, 0331, 0363, 0216, 0236, 0075, 0117, 0115, 0040, 0120, 0062, 0240, 0144, 0155, 0123, 0062, 
+  0070, 0205, 0016, 0154, 0014, 0330, 0330, 0055, 0146, 0333, 0024, 0073, 0120, 0201, 0170, 0331, 
+  0023, 0257, 0341, 0150, 0170, 0203, 0174, 0053, 0171, 0212, 0240, 0100, 0270, 0346, 0075, 0110, 
+  0206, 0163, 0111, 0032, 0171, 0217, 0331, 0006, 0061, 0261, 0356, 0250, 0113, 0054, 0221, 0001, 
+  0370, 0027, 0360, 0257, 0326, 0135, 0142, 0311, 0132, 0003, 0022, 0006, 0044, 0014, 0110, 0030, 
+  0044, 0060, 0226, 0156, 0334, 0154, 0002, 0343, 0101, 0046, 0007, 0324, 0003, 0202, 0054, 0106, 
+  0250, 0007, 0224, 0223, 0361, 0004, 0105, 0201, 0040, 0343, 0011, 0062, 0236, 0354, 0366, 0135, 
+  0220, 0361, 0004, 0076, 0233, 0353, 0014, 0226, 0101, 0111, 0242, 0276, 0224, 0044, 0072, 0230, 
+  0121, 0360, 0340, 0200, 0007, 0247, 0155, 0017, 0016, 0024, 0047, 0002, 0007, 0016, 0070, 0160, 
+  0156, 0065, 0247, 0051, 0367, 0314, 0372, 0001, 0104, 0270, 0222, 0370, 0053, 0217, 0064, 0172, 
+  0166, 0335, 0375, 0055, 0352, 0023, 0115, 0264, 0046, 0230, 0161, 0075, 0240, 0152, 0265, 0144, 
+  0340, 0004, 0073, 0234, 0140, 0277, 0034, 0174, 0064, 0170, 0202, 0175, 0330, 0143, 0374, 0200, 
+  0302, 0027, 0000, 0033, 0000, 0033, 0120, 0370, 0342, 0172, 0343, 0106, 0120, 0375, 0002, 0342, 
+  0106, 0275, 0256, 0176, 0321, 0120, 0334, 0150, 0101, 0066, 0023, 0201, 0245, 0017, 0201, 0043, 
+  0010, 0034, 0101, 0340, 0010, 0002, 0107, 0155, 0007, 0216, 0254, 0266, 0031, 0133, 0120, 0152, 
+  0323, 0117, 0261, 0275, 0307, 0233, 0303, 0002, 0266, 0033, 0260, 0335, 0000, 0057, 0005, 0154, 
+  0067, 0252, 0154, 0067, 0026, 0044, 0217, 0105, 0165, 0160, 0247, 0361, 0237, 0004, 0036, 0141, 
+  0253, 0321, 0271, 0255, 0306, 0350, 0074, 0205, 0366, 0312, 0024, 0207, 0263, 0302, 0233, 0362, 
+  0205, 0341, 0352, 0027, 0364, 0273, 0362, 0132, 0161, 0271, 0125, 0375, 0176, 0116, 0316, 0274, 
+  0264, 0136, 0332, 0317, 0362, 0151, 0161, 0275, 0025, 0001, 0127, 0201, 0202, 0152, 0200, 0067, 
+  0122, 0015, 0020, 0374, 0030, 0340, 0307, 0150, 0333, 0217, 0361, 0131, 0026, 0036, 0126, 0007, 
+  0107, 0206, 0365, 0066, 0125, 0257, 0345, 0012, 0376, 0207, 0103, 0325, 0010, 0266, 0132, 0162, 
+  0267, 0102, 0062, 0147, 0125, 0117, 0306, 0021, 0237, 0320, 0117, 0231, 0336, 0025, 0375, 0073, 
+  0163, 0061, 0272, 0226, 0335, 0004, 0247, 0323, 0065, 0323, 0163, 0127, 0347, 0016, 0025, 0362, 
+  0064, 0333, 0367, 0076, 0104, 0260, 0250, 0311, 0042, 0366, 0346, 0045, 0363, 0040, 0217, 0050, 
+  0235, 0010, 0252, 0164, 0164, 0015, 0371, 0015, 0231, 0346, 0312, 0304, 0272, 0377, 0226, 0032, 
+  0035, 0220, 0377, 0375, 0353, 0067, 0024, 0210, 0344, 0154, 0074, 0163, 0113, 0236, 0210, 0277, 
+  0250, 0135, 0352, 0111, 0002, 0223, 0264, 0062, 0311, 0141, 0017, 0114, 0262, 0304, 0071, 0364, 
+  0336, 0331, 0245, 0133, 0243, 0150, 0305, 0145, 0037, 0235, 0025, 0012, 0125, 0334, 0260, 0235, 
+  0216, 0072, 0226, 0032, 0170, 0372, 0354, 0101, 0037, 0071, 0357, 0274, 0332, 0251, 0200, 0063, 
+  0057, 0306, 0341, 0215, 0362, 0270, 0202, 0305, 0330, 0043, 0106, 0167, 0143, 0353, 0160, 0330, 
+  0057, 0120, 0354, 0031, 0215, 0271, 0261, 0305, 0010, 0131, 0270, 0265, 0302, 0342, 0306, 0002, 
+  0240, 0162, 0013, 0204, 0305, 0241, 0162, 0013, 0104, 0247, 0040, 0072, 0005, 0321, 0051, 0210, 
+  0116, 0135, 0105, 0164, 0312, 0276, 0102, 0100, 0017, 0202, 0123, 0115, 0227, 0024, 0271, 0250, 
+  0203, 0255, 0102, 0031, 0021, 0010, 0115, 0365, 0144, 0053, 0331, 0063, 0253, 0005, 0367, 0032, 
+  0354, 0044, 0053, 0075, 0266, 0340, 0054, 0047, 0354, 0044, 0157, 0351, 0115, 0346, 0325, 0122, 
+  0164, 0107, 0327, 0225, 0140, 0175, 0305, 0251, 0267, 0271, 0311, 0325, 0046, 0056, 0173, 0306, 
+  0304, 0352, 0121, 0067, 0023, 0253, 0147, 0204, 0023, 0231, 0351, 0344, 0206, 0344, 0152, 0110, 
+  0256, 0006, 0367, 0025, 0270, 0257, 0340, 0220, 0070, 0034, 0022, 0257, 0367, 0176, 0316, 0344, 
+  0031, 0343, 0106, 0131, 0122, 0120, 0164, 0270, 0271, 0242, 0303, 0145, 0025, 0333, 0250, 0162, 
+  0233, 0126, 0160, 0071, 0202, 0027, 0245, 0336, 0205, 0163, 0222, 0244, 0336, 0271, 0161, 0375, 
+  0001, 0223, 0202, 0027, 0110, 0242, 0072, 0367, 0252, 0316, 0275, 0231, 0204, 0122, 0303, 0145, 
+  0072, 0203, 0122, 0303, 0145, 0334, 0221, 0075, 0203, 0014, 0050, 0064, 0014, 0205, 0206, 0241, 
+  0320, 0160, 0023, 0344, 0114, 0255, 0124, 0100, 0070, 0274, 0100, 0275, 0005, 0172, 0146, 0257, 
+  0332, 0076, 0022, 0264, 0255, 0370, 0250, 0047, 0024, 0055, 0021, 0007, 0110, 0032, 0220, 0264, 
+  0266, 0111, 0132, 0157, 0200, 0003, 0150, 0032, 0320, 0264, 0033, 0175, 0253, 0172, 0307, 0003, 
+  0371, 0220, 0366, 0015, 0301, 0172, 0110, 0373, 0206, 0270, 0031, 0304, 0315, 0316, 0023, 0067, 
+  0073, 0332, 0227, 0163, 0021, 0322, 0251, 0251, 0212, 0032, 0331, 0002, 0104, 0325, 0156, 0071, 
+  0252, 0366, 0033, 0366, 0251, 0110, 0227, 0136, 0226, 0346, 0037, 0111, 0351, 0345, 0364, 0102, 
+  0161, 0071, 0171, 0251, 0024, 0152, 0313, 0251, 0272, 0374, 0305, 0164, 0271, 0173, 0305, 0013, 
+  0326, 0033, 0171, 0117, 0160, 0250, 0270, 0134, 0330, 0345, 0265, 0126, 0134, 0216, 0223, 0350, 
+  0057, 0135, 0271, 0131, 0367, 0247, 0264, 0172, 0060, 0333, 0316, 0045, 0243, 0336, 0202, 0370, 
+  0016, 0232, 0153, 0322, 0301, 0210, 0324, 0266, 0312, 0335, 0374, 0145, 0356, 0356, 0332, 0250, 
+  0065, 0016, 0002, 0242, 0355, 0202, 0213, 0074, 0342, 0325, 0321, 0215, 0120, 0203, 0065, 0243, 
+  0073, 0346, 0260, 0266, 0307, 0275, 0152, 0305, 0003, 0162, 0120, 0357, 0127, 0316, 0066, 0207, 
+  0240, 0027, 0037, 0103, 0111, 0012, 0317, 0246, 0152, 0062, 0325, 0253, 0162, 0004, 0160, 0170, 
+  0121, 0070, 0254, 0015, 0143, 0007, 0375, 0315, 0244, 0130, 0151, 0252, 0223, 0017, 0135, 0347, 
+  0302, 0111, 0275, 0064, 0001, 0045, 0273, 0341, 0057, 0072, 0007, 0112, 0172, 0163, 0315, 0243, 
+  0233, 0175, 0051, 0307, 0151, 0234, 0214, 0156, 0246, 0065, 0203, 0204, 0214, 0116, 0364, 0155, 
+  0277, 0003, 0126, 0002, 0126, 0136, 0043, 0126, 0306, 0306, 0001, 0160, 0131, 0032, 0056, 0107, 
+  0175, 0205, 0113, 0023, 0256, 0316, 0167, 0133, 0065, 0211, 0227, 0170, 0307, 0054, 0115, 0244, 
+  0334, 0215, 0357, 0015, 0140, 0011, 0140, 0171, 0215, 0140, 0231, 0230, 0006, 0240, 0145, 0151, 
+  0264, 0174, 0350, 0053, 0132, 0142, 0266, 0306, 0033, 0325, 0354, 0056, 0374, 0071, 0352, 0023, 
+  0234, 0217, 0000, 0212, 0135, 0000, 0305, 0330, 0002, 0000, 0023, 0113, 0143, 0342, 0017, 0220, 
+  0240, 0121, 0247, 0322, 0302, 0376, 0042, 0224, 0004, 0367, 0254, 0336, 0302, 0227, 0224, 0174, 
+  0350, 0131, 0313, 0007, 0311, 0034, 0120, 0171, 0241, 0311, 0063, 0374, 0017, 0327, 0125, 0171, 
+  0341, 0312, 0317, 0346, 0237, 0066, 0324, 0317, 0361, 0300, 0317, 0123, 0170, 0341, 0341, 0302, 
+  0205, 0027, 0262, 0144, 0311, 0226, 0243, 0222, 0061, 0226, 0067, 0302, 0322, 0306, 0227, 0041, 
+  0353, 0201, 0234, 0373, 0062, 0356, 0375, 0370, 0030, 0127, 0211, 0035, 0304, 0371, 0362, 0073, 
+  0354, 0333, 0377, 0067, 0322, 0333, 0304, 0100, 0160, 0245, 0107, 0063, 0030, 0016, 0235, 0161, 
+  0302, 0232, 0346, 0204, 0005, 0032, 0070, 0323, 0127, 0132, 0264, 0277, 0337, 0265, 0117, 0170, 
+  0262, 0052, 0335, 0307, 0077, 0166, 0135, 0170, 0114, 0030, 0335, 0147, 0264, 0077, 0370, 0147, 
+  0044, 0331, 0233, 0036, 0036, 0357, 0050, 0017, 0211, 0234, 0142, 0217, 0214, 0337, 0375, 0037, 
+  0310, 0057, 0223, 0004, 0000, 0050, 0165, 0165, 0141, 0171, 0051, 0160, 0162, 0145, 0146, 0145, 
+  0162, 0145, 0156, 0143, 0145, 0163, 0057, 0000, 0003, 0000, 0000, 0000, 0155, 0141, 0164, 0145, 
+  0057, 0000, 0000, 0000, 0000, 0000, 0000, 0000
+} };
+
+static GStaticResource static_resource = { preferences_resource_data.data, sizeof (preferences_resource_data.data) - 1 /* nul terminator */, NULL, NULL, NULL };
+
+G_MODULE_EXPORT
+GResource *preferences_get_resource (void);
+GResource *preferences_get_resource (void)
+{
+  return g_static_resource_get_resource (&static_resource);
+}
+/* GLIB - Library of useful routines for C programming
+ * Copyright (C) 1995-1997  Peter Mattis, Spencer Kimball and Josh MacDonald
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * Modified by the GLib Team and others 1997-2000.  See the AUTHORS
+ * file for a list of people on the GLib Team.  See the ChangeLog
+ * files for a list of changes.  These files are distributed with
+ * GLib at ftp://ftp.gtk.org/pub/gtk/.
+ */
+
+#ifndef __G_CONSTRUCTOR_H__
+#define __G_CONSTRUCTOR_H__
+
+/*
+  If G_HAS_CONSTRUCTORS is true then the compiler support *both* constructors and
+  destructors, in a usable way, including e.g. on library unload. If not you're on
+  your own.
+
+  Some compilers need #pragma to handle this, which does not work with macros,
+  so the way you need to use this is (for constructors):
+
+  #ifdef G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA
+  #pragma G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(my_constructor)
+  #endif
+  G_DEFINE_CONSTRUCTOR(my_constructor)
+  static void my_constructor(void) {
+   ...
+  }
+
+*/
+
+#ifndef __GTK_DOC_IGNORE__
+
+#if  __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
+
+#define G_HAS_CONSTRUCTORS 1
+
+#define G_DEFINE_CONSTRUCTOR(_func) static void __attribute__((constructor)) _func (void);
+#define G_DEFINE_DESTRUCTOR(_func) static void __attribute__((destructor)) _func (void);
+
+#elif defined (_MSC_VER) && (_MSC_VER >= 1500)
+/* Visual studio 2008 and later has _Pragma */
+
+/*
+ * Only try to include gslist.h if not already included via glib.h,
+ * so that items using gconstructor.h outside of GLib (such as
+ * GResources) continue to build properly.
+ */
+#ifndef __G_LIB_H__
+#include "gslist.h"
+#endif
+
+#include <stdlib.h>
+
+#define G_HAS_CONSTRUCTORS 1
+
+/* We do some weird things to avoid the constructors being optimized
+ * away on VS2015 if WholeProgramOptimization is enabled. First we
+ * make a reference to the array from the wrapper to make sure its
+ * references. Then we use a pragma to make sure the wrapper function
+ * symbol is always included at the link stage. Also, the symbols
+ * need to be extern (but not dllexport), even though they are not
+ * really used from another object file.
+ */
+
+/* We need to account for differences between the mangling of symbols
+ * for x86 and x64/ARM/ARM64 programs, as symbols on x86 are prefixed
+ * with an underscore but symbols on x64/ARM/ARM64 are not.
+ */
+#ifdef _M_IX86
+#define G_MSVC_SYMBOL_PREFIX "_"
+#else
+#define G_MSVC_SYMBOL_PREFIX ""
+#endif
+
+#define G_DEFINE_CONSTRUCTOR(_func) G_MSVC_CTOR (_func, G_MSVC_SYMBOL_PREFIX)
+#define G_DEFINE_DESTRUCTOR(_func) G_MSVC_DTOR (_func, G_MSVC_SYMBOL_PREFIX)
+
+#define G_MSVC_CTOR(_func,_sym_prefix) \
+  static void _func(void); \
+  extern int (* _array ## _func)(void);              \
+  int _func ## _wrapper(void);              \
+  int _func ## _wrapper(void) { _func(); g_slist_find (NULL,  _array ## _func); return 0; } \
+  __pragma(comment(linker,"/include:" _sym_prefix # _func "_wrapper")) \
+  __pragma(section(".CRT$XCU",read)) \
+  __declspec(allocate(".CRT$XCU")) int (* _array ## _func)(void) = _func ## _wrapper;
+
+#define G_MSVC_DTOR(_func,_sym_prefix) \
+  static void _func(void); \
+  extern int (* _array ## _func)(void);              \
+  int _func ## _constructor(void);              \
+  int _func ## _constructor(void) { atexit (_func); g_slist_find (NULL,  _array ## _func); return 0; } \
+   __pragma(comment(linker,"/include:" _sym_prefix # _func "_constructor")) \
+  __pragma(section(".CRT$XCU",read)) \
+  __declspec(allocate(".CRT$XCU")) int (* _array ## _func)(void) = _func ## _constructor;
+
+#elif defined (_MSC_VER)
+
+#define G_HAS_CONSTRUCTORS 1
+
+/* Pre Visual studio 2008 must use #pragma section */
+#define G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA 1
+#define G_DEFINE_DESTRUCTOR_NEEDS_PRAGMA 1
+
+#define G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(_func) \
+  section(".CRT$XCU",read)
+#define G_DEFINE_CONSTRUCTOR(_func) \
+  static void _func(void); \
+  static int _func ## _wrapper(void) { _func(); return 0; } \
+  __declspec(allocate(".CRT$XCU")) static int (*p)(void) = _func ## _wrapper;
+
+#define G_DEFINE_DESTRUCTOR_PRAGMA_ARGS(_func) \
+  section(".CRT$XCU",read)
+#define G_DEFINE_DESTRUCTOR(_func) \
+  static void _func(void); \
+  static int _func ## _constructor(void) { atexit (_func); return 0; } \
+  __declspec(allocate(".CRT$XCU")) static int (* _array ## _func)(void) = _func ## _constructor;
+
+#elif defined(__SUNPRO_C)
+
+/* This is not tested, but i believe it should work, based on:
+ * http://opensource.apple.com/source/OpenSSL098/OpenSSL098-35/src/fips/fips_premain.c
+ */
+
+#define G_HAS_CONSTRUCTORS 1
+
+#define G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA 1
+#define G_DEFINE_DESTRUCTOR_NEEDS_PRAGMA 1
+
+#define G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(_func) \
+  init(_func)
+#define G_DEFINE_CONSTRUCTOR(_func) \
+  static void _func(void);
+
+#define G_DEFINE_DESTRUCTOR_PRAGMA_ARGS(_func) \
+  fini(_func)
+#define G_DEFINE_DESTRUCTOR(_func) \
+  static void _func(void);
+
+#else
+
+/* constructors not supported for this compiler */
+
+#endif
+
+#endif /* __GTK_DOC_IGNORE__ */
+#endif /* __G_CONSTRUCTOR_H__ */
+
+#ifdef G_HAS_CONSTRUCTORS
+
+#ifdef G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA
+#pragma G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(preferencesresource_constructor)
+#endif
+G_DEFINE_CONSTRUCTOR(preferencesresource_constructor)
+#ifdef G_DEFINE_DESTRUCTOR_NEEDS_PRAGMA
+#pragma G_DEFINE_DESTRUCTOR_PRAGMA_ARGS(preferencesresource_destructor)
+#endif
+G_DEFINE_DESTRUCTOR(preferencesresource_destructor)
+
+#else
+#warning "Constructor not supported on this compiler, linking in resources will not work"
+#endif
+
+static void preferencesresource_constructor (void)
+{
+  g_static_resource_init (&static_resource);
+}
+
+static void preferencesresource_destructor (void)
+{
+  g_static_resource_fini (&static_resource);
+}
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/113.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/113.html new file mode 100644 index 0000000..6f26a55 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/113.html @@ -0,0 +1,893 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
#include <gio/gio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#if defined (__ELF__) && ( __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 6))
+# define SECTION __attribute__ ((section (".gresource.statistics"), aligned (8)))
+#else
+# define SECTION
+#endif
+
+static const SECTION union { const guint8 data[1925]; const double alignment; void * const ptr;}  statistics_resource_data = { {<--- union member 'Anonymous0::alignment' is never used.<--- union member 'Anonymous0::ptr' is never used.
+  0107, 0126, 0141, 0162, 0151, 0141, 0156, 0164, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 
+  0030, 0000, 0000, 0000, 0310, 0000, 0000, 0000, 0000, 0000, 0000, 0050, 0006, 0000, 0000, 0000, 
+  0000, 0000, 0000, 0000, 0002, 0000, 0000, 0000, 0003, 0000, 0000, 0000, 0005, 0000, 0000, 0000, 
+  0005, 0000, 0000, 0000, 0005, 0000, 0000, 0000, 0330, 0224, 0326, 0152, 0005, 0000, 0000, 0000, 
+  0310, 0000, 0000, 0000, 0015, 0000, 0114, 0000, 0330, 0000, 0000, 0000, 0334, 0000, 0000, 0000, 
+  0062, 0342, 0045, 0316, 0000, 0000, 0000, 0000, 0334, 0000, 0000, 0000, 0013, 0000, 0114, 0000, 
+  0350, 0000, 0000, 0000, 0354, 0000, 0000, 0000, 0113, 0120, 0220, 0013, 0004, 0000, 0000, 0000, 
+  0354, 0000, 0000, 0000, 0004, 0000, 0114, 0000, 0360, 0000, 0000, 0000, 0364, 0000, 0000, 0000, 
+  0332, 0267, 0346, 0334, 0001, 0000, 0000, 0000, 0364, 0000, 0000, 0000, 0021, 0000, 0166, 0000, 
+  0010, 0001, 0000, 0000, 0160, 0007, 0000, 0000, 0324, 0265, 0002, 0000, 0377, 0377, 0377, 0377, 
+  0160, 0007, 0000, 0000, 0001, 0000, 0114, 0000, 0164, 0007, 0000, 0000, 0170, 0007, 0000, 0000, 
+  0201, 0321, 0040, 0031, 0002, 0000, 0000, 0000, 0170, 0007, 0000, 0000, 0005, 0000, 0114, 0000, 
+  0200, 0007, 0000, 0000, 0204, 0007, 0000, 0000, 0160, 0157, 0167, 0145, 0162, 0155, 0141, 0156, 
+  0141, 0147, 0145, 0162, 0057, 0000, 0000, 0000, 0001, 0000, 0000, 0000, 0163, 0164, 0141, 0164, 
+  0151, 0163, 0164, 0151, 0143, 0163, 0057, 0000, 0003, 0000, 0000, 0000, 0157, 0162, 0147, 0057, 
+  0005, 0000, 0000, 0000, 0147, 0160, 0155, 0055, 0163, 0164, 0141, 0164, 0151, 0163, 0164, 0151, 
+  0143, 0163, 0056, 0165, 0151, 0000, 0000, 0000, 0257, 0151, 0000, 0000, 0001, 0000, 0000, 0000, 
+  0170, 0332, 0355, 0135, 0337, 0163, 0243, 0066, 0020, 0176, 0277, 0277, 0202, 0352, 0265, 0103, 
+  0034, 0073, 0271, 0114, 0323, 0261, 0175, 0063, 0275, 0314, 0345, 0036, 0072, 0235, 0316, 0044, 
+  0167, 0175, 0364, 0010, 0330, 0030, 0065, 0262, 0104, 0045, 0071, 0266, 0377, 0373, 0012, 0160, 
+  0210, 0211, 0301, 0040, 0040, 0361, 0217, 0350, 0051, 0066, 0321, 0112, 0332, 0117, 0332, 0157, 
+  0167, 0305, 0032, 0206, 0137, 0226, 0063, 0352, 0074, 0201, 0220, 0204, 0263, 0021, 0352, 0237, 
+  0235, 0043, 0007, 0230, 0317, 0003, 0302, 0246, 0043, 0364, 0343, 0376, 0233, 0373, 0033, 0372, 
+  0062, 0376, 0064, 0374, 0305, 0165, 0235, 0133, 0140, 0040, 0260, 0202, 0300, 0131, 0020, 0025, 
+  0072, 0123, 0212, 0003, 0160, 0056, 0316, 0006, 0203, 0263, 0276, 0343, 0272, 0272, 0021, 0141, 
+  0012, 0304, 0003, 0366, 0141, 0374, 0311, 0161, 0206, 0002, 0376, 0233, 0023, 0001, 0322, 0241, 
+  0304, 0033, 0241, 0251, 0172, 0374, 0025, 0275, 0014, 0164, 0241, 0007, 0352, 0045, 0315, 0270, 
+  0367, 0057, 0370, 0312, 0361, 0051, 0226, 0162, 0204, 0156, 0325, 0343, 0015, 0301, 0224, 0117, 
+  0221, 0103, 0202, 0021, 0012, 0222, 0317, 0023, 0251, 0260, 0222, 0050, 0156, 0256, 0005, 0042, 
+  0301, 0043, 0020, 0152, 0345, 0060, 0074, 0203, 0021, 0362, 0061, 0233, 0074, 0160, 0177, 0256, 
+  0377, 0377, 0015, 0123, 0011, 0303, 0336, 0163, 0203, 0342, 0366, 0036, 0027, 0001, 0210, 0311, 
+  0202, 0004, 0052, 0104, 0343, 0253, 0252, 0346, 0212, 0050, 0012, 0310, 0121, 0002, 0063, 0111, 
+  0261, 0302, 0036, 0325, 0027, 0127, 0240, 0107, 0373, 0233, 0057, 0100, 0070, 0167, 0172, 0152, 
+  0104, 0052, 0342, 0313, 0252, 0236, 0026, 0204, 0005, 0174, 0061, 0211, 0270, 0044, 0112, 0143, 
+  0200, 0306, 0076, 0304, 0170, 0271, 0234, 0271, 0021, 0026, 0372, 0163, 0345, 0124, 0126, 0021, 
+  0114, 0102, 0015, 0062, 0032, 0247, 0270, 0154, 0011, 0370, 0041, 0241, 0101, 0372, 0071, 0026, 
+  0247, 0172, 0051, 0102, 0116, 0265, 0272, 0275, 0165, 0203, 0336, 0106, 0213, 0264, 0265, 0223, 
+  0054, 0032, 0303, 0324, 0115, 0276, 0216, 0320, 0223, 0307, 0227, 0050, 0353, 0143, 0153, 0165, 
+  0376, 0320, 0377, 0335, 0130, 0032, 0067, 0156, 0336, 0317, 0332, 0157, 0117, 0372, 0211, 0110, 
+  0242, 0061, 0103, 0343, 0173, 0061, 0337, 0132, 0233, 0046, 0353, 0131, 0044, 0303, 0005, 0321, 
+  0370, 0341, 0024, 0126, 0275, 0307, 0364, 0162, 0140, 0132, 0107, 0120, 0106, 0330, 0327, 0073, 
+  0035, 0215, 0007, 0205, 0255, 0213, 0021, 0302, 0176, 0074, 0320, 0104, 0257, 0031, 0336, 0120, 
+  0274, 0020, 0254, 0271, 0122, 0234, 0275, 0206, 0154, 0103, 0276, 0237, 0353, 0240, 0001, 0172, 
+  0115, 0021, 0054, 0222, 0243, 0170, 0305, 0347, 0112, 0033, 0333, 0052, 0036, 0021, 0130, 0120, 
+  0052, 0230, 0333, 0147, 0125, 0352, 0247, 0272, 0173, 0311, 0347, 0111, 0010, 0064, 0102, 0257, 
+  0045, 0213, 0246, 0342, 0001, 0105, 0143, 0115, 0032, 0156, 0054, 0121, 0066, 0221, 0042, 0321, 
+  0271, 0204, 0311, 0063, 0302, 0121, 0004, 0130, 0033, 0256, 0017, 0025, 0110, 0064, 0206, 0276, 
+  0002, 0376, 0046, 0242, 0001, 0074, 0340, 0071, 0125, 0346, 0302, 0002, 0174, 0040, 0117, 0040, 
+  0137, 0172, 0060, 0326, 0071, 0306, 0116, 0052, 0356, 0077, 0126, 0215, 0076, 0354, 0245, 0213, 
+  0275, 0165, 0135, 0333, 0323, 0243, 0066, 0250, 0352, 0241, 0140, 0031, 0141, 0026, 0064, 0230, 
+  0343, 0003, 0241, 0264, 0201, 0330, 0013, 0355, 0236, 0233, 0210, 0111, 0360, 0071, 0013, 0260, 
+  0130, 0125, 0043, 0122, 0250, 0172, 0216, 0161, 0073, 0260, 0037, 0237, 0162, 0011, 0146, 0006, 
+  0224, 0210, 0130, 0013, 0262, 0026, 0324, 0231, 0005, 0365, 0273, 0060, 0203, 0042, 0000, 0212, 
+  0225, 0157, 0244, 0170, 0003, 0245, 0215, 0051, 0243, 0100, 0331, 0055, 0105, 0267, 0155, 0175, 
+  0333, 0316, 0277, 0147, 0021, 0102, 0370, 0052, 0232, 0332, 0173, 0114, 0120, 0021, 0055, 0127, 
+  0306, 0125, 0127, 0155, 0143, 0210, 0073, 0137, 0160, 0112, 0041, 0370, 0047, 0211, 0236, 0123, 
+  0224, 0344, 0372, 0132, 0032, 0121, 0017, 0320, 0141, 0122, 0121, 0230, 0116, 0323, 0303, 0102, 
+  0307, 0374, 0224, 0370, 0332, 0205, 0060, 0320, 0301, 0251, 0221, 0373, 0011, 0161, 0234, 0063, 
+  0304, 0221, 0077, 0032, 0023, 0266, 0123, 0264, 0020, 0320, 0142, 0120, 0357, 0005, 0300, 0117, 
+  0002, 0153, 0070, 0225, 0376, 0366, 0244, 0277, 0151, 0332, 0173, 0042, 0076, 0110, 0124, 0324, 
+  0111, 0013, 0114, 0133, 0342, 0132, 0210, 0055, 0350, 0334, 0123, 0310, 0111, 0066, 0207, 0112, 
+  0066, 0333, 0021, 0317, 0113, 0240, 0340, 0247, 0206, 0136, 0050, 0126, 0206, 0340, 0135, 0046, 
+  0227, 0203, 0321, 0315, 0372, 0353, 0243, 0136, 0311, 0104, 0172, 0345, 0213, 0125, 0342, 0027, 
+  0112, 0205, 0366, 0356, 0110, 0114, 0355, 0242, 0126, 0044, 0366, 0026, 0341, 0324, 0137, 0134, 
+  0201, 0307, 0371, 0143, 0272, 0134, 0154, 0375, 0255, 0177, 0050, 0364, 0141, 0140, 0277, 0325, 
+  0244, 0330, 0077, 0002, 0043, 0316, 0373, 0226, 0153, 0123, 0161, 0003, 0156, 0334, 0215, 0257, 
+  0021, 0107, 0022, 0366, 0300, 0113, 0171, 0242, 0045, 0276, 0035, 0140, 0334, 0212, 0346, 0132, 
+  0120, 0335, 0240, 0214, 0352, 0052, 0350, 0156, 0067, 0345, 0165, 0315, 0225, 0031, 0066, 0361, 
+  0246, 0321, 0152, 0140, 0017, 0325, 0063, 0270, 0077, 0223, 0164, 0052, 0321, 0075, 0311, 0254, 
+  0336, 0333, 0274, 0352, 0271, 0267, 0302, 0034, 0260, 0350, 0350, 0362, 0006, 0024, 0046, 0124, 
+  0356, 0356, 0160, 0327, 0262, 0224, 0073, 0227, 0302, 0203, 0113, 0354, 0115, 0152, 0046, 0035, 
+  0245, 0314, 0137, 0143, 0125, 0353, 0055, 0345, 0317, 0054, 0330, 0216, 0217, 0056, 0057, 0217, 
+  0141, 0041, 0333, 0022, 0345, 0163, 0060, 0176, 0335, 0065, 0107, 0346, 0023, 0227, 0313, 0075, 
+  0361, 0142, 0055, 0114, 0167, 0002, 0323, 0037, 0324, 0347, 0125, 0063, 0362, 0314, 0043, 0064, 
+  0330, 0111, 0275, 0035, 0240, 0324, 0025, 0122, 0315, 0162, 0072, 0163, 0300, 0352, 0261, 0355, 
+  0147, 0124, 0325, 0107, 0107, 0320, 0165, 0011, 0237, 0031, 0043, 0337, 0012, 0034, 0205, 0211, 
+  0133, 0372, 0275, 0376, 0000, 0273, 0035, 0147, 0135, 0266, 0356, 0044, 0065, 0350, 0046, 0125, 
+  0350, 0350, 0020, 0267, 0266, 0103, 0061, 0010, 0122, 0332, 0355, 0350, 0257, 0174, 0346, 0161, 
+  0115, 0005, 0367, 0260, 0124, 0351, 0306, 0366, 0343, 0053, 0232, 0022, 0046, 0041, 0221, 0212, 
+  0213, 0325, 0072, 0216, 0075, 0306, 0175, 0376, 0176, 0333, 0260, 0255, 0216, 0135, 0357, 0302, 
+  0376, 0076, 0166, 0141, 0035, 0270, 0353, 0101, 0335, 0005, 0314, 0355, 0041, 0156, 0155, 0344, 
+  0065, 0240, 0255, 0204, 0265, 0275, 0157, 0377, 0154, 0175, 0173, 0023, 0337, 0176, 0171, 0372, 
+  0276, 0375, 0106, 0177, 0163, 0050, 0260, 0251, 0012, 0255, 0163, 0377, 0240, 0316, 0235, 0314, 
+  0254, 0163, 0267, 0316, 0335, 0072, 0167, 0143, 0170, 0333, 0073, 0367, 0052, 0110, 0253, 0341, 
+  0154, 0115, 0234, 0355, 0160, 0154, 0105, 0224, 0025, 0370, 0355, 0304, 0316, 0364, 0070, 0050, 
+  0177, 0264, 0166, 0161, 0360, 0307, 0101, 0255, 0143, 0276, 0147, 0176, 0267, 0241, 0137, 0223, 
+  0320, 0157, 0202, 0227, 0104, 0146, 0056, 0162, 0165, 0132, 0201, 0340, 0170, 0345, 0306, 0352, 
+  0265, 0351, 0010, 0263, 0151, 0254, 0333, 0365, 0271, 0015, 0032, 0117, 0057, 0150, 0334, 0062, 
+  0206, 0147, 0073, 0140, 0074, 0320, 0371, 0302, 0351, 0147, 0105, 0367, 0041, 0010, 0160, 0210, 
+  0164, 0030, 0167, 0142, 0215, 0035, 0245, 0377, 0022, 0031, 0121, 0274, 0072, 0263, 0341, 0251, 
+  0015, 0117, 0355, 0331, 0123, 0163, 0137, 0272, 0074, 0346, 0200, 0144, 0355, 0077, 0227, 0006, 
+  0376, 0363, 0355, 0267, 0145, 0053, 0215, 0154, 0332, 0324, 0310, 0304, 0337, 0052, 0153, 0352, 
+  0037, 0126, 0326, 0224, 0117, 0051, 0256, 0217, 0366, 0046, 0372, 0125, 0023, 0351, 0220, 0317, 
+  0370, 0024, 0030, 0160, 0363, 0002, 0047, 0063, 0302, 0374, 0032, 0202, 0237, 0373, 0101, 0205, 
+  0037, 0137, 0130, 0377, 0252, 0102, 0316, 0070, 0127, 0141, 0303, 0154, 0256, 0074, 0304, 0371, 
+  0041, 0301, 0111, 0273, 0206, 0300, 0241, 0204, 0065, 0066, 0377, 0246, 0277, 0310, 0170, 0117, 
+  0316, 0157, 0323, 0115, 0203, 0037, 0136, 0354, 0352, 0056, 0020, 0070, 0056, 0324, 0013, 0210, 
+  0217, 0365, 0172, 0232, 0114, 0355, 0003, 0071, 0222, 0003, 0017, 0160, 0166, 0332, 0153, 0304, 
+  0011, 0123, 0262, 0163, 0173, 0275, 0013, 0371, 0042, 0315, 0105, 0322, 0001, 0254, 0271, 0132, 
+  0163, 0265, 0161, 0337, 0351, 0034, 0227, 0017, 0336, 0062, 0360, 0353, 0256, 0134, 0266, 0366, 
+  0242, 0067, 0057, 0225, 0155, 0135, 0000, 0075, 0070, 0356, 0002, 0350, 0357, 0251, 0347, 0170, 
+  0257, 0002, 0150, 0003, 0063, 0076, 0242, 0332, 0351, 0201, 0255, 0235, 0356, 0054, 0355, 0273, 
+  0072, 0361, 0264, 0257, 0203, 0043, 0256, 0253, 0343, 0077, 0324, 0352, 0244, 0362, 0327, 0346, 
+  0050, 0007, 0223, 0243, 0224, 0027, 0376, 0044, 0117, 0054, 0252, 0123, 0323, 0173, 0100, 0273, 
+  0326, 0326, 0236, 0330, 0140, 0372, 0104, 0152, 0117, 0076, 0177, 0200, 0332, 0023, 0231, 0075, 
+  0171, 0314, 0226, 0237, 0064, 0277, 0145, 0226, 0022, 0265, 0055, 0076, 0261, 0305, 0047, 0037, 
+  0271, 0370, 0044, 0265, 0002, 0133, 0172, 0142, 0113, 0117, 0154, 0351, 0211, 0315, 0172, 0232, 
+  0373, 0121, 0133, 0170, 0142, 0157, 0100, 0330, 0302, 0223, 0127, 0020, 0342, 0040, 0110, 0042, 
+  0334, 0213, 0023, 0056, 0133, 0351, 0237, 0333, 0272, 0225, 0275, 0325, 0255, 0154, 0076, 0036, 
+  0333, 0126, 0255, 0330, 0333, 0340, 0366, 0104, 0370, 0220, 0253, 0126, 0272, 0265, 0126, 0133, 
+  0263, 0142, 0215, 0325, 0206, 0214, 0266, 0146, 0345, 0140, 0152, 0126, 0006, 0007, 0133, 0263, 
+  0162, 0161, 0334, 0065, 0053, 0345, 0157, 0032, 0331, 0373, 0242, 0276, 0173, 0331, 0112, 0167, 
+  0017, 0275, 0065, 0175, 0242, 0153, 0333, 0147, 0336, 0036, 0310, 0263, 0323, 0115, 0236, 0035, 
+  0136, 0255, 0262, 0261, 0272, 0325, 0117, 0116, 0317, 0253, 0230, 0177, 0161, 0115, 0032, 0247, 
+  0270, 0013, 0022, 0114, 0101, 0311, 0114, 0042, 0167, 0331, 0021, 0040, 0043, 0316, 0244, 0236, 
+  0215, 0116, 0115, 0067, 0336, 0076, 0062, 0354, 0345, 0332, 0031, 0110, 0257, 0137, 0244, 0120, 
+  0040, 0376, 0352, 0342, 0172, 0112, 0303, 0344, 0115, 0052, 0331, 0000, 0011, 0061, 0255, 0001, 
+  0232, 0105, 0063, 0167, 0343, 0376, 0135, 0366, 0172, 0236, 0114, 0342, 0105, 0375, 0141, 0157, 
+  0343, 0265, 0112, 0377, 0003, 0105, 0202, 0071, 0023, 0000, 0050, 0165, 0165, 0141, 0171, 0051, 
+  0057, 0000, 0000, 0000, 0002, 0000, 0000, 0000, 0155, 0141, 0164, 0145, 0057, 0000, 0000, 0000, 
+  0000, 0000, 0000, 0000
+} };
+
+static GStaticResource static_resource = { statistics_resource_data.data, sizeof (statistics_resource_data.data) - 1 /* nul terminator */, NULL, NULL, NULL };
+
+G_MODULE_EXPORT
+GResource *statistics_get_resource (void);
+GResource *statistics_get_resource (void)
+{
+  return g_static_resource_get_resource (&static_resource);
+}
+/* GLIB - Library of useful routines for C programming
+ * Copyright (C) 1995-1997  Peter Mattis, Spencer Kimball and Josh MacDonald
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * Modified by the GLib Team and others 1997-2000.  See the AUTHORS
+ * file for a list of people on the GLib Team.  See the ChangeLog
+ * files for a list of changes.  These files are distributed with
+ * GLib at ftp://ftp.gtk.org/pub/gtk/.
+ */
+
+#ifndef __G_CONSTRUCTOR_H__
+#define __G_CONSTRUCTOR_H__
+
+/*
+  If G_HAS_CONSTRUCTORS is true then the compiler support *both* constructors and
+  destructors, in a usable way, including e.g. on library unload. If not you're on
+  your own.
+
+  Some compilers need #pragma to handle this, which does not work with macros,
+  so the way you need to use this is (for constructors):
+
+  #ifdef G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA
+  #pragma G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(my_constructor)
+  #endif
+  G_DEFINE_CONSTRUCTOR(my_constructor)
+  static void my_constructor(void) {
+   ...
+  }
+
+*/
+
+#ifndef __GTK_DOC_IGNORE__
+
+#if  __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
+
+#define G_HAS_CONSTRUCTORS 1
+
+#define G_DEFINE_CONSTRUCTOR(_func) static void __attribute__((constructor)) _func (void);
+#define G_DEFINE_DESTRUCTOR(_func) static void __attribute__((destructor)) _func (void);
+
+#elif defined (_MSC_VER) && (_MSC_VER >= 1500)
+/* Visual studio 2008 and later has _Pragma */
+
+/*
+ * Only try to include gslist.h if not already included via glib.h,
+ * so that items using gconstructor.h outside of GLib (such as
+ * GResources) continue to build properly.
+ */
+#ifndef __G_LIB_H__
+#include "gslist.h"
+#endif
+
+#include <stdlib.h>
+
+#define G_HAS_CONSTRUCTORS 1
+
+/* We do some weird things to avoid the constructors being optimized
+ * away on VS2015 if WholeProgramOptimization is enabled. First we
+ * make a reference to the array from the wrapper to make sure its
+ * references. Then we use a pragma to make sure the wrapper function
+ * symbol is always included at the link stage. Also, the symbols
+ * need to be extern (but not dllexport), even though they are not
+ * really used from another object file.
+ */
+
+/* We need to account for differences between the mangling of symbols
+ * for x86 and x64/ARM/ARM64 programs, as symbols on x86 are prefixed
+ * with an underscore but symbols on x64/ARM/ARM64 are not.
+ */
+#ifdef _M_IX86
+#define G_MSVC_SYMBOL_PREFIX "_"
+#else
+#define G_MSVC_SYMBOL_PREFIX ""
+#endif
+
+#define G_DEFINE_CONSTRUCTOR(_func) G_MSVC_CTOR (_func, G_MSVC_SYMBOL_PREFIX)
+#define G_DEFINE_DESTRUCTOR(_func) G_MSVC_DTOR (_func, G_MSVC_SYMBOL_PREFIX)
+
+#define G_MSVC_CTOR(_func,_sym_prefix) \
+  static void _func(void); \
+  extern int (* _array ## _func)(void);              \
+  int _func ## _wrapper(void);              \
+  int _func ## _wrapper(void) { _func(); g_slist_find (NULL,  _array ## _func); return 0; } \
+  __pragma(comment(linker,"/include:" _sym_prefix # _func "_wrapper")) \
+  __pragma(section(".CRT$XCU",read)) \
+  __declspec(allocate(".CRT$XCU")) int (* _array ## _func)(void) = _func ## _wrapper;
+
+#define G_MSVC_DTOR(_func,_sym_prefix) \
+  static void _func(void); \
+  extern int (* _array ## _func)(void);              \
+  int _func ## _constructor(void);              \
+  int _func ## _constructor(void) { atexit (_func); g_slist_find (NULL,  _array ## _func); return 0; } \
+   __pragma(comment(linker,"/include:" _sym_prefix # _func "_constructor")) \
+  __pragma(section(".CRT$XCU",read)) \
+  __declspec(allocate(".CRT$XCU")) int (* _array ## _func)(void) = _func ## _constructor;
+
+#elif defined (_MSC_VER)
+
+#define G_HAS_CONSTRUCTORS 1
+
+/* Pre Visual studio 2008 must use #pragma section */
+#define G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA 1
+#define G_DEFINE_DESTRUCTOR_NEEDS_PRAGMA 1
+
+#define G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(_func) \
+  section(".CRT$XCU",read)
+#define G_DEFINE_CONSTRUCTOR(_func) \
+  static void _func(void); \
+  static int _func ## _wrapper(void) { _func(); return 0; } \
+  __declspec(allocate(".CRT$XCU")) static int (*p)(void) = _func ## _wrapper;
+
+#define G_DEFINE_DESTRUCTOR_PRAGMA_ARGS(_func) \
+  section(".CRT$XCU",read)
+#define G_DEFINE_DESTRUCTOR(_func) \
+  static void _func(void); \
+  static int _func ## _constructor(void) { atexit (_func); return 0; } \
+  __declspec(allocate(".CRT$XCU")) static int (* _array ## _func)(void) = _func ## _constructor;
+
+#elif defined(__SUNPRO_C)
+
+/* This is not tested, but i believe it should work, based on:
+ * http://opensource.apple.com/source/OpenSSL098/OpenSSL098-35/src/fips/fips_premain.c
+ */
+
+#define G_HAS_CONSTRUCTORS 1
+
+#define G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA 1
+#define G_DEFINE_DESTRUCTOR_NEEDS_PRAGMA 1
+
+#define G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(_func) \
+  init(_func)
+#define G_DEFINE_CONSTRUCTOR(_func) \
+  static void _func(void);
+
+#define G_DEFINE_DESTRUCTOR_PRAGMA_ARGS(_func) \
+  fini(_func)
+#define G_DEFINE_DESTRUCTOR(_func) \
+  static void _func(void);
+
+#else
+
+/* constructors not supported for this compiler */
+
+#endif
+
+#endif /* __GTK_DOC_IGNORE__ */
+#endif /* __G_CONSTRUCTOR_H__ */
+
+#ifdef G_HAS_CONSTRUCTORS
+
+#ifdef G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA
+#pragma G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(statisticsresource_constructor)
+#endif
+G_DEFINE_CONSTRUCTOR(statisticsresource_constructor)
+#ifdef G_DEFINE_DESTRUCTOR_NEEDS_PRAGMA
+#pragma G_DEFINE_DESTRUCTOR_PRAGMA_ARGS(statisticsresource_destructor)
+#endif
+G_DEFINE_DESTRUCTOR(statisticsresource_destructor)
+
+#else
+#warning "Constructor not supported on this compiler, linking in resources will not work"
+#endif
+
+static void statisticsresource_constructor (void)
+{
+  g_static_resource_init (&static_resource);
+}
+
+static void statisticsresource_destructor (void)
+{
+  g_static_resource_fini (&static_resource);
+}
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/114.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/114.html new file mode 100644 index 0000000..cdeaa1d --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/114.html @@ -0,0 +1,1227 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * On-screen-display (OSD) window for mate-settings-daemon's plugins
+ *
+ * Copyright (C) 2006-2007 William Jon McCann <mccann@jhu.edu>
+ * Copyright (C) 2009 Novell, Inc
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * Authors:
+ *   William Jon McCann <mccann@jhu.edu>
+ *   Federico Mena-Quintero <federico@novell.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be
+ * useful, but WITHOUT ANY WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE.  See the GNU Lesser General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "config.h"<--- Include file: "config.h" not found.
+
+#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <math.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdk/gdkx.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "msd-osd-window.h"
+
+#define DIALOG_TIMEOUT 2000     /* dialog timeout in ms */
+#define DIALOG_FADE_TIMEOUT 1500 /* timeout before fade starts */
+#define FADE_TIMEOUT 10        /* timeout in ms between each frame of the fade */
+
+#define BG_ALPHA 0.75
+
+struct MsdOsdWindowPrivate
+{
+        guint                    is_composited : 1;
+        guint                    hide_timeout_id;
+        guint                    fade_timeout_id;
+        double                   fade_out_alpha;
+        gint                     scale_factor;
+};
+
+enum {
+        DRAW_WHEN_COMPOSITED,
+        LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL] = { 0 };
+
+G_DEFINE_TYPE_WITH_PRIVATE (MsdOsdWindow, msd_osd_window, GTK_TYPE_WINDOW)<--- There is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
+
+static gboolean
+fade_timeout (MsdOsdWindow *window)
+{
+        if (window->priv->fade_out_alpha <= 0.0) {
+                gtk_widget_hide (GTK_WIDGET (window));
+
+                /* Reset it for the next time */
+                window->priv->fade_out_alpha = 1.0;
+                window->priv->fade_timeout_id = 0;
+
+                return FALSE;
+        } else {
+                GdkRectangle rect;
+                GtkWidget *win = GTK_WIDGET (window);
+                GtkAllocation allocation;
+
+                window->priv->fade_out_alpha -= 0.10;
+
+                rect.x = 0;
+                rect.y = 0;
+                gtk_widget_get_allocation (win, &allocation);
+                rect.width = allocation.width;
+                rect.height = allocation.height;
+
+                gtk_widget_realize (win);
+                gdk_window_invalidate_rect (gtk_widget_get_window (win), &rect, FALSE);
+        }
+
+        return TRUE;
+}
+
+static gboolean
+hide_timeout (MsdOsdWindow *window)
+{
+        if (window->priv->is_composited) {
+                window->priv->hide_timeout_id = 0;
+                window->priv->fade_timeout_id = g_timeout_add (FADE_TIMEOUT,
+                                                               (GSourceFunc) fade_timeout,
+                                                               window);
+        } else {
+                gtk_widget_hide (GTK_WIDGET (window));
+        }
+
+        return FALSE;
+}
+
+static void
+remove_hide_timeout (MsdOsdWindow *window)
+{
+        if (window->priv->hide_timeout_id != 0) {
+                g_source_remove (window->priv->hide_timeout_id);
+                window->priv->hide_timeout_id = 0;
+        }
+
+        if (window->priv->fade_timeout_id != 0) {
+                g_source_remove (window->priv->fade_timeout_id);
+                window->priv->fade_timeout_id = 0;
+                window->priv->fade_out_alpha = 1.0;
+        }
+}
+
+static void
+add_hide_timeout (MsdOsdWindow *window)
+{
+        int timeout;
+
+        if (window->priv->is_composited) {
+                timeout = DIALOG_FADE_TIMEOUT;
+        } else {
+                timeout = DIALOG_TIMEOUT;
+        }
+        window->priv->hide_timeout_id = g_timeout_add (timeout,
+                                                       (GSourceFunc) hide_timeout,
+                                                       window);
+}
+
+/* This is our draw-event handler when the window is in a compositing manager.
+ * We draw everything by hand, using Cairo, so that we can have a nice
+ * transparent/rounded look.
+ */
+static void
+draw_when_composited (GtkWidget *widget, cairo_t *orig_cr)
+{
+        MsdOsdWindow    *window;
+        cairo_t         *cr;
+        cairo_surface_t *surface;
+        int              width;
+        int              height;
+        GtkStyleContext *context;
+
+        window = MSD_OSD_WINDOW (widget);
+
+        context = gtk_widget_get_style_context (widget);
+        cairo_set_operator (orig_cr, CAIRO_OPERATOR_SOURCE);
+        gtk_window_get_size (GTK_WINDOW (widget), &width, &height);
+
+        surface = cairo_surface_create_similar (cairo_get_target (orig_cr),
+                                                CAIRO_CONTENT_COLOR_ALPHA,
+                                                width,
+                                                height);
+
+        if (cairo_surface_status (surface) != CAIRO_STATUS_SUCCESS) {
+                goto done;
+        }
+
+        cr = cairo_create (surface);
+        if (cairo_status (cr) != CAIRO_STATUS_SUCCESS) {
+                goto done;
+        }
+
+        gtk_render_background (context, cr, 0, 0, width, height);
+        gtk_render_frame (context, cr, 0, 0, width, height);
+
+        g_signal_emit (window, signals[DRAW_WHEN_COMPOSITED], 0, cr);
+
+        cairo_destroy (cr);
+
+        /* Make sure we have a transparent background */
+        cairo_rectangle (orig_cr, 0, 0, width, height);
+        cairo_set_source_rgba (orig_cr, 0.0, 0.0, 0.0, 0.0);
+        cairo_fill (orig_cr);
+
+        cairo_set_source_surface (orig_cr, surface, 0, 0);
+        cairo_paint_with_alpha (orig_cr, window->priv->fade_out_alpha);
+
+done:
+        if (surface != NULL) {
+                cairo_surface_destroy (surface);
+        }
+}
+
+/* This is our expose/draw-event handler when the window is *not* in a compositing manager.
+ * We just draw a rectangular frame by hand.  We do this with hardcoded drawing code,
+ * instead of GtkFrame, to avoid changing the window's internal widget hierarchy:  in
+ * either case (composited or non-composited), callers can assume that this works
+ * identically to a GtkWindow without any intermediate widgetry.
+ */
+static void
+draw_when_not_composited (GtkWidget *widget, cairo_t *cr)
+{
+        GtkStyleContext *context;
+        int width;
+        int height;
+
+        gtk_window_get_size (GTK_WINDOW (widget), &width, &height);
+        context = gtk_widget_get_style_context (widget);
+
+        gtk_style_context_set_state (context, GTK_STATE_FLAG_ACTIVE);
+        gtk_style_context_add_class(context,"msd-osd-window-solid");
+        gtk_render_frame (context,
+                          cr,
+                          0,
+                          0,
+                          width,
+                          height);
+}
+
+static gboolean
+msd_osd_window_draw (GtkWidget *widget,
+                     cairo_t   *cr)
+{
+	MsdOsdWindow *window;
+	GtkWidget *child;
+
+	window = MSD_OSD_WINDOW (widget);
+
+	if (window->priv->is_composited)
+		draw_when_composited (widget, cr);
+	else
+		draw_when_not_composited (widget, cr);
+
+	child = gtk_bin_get_child (GTK_BIN (window));
+	if (child)
+		gtk_container_propagate_draw (GTK_CONTAINER (window), child, cr);
+
+	return FALSE;
+}
+
+static void
+msd_osd_window_real_show (GtkWidget *widget)
+{
+        MsdOsdWindow *window;
+
+        if (GTK_WIDGET_CLASS (msd_osd_window_parent_class)->show) {
+                GTK_WIDGET_CLASS (msd_osd_window_parent_class)->show (widget);
+        }
+
+        window = MSD_OSD_WINDOW (widget);
+        remove_hide_timeout (window);
+        add_hide_timeout (window);
+}
+
+static void
+msd_osd_window_real_hide (GtkWidget *widget)
+{
+        MsdOsdWindow *window;
+
+        if (GTK_WIDGET_CLASS (msd_osd_window_parent_class)->hide) {
+                GTK_WIDGET_CLASS (msd_osd_window_parent_class)->hide (widget);
+        }
+
+        window = MSD_OSD_WINDOW (widget);
+        remove_hide_timeout (window);
+}
+
+static void
+msd_osd_window_real_realize (GtkWidget *widget)
+{
+        GdkScreen *screen;
+        GdkVisual *visual;
+        cairo_region_t *region;
+
+        screen = gtk_widget_get_screen (widget);
+        visual = gdk_screen_get_rgba_visual (screen);
+
+        if (visual == NULL) {
+                visual = gdk_screen_get_system_visual (screen);
+        }
+
+        gtk_widget_set_visual (widget, visual);
+
+        if (GTK_WIDGET_CLASS (msd_osd_window_parent_class)->realize) {
+                GTK_WIDGET_CLASS (msd_osd_window_parent_class)->realize (widget);
+        }
+
+        /* make the whole window ignore events */
+        region = cairo_region_create ();
+        gtk_widget_input_shape_combine_region (widget, region);
+        cairo_region_destroy (region);
+}
+
+static void
+msd_osd_window_style_updated (GtkWidget *widget)
+{
+        GtkStyleContext *context;
+        GtkBorder padding;
+
+        GTK_WIDGET_CLASS (msd_osd_window_parent_class)->style_updated (widget);
+
+        /* We set our border width to 12 (per the MATE standard), plus the
+         * padding of the frame that we draw in our expose handler.  This will
+         * make our child be 12 pixels away from the frame.
+         */
+
+        context = gtk_widget_get_style_context (widget);
+        gtk_style_context_get_padding (context, GTK_STATE_FLAG_NORMAL, &padding);
+        gtk_container_set_border_width (GTK_CONTAINER (widget), 12 + MAX (padding.left, padding.top));
+}
+
+static void
+msd_osd_window_get_preferred_width (GtkWidget *widget,
+                                    gint      *minimum,
+                                    gint      *natural)
+{
+        GtkStyleContext *context;
+        GtkBorder padding;
+
+        GTK_WIDGET_CLASS (msd_osd_window_parent_class)->get_preferred_width (widget, minimum, natural);
+
+        /* See the comment in msd_osd_window_style_updated() for why we add the padding here */
+
+        context = gtk_widget_get_style_context (widget);
+        gtk_style_context_get_padding (context, GTK_STATE_FLAG_NORMAL, &padding);
+
+        *minimum += padding.left;
+        *natural += padding.left;
+}
+
+static void
+msd_osd_window_get_preferred_height (GtkWidget *widget,
+                                     gint      *minimum,
+                                     gint      *natural)
+{
+        GtkStyleContext *context;
+        GtkBorder padding;
+
+        GTK_WIDGET_CLASS (msd_osd_window_parent_class)->get_preferred_height (widget, minimum, natural);
+
+        /* See the comment in msd_osd_window_style_updated() for why we add the padding here */
+
+        context = gtk_widget_get_style_context (widget);
+        gtk_style_context_get_padding (context, GTK_STATE_FLAG_NORMAL, &padding);
+
+        *minimum += padding.top;
+        *natural += padding.top;
+}
+
+static GObject *
+msd_osd_window_constructor (GType                  type,
+                            guint                  n_construct_properties,
+                            GObjectConstructParam *construct_params)
+{
+        GObject         *object;
+        GtkWidget       *widget;
+        GtkStyleContext *style_context;
+
+        object = G_OBJECT_CLASS (msd_osd_window_parent_class)->constructor (type, n_construct_properties, construct_params);
+
+        g_object_set (object,
+                      "type", GTK_WINDOW_POPUP,
+                      "type-hint", GDK_WINDOW_TYPE_HINT_NOTIFICATION,
+                      "skip-taskbar-hint", TRUE,
+                      "skip-pager-hint", TRUE,
+                      "focus-on-map", FALSE,
+                      NULL);
+
+        widget = GTK_WIDGET (object);
+        style_context = gtk_widget_get_style_context (widget);
+        gtk_style_context_add_class (style_context, "osd");
+
+        return object;
+}
+
+static void
+msd_osd_window_class_init (MsdOsdWindowClass *klass)
+{
+        GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+        GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+        gobject_class->constructor = msd_osd_window_constructor;
+
+        widget_class->show = msd_osd_window_real_show;
+        widget_class->hide = msd_osd_window_real_hide;
+        widget_class->realize = msd_osd_window_real_realize;
+        widget_class->style_updated = msd_osd_window_style_updated;
+        widget_class->get_preferred_width = msd_osd_window_get_preferred_width;
+        widget_class->get_preferred_height = msd_osd_window_get_preferred_height;
+        widget_class->draw = msd_osd_window_draw;
+
+        signals[DRAW_WHEN_COMPOSITED] = g_signal_new ("draw-when-composited",
+                                                        G_TYPE_FROM_CLASS (gobject_class),
+                                                        G_SIGNAL_RUN_FIRST,
+                                                        G_STRUCT_OFFSET (MsdOsdWindowClass, draw_when_composited),
+                                                        NULL, NULL,
+                                                        g_cclosure_marshal_VOID__POINTER,
+                                                        G_TYPE_NONE, 1,
+                                                        G_TYPE_POINTER);
+
+        gtk_widget_class_set_css_name (widget_class, "MsdOsdWindow");
+}
+
+/**
+ * msd_osd_window_is_composited:
+ * @window: a #MsdOsdWindow
+ *
+ * Return value: whether the window was created on a composited screen.
+ */
+gboolean
+msd_osd_window_is_composited (MsdOsdWindow *window)
+{
+        return window->priv->is_composited;
+}
+
+/**
+ * msd_osd_window_is_valid:
+ * @window: a #MsdOsdWindow
+ *
+ * Return value: TRUE if the @window's idea of being composited matches whether
+ * its current screen is actually composited and whether the scale factor has
+ * not changed since last draw.
+ */
+gboolean
+msd_osd_window_is_valid (MsdOsdWindow *window)
+{
+        GdkScreen *screen = gtk_widget_get_screen (GTK_WIDGET (window));
+        gint scale_factor = gtk_widget_get_scale_factor (GTK_WIDGET (window));
+        return gdk_screen_is_composited (screen) == window->priv->is_composited
+            && scale_factor == window->priv->scale_factor;
+}
+
+static void
+msd_osd_window_init (MsdOsdWindow *window)
+{
+        GdkScreen       *screen;
+        GtkStyleContext *style;
+
+        window->priv = msd_osd_window_get_instance_private (window);
+
+        screen = gtk_widget_get_screen (GTK_WIDGET (window));
+
+        window->priv->is_composited = (gdk_screen_is_composited (screen) != FALSE);
+        window->priv->scale_factor = gtk_widget_get_scale_factor (GTK_WIDGET (window));
+
+        if (window->priv->is_composited) {
+                gdouble scalew, scaleh, scale;
+                gint size;
+
+                gtk_window_set_decorated (GTK_WINDOW (window), FALSE);
+                gtk_widget_set_app_paintable (GTK_WIDGET (window), TRUE);
+
+                style = gtk_widget_get_style_context (GTK_WIDGET (window));
+                gtk_style_context_add_class (style, "window-frame");
+
+                /* assume 110x110 on a 640x480 display and scale from there */
+                scalew = WidthOfScreen (gdk_x11_screen_get_xscreen (screen)) / (640.0 * window->priv->scale_factor);
+                scaleh = HeightOfScreen (gdk_x11_screen_get_xscreen (screen)) / (480.0 * window->priv->scale_factor);
+                scale = MIN (scalew, scaleh);
+                size = 110 * MAX (1, scale);
+
+                gtk_window_set_default_size (GTK_WINDOW (window), size, size);
+
+                window->priv->fade_out_alpha = 1.0;
+        } else {
+                gtk_container_set_border_width (GTK_CONTAINER (window), 12);
+        }
+}
+
+GtkWidget *
+msd_osd_window_new (void)
+{
+        return g_object_new (MSD_TYPE_OSD_WINDOW, NULL);
+}
+
+/**
+ * msd_osd_window_update_and_hide:
+ * @window: a #MsdOsdWindow
+ *
+ * Queues the @window for immediate drawing, and queues a timer to hide the window.
+ */
+void
+msd_osd_window_update_and_hide (MsdOsdWindow *window)
+{
+        remove_hide_timeout (window);
+        add_hide_timeout (window);
+
+        if (window->priv->is_composited) {
+                gtk_widget_queue_draw (GTK_WIDGET (window));
+        }
+}
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/12.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/12.html new file mode 100644 index 0000000..1e1d884 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/12.html @@ -0,0 +1,309 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
/* private.h: various private functions
+
+   Copyright 2009, Novell, Inc.
+
+   This file is part of the Mate Library.
+
+   The Mate Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The Mate Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the Mate Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+   Boston, MA 02110-1301, USA.
+
+   Author: Vincent Untz <vuntz@gnome.org>
+*/
+
+#ifndef __MATE_DESKTOP_PRIVATE_H__
+#define __MATE_DESKTOP_PRIVATE_H__
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+G_BEGIN_DECLS
+
+void _mate_desktop_init_i18n (void);
+
+G_END_DECLS
+
+#endif
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/13.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/13.html new file mode 100644 index 0000000..3822306 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/13.html @@ -0,0 +1,437 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
/*
+ * GTK - The GIMP Toolkit
+ * Copyright (C) 1998, 1999 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This Library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This Library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with the Mate Library; see the file COPYING.LIB. If not,
+ * write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+/* Color picker button for GNOME
+ *
+ * Author: Federico Mena <federico@nuclecu.unam.mx>
+ *
+ * Modified by the GTK+ Team and others 2003.  See the AUTHORS
+ * file for a list of people on the GTK+ Team.  See the ChangeLog
+ * files for a list of changes.  These files are distributed with
+ * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
+ */
+
+#ifndef __MATE_COLOR_BUTTON_H__
+#define __MATE_COLOR_BUTTON_H__
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+G_BEGIN_DECLS
+
+/* The MateColorButton widget is a simple color picker in a button.
+ * The button displays a sample of the currently selected color.  When
+ * the user clicks on the button, a color selection dialog pops up.
+ * The color picker emits the "color_set" signal when the color is set.
+ */
+
+#define MATE_TYPE_COLOR_BUTTON             (mate_color_button_get_type ())
+#define MATE_COLOR_BUTTON(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), MATE_TYPE_COLOR_BUTTON, MateColorButton))
+#define MATE_COLOR_BUTTON_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), MATE_TYPE_COLOR_BUTTON, MateColorButtonClass))
+#define MATE_IS_COLOR_BUTTON(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MATE_TYPE_COLOR_BUTTON))
+#define MATE_IS_COLOR_BUTTON_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), MATE_TYPE_COLOR_BUTTON))
+#define MATE_COLOR_BUTTON_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), MATE_TYPE_COLOR_BUTTON, MateColorButtonClass))
+
+typedef struct _MateColorButton          MateColorButton;
+typedef struct _MateColorButtonClass     MateColorButtonClass;
+typedef struct _MateColorButtonPrivate   MateColorButtonPrivate;
+
+struct _MateColorButton {
+  GtkButton button;
+
+  /*< private >*/
+
+  MateColorButtonPrivate *priv;
+};
+
+struct _MateColorButtonClass {
+  GtkButtonClass parent_class;
+
+  void (* color_set) (MateColorButton *cp);
+
+  /* Padding for future expansion */
+  void (*_gtk_reserved1) (void);
+  void (*_gtk_reserved2) (void);
+  void (*_gtk_reserved3) (void);
+  void (*_gtk_reserved4) (void);
+};
+
+GType      mate_color_button_get_type       (void) G_GNUC_CONST;
+GtkWidget *mate_color_button_new            (void);
+GtkWidget *mate_color_button_new_with_color (const GdkColor *color);
+void       mate_color_button_set_color      (MateColorButton *color_button,
+					    const GdkColor *color);
+void       mate_color_button_set_rgba       (MateColorButton *color_button,
+					     const GdkRGBA   *color);
+void       mate_color_button_set_alpha      (MateColorButton *color_button,
+					    guint16         alpha);
+void       mate_color_button_get_color      (MateColorButton *color_button,
+					    GdkColor       *color);
+void       mate_color_button_get_rgba       (MateColorButton *color_button,
+					     GdkRGBA         *color);
+guint16    mate_color_button_get_alpha      (MateColorButton *color_button);
+void       mate_color_button_set_use_alpha  (MateColorButton *color_button,
+					    gboolean        use_alpha);
+gboolean   mate_color_button_get_use_alpha  (MateColorButton *color_button);
+void       mate_color_button_set_title      (MateColorButton *color_button,
+					    const gchar    *title);
+const gchar *mate_color_button_get_title (MateColorButton *color_button);
+
+G_END_DECLS
+
+#endif  /* __MATE_COLOR_BUTTON_H__ */
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/14.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/14.html new file mode 100644 index 0000000..94db508 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/14.html @@ -0,0 +1,489 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
/* GTK - The GIMP Toolkit
+ * Copyright (C) 2000 Red Hat, Inc.
+ * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+/*
+ * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
+ * file for a list of people on the GTK+ Team.  See the ChangeLog
+ * files for a list of changes.  These files are distributed with
+ * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
+ */
+
+#ifndef __MATE_COLOR_SELECTION_H__
+#define __MATE_COLOR_SELECTION_H__
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+G_BEGIN_DECLS
+
+#define MATE_TYPE_COLOR_SELECTION			(mate_color_selection_get_type ())
+#define MATE_COLOR_SELECTION(obj)			(G_TYPE_CHECK_INSTANCE_CAST ((obj), MATE_TYPE_COLOR_SELECTION, MateColorSelection))
+#define MATE_COLOR_SELECTION_CLASS(klass)		(G_TYPE_CHECK_CLASS_CAST ((klass), MATE_TYPE_COLOR_SELECTION, MateColorSelectionClass))
+#define MATE_IS_COLOR_SELECTION(obj)			(G_TYPE_CHECK_INSTANCE_TYPE ((obj), MATE_TYPE_COLOR_SELECTION))
+#define MATE_IS_COLOR_SELECTION_CLASS(klass)		(G_TYPE_CHECK_CLASS_TYPE ((klass), MATE_TYPE_COLOR_SELECTION))
+#define MATE_COLOR_SELECTION_GET_CLASS(obj)              (G_TYPE_INSTANCE_GET_CLASS ((obj), MATE_TYPE_COLOR_SELECTION, MateColorSelectionClass))
+
+typedef struct _MateColorSelection       MateColorSelection;
+typedef struct _MateColorSelectionClass  MateColorSelectionClass;
+typedef struct _MateColorSelectionPrivate    MateColorSelectionPrivate;
+
+typedef void (* MateColorSelectionChangePaletteFunc) (const GdkColor    *colors,
+                                                     gint               n_colors);
+typedef void (* MateColorSelectionChangePaletteWithScreenFunc) (GdkScreen         *screen,
+							       const GdkColor    *colors,
+							       gint               n_colors);
+
+struct _MateColorSelection
+{
+  GtkBox parent_instance;
+
+  /* < private_data > */
+  MateColorSelectionPrivate *private_data;
+};
+
+struct _MateColorSelectionClass
+{
+  GtkBoxClass parent_class;
+
+  void (*color_changed)	(MateColorSelection *color_selection);
+
+  /* Padding for future expansion */
+  void (*_gtk_reserved1) (void);
+  void (*_gtk_reserved2) (void);
+  void (*_gtk_reserved3) (void);
+  void (*_gtk_reserved4) (void);
+};
+
+/* ColorSelection */
+
+GType      mate_color_selection_get_type                (void) G_GNUC_CONST;
+GtkWidget *mate_color_selection_new                     (void);
+gboolean   mate_color_selection_get_has_opacity_control (MateColorSelection *colorsel);
+void       mate_color_selection_set_has_opacity_control (MateColorSelection *colorsel,
+							gboolean           has_opacity);
+gboolean   mate_color_selection_get_has_palette         (MateColorSelection *colorsel);
+void       mate_color_selection_set_has_palette         (MateColorSelection *colorsel,
+							gboolean           has_palette);
+
+void     mate_color_selection_set_current_color   (MateColorSelection *colorsel,
+						  const GdkColor    *color);
+void     mate_color_selection_set_current_alpha   (MateColorSelection *colorsel,
+						  guint16            alpha);
+void     mate_color_selection_get_current_color   (MateColorSelection *colorsel,
+						  GdkColor          *color);
+guint16  mate_color_selection_get_current_alpha   (MateColorSelection *colorsel);
+void     mate_color_selection_set_previous_color  (MateColorSelection *colorsel,
+						  const GdkColor    *color);
+void     mate_color_selection_set_previous_alpha  (MateColorSelection *colorsel,
+						  guint16            alpha);
+void     mate_color_selection_get_previous_color  (MateColorSelection *colorsel,
+						  GdkColor          *color);
+guint16  mate_color_selection_get_previous_alpha  (MateColorSelection *colorsel);
+
+gboolean mate_color_selection_is_adjusting        (MateColorSelection *colorsel);
+
+gboolean mate_color_selection_palette_from_string (const gchar       *str,
+                                                  GdkColor         **colors,
+                                                  gint              *n_colors);
+gchar*   mate_color_selection_palette_to_string   (const GdkColor    *colors,
+                                                  gint               n_colors);
+
+#ifndef GTK_DISABLE_DEPRECATED
+#ifndef GDK_MULTIHEAD_SAFE
+MateColorSelectionChangePaletteFunc           mate_color_selection_set_change_palette_hook             (MateColorSelectionChangePaletteFunc           func);
+#endif
+#endif
+
+MateColorSelectionChangePaletteWithScreenFunc mate_color_selection_set_change_palette_with_screen_hook (MateColorSelectionChangePaletteWithScreenFunc func);
+
+#ifndef GTK_DISABLE_DEPRECATED
+/* Deprecated calls: */
+void mate_color_selection_set_color         (MateColorSelection *colorsel,
+					    gdouble           *color);
+void mate_color_selection_get_color         (MateColorSelection *colorsel,
+					    gdouble           *color);
+#endif /* GTK_DISABLE_DEPRECATED */
+
+G_END_DECLS
+
+#endif /* __MATE_COLOR_SELECTION_H__ */
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/15.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/15.html new file mode 100644 index 0000000..614eadb --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/15.html @@ -0,0 +1,383 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
/* GTK - The GIMP Toolkit
+ * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+/*
+ * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
+ * file for a list of people on the GTK+ Team.  See the ChangeLog
+ * files for a list of changes.  These files are distributed with
+ * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
+ */
+
+#ifndef __MATE_COLOR_SELECTION_DIALOG_H__
+#define __MATE_COLOR_SELECTION_DIALOG_H__
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+G_BEGIN_DECLS
+
+#define MATE_TYPE_COLOR_SELECTION_DIALOG            (mate_color_selection_dialog_get_type ())
+#define MATE_COLOR_SELECTION_DIALOG(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), MATE_TYPE_COLOR_SELECTION_DIALOG, MateColorSelectionDialog))
+#define MATE_COLOR_SELECTION_DIALOG_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), MATE_TYPE_COLOR_SELECTION_DIALOG, MateColorSelectionDialogClass))
+#define MATE_IS_COLOR_SELECTION_DIALOG(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MATE_TYPE_COLOR_SELECTION_DIALOG))
+#define MATE_IS_COLOR_SELECTION_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MATE_TYPE_COLOR_SELECTION_DIALOG))
+#define MATE_COLOR_SELECTION_DIALOG_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), MATE_TYPE_COLOR_SELECTION_DIALOG, MateColorSelectionDialogClass))
+
+typedef struct _MateColorSelectionDialog       MateColorSelectionDialog;
+typedef struct _MateColorSelectionDialogClass  MateColorSelectionDialogClass;
+
+struct _MateColorSelectionDialog
+{
+  GtkDialog parent_instance;
+
+  GtkWidget *colorsel;
+  GtkWidget *ok_button;
+  GtkWidget *cancel_button;
+  GtkWidget *help_button;
+};
+
+struct _MateColorSelectionDialogClass
+{
+  GtkDialogClass parent_class;
+
+  /* Padding for future expansion */
+  void (*_gtk_reserved1) (void);
+  void (*_gtk_reserved2) (void);
+  void (*_gtk_reserved3) (void);
+  void (*_gtk_reserved4) (void);
+};
+
+/* ColorSelectionDialog */
+GType      mate_color_selection_dialog_get_type            (void) G_GNUC_CONST;
+GtkWidget* mate_color_selection_dialog_new                 (const gchar *title);
+GtkWidget* mate_color_selection_dialog_get_color_selection (MateColorSelectionDialog *colorsel);
+
+G_END_DECLS
+
+#endif /* __MATE_COLOR_SELECTION_DIALOG_H__ */
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/16.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/16.html new file mode 100644 index 0000000..1942212 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/16.html @@ -0,0 +1,6079 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
   1
+   2
+   3
+   4
+   5
+   6
+   7
+   8
+   9
+  10
+  11
+  12
+  13
+  14
+  15
+  16
+  17
+  18
+  19
+  20
+  21
+  22
+  23
+  24
+  25
+  26
+  27
+  28
+  29
+  30
+  31
+  32
+  33
+  34
+  35
+  36
+  37
+  38
+  39
+  40
+  41
+  42
+  43
+  44
+  45
+  46
+  47
+  48
+  49
+  50
+  51
+  52
+  53
+  54
+  55
+  56
+  57
+  58
+  59
+  60
+  61
+  62
+  63
+  64
+  65
+  66
+  67
+  68
+  69
+  70
+  71
+  72
+  73
+  74
+  75
+  76
+  77
+  78
+  79
+  80
+  81
+  82
+  83
+  84
+  85
+  86
+  87
+  88
+  89
+  90
+  91
+  92
+  93
+  94
+  95
+  96
+  97
+  98
+  99
+ 100
+ 101
+ 102
+ 103
+ 104
+ 105
+ 106
+ 107
+ 108
+ 109
+ 110
+ 111
+ 112
+ 113
+ 114
+ 115
+ 116
+ 117
+ 118
+ 119
+ 120
+ 121
+ 122
+ 123
+ 124
+ 125
+ 126
+ 127
+ 128
+ 129
+ 130
+ 131
+ 132
+ 133
+ 134
+ 135
+ 136
+ 137
+ 138
+ 139
+ 140
+ 141
+ 142
+ 143
+ 144
+ 145
+ 146
+ 147
+ 148
+ 149
+ 150
+ 151
+ 152
+ 153
+ 154
+ 155
+ 156
+ 157
+ 158
+ 159
+ 160
+ 161
+ 162
+ 163
+ 164
+ 165
+ 166
+ 167
+ 168
+ 169
+ 170
+ 171
+ 172
+ 173
+ 174
+ 175
+ 176
+ 177
+ 178
+ 179
+ 180
+ 181
+ 182
+ 183
+ 184
+ 185
+ 186
+ 187
+ 188
+ 189
+ 190
+ 191
+ 192
+ 193
+ 194
+ 195
+ 196
+ 197
+ 198
+ 199
+ 200
+ 201
+ 202
+ 203
+ 204
+ 205
+ 206
+ 207
+ 208
+ 209
+ 210
+ 211
+ 212
+ 213
+ 214
+ 215
+ 216
+ 217
+ 218
+ 219
+ 220
+ 221
+ 222
+ 223
+ 224
+ 225
+ 226
+ 227
+ 228
+ 229
+ 230
+ 231
+ 232
+ 233
+ 234
+ 235
+ 236
+ 237
+ 238
+ 239
+ 240
+ 241
+ 242
+ 243
+ 244
+ 245
+ 246
+ 247
+ 248
+ 249
+ 250
+ 251
+ 252
+ 253
+ 254
+ 255
+ 256
+ 257
+ 258
+ 259
+ 260
+ 261
+ 262
+ 263
+ 264
+ 265
+ 266
+ 267
+ 268
+ 269
+ 270
+ 271
+ 272
+ 273
+ 274
+ 275
+ 276
+ 277
+ 278
+ 279
+ 280
+ 281
+ 282
+ 283
+ 284
+ 285
+ 286
+ 287
+ 288
+ 289
+ 290
+ 291
+ 292
+ 293
+ 294
+ 295
+ 296
+ 297
+ 298
+ 299
+ 300
+ 301
+ 302
+ 303
+ 304
+ 305
+ 306
+ 307
+ 308
+ 309
+ 310
+ 311
+ 312
+ 313
+ 314
+ 315
+ 316
+ 317
+ 318
+ 319
+ 320
+ 321
+ 322
+ 323
+ 324
+ 325
+ 326
+ 327
+ 328
+ 329
+ 330
+ 331
+ 332
+ 333
+ 334
+ 335
+ 336
+ 337
+ 338
+ 339
+ 340
+ 341
+ 342
+ 343
+ 344
+ 345
+ 346
+ 347
+ 348
+ 349
+ 350
+ 351
+ 352
+ 353
+ 354
+ 355
+ 356
+ 357
+ 358
+ 359
+ 360
+ 361
+ 362
+ 363
+ 364
+ 365
+ 366
+ 367
+ 368
+ 369
+ 370
+ 371
+ 372
+ 373
+ 374
+ 375
+ 376
+ 377
+ 378
+ 379
+ 380
+ 381
+ 382
+ 383
+ 384
+ 385
+ 386
+ 387
+ 388
+ 389
+ 390
+ 391
+ 392
+ 393
+ 394
+ 395
+ 396
+ 397
+ 398
+ 399
+ 400
+ 401
+ 402
+ 403
+ 404
+ 405
+ 406
+ 407
+ 408
+ 409
+ 410
+ 411
+ 412
+ 413
+ 414
+ 415
+ 416
+ 417
+ 418
+ 419
+ 420
+ 421
+ 422
+ 423
+ 424
+ 425
+ 426
+ 427
+ 428
+ 429
+ 430
+ 431
+ 432
+ 433
+ 434
+ 435
+ 436
+ 437
+ 438
+ 439
+ 440
+ 441
+ 442
+ 443
+ 444
+ 445
+ 446
+ 447
+ 448
+ 449
+ 450
+ 451
+ 452
+ 453
+ 454
+ 455
+ 456
+ 457
+ 458
+ 459
+ 460
+ 461
+ 462
+ 463
+ 464
+ 465
+ 466
+ 467
+ 468
+ 469
+ 470
+ 471
+ 472
+ 473
+ 474
+ 475
+ 476
+ 477
+ 478
+ 479
+ 480
+ 481
+ 482
+ 483
+ 484
+ 485
+ 486
+ 487
+ 488
+ 489
+ 490
+ 491
+ 492
+ 493
+ 494
+ 495
+ 496
+ 497
+ 498
+ 499
+ 500
+ 501
+ 502
+ 503
+ 504
+ 505
+ 506
+ 507
+ 508
+ 509
+ 510
+ 511
+ 512
+ 513
+ 514
+ 515
+ 516
+ 517
+ 518
+ 519
+ 520
+ 521
+ 522
+ 523
+ 524
+ 525
+ 526
+ 527
+ 528
+ 529
+ 530
+ 531
+ 532
+ 533
+ 534
+ 535
+ 536
+ 537
+ 538
+ 539
+ 540
+ 541
+ 542
+ 543
+ 544
+ 545
+ 546
+ 547
+ 548
+ 549
+ 550
+ 551
+ 552
+ 553
+ 554
+ 555
+ 556
+ 557
+ 558
+ 559
+ 560
+ 561
+ 562
+ 563
+ 564
+ 565
+ 566
+ 567
+ 568
+ 569
+ 570
+ 571
+ 572
+ 573
+ 574
+ 575
+ 576
+ 577
+ 578
+ 579
+ 580
+ 581
+ 582
+ 583
+ 584
+ 585
+ 586
+ 587
+ 588
+ 589
+ 590
+ 591
+ 592
+ 593
+ 594
+ 595
+ 596
+ 597
+ 598
+ 599
+ 600
+ 601
+ 602
+ 603
+ 604
+ 605
+ 606
+ 607
+ 608
+ 609
+ 610
+ 611
+ 612
+ 613
+ 614
+ 615
+ 616
+ 617
+ 618
+ 619
+ 620
+ 621
+ 622
+ 623
+ 624
+ 625
+ 626
+ 627
+ 628
+ 629
+ 630
+ 631
+ 632
+ 633
+ 634
+ 635
+ 636
+ 637
+ 638
+ 639
+ 640
+ 641
+ 642
+ 643
+ 644
+ 645
+ 646
+ 647
+ 648
+ 649
+ 650
+ 651
+ 652
+ 653
+ 654
+ 655
+ 656
+ 657
+ 658
+ 659
+ 660
+ 661
+ 662
+ 663
+ 664
+ 665
+ 666
+ 667
+ 668
+ 669
+ 670
+ 671
+ 672
+ 673
+ 674
+ 675
+ 676
+ 677
+ 678
+ 679
+ 680
+ 681
+ 682
+ 683
+ 684
+ 685
+ 686
+ 687
+ 688
+ 689
+ 690
+ 691
+ 692
+ 693
+ 694
+ 695
+ 696
+ 697
+ 698
+ 699
+ 700
+ 701
+ 702
+ 703
+ 704
+ 705
+ 706
+ 707
+ 708
+ 709
+ 710
+ 711
+ 712
+ 713
+ 714
+ 715
+ 716
+ 717
+ 718
+ 719
+ 720
+ 721
+ 722
+ 723
+ 724
+ 725
+ 726
+ 727
+ 728
+ 729
+ 730
+ 731
+ 732
+ 733
+ 734
+ 735
+ 736
+ 737
+ 738
+ 739
+ 740
+ 741
+ 742
+ 743
+ 744
+ 745
+ 746
+ 747
+ 748
+ 749
+ 750
+ 751
+ 752
+ 753
+ 754
+ 755
+ 756
+ 757
+ 758
+ 759
+ 760
+ 761
+ 762
+ 763
+ 764
+ 765
+ 766
+ 767
+ 768
+ 769
+ 770
+ 771
+ 772
+ 773
+ 774
+ 775
+ 776
+ 777
+ 778
+ 779
+ 780
+ 781
+ 782
+ 783
+ 784
+ 785
+ 786
+ 787
+ 788
+ 789
+ 790
+ 791
+ 792
+ 793
+ 794
+ 795
+ 796
+ 797
+ 798
+ 799
+ 800
+ 801
+ 802
+ 803
+ 804
+ 805
+ 806
+ 807
+ 808
+ 809
+ 810
+ 811
+ 812
+ 813
+ 814
+ 815
+ 816
+ 817
+ 818
+ 819
+ 820
+ 821
+ 822
+ 823
+ 824
+ 825
+ 826
+ 827
+ 828
+ 829
+ 830
+ 831
+ 832
+ 833
+ 834
+ 835
+ 836
+ 837
+ 838
+ 839
+ 840
+ 841
+ 842
+ 843
+ 844
+ 845
+ 846
+ 847
+ 848
+ 849
+ 850
+ 851
+ 852
+ 853
+ 854
+ 855
+ 856
+ 857
+ 858
+ 859
+ 860
+ 861
+ 862
+ 863
+ 864
+ 865
+ 866
+ 867
+ 868
+ 869
+ 870
+ 871
+ 872
+ 873
+ 874
+ 875
+ 876
+ 877
+ 878
+ 879
+ 880
+ 881
+ 882
+ 883
+ 884
+ 885
+ 886
+ 887
+ 888
+ 889
+ 890
+ 891
+ 892
+ 893
+ 894
+ 895
+ 896
+ 897
+ 898
+ 899
+ 900
+ 901
+ 902
+ 903
+ 904
+ 905
+ 906
+ 907
+ 908
+ 909
+ 910
+ 911
+ 912
+ 913
+ 914
+ 915
+ 916
+ 917
+ 918
+ 919
+ 920
+ 921
+ 922
+ 923
+ 924
+ 925
+ 926
+ 927
+ 928
+ 929
+ 930
+ 931
+ 932
+ 933
+ 934
+ 935
+ 936
+ 937
+ 938
+ 939
+ 940
+ 941
+ 942
+ 943
+ 944
+ 945
+ 946
+ 947
+ 948
+ 949
+ 950
+ 951
+ 952
+ 953
+ 954
+ 955
+ 956
+ 957
+ 958
+ 959
+ 960
+ 961
+ 962
+ 963
+ 964
+ 965
+ 966
+ 967
+ 968
+ 969
+ 970
+ 971
+ 972
+ 973
+ 974
+ 975
+ 976
+ 977
+ 978
+ 979
+ 980
+ 981
+ 982
+ 983
+ 984
+ 985
+ 986
+ 987
+ 988
+ 989
+ 990
+ 991
+ 992
+ 993
+ 994
+ 995
+ 996
+ 997
+ 998
+ 999
+1000
+1001
+1002
+1003
+1004
+1005
+1006
+1007
+1008
+1009
+1010
+1011
+1012
+1013
+1014
+1015
+1016
+1017
+1018
+1019
+1020
+1021
+1022
+1023
+1024
+1025
+1026
+1027
+1028
+1029
+1030
+1031
+1032
+1033
+1034
+1035
+1036
+1037
+1038
+1039
+1040
+1041
+1042
+1043
+1044
+1045
+1046
+1047
+1048
+1049
+1050
+1051
+1052
+1053
+1054
+1055
+1056
+1057
+1058
+1059
+1060
+1061
+1062
+1063
+1064
+1065
+1066
+1067
+1068
+1069
+1070
+1071
+1072
+1073
+1074
+1075
+1076
+1077
+1078
+1079
+1080
+1081
+1082
+1083
+1084
+1085
+1086
+1087
+1088
+1089
+1090
+1091
+1092
+1093
+1094
+1095
+1096
+1097
+1098
+1099
+1100
+1101
+1102
+1103
+1104
+1105
+1106
+1107
+1108
+1109
+1110
+1111
+1112
+1113
+1114
+1115
+1116
+1117
+1118
+1119
+1120
+1121
+1122
+1123
+1124
+1125
+1126
+1127
+1128
+1129
+1130
+1131
+1132
+1133
+1134
+1135
+1136
+1137
+1138
+1139
+1140
+1141
+1142
+1143
+1144
+1145
+1146
+1147
+1148
+1149
+1150
+1151
+1152
+1153
+1154
+1155
+1156
+1157
+1158
+1159
+1160
+1161
+1162
+1163
+1164
+1165
+1166
+1167
+1168
+1169
+1170
+1171
+1172
+1173
+1174
+1175
+1176
+1177
+1178
+1179
+1180
+1181
+1182
+1183
+1184
+1185
+1186
+1187
+1188
+1189
+1190
+1191
+1192
+1193
+1194
+1195
+1196
+1197
+1198
+1199
+1200
+1201
+1202
+1203
+1204
+1205
+1206
+1207
+1208
+1209
+1210
+1211
+1212
+1213
+1214
+1215
+1216
+1217
+1218
+1219
+1220
+1221
+1222
+1223
+1224
+1225
+1226
+1227
+1228
+1229
+1230
+1231
+1232
+1233
+1234
+1235
+1236
+1237
+1238
+1239
+1240
+1241
+1242
+1243
+1244
+1245
+1246
+1247
+1248
+1249
+1250
+1251
+1252
+1253
+1254
+1255
+1256
+1257
+1258
+1259
+1260
+1261
+1262
+1263
+1264
+1265
+1266
+1267
+1268
+1269
+1270
+1271
+1272
+1273
+1274
+1275
+1276
+1277
+1278
+1279
+1280
+1281
+1282
+1283
+1284
+1285
+1286
+1287
+1288
+1289
+1290
+1291
+1292
+1293
+1294
+1295
+1296
+1297
+1298
+1299
+1300
+1301
+1302
+1303
+1304
+1305
+1306
+1307
+1308
+1309
+1310
+1311
+1312
+1313
+1314
+1315
+1316
+1317
+1318
+1319
+1320
+1321
+1322
+1323
+1324
+1325
+1326
+1327
+1328
+1329
+1330
+1331
+1332
+1333
+1334
+1335
+1336
+1337
+1338
+1339
+1340
+1341
+1342
+1343
+1344
+1345
+1346
+1347
+1348
+1349
+1350
+1351
+1352
+1353
+1354
+1355
+1356
+1357
+1358
+1359
+1360
+1361
+1362
+1363
+1364
+1365
+1366
+1367
+1368
+1369
+1370
+1371
+1372
+1373
+1374
+1375
+1376
+1377
+1378
+1379
+1380
+1381
+1382
+1383
+1384
+1385
+1386
+1387
+1388
+1389
+1390
+1391
+1392
+1393
+1394
+1395
+1396
+1397
+1398
+1399
+1400
+1401
+1402
+1403
+1404
+1405
+1406
+1407
+1408
+1409
+1410
+1411
+1412
+1413
+1414
+1415
+1416
+1417
+1418
+1419
+1420
+1421
+1422
+1423
+1424
+1425
+1426
+1427
+1428
+1429
+1430
+1431
+1432
+1433
+1434
+1435
+1436
+1437
+1438
+1439
+1440
+1441
+1442
+1443
+1444
+1445
+1446
+1447
+1448
+1449
+1450
+1451
+1452
+1453
+1454
+1455
+1456
+1457
+1458
+1459
+1460
+1461
+1462
+1463
+1464
+1465
+1466
+1467
+1468
+1469
+1470
+1471
+1472
+1473
+1474
+1475
+1476
+1477
+1478
+1479
+1480
+1481
+1482
+1483
+1484
+1485
+1486
+1487
+1488
+1489
+1490
+1491
+1492
+1493
+1494
+1495
+1496
+1497
+1498
+1499
+1500
+1501
+1502
+1503
+1504
+1505
+1506
+1507
+1508
+1509
+1510
+1511
+1512
+1513
+1514
+1515
+1516
+1517
+1518
+1519
+1520
+1521
+1522
+1523
+1524
+1525
+1526
+1527
+1528
+1529
+1530
+1531
+1532
+1533
+1534
+1535
+1536
+1537
+1538
+1539
+1540
+1541
+1542
+1543
+1544
+1545
+1546
+1547
+1548
+1549
+1550
+1551
+1552
+1553
+1554
+1555
+1556
+1557
+1558
+1559
+1560
+1561
+1562
+1563
+1564
+1565
+1566
+1567
+1568
+1569
+1570
+1571
+1572
+1573
+1574
+1575
+1576
+1577
+1578
+1579
+1580
+1581
+1582
+1583
+1584
+1585
+1586
+1587
+1588
+1589
+1590
+1591
+1592
+1593
+1594
+1595
+1596
+1597
+1598
+1599
+1600
+1601
+1602
+1603
+1604
+1605
+1606
+1607
+1608
+1609
+1610
+1611
+1612
+1613
+1614
+1615
+1616
+1617
+1618
+1619
+1620
+1621
+1622
+1623
+1624
+1625
+1626
+1627
+1628
+1629
+1630
+1631
+1632
+1633
+1634
+1635
+1636
+1637
+1638
+1639
+1640
+1641
+1642
+1643
+1644
+1645
+1646
+1647
+1648
+1649
+1650
+1651
+1652
+1653
+1654
+1655
+1656
+1657
+1658
+1659
+1660
+1661
+1662
+1663
+1664
+1665
+1666
+1667
+1668
+1669
+1670
+1671
+1672
+1673
+1674
+1675
+1676
+1677
+1678
+1679
+1680
+1681
+1682
+1683
+1684
+1685
+1686
+1687
+1688
+1689
+1690
+1691
+1692
+1693
+1694
+1695
+1696
+1697
+1698
+1699
+1700
+1701
+1702
+1703
+1704
+1705
+1706
+1707
+1708
+1709
+1710
+1711
+1712
+1713
+1714
+1715
+1716
+1717
+1718
+1719
+1720
+1721
+1722
+1723
+1724
+1725
+1726
+1727
+1728
+1729
+1730
+1731
+1732
+1733
+1734
+1735
+1736
+1737
+1738
+1739
+1740
+1741
+1742
+1743
+1744
+1745
+1746
+1747
+1748
+1749
+1750
+1751
+1752
+1753
+1754
+1755
+1756
+1757
+1758
+1759
+1760
+1761
+1762
+1763
+1764
+1765
+1766
+1767
+1768
+1769
+1770
+1771
+1772
+1773
+1774
+1775
+1776
+1777
+1778
+1779
+1780
+1781
+1782
+1783
+1784
+1785
+1786
+1787
+1788
+1789
+1790
+1791
+1792
+1793
+1794
+1795
+1796
+1797
+1798
+1799
+1800
+1801
+1802
+1803
+1804
+1805
+1806
+1807
+1808
+1809
+1810
+1811
+1812
+1813
+1814
+1815
+1816
+1817
+1818
+1819
+1820
+1821
+1822
+1823
+1824
+1825
+1826
+1827
+1828
+1829
+1830
+1831
+1832
+1833
+1834
+1835
+1836
+1837
+1838
+1839
+1840
+1841
+1842
+1843
+1844
+1845
+1846
+1847
+1848
+1849
+1850
+1851
+1852
+1853
+1854
+1855
+1856
+1857
+1858
+1859
+1860
+1861
+1862
+1863
+1864
+1865
+1866
+1867
+1868
+1869
+1870
+1871
+1872
+1873
+1874
+1875
+1876
+1877
+1878
+1879
+1880
+1881
+1882
+1883
+1884
+1885
+1886
+1887
+1888
+1889
+1890
+1891
+1892
+1893
+1894
+1895
+1896
+1897
+1898
+1899
+1900
+1901
+1902
+1903
+1904
+1905
+1906
+1907
+1908
+1909
+1910
+1911
+1912
+1913
+1914
+1915
+1916
+1917
+1918
+1919
+1920
+1921
+1922
+1923
+1924
+1925
+1926
+1927
+1928
+1929
+1930
+1931
+1932
+1933
+1934
+1935
+1936
+1937
+1938
+1939
+1940
+1941
+1942
+1943
+1944
+1945
+1946
+1947
+1948
+1949
+1950
+1951
+1952
+1953
+1954
+1955
+1956
+1957
+1958
+1959
+1960
+1961
+1962
+1963
+1964
+1965
+1966
+1967
+1968
+1969
+1970
+1971
+1972
+1973
+1974
+1975
+1976
+1977
+1978
+1979
+1980
+1981
+1982
+1983
+1984
+1985
+1986
+1987
+1988
+1989
+1990
+1991
+1992
+1993
+1994
+1995
+1996
+1997
+1998
+1999
+2000
+2001
+2002
+2003
+2004
+2005
+2006
+2007
+2008
+2009
+2010
+2011
+2012
+2013
+2014
+2015
+2016
+2017
+2018
+2019
+2020
+2021
+2022
+2023
+2024
+2025
+2026
+2027
+2028
+2029
+2030
+2031
+2032
+2033
+2034
+2035
+2036
+2037
+2038
+2039
+2040
+2041
+2042
+2043
+2044
+2045
+2046
+2047
+2048
+2049
+2050
+2051
+2052
+2053
+2054
+2055
+2056
+2057
+2058
+2059
+2060
+2061
+2062
+2063
+2064
+2065
+2066
+2067
+2068
+2069
+2070
+2071
+2072
+2073
+2074
+2075
+2076
+2077
+2078
+2079
+2080
+2081
+2082
+2083
+2084
+2085
+2086
+2087
+2088
+2089
+2090
+2091
+2092
+2093
+2094
+2095
+2096
+2097
+2098
+2099
+2100
+2101
+2102
+2103
+2104
+2105
+2106
+2107
+2108
+2109
+2110
+2111
+2112
+2113
+2114
+2115
+2116
+2117
+2118
+2119
+2120
+2121
+2122
+2123
+2124
+2125
+2126
+2127
+2128
+2129
+2130
+2131
+2132
+2133
+2134
+2135
+2136
+2137
+2138
+2139
+2140
+2141
+2142
+2143
+2144
+2145
+2146
+2147
+2148
+2149
+2150
+2151
+2152
+2153
+2154
+2155
+2156
+2157
+2158
+2159
+2160
+2161
+2162
+2163
+2164
+2165
+2166
+2167
+2168
+2169
+2170
+2171
+2172
+2173
+2174
+2175
+2176
+2177
+2178
+2179
+2180
+2181
+2182
+2183
+2184
+2185
+2186
+2187
+2188
+2189
+2190
+2191
+2192
+2193
+2194
+2195
+2196
+2197
+2198
+2199
+2200
+2201
+2202
+2203
+2204
+2205
+2206
+2207
+2208
+2209
+2210
+2211
+2212
+2213
+2214
+2215
+2216
+2217
+2218
+2219
+2220
+2221
+2222
+2223
+2224
+2225
+2226
+2227
+2228
+2229
+2230
+2231
+2232
+2233
+2234
+2235
+2236
+2237
+2238
+2239
+2240
+2241
+2242
+2243
+2244
+2245
+2246
+2247
+2248
+2249
+2250
+2251
+2252
+2253
+2254
+2255
+2256
+2257
+2258
+2259
+2260
+2261
+2262
+2263
+2264
+2265
+2266
+2267
+2268
+2269
+2270
+2271
+2272
+2273
+2274
+2275
+2276
+2277
+2278
+2279
+2280
+2281
+2282
+2283
+2284
+2285
+2286
+2287
+2288
+2289
+2290
+2291
+2292
+2293
+2294
+2295
+2296
+2297
+2298
+2299
+2300
+2301
+2302
+2303
+2304
+2305
+2306
+2307
+2308
+2309
+2310
+2311
+2312
+2313
+2314
+2315
+2316
+2317
+2318
+2319
+2320
+2321
+2322
+2323
+2324
+2325
+2326
+2327
+2328
+2329
+2330
+2331
+2332
+2333
+2334
+2335
+2336
+2337
+2338
+2339
+2340
+2341
+2342
+2343
+2344
+2345
+2346
+2347
+2348
+2349
+2350
+2351
+2352
+2353
+2354
+2355
+2356
+2357
+2358
+2359
+2360
+2361
+2362
+2363
+2364
+2365
+2366
+2367
+2368
+2369
+2370
+2371
+2372
+2373
+2374
+2375
+2376
+2377
+2378
+2379
+2380
+2381
+2382
+2383
+2384
+2385
+2386
+2387
+2388
+2389
+2390
+2391
+2392
+2393
+2394
+2395
+2396
+2397
+2398
+2399
+2400
+2401
+2402
+2403
+2404
+2405
+2406
+2407
+2408
+2409
+2410
+2411
+2412
+2413
+2414
+2415
+2416
+2417
+2418
+2419
+2420
+2421
+2422
+2423
+2424
+2425
+2426
+2427
+2428
+2429
+2430
+2431
+2432
+2433
+2434
+2435
+2436
+2437
+2438
+2439
+2440
+2441
+2442
+2443
+2444
+2445
+2446
+2447
+2448
+2449
+2450
+2451
+2452
+2453
+2454
+2455
+2456
+2457
+2458
+2459
+2460
+2461
+2462
+2463
+2464
+2465
+2466
+2467
+2468
+2469
+2470
+2471
+2472
+2473
+2474
+2475
+2476
+2477
+2478
+2479
+2480
+2481
+2482
+2483
+2484
+2485
+2486
+2487
+2488
+2489
+2490
+2491
+2492
+2493
+2494
+2495
+2496
+2497
+2498
+2499
+2500
+2501
+2502
+2503
+2504
+2505
+2506
+2507
+2508
+2509
+2510
+2511
+2512
+2513
+2514
+2515
+2516
+2517
+2518
+2519
+2520
+2521
+2522
+2523
+2524
+2525
+2526
+2527
+2528
+2529
+2530
+2531
+2532
+2533
+2534
+2535
+2536
+2537
+2538
+2539
+2540
+2541
+2542
+2543
+2544
+2545
+2546
+2547
+2548
+2549
+2550
+2551
+2552
+2553
+2554
+2555
+2556
+2557
+2558
+2559
+2560
+2561
+2562
+2563
+2564
+2565
+2566
+2567
+2568
+2569
+2570
+2571
+2572
+2573
+2574
+2575
+2576
+2577
+2578
+2579
+2580
+2581
+2582
+2583
+2584
+2585
+2586
+2587
+2588
+2589
+2590
+2591
+2592
+2593
+2594
+2595
+2596
+2597
+2598
+2599
+2600
+2601
+2602
+2603
+2604
+2605
+2606
+2607
+2608
+2609
+2610
+2611
+2612
+2613
+2614
+2615
+2616
+2617
+2618
+2619
+2620
+2621
+2622
+2623
+2624
+2625
+2626
+2627
+2628
+2629
+2630
+2631
+2632
+2633
+2634
+2635
+2636
+2637
+2638
+2639
+2640
+2641
+2642
+2643
+2644
+2645
+2646
+2647
+2648
+2649
+2650
+2651
+2652
+2653
+2654
+2655
+2656
+2657
+2658
+2659
+2660
+2661
+2662
+2663
+2664
+2665
+2666
+2667
+2668
+2669
+2670
+2671
+2672
+2673
+2674
+2675
+2676
+2677
+2678
+2679
+2680
+2681
+2682
+2683
+2684
+2685
+2686
+2687
+2688
+2689
+2690
+2691
+2692
+2693
+2694
+2695
+2696
+2697
+2698
+2699
+2700
+2701
+2702
+2703
+2704
+2705
+2706
+2707
+2708
+2709
+2710
+2711
+2712
+2713
+2714
+2715
+2716
+2717
+2718
+2719
+2720
+2721
+2722
+2723
+2724
+2725
+2726
+2727
+2728
+2729
+2730
+2731
+2732
+2733
+2734
+2735
+2736
+2737
+2738
+2739
+2740
+2741
+2742
+2743
+2744
+2745
+2746
+2747
+2748
+2749
+2750
+2751
+2752
+2753
+2754
+2755
+2756
+2757
+2758
+2759
+2760
+2761
+2762
+2763
+2764
+2765
+2766
+2767
+2768
+2769
+2770
+2771
+2772
+2773
+2774
+2775
+2776
+2777
+2778
+2779
+2780
+2781
+2782
+2783
+2784
+2785
+2786
+2787
+2788
+2789
+2790
+2791
+2792
+2793
+2794
+2795
+2796
+2797
+2798
+2799
+2800
+2801
+2802
+2803
+2804
+2805
+2806
+2807
+2808
+2809
+2810
+2811
+2812
+2813
+2814
+2815
+2816
+2817
+2818
+2819
+2820
+2821
+2822
+2823
+2824
+2825
+2826
+2827
+2828
+2829
+2830
+2831
+2832
+2833
+2834
+2835
+2836
+2837
+2838
+2839
+2840
+2841
+2842
+2843
+2844
+2845
+2846
+2847
+2848
+2849
+2850
+2851
+2852
+2853
+2854
+2855
+2856
+2857
+2858
+2859
+2860
+2861
+2862
+2863
+2864
+2865
+2866
+2867
+2868
+2869
+2870
+2871
+2872
+2873
+2874
+2875
+2876
+2877
+2878
+2879
+2880
+2881
+2882
+2883
+2884
+2885
+2886
+2887
+2888
+2889
+2890
+2891
+2892
+2893
+2894
+2895
+2896
+2897
+2898
+2899
+2900
+2901
+2902
+2903
+2904
+2905
+2906
+2907
+2908
+2909
+2910
+2911
+2912
+2913
+2914
+2915
+2916
+2917
+2918
+2919
+2920
+2921
/* GTK - The GIMP Toolkit
+ * Copyright (C) 2000 Red Hat, Inc.
+ * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+/*
+ * Modified by the GTK+ Team and others 1997-2001.  See the AUTHORS
+ * file for a list of people on the GTK+ Team.  See the ChangeLog
+ * files for a list of changes.  These files are distributed with
+ * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
+ */
+
+#include "config.h"<--- Include file: "config.h" not found.
+#include "private.h"
+#include <math.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <gdk/gdkx.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdk/gdkkeysyms.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n-lib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include "mate-colorsel.h"
+#include "mate-hsv.h"
+
+#define DEFAULT_COLOR_PALETTE "#ef2929:#fcaf3e:#fce94f:#8ae234:#729fcf:#ad7fa8:#e9b96e:#888a85:#eeeeec:#cc0000:#f57900:#edd400:#73d216:#3465a4:#75507b:#c17d11:#555753:#d3d7cf:#a40000:#ce5c00:#c4a000:#4e9a06:#204a87:#5c3566:#8f5902:#2e3436:#babdb6:#000000:#2e3436:#555753:#888a85:#babdb6:#d3d7cf:#eeeeec:#f3f3f3:#ffffff"
+
+/* Number of elements in the custom palatte */
+#define GTK_CUSTOM_PALETTE_WIDTH 9
+#define GTK_CUSTOM_PALETTE_HEIGHT 4
+
+#define CUSTOM_PALETTE_ENTRY_WIDTH   20
+#define CUSTOM_PALETTE_ENTRY_HEIGHT  20
+
+/* The cursor for the dropper */
+#define DROPPER_WIDTH 16
+#define DROPPER_HEIGHT 16
+#define DROPPER_STRIDE 64
+#define DROPPER_X_HOT 2
+#define DROPPER_Y_HOT 16
+
+#define CHECK_SIZE 16
+#define BIG_STEP 20
+
+/* Conversion between 0->1 double and and guint16. See
+ * scale_round() below for more general conversions
+ */
+#define SCALE(i) (i / 65535.)
+#define UNSCALE(d) ((guint16)(d * 65535 + 0.5))
+#define INTENSITY(r, g, b) ((r) * 0.30 + (g) * 0.59 + (b) * 0.11)
+
+enum {
+  COLOR_CHANGED,
+  LAST_SIGNAL
+};
+
+enum {
+  PROP_0,
+  PROP_HAS_PALETTE,
+  PROP_HAS_OPACITY_CONTROL,
+  PROP_CURRENT_COLOR,
+  PROP_CURRENT_ALPHA,
+  PROP_HEX_STRING
+};
+
+enum {
+  COLORSEL_RED = 0,
+  COLORSEL_GREEN = 1,
+  COLORSEL_BLUE = 2,
+  COLORSEL_OPACITY = 3,
+  COLORSEL_HUE,
+  COLORSEL_SATURATION,
+  COLORSEL_VALUE,
+  COLORSEL_NUM_CHANNELS
+};
+
+struct _MateColorSelectionPrivate
+{
+  guint has_opacity : 1;
+  guint has_palette : 1;
+  guint changing : 1;
+  guint default_set : 1;
+  guint default_alpha_set : 1;
+  guint has_grab : 1;
+
+  gdouble color[COLORSEL_NUM_CHANNELS];
+  gdouble old_color[COLORSEL_NUM_CHANNELS];
+
+  GtkWidget *triangle_colorsel;
+  GtkWidget *hue_spinbutton;
+  GtkWidget *sat_spinbutton;
+  GtkWidget *val_spinbutton;
+  GtkWidget *red_spinbutton;
+  GtkWidget *green_spinbutton;
+  GtkWidget *blue_spinbutton;
+  GtkWidget *opacity_slider;
+  GtkWidget *opacity_label;
+  GtkWidget *opacity_entry;
+  GtkWidget *palette_frame;
+  GtkWidget *hex_entry;
+
+  /* The Palette code */
+  GtkWidget *custom_palette [GTK_CUSTOM_PALETTE_WIDTH][GTK_CUSTOM_PALETTE_HEIGHT];
+
+  /* The color_sample stuff */
+  GtkWidget *sample_area;
+  GtkWidget *old_sample;
+  GtkWidget *cur_sample;
+  GtkWidget *colorsel;
+
+  /* Window for grabbing on */
+  GtkWidget *dropper_grab_widget;
+  guint32    grab_time;
+
+  /* Connection to settings */
+  gulong settings_connection;
+};
+
+static void mate_color_selection_dispose		(GObject		 *object);
+static void mate_color_selection_finalize        (GObject		 *object);
+static void update_color			(MateColorSelection	 *colorsel);
+static void mate_color_selection_set_property    (GObject                 *object,
+					         guint                    prop_id,
+					         const GValue            *value,
+					         GParamSpec              *pspec);
+static void mate_color_selection_get_property    (GObject                 *object,
+					         guint                    prop_id,
+					         GValue                  *value,
+					         GParamSpec              *pspec);
+
+static void mate_color_selection_realize         (GtkWidget               *widget);
+static void mate_color_selection_unrealize       (GtkWidget               *widget);
+static void mate_color_selection_show_all        (GtkWidget               *widget);
+static gboolean mate_color_selection_grab_broken (GtkWidget               *widget,
+						 GdkEventGrabBroken      *event);
+
+static void     mate_color_selection_set_palette_color   (MateColorSelection *colorsel,
+                                                         gint               index,
+                                                         GdkColor          *color);
+static void     default_noscreen_change_palette_func    (const GdkColor    *colors,
+							 gint               n_colors);
+static void     default_change_palette_func             (GdkScreen	   *screen,
+							 const GdkColor    *colors,
+							 gint               n_colors);
+static void     make_control_relations                  (AtkObject         *atk_obj,
+                                                         GtkWidget         *widget);
+static void     make_all_relations                      (AtkObject         *atk_obj,
+                                                         MateColorSelectionPrivate *priv);
+
+static void 	hsv_changed                             (GtkWidget         *hsv,
+							 gpointer           data);
+static void 	get_screen_color                        (GtkWidget         *button);
+static void 	adjustment_changed                      (GtkAdjustment     *adjustment,
+							 gpointer           data);
+static void 	opacity_entry_changed                   (GtkWidget 	   *opacity_entry,
+							 gpointer  	    data);
+static void 	hex_changed                             (GtkWidget 	   *hex_entry,
+							 gpointer  	    data);
+static gboolean hex_focus_out                           (GtkWidget     	   *hex_entry,
+							 GdkEventFocus 	   *event,
+							 gpointer      	    data);
+static void 	color_sample_new                        (MateColorSelection *colorsel);
+static void 	make_label_spinbutton     		(MateColorSelection *colorsel,
+	    				  		 GtkWidget        **spinbutton,
+	    				  		 gchar             *text,
+	    				  		 GtkWidget         *grid,
+	    				  		 gint               i,
+	    				  		 gint               j,
+	    				  		 gint               channel_type,
+	    				  		 const gchar       *tooltip);
+static void 	make_palette_frame                      (MateColorSelection *colorsel,
+							 GtkWidget         *grid,
+							 gint               i,
+							 gint               j);
+static void 	set_selected_palette                    (MateColorSelection *colorsel,
+							 int                x,
+							 int                y);
+static void 	set_focus_line_attributes               (GtkWidget 	   *drawing_area,
+							 cairo_t   	   *cr,
+							 gint      	   *focus_width);
+static gboolean mouse_press 		     	       	(GtkWidget         *invisible,
+                            		     	       	 GdkEventButton    *event,
+                            		     	       	 gpointer           data);
+static void  palette_change_notify_instance (GObject    *object,
+					     GParamSpec *pspec,
+					     gpointer    data);
+static void update_palette (MateColorSelection *colorsel);
+static void shutdown_eyedropper (GtkWidget *widget);
+
+static guint color_selection_signals[LAST_SIGNAL] = { 0 };
+
+static MateColorSelectionChangePaletteFunc noscreen_change_palette_hook = default_noscreen_change_palette_func;
+static MateColorSelectionChangePaletteWithScreenFunc change_palette_hook = default_change_palette_func;
+
+static const guchar dropper_bits[] = {
+"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+  "\0U\35\35\35\373\40\40\40\350\0\0\0""6\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\"\0\0\0\265"
+  "\0\0\0\373\233\233\233\377\233\233\233\377\0\0\0\351\0\0\0\0\0\0\0\0"
+  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+  "\0y\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\375\0\0\0\0\0\0\0\0"
+  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+  "\0U555\374\0\0\0\377\0\0\0\377\0\0\0\366\0\0\0t\0\0\0\15\0\0\0\0\0\0"
+  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0=EEE\377\362"
+  "\362\362\377HHH\377\0\0\0\377\0\0\0\332\0\0\0.\0\0\0\6\0\0\0\0\0\0\0"
+  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0=ddd\370\352\352\352"
+  "\377xxx\377\5\5\5\305\0\0\0\256\0\0\0q\0\0\0\15\0\0\0\0\0\0\0\0\0\0\0"
+  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0=EEE\377\353\353\353\377\206"
+  "\206\206\377\2\2\2\311\1\1\1=\0\0\0@\0\0\0-\0\0\0\4\0\0\0\0\0\0\0\0\0"
+  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0=ddd\370\354\354\354\377xxx\377\2"
+  "\2\2\311\0\0\0\77\0\0\0\21\0\0\0\14\0\0\0\10\0\0\0\0\0\0\0\0\0\0\0\0"
+  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0<EEE\377\354\354\354\377\206\206\206\377"
+  "\2\2\2\311\2\2\2""6\0\0\0\20\0\0\0\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\316\374\374\374\377yyy\377\2\2"
+  "\2\311\0\0\0\77\0\0\0\20\0\0\0\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\32)))\351111\362\0\0\0\306\2\2\2""6"
+  "\0\0\0\20\0\0\0\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+  "\0\0\0\0\0\0\0\0\0\0\0\0\0\21\0\0\0j\0\0\0g\0\0\0<\0\0\0\20\0\0\0\1\0"
+  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+  "\0\0\0\0\0\0\0\0\11\0\0\0(\0\0\0\40\0\0\0\14\0\0\0\1\0\0\0\0\0\0\0\0"
+  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+  "\0\0\0\0\0\0\0\0\0\3\0\0\0\2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+  "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"};
+
+G_DEFINE_TYPE_WITH_PRIVATE (MateColorSelection, mate_color_selection, GTK_TYPE_BOX)<--- There is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
+
+static void
+mate_color_selection_class_init (MateColorSelectionClass *klass)
+{
+  GObjectClass *gobject_class;
+  GtkWidgetClass *widget_class;
+
+  gobject_class = G_OBJECT_CLASS (klass);
+  gobject_class->finalize = mate_color_selection_finalize;
+  gobject_class->set_property = mate_color_selection_set_property;
+  gobject_class->get_property = mate_color_selection_get_property;
+
+  gobject_class->dispose = mate_color_selection_dispose;
+
+  widget_class = GTK_WIDGET_CLASS (klass);
+  widget_class->realize = mate_color_selection_realize;
+  widget_class->unrealize = mate_color_selection_unrealize;
+  widget_class->show_all = mate_color_selection_show_all;
+  widget_class->grab_broken_event = mate_color_selection_grab_broken;
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_HAS_OPACITY_CONTROL,
+                                   g_param_spec_boolean ("has-opacity-control",
+							 _("Has Opacity Control"),
+							 _("Whether the color selector should allow setting opacity"),
+							 FALSE,
+							 G_PARAM_READWRITE));
+  g_object_class_install_property (gobject_class,
+                                   PROP_HAS_PALETTE,
+                                   g_param_spec_boolean ("has-palette",
+							 _("Has palette"),
+							 _("Whether a palette should be used"),
+							 FALSE,
+							 G_PARAM_READWRITE));
+  g_object_class_install_property (gobject_class,
+                                   PROP_CURRENT_COLOR,
+                                   g_param_spec_boxed ("current-color",
+                                                       _("Current Color"),
+                                                       _("The current color"),
+                                                       GDK_TYPE_COLOR,
+                                                       G_PARAM_READWRITE));
+  g_object_class_install_property (gobject_class,
+                                   PROP_CURRENT_ALPHA,
+                                   g_param_spec_uint ("current-alpha",
+						      _("Current Alpha"),
+						      _("The current opacity value (0 fully transparent, 65535 fully opaque)"),
+						      0, 65535, 65535,
+						      G_PARAM_READWRITE));
+  g_object_class_install_property (gobject_class,
+                                   PROP_HEX_STRING,
+                                   g_param_spec_string ("hex-string",
+                                                       _("HEX String"),
+                                                       _("The hexadecimal string of current color"),
+                                                       "",
+                                                       G_PARAM_READABLE));
+
+  color_selection_signals[COLOR_CHANGED] =
+    g_signal_new ("color-changed",
+		  G_OBJECT_CLASS_TYPE (gobject_class),
+		  G_SIGNAL_RUN_FIRST,
+		  G_STRUCT_OFFSET (MateColorSelectionClass, color_changed),
+		  NULL, NULL,
+		  g_cclosure_marshal_VOID__VOID,
+		  G_TYPE_NONE, 0);
+}
+
+static void
+mate_color_selection_init (MateColorSelection *colorsel)
+{
+  GtkWidget *top_hbox;
+  GtkWidget *top_right_vbox;
+  GtkWidget *grid, *label, *hbox, *frame, *vbox, *button;
+  GtkAdjustment *adjust;
+  GtkWidget *picker_image;
+  gint i, j;
+  MateColorSelectionPrivate *priv;
+  AtkObject *atk_obj;
+  GList *focus_chain = NULL;
+
+  _mate_desktop_init_i18n ();
+
+  priv = colorsel->private_data = mate_color_selection_get_instance_private (colorsel);
+  priv->changing = FALSE;
+  priv->default_set = FALSE;
+  priv->default_alpha_set = FALSE;
+
+  top_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
+  gtk_box_pack_start (GTK_BOX (colorsel), top_hbox, FALSE, FALSE, 0);
+
+  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
+  priv->triangle_colorsel = mate_hsv_new ();
+  g_signal_connect (priv->triangle_colorsel, "changed",
+                    G_CALLBACK (hsv_changed), colorsel);
+  mate_hsv_set_metrics (MATE_HSV (priv->triangle_colorsel), 174, 15);
+  gtk_box_pack_start (GTK_BOX (top_hbox), vbox, FALSE, FALSE, 0);
+  gtk_box_pack_start (GTK_BOX (vbox), priv->triangle_colorsel, FALSE, FALSE, 0);
+  gtk_widget_set_tooltip_text (priv->triangle_colorsel,
+                        _("Select the color you want from the outer ring. Select the darkness or lightness of that color using the inner triangle."));
+
+  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
+  gtk_box_pack_end (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
+
+  frame = gtk_frame_new (NULL);
+  gtk_widget_set_size_request (frame, -1, 30);
+  gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
+  color_sample_new (colorsel);
+  gtk_container_add (GTK_CONTAINER (frame), priv->sample_area);
+  gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0);
+
+  button = gtk_button_new ();
+
+  gtk_widget_set_events (button, GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK);
+  g_object_set_data (G_OBJECT (button), "COLORSEL", colorsel);
+  g_signal_connect (button, "clicked",
+                    G_CALLBACK (get_screen_color), NULL);
+  picker_image = gtk_image_new_from_icon_name ("gtk-color-picker", GTK_ICON_SIZE_BUTTON);
+  gtk_container_add (GTK_CONTAINER (button), picker_image);
+  gtk_widget_show (GTK_WIDGET (picker_image));
+  gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 0);
+
+  gtk_widget_set_tooltip_text (button,
+                        _("Click the eyedropper, then click a color anywhere on your screen to select that color."));
+
+  top_right_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
+  gtk_box_pack_start (GTK_BOX (top_hbox), top_right_vbox, FALSE, FALSE, 0);
+  grid = gtk_grid_new ();
+  gtk_box_pack_start (GTK_BOX (top_right_vbox), grid, FALSE, FALSE, 0);
+  gtk_grid_set_row_spacing (GTK_GRID (grid), 6);
+  gtk_grid_set_column_spacing (GTK_GRID (grid), 12);
+
+  make_label_spinbutton (colorsel, &priv->hue_spinbutton, _("_Hue:"), grid, 0, 0, COLORSEL_HUE,
+                         _("Position on the color wheel."));
+  gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (priv->hue_spinbutton), TRUE);
+  make_label_spinbutton (colorsel, &priv->sat_spinbutton, _("_Saturation:"), grid, 0, 1, COLORSEL_SATURATION,
+                         _("\"Deepness\" of the color."));
+  make_label_spinbutton (colorsel, &priv->val_spinbutton, _("_Value:"), grid, 0, 2, COLORSEL_VALUE,
+                         _("Brightness of the color."));
+  make_label_spinbutton (colorsel, &priv->red_spinbutton, _("_Red:"), grid, 6, 0, COLORSEL_RED,
+                         _("Amount of red light in the color."));
+  make_label_spinbutton (colorsel, &priv->green_spinbutton, _("_Green:"), grid, 6, 1, COLORSEL_GREEN,
+                         _("Amount of green light in the color."));
+  make_label_spinbutton (colorsel, &priv->blue_spinbutton, _("_Blue:"), grid, 6, 2, COLORSEL_BLUE,
+                         _("Amount of blue light in the color."));
+  gtk_grid_attach (GTK_GRID (grid), gtk_separator_new (GTK_ORIENTATION_HORIZONTAL), 0, 3, 8, 1);
+
+  priv->opacity_label = gtk_label_new_with_mnemonic (_("Op_acity:"));
+  gtk_label_set_xalign (GTK_LABEL (priv->opacity_label), 0.0);
+  gtk_grid_attach (GTK_GRID (grid), priv->opacity_label, 0, 4, 1, 1);
+  adjust = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 255.0, 1.0, 1.0, 0.0));
+  g_object_set_data (G_OBJECT (adjust), "COLORSEL", colorsel);
+  priv->opacity_slider = gtk_scale_new (GTK_ORIENTATION_HORIZONTAL, adjust);
+  gtk_widget_set_tooltip_text (priv->opacity_slider,
+                        _("Transparency of the color."));
+  gtk_label_set_mnemonic_widget (GTK_LABEL (priv->opacity_label),
+                                 priv->opacity_slider);
+  gtk_scale_set_draw_value (GTK_SCALE (priv->opacity_slider), FALSE);
+  g_signal_connect (adjust, "value-changed",
+                    G_CALLBACK (adjustment_changed),
+                    GINT_TO_POINTER (COLORSEL_OPACITY));
+  gtk_grid_attach (GTK_GRID (grid), priv->opacity_slider, 1, 4, 6, 1);
+  priv->opacity_entry = gtk_entry_new ();
+  gtk_widget_set_tooltip_text (priv->opacity_entry,
+                        _("Transparency of the color."));
+  gtk_widget_set_size_request (priv->opacity_entry, 40, -1);
+
+  g_signal_connect (priv->opacity_entry, "activate",
+                    G_CALLBACK (opacity_entry_changed), colorsel);
+  gtk_grid_attach (GTK_GRID (grid), priv->opacity_entry, 7, 4, 1, 1);
+
+  label = gtk_label_new_with_mnemonic (_("Color _name:"));
+  gtk_grid_attach (GTK_GRID (grid), label, 0, 5, 1, 1);
+  gtk_label_set_xalign (GTK_LABEL (label), 0.0);
+  priv->hex_entry = gtk_entry_new ();
+
+  gtk_label_set_mnemonic_widget (GTK_LABEL (label), priv->hex_entry);
+
+  g_signal_connect (priv->hex_entry, "activate",
+                    G_CALLBACK (hex_changed), colorsel);
+
+  g_signal_connect (priv->hex_entry, "focus-out-event",
+                    G_CALLBACK (hex_focus_out), colorsel);
+
+  gtk_widget_set_tooltip_text (priv->hex_entry,
+                        _("You can enter an HTML-style hexadecimal color value, or simply a color name such as 'orange' in this entry."));
+
+  gtk_entry_set_width_chars (GTK_ENTRY (priv->hex_entry), 7);
+  gtk_grid_attach (GTK_GRID (grid), priv->hex_entry, 1, 5, 4, 1);
+
+  focus_chain = g_list_append (focus_chain, priv->hue_spinbutton);
+  focus_chain = g_list_append (focus_chain, priv->sat_spinbutton);
+  focus_chain = g_list_append (focus_chain, priv->val_spinbutton);
+  focus_chain = g_list_append (focus_chain, priv->red_spinbutton);
+  focus_chain = g_list_append (focus_chain, priv->green_spinbutton);
+  focus_chain = g_list_append (focus_chain, priv->blue_spinbutton);
+  focus_chain = g_list_append (focus_chain, priv->opacity_slider);
+  focus_chain = g_list_append (focus_chain, priv->opacity_entry);
+  focus_chain = g_list_append (focus_chain, priv->hex_entry);
+  gtk_container_set_focus_chain (GTK_CONTAINER (grid), focus_chain);
+  g_list_free (focus_chain);
+
+  /* Set up the palette */
+  grid = gtk_grid_new ();
+  gtk_grid_set_row_spacing (GTK_GRID (grid), 1);
+  gtk_grid_set_column_spacing (GTK_GRID (grid), 1);
+  for (i = 0; i < GTK_CUSTOM_PALETTE_WIDTH; i++)
+    {
+      for (j = 0; j < GTK_CUSTOM_PALETTE_HEIGHT; j++)
+	{
+	  make_palette_frame (colorsel, grid, i, j);
+	}
+    }
+  set_selected_palette (colorsel, 0, 0);
+  priv->palette_frame = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
+  label = gtk_label_new_with_mnemonic (_("_Palette:"));
+
+  gtk_label_set_xalign (GTK_LABEL (label), 0.0);
+  gtk_box_pack_start (GTK_BOX (priv->palette_frame), label, FALSE, FALSE, 0);
+
+  gtk_label_set_mnemonic_widget (GTK_LABEL (label),
+                                 priv->custom_palette[0][0]);
+
+  gtk_box_pack_end (GTK_BOX (top_right_vbox), priv->palette_frame, FALSE, FALSE, 0);
+  gtk_box_pack_start (GTK_BOX (priv->palette_frame), grid, FALSE, FALSE, 0);
+
+  gtk_widget_show_all (top_hbox);
+
+  /* hide unused stuff */
+
+  if (priv->has_opacity == FALSE)
+    {
+      gtk_widget_hide (priv->opacity_label);
+      gtk_widget_hide (priv->opacity_slider);
+      gtk_widget_hide (priv->opacity_entry);
+    }
+
+  if (priv->has_palette == FALSE)
+    {
+      gtk_widget_hide (priv->palette_frame);
+    }
+
+  atk_obj = gtk_widget_get_accessible (priv->triangle_colorsel);
+  if (GTK_IS_ACCESSIBLE (atk_obj))
+    {
+      atk_object_set_name (atk_obj, _("Color Wheel"));
+      atk_object_set_role (gtk_widget_get_accessible (GTK_WIDGET (colorsel)), ATK_ROLE_COLOR_CHOOSER);
+      make_all_relations (atk_obj, priv);
+    }
+}
+
+/* GObject methods */
+static void
+mate_color_selection_finalize (GObject *object)
+{
+  G_OBJECT_CLASS (mate_color_selection_parent_class)->finalize (object);
+}
+
+static void
+mate_color_selection_set_property (GObject         *object,
+				  guint            prop_id,
+				  const GValue    *value,
+				  GParamSpec      *pspec)
+{
+  MateColorSelection *colorsel = MATE_COLOR_SELECTION (object);
+
+  switch (prop_id)
+    {
+    case PROP_HAS_OPACITY_CONTROL:
+      mate_color_selection_set_has_opacity_control (colorsel,
+						   g_value_get_boolean (value));
+      break;
+    case PROP_HAS_PALETTE:
+      mate_color_selection_set_has_palette (colorsel,
+					   g_value_get_boolean (value));
+      break;
+    case PROP_CURRENT_COLOR:
+      mate_color_selection_set_current_color (colorsel, g_value_get_boxed (value));
+      break;
+    case PROP_CURRENT_ALPHA:
+      mate_color_selection_set_current_alpha (colorsel, g_value_get_uint (value));
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+
+}
+
+static void
+mate_color_selection_get_property (GObject     *object,
+				  guint        prop_id,
+				  GValue      *value,
+				  GParamSpec  *pspec)
+{
+  MateColorSelection *colorsel = MATE_COLOR_SELECTION (object);
+  MateColorSelectionPrivate *priv = colorsel->private_data;
+  GdkColor color;
+
+  switch (prop_id)
+    {
+    case PROP_HAS_OPACITY_CONTROL:
+      g_value_set_boolean (value, mate_color_selection_get_has_opacity_control (colorsel));
+      break;
+    case PROP_HAS_PALETTE:
+      g_value_set_boolean (value, mate_color_selection_get_has_palette (colorsel));
+      break;
+    case PROP_CURRENT_COLOR:
+      mate_color_selection_get_current_color (colorsel, &color);
+      g_value_set_boxed (value, &color);
+      break;
+    case PROP_CURRENT_ALPHA:
+      g_value_set_uint (value, mate_color_selection_get_current_alpha (colorsel));
+      break;
+    case PROP_HEX_STRING:
+      g_value_set_string (value, gtk_editable_get_chars (GTK_EDITABLE (priv->hex_entry), 0, -1));
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+}
+
+static void
+mate_color_selection_dispose (GObject *object)
+{
+  MateColorSelection *cselection = MATE_COLOR_SELECTION (object);
+  MateColorSelectionPrivate *priv = cselection->private_data;
+
+  if (priv->dropper_grab_widget)
+    {
+      gtk_widget_destroy (priv->dropper_grab_widget);
+      priv->dropper_grab_widget = NULL;
+    }
+
+  G_OBJECT_CLASS (mate_color_selection_parent_class)->dispose (object);
+}
+
+/* GtkWidget methods */
+
+static void
+mate_color_selection_realize (GtkWidget *widget)
+{
+  MateColorSelection *colorsel = MATE_COLOR_SELECTION (widget);
+  MateColorSelectionPrivate *priv = colorsel->private_data;
+  GtkSettings *settings = gtk_widget_get_settings (widget);
+
+  priv->settings_connection =  g_signal_connect (settings,
+						 "notify::gtk-color-palette",
+						 G_CALLBACK (palette_change_notify_instance),
+						 widget);
+  update_palette (colorsel);
+
+  GTK_WIDGET_CLASS (mate_color_selection_parent_class)->realize (widget);
+}
+
+static void
+mate_color_selection_unrealize (GtkWidget *widget)
+{
+  MateColorSelection *colorsel = MATE_COLOR_SELECTION (widget);
+  MateColorSelectionPrivate *priv = colorsel->private_data;
+  GtkSettings *settings = gtk_widget_get_settings (widget);
+
+  g_signal_handler_disconnect (settings, priv->settings_connection);
+
+  GTK_WIDGET_CLASS (mate_color_selection_parent_class)->unrealize (widget);
+}
+
+/* We override show-all since we have internal widgets that
+ * shouldn't be shown when you call show_all(), like the
+ * palette and opacity sliders.
+ */
+static void
+mate_color_selection_show_all (GtkWidget *widget)
+{
+  gtk_widget_show (widget);
+}
+
+static gboolean
+mate_color_selection_grab_broken (GtkWidget          *widget,
+				 GdkEventGrabBroken *event)
+{
+  shutdown_eyedropper (widget);
+
+  return TRUE;
+}
+
+/*
+ *
+ * The Sample Color
+ *
+ */
+
+static void color_sample_draw_sample (MateColorSelection *colorsel, cairo_t *cr, int which);
+static void color_sample_update_samples (MateColorSelection *colorsel);
+
+static void
+set_color_internal (MateColorSelection *colorsel,
+		    gdouble           *color)
+{
+  MateColorSelectionPrivate *priv;
+  gint i;
+
+  priv = colorsel->private_data;
+  priv->changing = TRUE;
+  priv->color[COLORSEL_RED] = color[0];
+  priv->color[COLORSEL_GREEN] = color[1];
+  priv->color[COLORSEL_BLUE] = color[2];
+  priv->color[COLORSEL_OPACITY] = color[3];
+  gtk_rgb_to_hsv (priv->color[COLORSEL_RED],
+		  priv->color[COLORSEL_GREEN],
+		  priv->color[COLORSEL_BLUE],
+		  &priv->color[COLORSEL_HUE],
+		  &priv->color[COLORSEL_SATURATION],
+		  &priv->color[COLORSEL_VALUE]);
+  if (priv->default_set == FALSE)
+    {
+      for (i = 0; i < COLORSEL_NUM_CHANNELS; i++)
+	priv->old_color[i] = priv->color[i];
+    }
+  priv->default_set = TRUE;
+  priv->default_alpha_set = TRUE;
+  update_color (colorsel);
+}
+
+static void
+set_color_icon (GdkDragContext *context,
+		gdouble        *colors)
+{
+  GdkPixbuf *pixbuf;
+  guint32 pixel;
+
+  pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE,
+			   8, 48, 32);
+
+  pixel = (((UNSCALE (colors[COLORSEL_RED])   & 0xff00) << 16) |
+	   ((UNSCALE (colors[COLORSEL_GREEN]) & 0xff00) << 8) |
+	   ((UNSCALE (colors[COLORSEL_BLUE])  & 0xff00)));
+
+  gdk_pixbuf_fill (pixbuf, pixel);
+
+  gtk_drag_set_icon_pixbuf (context, pixbuf, -2, -2);
+  g_object_unref (pixbuf);
+}
+
+static void
+color_sample_drag_begin (GtkWidget      *widget,
+			 GdkDragContext *context,
+			 gpointer        data)
+{
+  MateColorSelection *colorsel = data;
+  MateColorSelectionPrivate *priv;
+  gdouble *colsrc;
+
+  priv = colorsel->private_data;
+
+  if (widget == priv->old_sample)
+    colsrc = priv->old_color;
+  else
+    colsrc = priv->color;
+
+  set_color_icon (context, colsrc);
+}
+
+static void
+color_sample_drag_end (GtkWidget      *widget,
+		       GdkDragContext *context,
+		       gpointer        data)
+{
+  g_object_set_data (G_OBJECT (widget), "gtk-color-selection-drag-window", NULL);
+}
+
+static void
+color_sample_drop_handle (GtkWidget        *widget,
+			  GdkDragContext   *context,
+			  gint              x,
+			  gint              y,
+			  GtkSelectionData *selection_data,
+			  guint             info,
+			  guint             time,
+			  gpointer          data)
+{
+  MateColorSelection *colorsel = data;
+  MateColorSelectionPrivate *priv;
+  guint16 *vals;
+  gdouble color[4];
+  priv = colorsel->private_data;
+
+  /* This is currently a guint16 array of the format:
+   * R
+   * G
+   * B
+   * opacity
+   */
+
+  if (gtk_selection_data_get_length (selection_data) < 0)
+    return;
+
+  /* We accept drops with the wrong format, since the KDE color
+   * chooser incorrectly drops application/x-color with format 8.
+   */
+  if (gtk_selection_data_get_length (selection_data) != 8)
+    {
+      g_warning ("Received invalid color data\n");
+      return;
+    }
+
+  vals = (guint16 *) gtk_selection_data_get_data (selection_data);
+
+  if (widget == priv->cur_sample)
+    {
+      color[0] = (gdouble)vals[0] / 0xffff;
+      color[1] = (gdouble)vals[1] / 0xffff;
+      color[2] = (gdouble)vals[2] / 0xffff;
+      color[3] = (gdouble)vals[3] / 0xffff;
+
+      set_color_internal (colorsel, color);
+    }
+}
+
+static void
+color_sample_drag_handle (GtkWidget        *widget,
+			  GdkDragContext   *context,
+			  GtkSelectionData *selection_data,
+			  guint             info,
+			  guint             time,
+			  gpointer          data)
+{
+  MateColorSelection *colorsel = data;
+  MateColorSelectionPrivate *priv;
+  guint16 vals[4];
+  gdouble *colsrc;
+
+  priv = colorsel->private_data;
+
+  if (widget == priv->old_sample)
+    colsrc = priv->old_color;
+  else
+    colsrc = priv->color;
+
+  vals[0] = colsrc[COLORSEL_RED] * 0xffff;
+  vals[1] = colsrc[COLORSEL_GREEN] * 0xffff;
+  vals[2] = colsrc[COLORSEL_BLUE] * 0xffff;
+  vals[3] = priv->has_opacity ? colsrc[COLORSEL_OPACITY] * 0xffff : 0xffff;
+
+  gtk_selection_data_set (selection_data,
+			  gdk_atom_intern_static_string ("application/x-color"),
+			  16, (guchar *)vals, 8);
+}
+
+/* which = 0 means draw old sample, which = 1 means draw new */
+static void
+color_sample_draw_sample (MateColorSelection *colorsel, cairo_t *cr, int which)
+{
+  GtkWidget *da;
+  gint x, y, wid, heig, goff;
+  MateColorSelectionPrivate *priv;
+  GtkAllocation allocation;
+
+  g_return_if_fail (colorsel != NULL);
+  priv = colorsel->private_data;
+
+  g_return_if_fail (priv->sample_area != NULL);
+  if (!gtk_widget_is_drawable (priv->sample_area))
+    return;
+
+  if (which == 0)
+    {
+      da = priv->old_sample;
+      goff = 0;
+    }
+  else
+    {
+      da = priv->cur_sample;
+      gtk_widget_get_allocation (priv->old_sample, &allocation);
+      goff =  allocation.width % 32;
+    }
+
+  gtk_widget_get_allocation (da, &allocation);
+  wid = allocation.width;
+  heig = allocation.height;
+
+  /* Below needs tweaking for non-power-of-two */
+
+  if (priv->has_opacity)
+    {
+      /* Draw checks in background */
+
+      cairo_set_source_rgb (cr, 0.5, 0.5, 0.5);
+      cairo_rectangle (cr, 0, 0, wid, heig);
+      cairo_fill (cr);
+
+      cairo_set_source_rgb (cr, 0.75, 0.75, 0.75);
+      for (x = goff & -CHECK_SIZE; x < goff + wid; x += CHECK_SIZE)
+	for (y = 0; y < heig; y += CHECK_SIZE)
+	  if ((x / CHECK_SIZE + y / CHECK_SIZE) % 2 == 0)
+	    cairo_rectangle (cr, x - goff, y, CHECK_SIZE, CHECK_SIZE);
+      cairo_fill (cr);
+    }
+
+  if (which == 0)
+    {
+      cairo_set_source_rgba (cr,
+			     priv->old_color[COLORSEL_RED],
+			     priv->old_color[COLORSEL_GREEN],
+			     priv->old_color[COLORSEL_BLUE],
+			     priv->has_opacity ?
+			        priv->old_color[COLORSEL_OPACITY] : 1.0);
+    }
+  else
+    {
+      cairo_set_source_rgba (cr,
+			     priv->color[COLORSEL_RED],
+			     priv->color[COLORSEL_GREEN],
+			     priv->color[COLORSEL_BLUE],
+			     priv->has_opacity ?
+			       priv->color[COLORSEL_OPACITY] : 1.0);
+    }
+
+  cairo_rectangle (cr, 0, 0, wid, heig);
+  cairo_fill (cr);
+}
+
+static void
+color_sample_update_samples (MateColorSelection *colorsel)
+{
+  MateColorSelectionPrivate *priv = colorsel->private_data;
+  gtk_widget_queue_draw (priv->old_sample);
+  gtk_widget_queue_draw (priv->cur_sample);
+}
+
+static gboolean
+color_old_sample_draw (GtkWidget          *da,
+                       cairo_t            *cr,
+                       MateColorSelection *colorsel)
+{
+  color_sample_draw_sample (colorsel, cr, 0);
+  return FALSE;
+}
+
+static gboolean
+color_cur_sample_draw (GtkWidget          *da,
+                       cairo_t            *cr,
+                       MateColorSelection *colorsel)
+{
+  color_sample_draw_sample (colorsel, cr, 1);
+  return FALSE;
+}
+
+static void
+color_sample_setup_dnd (MateColorSelection *colorsel, GtkWidget *sample)
+{
+  static const GtkTargetEntry targets[] = {
+    { .target = "application/x-color", .flags = 0, .info = 0 }
+  };
+  MateColorSelectionPrivate *priv;
+  priv = colorsel->private_data;
+
+  gtk_drag_source_set (sample,
+		       GDK_BUTTON1_MASK | GDK_BUTTON3_MASK,
+		       targets, 1,
+		       GDK_ACTION_COPY | GDK_ACTION_MOVE);
+
+  g_signal_connect (sample, "drag-begin",
+		    G_CALLBACK (color_sample_drag_begin),
+		    colorsel);
+  if (sample == priv->cur_sample)
+    {
+
+      gtk_drag_dest_set (sample,
+			 GTK_DEST_DEFAULT_HIGHLIGHT |
+			 GTK_DEST_DEFAULT_MOTION |
+			 GTK_DEST_DEFAULT_DROP,
+			 targets, 1,
+			 GDK_ACTION_COPY);
+
+      g_signal_connect (sample, "drag-end",
+			G_CALLBACK (color_sample_drag_end),
+			colorsel);
+    }
+
+  g_signal_connect (sample, "drag-data-get",
+		    G_CALLBACK (color_sample_drag_handle),
+		    colorsel);
+  g_signal_connect (sample, "drag-data-received",
+		    G_CALLBACK (color_sample_drop_handle),
+		    colorsel);
+
+}
+
+static void
+update_tooltips (MateColorSelection *colorsel)
+{
+  MateColorSelectionPrivate *priv;
+
+  priv = colorsel->private_data;
+
+  if (priv->has_palette == TRUE)
+    {
+      gtk_widget_set_tooltip_text (priv->old_sample,
+                            _("The previously-selected color, for comparison to the color you're selecting now. You can drag this color to a palette entry, or select this color as current by dragging it to the other color swatch alongside."));
+
+      gtk_widget_set_tooltip_text (priv->cur_sample,
+                            _("The color you've chosen. You can drag this color to a palette entry to save it for use in the future."));
+    }
+  else
+    {
+      gtk_widget_set_tooltip_text (priv->old_sample,
+                            _("The previously-selected color, for comparison to the color you're selecting now."));
+
+      gtk_widget_set_tooltip_text (priv->cur_sample,
+                            _("The color you've chosen."));
+    }
+}
+
+static void
+color_sample_new (MateColorSelection *colorsel)
+{
+  MateColorSelectionPrivate *priv;
+
+  priv = colorsel->private_data;
+
+  priv->sample_area = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+  priv->old_sample = gtk_drawing_area_new ();
+  priv->cur_sample = gtk_drawing_area_new ();
+
+  gtk_box_pack_start (GTK_BOX (priv->sample_area), priv->old_sample,
+		      TRUE, TRUE, 0);
+  gtk_box_pack_start (GTK_BOX (priv->sample_area), priv->cur_sample,
+		      TRUE, TRUE, 0);
+
+  g_signal_connect (priv->old_sample, "draw",
+		    G_CALLBACK (color_old_sample_draw),
+		    colorsel);
+  g_signal_connect (priv->cur_sample, "draw",
+		    G_CALLBACK (color_cur_sample_draw),
+		    colorsel);
+
+  color_sample_setup_dnd (colorsel, priv->old_sample);
+  color_sample_setup_dnd (colorsel, priv->cur_sample);
+
+  update_tooltips (colorsel);
+
+  gtk_widget_show_all (priv->sample_area);
+}
+
+/*
+ *
+ * The palette area code
+ *
+ */
+
+static void
+palette_get_color (GtkWidget *drawing_area, gdouble *color)
+{
+  gdouble *color_val;
+
+  g_return_if_fail (color != NULL);
+
+  color_val = g_object_get_data (G_OBJECT (drawing_area), "color_val");
+  if (color_val == NULL)
+    {
+      /* Default to white for no good reason */
+      color[0] = 1.0;
+      color[1] = 1.0;
+      color[2] = 1.0;
+      color[3] = 1.0;
+      return;
+    }
+
+  color[0] = color_val[0];
+  color[1] = color_val[1];
+  color[2] = color_val[2];
+  color[3] = 1.0;
+}
+
+static void
+palette_paint (GtkWidget    *drawing_area,
+               cairo_t      *cr,
+               gpointer      data)
+{
+  gint focus_width;
+  GtkAllocation allocation;
+
+  if (gtk_widget_get_window (drawing_area) == NULL)
+    return;
+
+  gtk_widget_get_allocation (drawing_area, &allocation);
+
+  gdk_cairo_set_source_color (cr, &gtk_widget_get_style (drawing_area)->bg[GTK_STATE_NORMAL]);
+  cairo_rectangle (cr, 0, 0, allocation.width, allocation.height);
+  cairo_fill (cr);
+
+  if (gtk_widget_has_focus (drawing_area))
+    {
+      set_focus_line_attributes (drawing_area, cr, &focus_width);
+
+      cairo_rectangle (cr,
+		       focus_width / 2., focus_width / 2.,
+		       allocation.width - focus_width,
+		       allocation.height - focus_width);
+      cairo_stroke (cr);
+    }
+}
+
+static void
+set_focus_line_attributes (GtkWidget *drawing_area,
+			   cairo_t   *cr,
+			   gint      *focus_width)
+{
+  gdouble color[4];
+  gint8 *dash_list;
+
+  gtk_widget_style_get (drawing_area,
+			"focus-line-width", focus_width,
+			"focus-line-pattern", (gchar *)&dash_list,
+			NULL);
+
+  palette_get_color (drawing_area, color);
+
+  if (INTENSITY (color[0], color[1], color[2]) > 0.5)
+    cairo_set_source_rgb (cr, 0., 0., 0.);
+  else
+    cairo_set_source_rgb (cr, 1., 1., 1.);
+
+  cairo_set_line_width (cr, *focus_width);
+
+  if (dash_list[0])
+    {
+      gint n_dashes = strlen ((gchar *)dash_list);
+      gdouble *dashes = g_new (gdouble, n_dashes);
+      gdouble total_length = 0;
+      gdouble dash_offset;
+      gint i;
+
+      for (i = 0; i < n_dashes; i++)
+	{
+	  dashes[i] = dash_list[i];
+	  total_length += dash_list[i];
+	}
+
+      /* The dash offset here aligns the pattern to integer pixels
+       * by starting the dash at the right side of the left border
+       * Negative dash offsets in cairo don't work
+       * (https://bugs.freedesktop.org/show_bug.cgi?id=2729)
+       */
+      dash_offset = - *focus_width / 2.;
+      while (dash_offset < 0)
+	dash_offset += total_length;
+
+      cairo_set_dash (cr, dashes, n_dashes, dash_offset);
+      g_free (dashes);
+    }
+
+  g_free (dash_list);
+}
+
+static void
+palette_drag_begin (GtkWidget      *widget,
+		    GdkDragContext *context,
+		    gpointer        data)
+{
+  gdouble colors[4];
+
+  palette_get_color (widget, colors);
+  set_color_icon (context, colors);
+}
+
+static void
+palette_drag_handle (GtkWidget        *widget,
+		     GdkDragContext   *context,
+		     GtkSelectionData *selection_data,
+		     guint             info,
+		     guint             time,
+		     gpointer          data)
+{
+  guint16 vals[4];
+  gdouble colsrc[4];
+
+  palette_get_color (widget, colsrc);
+
+  vals[0] = colsrc[COLORSEL_RED] * 0xffff;
+  vals[1] = colsrc[COLORSEL_GREEN] * 0xffff;
+  vals[2] = colsrc[COLORSEL_BLUE] * 0xffff;
+  vals[3] = 0xffff;
+
+  gtk_selection_data_set (selection_data,
+			  gdk_atom_intern_static_string ("application/x-color"),
+			  16, (guchar *)vals, 8);
+}
+
+static void
+palette_drag_end (GtkWidget      *widget,
+		  GdkDragContext *context,
+		  gpointer        data)
+{
+  g_object_set_data (G_OBJECT (widget), "gtk-color-selection-drag-window", NULL);
+}
+
+static GdkColor *
+get_current_colors (MateColorSelection *colorsel)
+{
+  GdkColor *colors = NULL;
+  gint n_colors = 0;
+
+  mate_color_selection_palette_from_string (DEFAULT_COLOR_PALETTE,
+                                            &colors,
+                                            &n_colors);
+
+  /* make sure that we fill every slot */
+  g_assert (n_colors == GTK_CUSTOM_PALETTE_WIDTH * GTK_CUSTOM_PALETTE_HEIGHT);
+
+  return colors;
+}
+
+/* Changes the model color */
+static void
+palette_change_color (GtkWidget         *drawing_area,
+                      MateColorSelection *colorsel,
+                      gdouble           *color)
+{
+  gint x, y;
+  MateColorSelectionPrivate *priv;
+  GdkColor gdk_color;
+  GdkColor *current_colors;
+  GdkScreen *screen;
+
+  g_return_if_fail (MATE_IS_COLOR_SELECTION (colorsel));
+  g_return_if_fail (GTK_IS_DRAWING_AREA (drawing_area));
+
+  priv = colorsel->private_data;
+
+  gdk_color.red = UNSCALE (color[0]);
+  gdk_color.green = UNSCALE (color[1]);
+  gdk_color.blue = UNSCALE (color[2]);
+  gdk_color.pixel = 0;
+
+  x = 0;
+  y = 0;			/* Quiet GCC */
+  while (x < GTK_CUSTOM_PALETTE_WIDTH)
+    {
+      y = 0;
+      while (y < GTK_CUSTOM_PALETTE_HEIGHT)
+        {
+          if (priv->custom_palette[x][y] == drawing_area)
+            goto out;
+
+          ++y;
+        }
+
+      ++x;
+    }
+
+ out:
+
+  g_assert (x < GTK_CUSTOM_PALETTE_WIDTH || y < GTK_CUSTOM_PALETTE_HEIGHT);
+
+  current_colors = get_current_colors (colorsel);
+  current_colors[y * GTK_CUSTOM_PALETTE_WIDTH + x] = gdk_color;
+
+  screen = gtk_widget_get_screen (GTK_WIDGET (colorsel));
+  if (change_palette_hook != default_change_palette_func)
+    (* change_palette_hook) (screen, current_colors,
+			     GTK_CUSTOM_PALETTE_WIDTH * GTK_CUSTOM_PALETTE_HEIGHT);
+  else if (noscreen_change_palette_hook != default_noscreen_change_palette_func)
+    {
+      if (screen != gdk_screen_get_default ())
+	g_warning ("mate_color_selection_set_change_palette_hook used by widget is not on the default screen.");
+      (* noscreen_change_palette_hook) (current_colors,
+					GTK_CUSTOM_PALETTE_WIDTH * GTK_CUSTOM_PALETTE_HEIGHT);
+    }
+  else
+    (* change_palette_hook) (screen, current_colors,
+			     GTK_CUSTOM_PALETTE_WIDTH * GTK_CUSTOM_PALETTE_HEIGHT);
+
+  g_free (current_colors);
+}
+
+static void
+override_background_color (GtkWidget *widget,
+                           GdkRGBA   *rgba)
+{
+  gchar          *css;
+  GtkCssProvider *provider;
+
+  provider = gtk_css_provider_new ();
+
+  css = g_strdup_printf ("* { background-color: %s;}",
+                         gdk_rgba_to_string (rgba));
+  gtk_css_provider_load_from_data (provider, css, -1, NULL);
+  g_free (css);
+
+  gtk_style_context_add_provider (gtk_widget_get_style_context (widget),
+                                  GTK_STYLE_PROVIDER (provider),
+                                  GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+  g_object_unref (provider);
+}
+
+/* Changes the view color */
+static void
+palette_set_color (GtkWidget         *drawing_area,
+		   MateColorSelection *colorsel,
+		   gdouble           *color)
+{
+  gpointer pointer;
+  gdouble *new_color = g_new (double, 4);
+  GdkRGBA  box_color;
+
+  box_color.red = color[0];
+  box_color.green = color[1];
+  box_color.blue = color[2];
+  box_color.alpha = 1;
+
+  override_background_color (drawing_area, &box_color);
+
+  pointer = g_object_get_data (G_OBJECT (drawing_area), "color_set");
+  if (!pointer || GPOINTER_TO_INT (pointer) == 0)
+    {
+      static const GtkTargetEntry targets[] = {
+	{ .target = "application/x-color", .flags = 0, .info = 0 }
+      };
+      gtk_drag_source_set (drawing_area,
+			   GDK_BUTTON1_MASK | GDK_BUTTON3_MASK,
+			   targets, 1,
+			   GDK_ACTION_COPY | GDK_ACTION_MOVE);
+
+      g_signal_connect (drawing_area, "drag-begin",
+			G_CALLBACK (palette_drag_begin),
+			colorsel);
+      g_signal_connect (drawing_area, "drag-data-get",
+			G_CALLBACK (palette_drag_handle),
+			colorsel);
+
+      g_object_set_data (G_OBJECT (drawing_area), "color_set",
+			 GINT_TO_POINTER (1));
+    }
+
+  new_color[0] = color[0];
+  new_color[1] = color[1];
+  new_color[2] = color[2];
+  new_color[3] = 1.0;
+
+  g_object_set_data_full (G_OBJECT (drawing_area), "color_val", new_color, (GDestroyNotify)g_free);
+}
+
+static gboolean
+palette_draw (GtkWidget      *drawing_area,
+		cairo_t        *cr,
+		gpointer        data)
+{
+  if (gtk_widget_get_window (drawing_area) == NULL)
+    return FALSE;
+
+  palette_paint (drawing_area, cr, data);
+
+  return FALSE;
+}
+
+static void
+popup_position_func (GtkMenu   *menu,
+                     gint      *x,
+                     gint      *y,
+                     gboolean  *push_in,
+                     gpointer	user_data)
+{
+  GtkWidget *widget;
+  GtkRequisition req;
+  gint root_x, root_y;
+  GdkScreen *screen;
+  GtkAllocation allocation;
+
+  widget = GTK_WIDGET (user_data);
+
+  g_return_if_fail (gtk_widget_get_realized (widget));
+
+  gdk_window_get_origin (gtk_widget_get_window (widget), &root_x, &root_y);
+
+  gtk_widget_get_preferred_size (GTK_WIDGET (menu), &req, NULL);
+
+  /* Put corner of menu centered on color cell */
+  gtk_widget_get_allocation (widget, &allocation);
+  *x = root_x + allocation.width / 2;
+  *y = root_y + allocation.height / 2;
+
+  /* Ensure sanity */
+  screen = gtk_widget_get_screen (widget);
+  *x = CLAMP (*x, 0, MAX (0, WidthOfScreen (gdk_x11_screen_get_xscreen (screen)) - req.width));
+  *y = CLAMP (*y, 0, MAX (0, HeightOfScreen (gdk_x11_screen_get_xscreen (screen)) - req.height));
+}
+
+static void
+save_color_selected (GtkWidget *menuitem,
+                     gpointer   data)
+{
+  MateColorSelection *colorsel;
+  GtkWidget *drawing_area;
+  MateColorSelectionPrivate *priv;
+
+  drawing_area = GTK_WIDGET (data);
+
+  colorsel = MATE_COLOR_SELECTION (g_object_get_data (G_OBJECT (drawing_area),
+                                                     "gtk-color-sel"));
+
+  priv = colorsel->private_data;
+
+  palette_change_color (drawing_area, colorsel, priv->color);
+}
+
+static void
+do_popup (MateColorSelection *colorsel,
+          GtkWidget         *drawing_area,
+          guint32            timestamp)
+{
+  GtkWidget *menu;
+  GtkWidget *mi;
+
+  g_object_set_data (G_OBJECT (drawing_area),
+                     _("gtk-color-sel"),
+                     colorsel);
+
+  menu = gtk_menu_new ();
+
+  mi = gtk_menu_item_new_with_mnemonic (_("_Save color here"));
+
+  g_signal_connect (mi, "activate",
+                    G_CALLBACK (save_color_selected),
+                    drawing_area);
+
+  gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
+
+  gtk_widget_show_all (mi);
+
+  gtk_menu_popup (GTK_MENU (menu), NULL, NULL,
+                  popup_position_func, drawing_area,
+                  3, timestamp);
+}
+
+static gboolean
+palette_enter (GtkWidget        *drawing_area,
+	       GdkEventCrossing *event,
+	       gpointer        data)
+{
+  g_object_set_data (G_OBJECT (drawing_area),
+		     "gtk-colorsel-have-pointer",
+		     GUINT_TO_POINTER (TRUE));
+
+  return FALSE;
+}
+
+static gboolean
+palette_leave (GtkWidget        *drawing_area,
+	       GdkEventCrossing *event,
+	       gpointer        data)
+{
+  g_object_set_data (G_OBJECT (drawing_area),
+		     "gtk-colorsel-have-pointer",
+		     NULL);
+
+  return FALSE;
+}
+
+/* private function copied from gtk2/gtkmain.c */
+static gboolean
+_gtk_button_event_triggers_context_menu (GdkEventButton *event)
+{
+  if (event->type == GDK_BUTTON_PRESS)
+    {
+      if (event->button == 3 &&
+          ! (event->state & (GDK_BUTTON1_MASK | GDK_BUTTON2_MASK)))
+        return TRUE;
+
+#ifdef GDK_WINDOWING_QUARTZ
+      if (event->button == 1 &&
+          ! (event->state & (GDK_BUTTON2_MASK | GDK_BUTTON3_MASK)) &&
+          (event->state & GDK_CONTROL_MASK))
+        return TRUE;
+#endif
+    }
+
+  return FALSE;
+}
+
+static gboolean
+palette_press (GtkWidget      *drawing_area,
+	       GdkEventButton *event,
+	       gpointer        data)
+{
+  MateColorSelection *colorsel = MATE_COLOR_SELECTION (data);
+
+  gtk_widget_grab_focus (drawing_area);
+
+  if (_gtk_button_event_triggers_context_menu (event))
+    {
+      do_popup (colorsel, drawing_area, event->time);
+      return TRUE;
+    }
+
+  return FALSE;
+}
+
+static gboolean
+palette_release (GtkWidget      *drawing_area,
+		 GdkEventButton *event,
+		 gpointer        data)
+{
+  MateColorSelection *colorsel = MATE_COLOR_SELECTION (data);
+
+  gtk_widget_grab_focus (drawing_area);
+
+  if (event->button == 1 &&
+      g_object_get_data (G_OBJECT (drawing_area),
+			 "gtk-colorsel-have-pointer") != NULL)
+    {
+      gpointer pointer = g_object_get_data (G_OBJECT (drawing_area), "color_set");
+      if (pointer && GPOINTER_TO_INT (pointer) != 0)
+        {
+          gdouble color[4];
+          palette_get_color (drawing_area, color);
+          set_color_internal (colorsel, color);
+        }
+    }
+
+  return FALSE;
+}
+
+static void
+palette_drop_handle (GtkWidget        *widget,
+		     GdkDragContext   *context,
+		     gint              x,
+		     gint              y,
+		     GtkSelectionData *selection_data,
+		     guint             info,
+		     guint             time,
+		     gpointer          data)
+{
+  MateColorSelection *colorsel = MATE_COLOR_SELECTION (data);
+  guint16 *vals;
+  gdouble color[4];
+
+  if (gtk_selection_data_get_length (selection_data) < 0)
+    return;
+
+  /* We accept drops with the wrong format, since the KDE color
+   * chooser incorrectly drops application/x-color with format 8.
+   */
+  if (gtk_selection_data_get_length (selection_data) != 8)
+    {
+      g_warning ("Received invalid color data\n");
+      return;
+    }
+
+  vals = (guint16 *) gtk_selection_data_get_data (selection_data);
+
+  color[0] = (gdouble)vals[0] / 0xffff;
+  color[1] = (gdouble)vals[1] / 0xffff;
+  color[2] = (gdouble)vals[2] / 0xffff;
+  color[3] = (gdouble)vals[3] / 0xffff;
+  palette_change_color (widget, colorsel, color);
+  set_color_internal (colorsel, color);
+}
+
+static gint
+palette_activate (GtkWidget   *widget,
+		  GdkEventKey *event,
+		  gpointer     data)
+{
+  /* should have a drawing area subclass with an activate signal */
+  if ((event->keyval == GDK_KEY_space) ||
+      (event->keyval == GDK_KEY_Return) ||
+      (event->keyval == GDK_KEY_ISO_Enter) ||
+      (event->keyval == GDK_KEY_KP_Enter) ||
+      (event->keyval == GDK_KEY_KP_Space))
+    {
+      gpointer pointer = g_object_get_data (G_OBJECT (widget), "color_set");
+      if (pointer && GPOINTER_TO_INT (pointer) != 0)
+        {
+          gdouble color[4];
+          palette_get_color (widget, color);
+          set_color_internal (MATE_COLOR_SELECTION (data), color);
+        }
+      return TRUE;
+    }
+
+  return FALSE;
+}
+
+static gboolean
+palette_popup (GtkWidget *widget,
+               gpointer   data)
+{
+  MateColorSelection *colorsel = MATE_COLOR_SELECTION (data);
+
+  do_popup (colorsel, widget, GDK_CURRENT_TIME);
+  return TRUE;
+}
+
+static GtkWidget*
+palette_new (MateColorSelection *colorsel)
+{
+  static const GtkTargetEntry targets[] = {
+    { .target = "application/x-color", .flags = 0, .info = 0 }
+  };
+
+  GtkWidget *retval = gtk_drawing_area_new ();
+
+  gtk_widget_set_can_focus (retval, TRUE);
+
+  g_object_set_data (G_OBJECT (retval), "color_set", GINT_TO_POINTER (0));
+  gtk_widget_set_events (retval, GDK_BUTTON_PRESS_MASK
+                         | GDK_BUTTON_RELEASE_MASK
+                         | GDK_EXPOSURE_MASK
+                         | GDK_ENTER_NOTIFY_MASK
+                         | GDK_LEAVE_NOTIFY_MASK);
+
+  g_signal_connect (retval, "draw",
+		    G_CALLBACK (palette_draw), colorsel);
+  g_signal_connect (retval, "button-press-event",
+		    G_CALLBACK (palette_press), colorsel);
+  g_signal_connect (retval, "button-release-event",
+		    G_CALLBACK (palette_release), colorsel);
+  g_signal_connect (retval, "enter-notify-event",
+		    G_CALLBACK (palette_enter), colorsel);
+  g_signal_connect (retval, "leave-notify-event",
+		    G_CALLBACK (palette_leave), colorsel);
+  g_signal_connect (retval, "key-press-event",
+		    G_CALLBACK (palette_activate), colorsel);
+  g_signal_connect (retval, "popup-menu",
+		    G_CALLBACK (palette_popup), colorsel);
+
+  gtk_drag_dest_set (retval,
+		     GTK_DEST_DEFAULT_HIGHLIGHT |
+		     GTK_DEST_DEFAULT_MOTION |
+		     GTK_DEST_DEFAULT_DROP,
+		     targets, 1,
+		     GDK_ACTION_COPY);
+
+  g_signal_connect (retval, "drag-end",
+                    G_CALLBACK (palette_drag_end), NULL);
+  g_signal_connect (retval, "drag-data-received",
+                    G_CALLBACK (palette_drop_handle), colorsel);
+
+  gtk_widget_set_tooltip_text (retval,
+                        _("Click this palette entry to make it the current color. To change this entry, drag a color swatch here or right-click it and select \"Save color here.\""));
+  return retval;
+}
+
+/*
+ *
+ * The actual MateColorSelection widget
+ *
+ */
+
+static GdkCursor *
+make_picker_cursor (GdkScreen *screen)
+{
+  GdkCursor *cursor;
+
+  cursor = gdk_cursor_new_from_name (gdk_screen_get_display (screen),
+				     "color-picker");
+
+  if (!cursor)
+    {
+      GdkPixbuf *pixbuf;
+
+      pixbuf = gdk_pixbuf_new_from_data (dropper_bits,
+                                         GDK_COLORSPACE_RGB, TRUE, 8,
+                                         DROPPER_WIDTH, DROPPER_HEIGHT,
+                                         DROPPER_STRIDE,
+                                         NULL, NULL);
+
+      cursor = gdk_cursor_new_from_pixbuf (gdk_screen_get_display (screen),
+                                           pixbuf,
+                                           DROPPER_X_HOT, DROPPER_Y_HOT);
+      g_object_unref (pixbuf);
+    }
+
+  return cursor;
+}
+
+static GdkDevice *get_device (GdkDisplay *display)
+{
+  GdkSeat   *seat;
+  GdkDevice *device;
+
+  seat = gdk_display_get_default_seat (display);
+  device = gdk_seat_get_pointer (seat);
+
+  return device;
+}
+
+static void
+grab_color_at_mouse (GdkScreen *screen,
+		     gint       x_root,
+		     gint       y_root,
+		     gpointer   data)
+{
+  GdkPixbuf *pixbuf;
+  guchar *pixels;
+  MateColorSelection *colorsel = data;
+  MateColorSelectionPrivate *priv;
+  GdkColor color;
+  GdkWindow *root_window = gdk_screen_get_root_window (screen);
+
+  priv = colorsel->private_data;
+
+  pixbuf = gdk_pixbuf_get_from_window (root_window,
+                                       x_root, y_root,
+                                       1, 1);
+  if (!pixbuf)
+    {
+      gint x, y;
+      GdkDevice *device;
+      GdkDisplay *display = gdk_screen_get_display (screen);
+      device = get_device (display);
+      GdkWindow *window = gdk_device_get_window_at_position (device, &x, &y);
+      if (!window)
+	return;
+      pixbuf = gdk_pixbuf_get_from_window (window,
+                                           x, y,
+                                           1, 1);
+      if (!pixbuf)
+	return;
+    }
+  pixels = gdk_pixbuf_get_pixels (pixbuf);
+  color.red = pixels[0] * 0x101;
+  color.green = pixels[1] * 0x101;
+  color.blue = pixels[2] * 0x101;
+  g_object_unref (pixbuf);
+
+  priv->color[COLORSEL_RED] = SCALE (color.red);
+  priv->color[COLORSEL_GREEN] = SCALE (color.green);
+  priv->color[COLORSEL_BLUE] = SCALE (color.blue);
+
+  gtk_rgb_to_hsv (priv->color[COLORSEL_RED],
+		  priv->color[COLORSEL_GREEN],
+		  priv->color[COLORSEL_BLUE],
+		  &priv->color[COLORSEL_HUE],
+		  &priv->color[COLORSEL_SATURATION],
+		  &priv->color[COLORSEL_VALUE]);
+
+  update_color (colorsel);
+}
+
+static void
+shutdown_eyedropper (GtkWidget *widget)
+{
+  MateColorSelection *colorsel;
+  MateColorSelectionPrivate *priv;
+  GdkDisplay *display = gtk_widget_get_display (widget);
+  GdkSeat   *seat = gdk_display_get_default_seat (display);
+
+  colorsel = MATE_COLOR_SELECTION (widget);
+  priv = colorsel->private_data;
+
+  if (priv->has_grab)
+    {
+      gdk_seat_ungrab (seat);
+      gtk_grab_remove (priv->dropper_grab_widget);
+
+      priv->has_grab = FALSE;
+    }
+}
+
+static void
+mouse_motion (GtkWidget      *invisible,
+	      GdkEventMotion *event,
+	      gpointer        data)
+{
+  grab_color_at_mouse (gdk_event_get_screen ((GdkEvent *)event),
+		       event->x_root, event->y_root, data);
+}
+
+static gboolean
+mouse_release (GtkWidget      *invisible,
+	       GdkEventButton *event,
+	       gpointer        data)
+{
+  /* MateColorSelection *colorsel = data; */
+
+  if (event->button != 1)
+    return FALSE;
+
+  grab_color_at_mouse (gdk_event_get_screen ((GdkEvent *)event),
+		       event->x_root, event->y_root, data);
+
+  shutdown_eyedropper (GTK_WIDGET (data));
+
+  g_signal_handlers_disconnect_by_func (invisible,
+					mouse_motion,
+					data);
+  g_signal_handlers_disconnect_by_func (invisible,
+					mouse_release,
+					data);
+
+  return TRUE;
+}
+
+/* Helper Functions */
+
+static gboolean
+key_press (GtkWidget   *invisible,
+           GdkEventKey *event,
+           gpointer     data)
+{
+  GdkDevice *device;
+  GdkDisplay *display = gtk_widget_get_display (invisible);
+  GdkScreen *screen = gdk_event_get_screen ((GdkEvent *)event);
+  guint state = event->state & gtk_accelerator_get_default_mod_mask ();
+  gint x, y;
+  gint dx, dy;
+
+  device = get_device (display);
+  gdk_device_get_position (device, NULL, &x, &y);
+
+  dx = 0;
+  dy = 0;
+
+  switch (event->keyval)
+    {
+    case GDK_KEY_space:
+    case GDK_KEY_Return:
+    case GDK_KEY_ISO_Enter:
+    case GDK_KEY_KP_Enter:
+    case GDK_KEY_KP_Space:
+      grab_color_at_mouse (screen, x, y, data);
+      /* fall through */
+
+    case GDK_KEY_Escape:
+      shutdown_eyedropper (data);
+
+      g_signal_handlers_disconnect_by_func (invisible,
+					    mouse_press,
+					    data);
+      g_signal_handlers_disconnect_by_func (invisible,
+					    key_press,
+					    data);
+
+      return TRUE;
+
+#if defined GDK_WINDOWING_X11
+    case GDK_KEY_Up:
+    case GDK_KEY_KP_Up:
+      dy = state == GDK_MOD1_MASK ? -BIG_STEP : -1;
+      break;
+
+    case GDK_KEY_Down:
+    case GDK_KEY_KP_Down:
+      dy = state == GDK_MOD1_MASK ? BIG_STEP : 1;
+      break;
+
+    case GDK_KEY_Left:
+    case GDK_KEY_KP_Left:
+      dx = state == GDK_MOD1_MASK ? -BIG_STEP : -1;
+      break;
+
+    case GDK_KEY_Right:
+    case GDK_KEY_KP_Right:
+      dx = state == GDK_MOD1_MASK ? BIG_STEP : 1;
+      break;
+#endif
+
+    default:
+      return FALSE;
+    }
+
+  gdk_device_warp (device, screen, x + dx, y + dy);
+
+  return TRUE;
+
+}
+
+static gboolean
+mouse_press (GtkWidget      *invisible,
+	     GdkEventButton *event,
+	     gpointer        data)
+{
+  /* MateColorSelection *colorsel = data; */
+
+  if (event->type == GDK_BUTTON_PRESS &&
+      event->button == 1)
+    {
+      g_signal_connect (invisible, "motion-notify-event",
+                        G_CALLBACK (mouse_motion),
+                        data);
+      g_signal_connect (invisible, "button-release-event",
+                        G_CALLBACK (mouse_release),
+                        data);
+      g_signal_handlers_disconnect_by_func (invisible,
+					    mouse_press,
+					    data);
+      g_signal_handlers_disconnect_by_func (invisible,
+					    key_press,
+					    data);
+      return TRUE;
+    }
+
+  return FALSE;
+}
+
+/* when the button is clicked */
+static void
+get_screen_color (GtkWidget *button)
+{
+  MateColorSelection *colorsel = g_object_get_data (G_OBJECT (button), "COLORSEL");
+  MateColorSelectionPrivate *priv = colorsel->private_data;
+  GdkScreen *screen = gtk_widget_get_screen (GTK_WIDGET (button));
+  GdkCursor *picker_cursor;
+  GdkGrabStatus grab_status;
+  GtkWidget *grab_widget, *toplevel;
+  GdkDisplay *display;
+  GdkEvent   *event;
+  GdkSeat    *seat;
+
+  guint32 time = gtk_get_current_event_time ();
+  event = gtk_get_current_event ();
+  if (priv->dropper_grab_widget == NULL)
+    {
+      grab_widget = gtk_window_new (GTK_WINDOW_POPUP);
+      gtk_window_set_screen (GTK_WINDOW (grab_widget), screen);
+      gtk_window_resize (GTK_WINDOW (grab_widget), 1, 1);
+      gtk_window_move (GTK_WINDOW (grab_widget), -100, -100);
+      gtk_widget_show (grab_widget);
+
+      gtk_widget_add_events (grab_widget,
+                             GDK_BUTTON_RELEASE_MASK | GDK_BUTTON_PRESS_MASK | GDK_POINTER_MOTION_MASK);
+
+      toplevel = gtk_widget_get_toplevel (GTK_WIDGET (colorsel));
+
+      if (GTK_IS_WINDOW (toplevel))
+	{
+	  if (gtk_window_get_group (GTK_WINDOW (toplevel)))
+	    gtk_window_group_add_window (gtk_window_get_group (GTK_WINDOW (toplevel)),
+					 GTK_WINDOW (grab_widget));
+	}
+
+      priv->dropper_grab_widget = grab_widget;
+    }
+
+  display = gtk_widget_get_display (priv->dropper_grab_widget);
+  seat = gdk_display_get_default_seat (display);
+
+  if (gdk_seat_grab (seat, gtk_widget_get_window (priv->dropper_grab_widget),
+                     GDK_SEAT_CAPABILITY_KEYBOARD, FALSE, NULL,
+                     event,
+                     NULL, NULL) != GDK_GRAB_SUCCESS)
+  {
+    gdk_event_free (event);
+    return;
+  }
+
+  picker_cursor = make_picker_cursor (screen);
+  grab_status = gdk_seat_grab (seat, gtk_widget_get_window (priv->dropper_grab_widget),
+                               GDK_SEAT_CAPABILITY_POINTER, FALSE, picker_cursor,
+                               event,
+                               NULL, NULL);
+  gdk_event_free (event);
+  g_object_unref (picker_cursor);
+
+  if (grab_status != GDK_GRAB_SUCCESS)
+    {
+      gdk_seat_ungrab (seat);
+      return;
+    }
+
+  gtk_grab_add (priv->dropper_grab_widget);
+  priv->grab_time = time;
+  priv->has_grab = TRUE;
+
+  g_signal_connect (priv->dropper_grab_widget, "button-press-event",
+                    G_CALLBACK (mouse_press), colorsel);
+  g_signal_connect (priv->dropper_grab_widget, "key-press-event",
+                    G_CALLBACK (key_press), colorsel);
+}
+
+static void
+hex_changed (GtkWidget *hex_entry,
+	     gpointer   data)
+{
+  MateColorSelection *colorsel;
+  MateColorSelectionPrivate *priv;
+  GdkColor color;
+  gchar *text;
+
+  colorsel = MATE_COLOR_SELECTION (data);
+  priv = colorsel->private_data;
+
+  if (priv->changing)
+    return;
+
+  text = gtk_editable_get_chars (GTK_EDITABLE (priv->hex_entry), 0, -1);
+  if (gdk_color_parse (text, &color))
+    {
+      priv->color[COLORSEL_RED] = CLAMP (color.red/65535.0, 0.0, 1.0);
+      priv->color[COLORSEL_GREEN] = CLAMP (color.green/65535.0, 0.0, 1.0);
+      priv->color[COLORSEL_BLUE] = CLAMP (color.blue/65535.0, 0.0, 1.0);
+      gtk_rgb_to_hsv (priv->color[COLORSEL_RED],
+		      priv->color[COLORSEL_GREEN],
+		      priv->color[COLORSEL_BLUE],
+		      &priv->color[COLORSEL_HUE],
+		      &priv->color[COLORSEL_SATURATION],
+		      &priv->color[COLORSEL_VALUE]);
+      update_color (colorsel);
+    }
+  g_free (text);
+}
+
+static gboolean
+hex_focus_out (GtkWidget     *hex_entry,
+	       GdkEventFocus *event,
+	       gpointer       data)
+{
+  hex_changed (hex_entry, data);
+
+  return FALSE;
+}
+
+static void
+hsv_changed (GtkWidget *hsv,
+	     gpointer   data)
+{
+  MateColorSelection *colorsel;
+  MateColorSelectionPrivate *priv;
+
+  colorsel = MATE_COLOR_SELECTION (data);
+  priv = colorsel->private_data;
+
+  if (priv->changing)
+    return;
+
+  mate_hsv_get_color (MATE_HSV (hsv),
+		      &priv->color[COLORSEL_HUE],
+		      &priv->color[COLORSEL_SATURATION],
+		      &priv->color[COLORSEL_VALUE]);
+  gtk_hsv_to_rgb (priv->color[COLORSEL_HUE],
+		  priv->color[COLORSEL_SATURATION],
+		  priv->color[COLORSEL_VALUE],
+		  &priv->color[COLORSEL_RED],
+		  &priv->color[COLORSEL_GREEN],
+		  &priv->color[COLORSEL_BLUE]);
+  update_color (colorsel);
+}
+
+static void
+adjustment_changed (GtkAdjustment *adjustment,
+		    gpointer       data)
+{
+  MateColorSelection *colorsel;
+  MateColorSelectionPrivate *priv;
+  gdouble value;
+
+  colorsel = MATE_COLOR_SELECTION (g_object_get_data (G_OBJECT (adjustment), "COLORSEL"));
+  priv = colorsel->private_data;
+  value = gtk_adjustment_get_value (adjustment);
+
+  if (priv->changing)
+    return;
+
+  switch (GPOINTER_TO_INT (data))
+    {
+    case COLORSEL_SATURATION:
+    case COLORSEL_VALUE:
+      priv->color[GPOINTER_TO_INT (data)] = value / 100;
+      gtk_hsv_to_rgb (priv->color[COLORSEL_HUE],
+		      priv->color[COLORSEL_SATURATION],
+		      priv->color[COLORSEL_VALUE],
+		      &priv->color[COLORSEL_RED],
+		      &priv->color[COLORSEL_GREEN],
+		      &priv->color[COLORSEL_BLUE]);
+      break;
+    case COLORSEL_HUE:
+      priv->color[GPOINTER_TO_INT (data)] = value / 360;
+      gtk_hsv_to_rgb (priv->color[COLORSEL_HUE],
+		      priv->color[COLORSEL_SATURATION],
+		      priv->color[COLORSEL_VALUE],
+		      &priv->color[COLORSEL_RED],
+		      &priv->color[COLORSEL_GREEN],
+		      &priv->color[COLORSEL_BLUE]);
+      break;
+    case COLORSEL_RED:
+    case COLORSEL_GREEN:
+    case COLORSEL_BLUE:
+      priv->color[GPOINTER_TO_INT (data)] = value / 255;
+
+      gtk_rgb_to_hsv (priv->color[COLORSEL_RED],
+		      priv->color[COLORSEL_GREEN],
+		      priv->color[COLORSEL_BLUE],
+		      &priv->color[COLORSEL_HUE],
+		      &priv->color[COLORSEL_SATURATION],
+		      &priv->color[COLORSEL_VALUE]);
+      break;
+    default:
+      priv->color[GPOINTER_TO_INT (data)] = value / 255;
+      break;
+    }
+  update_color (colorsel);
+}
+
+static void
+opacity_entry_changed (GtkWidget *opacity_entry,
+		       gpointer   data)
+{
+  MateColorSelection *colorsel;
+  MateColorSelectionPrivate *priv;
+  GtkAdjustment *adj;
+  gchar *text;
+
+  colorsel = MATE_COLOR_SELECTION (data);
+  priv = colorsel->private_data;
+
+  if (priv->changing)
+    return;
+
+  text = gtk_editable_get_chars (GTK_EDITABLE (priv->opacity_entry), 0, -1);
+  adj = gtk_range_get_adjustment (GTK_RANGE (priv->opacity_slider));
+  gtk_adjustment_set_value (adj, g_strtod (text, NULL));
+
+  update_color (colorsel);
+
+  g_free (text);
+}
+
+static void
+make_label_spinbutton (MateColorSelection *colorsel,
+		       GtkWidget        **spinbutton,
+		       gchar             *text,
+		       GtkWidget         *grid,
+		       gint               i,
+		       gint               j,
+		       gint               channel_type,
+                       const gchar       *tooltip)
+{
+  GtkWidget *label;
+  GtkAdjustment *adjust;
+
+  if (channel_type == COLORSEL_HUE)
+    {
+      adjust = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 360.0, 1.0, 1.0, 0.0));
+    }
+  else if (channel_type == COLORSEL_SATURATION ||
+	   channel_type == COLORSEL_VALUE)
+    {
+      adjust = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 100.0, 1.0, 1.0, 0.0));
+    }
+  else
+    {
+      adjust = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 255.0, 1.0, 1.0, 0.0));
+    }
+  g_object_set_data (G_OBJECT (adjust), "COLORSEL", colorsel);
+  *spinbutton = gtk_spin_button_new (adjust, 10.0, 0);
+
+  gtk_widget_set_tooltip_text (*spinbutton, tooltip);
+
+  g_signal_connect (adjust, "value-changed",
+                    G_CALLBACK (adjustment_changed),
+                    GINT_TO_POINTER (channel_type));
+  label = gtk_label_new_with_mnemonic (text);
+  gtk_label_set_mnemonic_widget (GTK_LABEL (label), *spinbutton);
+
+  gtk_label_set_xalign (GTK_LABEL (label), 0.0);
+  gtk_grid_attach (GTK_GRID (grid), label, i, j, 1, 1);
+  gtk_grid_attach (GTK_GRID (grid), *spinbutton, i+1, j, 1, 1);
+}
+
+static void
+make_palette_frame (MateColorSelection *colorsel,
+		    GtkWidget         *grid,
+		    gint               i,
+		    gint               j)
+{
+  GtkWidget *frame;
+  MateColorSelectionPrivate *priv;
+
+  priv = colorsel->private_data;
+  frame = gtk_frame_new (NULL);
+  gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
+  priv->custom_palette[i][j] = palette_new (colorsel);
+  gtk_widget_set_size_request (priv->custom_palette[i][j], CUSTOM_PALETTE_ENTRY_WIDTH, CUSTOM_PALETTE_ENTRY_HEIGHT);
+  gtk_container_add (GTK_CONTAINER (frame), priv->custom_palette[i][j]);
+  gtk_widget_set_hexpand (frame, TRUE);
+  gtk_grid_attach (GTK_GRID (grid), frame, i, j, 1, 1);
+}
+
+/* Set the palette entry [x][y] to be the currently selected one. */
+static void
+set_selected_palette (MateColorSelection *colorsel, int x, int y)
+{
+  MateColorSelectionPrivate *priv = colorsel->private_data;
+
+  gtk_widget_grab_focus (priv->custom_palette[x][y]);
+}
+
+static double
+scale_round (double val, double factor)
+{
+  val = floor (val * factor + 0.5);
+  val = MAX (val, 0);
+  val = MIN (val, factor);
+  return val;
+}
+
+static void
+update_color (MateColorSelection *colorsel)
+{
+  MateColorSelectionPrivate *priv = colorsel->private_data;
+  gchar entryval[12];
+  gchar opacity_text[32];
+  gchar *ptr;
+  double r;
+  double g;
+  double b;
+
+  priv->changing = TRUE;
+  color_sample_update_samples (colorsel);
+
+  mate_hsv_set_color (MATE_HSV (priv->triangle_colorsel),
+		      priv->color[COLORSEL_HUE],
+		      priv->color[COLORSEL_SATURATION],
+		      priv->color[COLORSEL_VALUE]);
+  gtk_adjustment_set_value (gtk_spin_button_get_adjustment
+			    (GTK_SPIN_BUTTON (priv->hue_spinbutton)),
+			    scale_round (priv->color[COLORSEL_HUE], 360));
+  gtk_adjustment_set_value (gtk_spin_button_get_adjustment
+			    (GTK_SPIN_BUTTON (priv->sat_spinbutton)),
+			    scale_round (priv->color[COLORSEL_SATURATION], 100));
+  gtk_adjustment_set_value (gtk_spin_button_get_adjustment
+			    (GTK_SPIN_BUTTON (priv->val_spinbutton)),
+			    scale_round (priv->color[COLORSEL_VALUE], 100));
+  gtk_adjustment_set_value (gtk_spin_button_get_adjustment
+			    (GTK_SPIN_BUTTON (priv->red_spinbutton)),
+			    scale_round (priv->color[COLORSEL_RED], 255));
+  gtk_adjustment_set_value (gtk_spin_button_get_adjustment
+			    (GTK_SPIN_BUTTON (priv->green_spinbutton)),
+			    scale_round (priv->color[COLORSEL_GREEN], 255));
+  gtk_adjustment_set_value (gtk_spin_button_get_adjustment
+			    (GTK_SPIN_BUTTON (priv->blue_spinbutton)),
+			    scale_round (priv->color[COLORSEL_BLUE], 255));
+  gtk_adjustment_set_value (gtk_range_get_adjustment
+			    (GTK_RANGE (priv->opacity_slider)),
+			    scale_round (priv->color[COLORSEL_OPACITY], 255));
+
+  g_snprintf (opacity_text, 32, "%.0f", scale_round (priv->color[COLORSEL_OPACITY], 255));
+  gtk_entry_set_text (GTK_ENTRY (priv->opacity_entry), opacity_text);
+
+  r = scale_round (priv->color[COLORSEL_RED],   255);
+  g = scale_round (priv->color[COLORSEL_GREEN], 255);
+  b = scale_round (priv->color[COLORSEL_BLUE],  255);
+  g_snprintf (entryval, 11, "#%2X%2X%2X", (guint) r, (guint) g, (guint) b);
+
+  for (ptr = entryval; *ptr; ptr++)
+    if (*ptr == ' ')
+      *ptr = '0';
+  gtk_entry_set_text (GTK_ENTRY (priv->hex_entry), entryval);
+  priv->changing = FALSE;
+
+  g_object_ref (colorsel);
+
+  g_signal_emit (colorsel, color_selection_signals[COLOR_CHANGED], 0);
+
+  g_object_freeze_notify (G_OBJECT (colorsel));
+  g_object_notify (G_OBJECT (colorsel), "current-color");
+  g_object_notify (G_OBJECT (colorsel), "current-alpha");
+  g_object_thaw_notify (G_OBJECT (colorsel));
+
+  g_object_unref (colorsel);
+}
+
+static void
+update_palette (MateColorSelection *colorsel)
+{
+  GdkColor *current_colors;
+  gint i, j;
+
+  current_colors = get_current_colors (colorsel);
+
+  for (i = 0; i < GTK_CUSTOM_PALETTE_HEIGHT; i++)
+    {
+      for (j = 0; j < GTK_CUSTOM_PALETTE_WIDTH; j++)
+	{
+          gint index;
+
+          index = i * GTK_CUSTOM_PALETTE_WIDTH + j;
+
+          mate_color_selection_set_palette_color (colorsel,
+                                                 index,
+                                                 &current_colors[index]);
+	}
+    }
+
+  g_free (current_colors);
+}
+
+static void
+palette_change_notify_instance (GObject    *object,
+                                GParamSpec *pspec,
+                                gpointer    data)
+{
+  update_palette (MATE_COLOR_SELECTION (data));
+}
+
+static void
+default_noscreen_change_palette_func (const GdkColor *colors,
+				      gint            n_colors)
+{
+  default_change_palette_func (gdk_screen_get_default (), colors, n_colors);
+}
+
+static void
+default_change_palette_func (GdkScreen	    *screen,
+			     const GdkColor *colors,
+                             gint            n_colors)
+{
+  gchar *str;
+
+  str = mate_color_selection_palette_to_string (colors, n_colors);
+
+  gtk_settings_set_string_property (gtk_settings_get_for_screen (screen),
+                                    "gtk-color-palette",
+                                    str,
+                                    "mate_color_selection_palette_to_string");
+
+  g_free (str);
+}
+
+/**
+ * mate_color_selection_new:
+ *
+ * Creates a new MateColorSelection.
+ *
+ * Return value: a new #MateColorSelection
+ **/
+GtkWidget *
+mate_color_selection_new (void)
+{
+  MateColorSelection *colorsel;
+  MateColorSelectionPrivate *priv;
+  gdouble color[4];
+  color[0] = 1.0;
+  color[1] = 1.0;
+  color[2] = 1.0;
+  color[3] = 1.0;
+
+  colorsel = g_object_new (MATE_TYPE_COLOR_SELECTION, "orientation", GTK_ORIENTATION_VERTICAL, NULL);
+  priv = colorsel->private_data;
+  set_color_internal (colorsel, color);
+  mate_color_selection_set_has_opacity_control (colorsel, TRUE);
+
+  /* We want to make sure that default_set is FALSE */
+  /* This way the user can still set it */
+  priv->default_set = FALSE;
+  priv->default_alpha_set = FALSE;
+
+  return GTK_WIDGET (colorsel);
+}
+
+/**
+ * mate_color_selection_get_has_opacity_control:
+ * @colorsel: a #MateColorSelection.
+ *
+ * Determines whether the colorsel has an opacity control.
+ *
+ * Return value: %TRUE if the @colorsel has an opacity control.  %FALSE if it does't.
+ **/
+gboolean
+mate_color_selection_get_has_opacity_control (MateColorSelection *colorsel)
+{
+  MateColorSelectionPrivate *priv;
+
+  g_return_val_if_fail (MATE_IS_COLOR_SELECTION (colorsel), FALSE);
+
+  priv = colorsel->private_data;
+
+  return priv->has_opacity;
+}
+
+/**
+ * mate_color_selection_set_has_opacity_control:
+ * @colorsel: a #MateColorSelection.
+ * @has_opacity: %TRUE if @colorsel can set the opacity, %FALSE otherwise.
+ *
+ * Sets the @colorsel to use or not use opacity.
+ *
+ **/
+void
+mate_color_selection_set_has_opacity_control (MateColorSelection *colorsel,
+					     gboolean           has_opacity)
+{
+  MateColorSelectionPrivate *priv;
+
+  g_return_if_fail (MATE_IS_COLOR_SELECTION (colorsel));
+
+  priv = colorsel->private_data;
+  has_opacity = has_opacity != FALSE;
+
+  if (priv->has_opacity != has_opacity)
+    {
+      priv->has_opacity = (has_opacity != FALSE);
+      if (has_opacity)
+	{
+	  gtk_widget_show (priv->opacity_slider);
+	  gtk_widget_show (priv->opacity_label);
+	  gtk_widget_show (priv->opacity_entry);
+	}
+      else
+	{
+	  gtk_widget_hide (priv->opacity_slider);
+	  gtk_widget_hide (priv->opacity_label);
+	  gtk_widget_hide (priv->opacity_entry);
+	}
+      color_sample_update_samples (colorsel);
+
+      g_object_notify (G_OBJECT (colorsel), "has-opacity-control");
+    }
+}
+
+/**
+ * mate_color_selection_get_has_palette:
+ * @colorsel: a #MateColorSelection.
+ *
+ * Determines whether the color selector has a color palette.
+ *
+ * Return value: %TRUE if the selector has a palette.  %FALSE if it hasn't.
+ **/
+gboolean
+mate_color_selection_get_has_palette (MateColorSelection *colorsel)
+{
+  MateColorSelectionPrivate *priv;
+
+  g_return_val_if_fail (MATE_IS_COLOR_SELECTION (colorsel), FALSE);
+
+  priv = colorsel->private_data;
+
+  return priv->has_palette;
+}
+
+/**
+ * mate_color_selection_set_has_palette:
+ * @colorsel: a #MateColorSelection.
+ * @has_palette: %TRUE if palette is to be visible, %FALSE otherwise.
+ *
+ * Shows and hides the palette based upon the value of @has_palette.
+ *
+ **/
+void
+mate_color_selection_set_has_palette (MateColorSelection *colorsel,
+				     gboolean           has_palette)
+{
+  MateColorSelectionPrivate *priv;
+  g_return_if_fail (MATE_IS_COLOR_SELECTION (colorsel));
+
+  priv = colorsel->private_data;
+  has_palette = has_palette != FALSE;
+
+  if (priv->has_palette != has_palette)
+    {
+      priv->has_palette = (has_palette != FALSE);
+      if (has_palette)
+	gtk_widget_show (priv->palette_frame);
+      else
+	gtk_widget_hide (priv->palette_frame);
+
+      update_tooltips (colorsel);
+
+      g_object_notify (G_OBJECT (colorsel), "has-palette");
+    }
+}
+
+/**
+ * mate_color_selection_set_current_color:
+ * @colorsel: a #MateColorSelection.
+ * @color: A #GdkColor to set the current color with.
+ *
+ * Sets the current color to be @color.  The first time this is called, it will
+ * also set the original color to be @color too.
+ **/
+void
+mate_color_selection_set_current_color (MateColorSelection *colorsel,
+				       const GdkColor    *color)
+{
+  MateColorSelectionPrivate *priv;
+  gint i;
+
+  g_return_if_fail (MATE_IS_COLOR_SELECTION (colorsel));
+  g_return_if_fail (color != NULL);
+
+  priv = colorsel->private_data;
+  priv->changing = TRUE;
+  priv->color[COLORSEL_RED] = SCALE (color->red);
+  priv->color[COLORSEL_GREEN] = SCALE (color->green);
+  priv->color[COLORSEL_BLUE] = SCALE (color->blue);
+  gtk_rgb_to_hsv (priv->color[COLORSEL_RED],
+		  priv->color[COLORSEL_GREEN],
+		  priv->color[COLORSEL_BLUE],
+		  &priv->color[COLORSEL_HUE],
+		  &priv->color[COLORSEL_SATURATION],
+		  &priv->color[COLORSEL_VALUE]);
+  if (priv->default_set == FALSE)
+    {
+      for (i = 0; i < COLORSEL_NUM_CHANNELS; i++)
+	priv->old_color[i] = priv->color[i];
+    }
+  priv->default_set = TRUE;
+  update_color (colorsel);
+}
+
+/**
+ * mate_color_selection_set_current_alpha:
+ * @colorsel: a #MateColorSelection.
+ * @alpha: an integer between 0 and 65535.
+ *
+ * Sets the current opacity to be @alpha.  The first time this is called, it will
+ * also set the original opacity to be @alpha too.
+ **/
+void
+mate_color_selection_set_current_alpha (MateColorSelection *colorsel,
+				       guint16            alpha)
+{
+  MateColorSelectionPrivate *priv;
+  gint i;
+
+  g_return_if_fail (MATE_IS_COLOR_SELECTION (colorsel));
+
+  priv = colorsel->private_data;
+  priv->changing = TRUE;
+  priv->color[COLORSEL_OPACITY] = SCALE (alpha);
+  if (priv->default_alpha_set == FALSE)
+    {
+      for (i = 0; i < COLORSEL_NUM_CHANNELS; i++)
+	priv->old_color[i] = priv->color[i];
+    }
+  priv->default_alpha_set = TRUE;
+  update_color (colorsel);
+}
+
+/**
+ * mate_color_selection_set_color:
+ * @colorsel: a #MateColorSelection.
+ * @color: an array of 4 doubles specifying the red, green, blue and opacity
+ *   to set the current color to.
+ *
+ * Sets the current color to be @color.  The first time this is called, it will
+ * also set the original color to be @color too.
+ *
+ * Deprecated: 2.0: Use mate_color_selection_set_current_color() instead.
+ **/
+void
+mate_color_selection_set_color (MateColorSelection    *colorsel,
+			       gdouble              *color)
+{
+  g_return_if_fail (MATE_IS_COLOR_SELECTION (colorsel));
+
+  set_color_internal (colorsel, color);
+}
+
+/**
+ * mate_color_selection_get_current_color:
+ * @colorsel: a #MateColorSelection.
+ * @color: (out): a #GdkColor to fill in with the current color.
+ *
+ * Sets @color to be the current color in the MateColorSelection widget.
+ **/
+void
+mate_color_selection_get_current_color (MateColorSelection *colorsel,
+				       GdkColor          *color)
+{
+  MateColorSelectionPrivate *priv;
+
+  g_return_if_fail (MATE_IS_COLOR_SELECTION (colorsel));
+  g_return_if_fail (color != NULL);
+
+  priv = colorsel->private_data;
+  color->red = UNSCALE (priv->color[COLORSEL_RED]);
+  color->green = UNSCALE (priv->color[COLORSEL_GREEN]);
+  color->blue = UNSCALE (priv->color[COLORSEL_BLUE]);
+}
+
+/**
+ * mate_color_selection_get_current_alpha:
+ * @colorsel: a #MateColorSelection.
+ *
+ * Returns the current alpha value.
+ *
+ * Return value: an integer between 0 and 65535.
+ **/
+guint16
+mate_color_selection_get_current_alpha (MateColorSelection *colorsel)
+{
+  MateColorSelectionPrivate *priv;
+
+  g_return_val_if_fail (MATE_IS_COLOR_SELECTION (colorsel), 0);
+
+  priv = colorsel->private_data;
+  return priv->has_opacity ? UNSCALE (priv->color[COLORSEL_OPACITY]) : 65535;
+}
+
+/**
+ * mate_color_selection_get_color:
+ * @colorsel: a #MateColorSelection.
+ * @color: an array of 4 #gdouble to fill in with the current color.
+ *
+ * Sets @color to be the current color in the MateColorSelection widget.
+ *
+ * Deprecated: 2.0: Use mate_color_selection_get_current_color() instead.
+ **/
+void
+mate_color_selection_get_color (MateColorSelection *colorsel,
+			       gdouble           *color)
+{
+  MateColorSelectionPrivate *priv;
+
+  g_return_if_fail (MATE_IS_COLOR_SELECTION (colorsel));
+
+  priv = colorsel->private_data;
+  color[0] = priv->color[COLORSEL_RED];
+  color[1] = priv->color[COLORSEL_GREEN];
+  color[2] = priv->color[COLORSEL_BLUE];
+  color[3] = priv->has_opacity ? priv->color[COLORSEL_OPACITY] : 65535;
+}
+
+/**
+ * mate_color_selection_set_previous_color:
+ * @colorsel: a #MateColorSelection.
+ * @color: a #GdkColor to set the previous color with.
+ *
+ * Sets the 'previous' color to be @color.  This function should be called with
+ * some hesitations, as it might seem confusing to have that color change.
+ * Calling mate_color_selection_set_current_color() will also set this color the first
+ * time it is called.
+ **/
+void
+mate_color_selection_set_previous_color (MateColorSelection *colorsel,
+					const GdkColor    *color)
+{
+  MateColorSelectionPrivate *priv;
+
+  g_return_if_fail (MATE_IS_COLOR_SELECTION (colorsel));
+  g_return_if_fail (color != NULL);
+
+  priv = colorsel->private_data;
+  priv->changing = TRUE;
+  priv->old_color[COLORSEL_RED] = SCALE (color->red);
+  priv->old_color[COLORSEL_GREEN] = SCALE (color->green);
+  priv->old_color[COLORSEL_BLUE] = SCALE (color->blue);
+  gtk_rgb_to_hsv (priv->old_color[COLORSEL_RED],
+		  priv->old_color[COLORSEL_GREEN],
+		  priv->old_color[COLORSEL_BLUE],
+		  &priv->old_color[COLORSEL_HUE],
+		  &priv->old_color[COLORSEL_SATURATION],
+		  &priv->old_color[COLORSEL_VALUE]);
+  color_sample_update_samples (colorsel);
+  priv->default_set = TRUE;
+  priv->changing = FALSE;
+}
+
+/**
+ * mate_color_selection_set_previous_alpha:
+ * @colorsel: a #MateColorSelection.
+ * @alpha: an integer between 0 and 65535.
+ *
+ * Sets the 'previous' alpha to be @alpha.  This function should be called with
+ * some hesitations, as it might seem confusing to have that alpha change.
+ **/
+void
+mate_color_selection_set_previous_alpha (MateColorSelection *colorsel,
+					guint16            alpha)
+{
+  MateColorSelectionPrivate *priv;
+
+  g_return_if_fail (MATE_IS_COLOR_SELECTION (colorsel));
+
+  priv = colorsel->private_data;
+  priv->changing = TRUE;
+  priv->old_color[COLORSEL_OPACITY] = SCALE (alpha);
+  color_sample_update_samples (colorsel);
+  priv->default_alpha_set = TRUE;
+  priv->changing = FALSE;
+}
+
+/**
+ * mate_color_selection_get_previous_color:
+ * @colorsel: a #MateColorSelection.
+ * @color: (out): a #GdkColor to fill in with the original color value.
+ *
+ * Fills @color in with the original color value.
+ **/
+void
+mate_color_selection_get_previous_color (MateColorSelection *colorsel,
+					GdkColor           *color)
+{
+  MateColorSelectionPrivate *priv;
+
+  g_return_if_fail (MATE_IS_COLOR_SELECTION (colorsel));
+  g_return_if_fail (color != NULL);
+
+  priv = colorsel->private_data;
+  color->red = UNSCALE (priv->old_color[COLORSEL_RED]);
+  color->green = UNSCALE (priv->old_color[COLORSEL_GREEN]);
+  color->blue = UNSCALE (priv->old_color[COLORSEL_BLUE]);
+}
+
+/**
+ * mate_color_selection_get_previous_alpha:
+ * @colorsel: a #MateColorSelection.
+ *
+ * Returns the previous alpha value.
+ *
+ * Return value: an integer between 0 and 65535.
+ **/
+guint16
+mate_color_selection_get_previous_alpha (MateColorSelection *colorsel)
+{
+  MateColorSelectionPrivate *priv;
+
+  g_return_val_if_fail (MATE_IS_COLOR_SELECTION (colorsel), 0);
+
+  priv = colorsel->private_data;
+  return priv->has_opacity ? UNSCALE (priv->old_color[COLORSEL_OPACITY]) : 65535;
+}
+
+/**
+ * mate_color_selection_set_palette_color:
+ * @colorsel: a #MateColorSelection.
+ * @index: the color index of the palette.
+ * @color: A #GdkColor to set the palette with.
+ *
+ * Sets the palette located at @index to have @color as its color.
+ *
+ **/
+static void
+mate_color_selection_set_palette_color (MateColorSelection   *colorsel,
+				       gint                 index,
+				       GdkColor            *color)
+{
+  MateColorSelectionPrivate *priv;
+  gint x, y;
+  gdouble col[3];
+
+  g_return_if_fail (MATE_IS_COLOR_SELECTION (colorsel));
+  g_return_if_fail (index >= 0  && index < GTK_CUSTOM_PALETTE_WIDTH*GTK_CUSTOM_PALETTE_HEIGHT);
+
+  x = index % GTK_CUSTOM_PALETTE_WIDTH;
+  y = index / GTK_CUSTOM_PALETTE_WIDTH;
+
+  priv = colorsel->private_data;
+  col[0] = SCALE (color->red);
+  col[1] = SCALE (color->green);
+  col[2] = SCALE (color->blue);
+
+  palette_set_color (priv->custom_palette[x][y], colorsel, col);
+}
+
+/**
+ * mate_color_selection_is_adjusting:
+ * @colorsel: a #MateColorSelection.
+ *
+ * Gets the current state of the @colorsel.
+ *
+ * Return value: %TRUE if the user is currently dragging a color around, and %FALSE
+ * if the selection has stopped.
+ **/
+gboolean
+mate_color_selection_is_adjusting (MateColorSelection *colorsel)
+{
+  MateColorSelectionPrivate *priv;
+
+  g_return_val_if_fail (MATE_IS_COLOR_SELECTION (colorsel), FALSE);
+
+  priv = colorsel->private_data;
+
+  return (mate_hsv_is_adjusting (MATE_HSV (priv->triangle_colorsel)));
+}
+
+/**
+ * mate_color_selection_palette_from_string:
+ * @str: a string encoding a color palette.
+ * @colors: (out) (array length=n_colors): return location for allocated
+ *          array of #GdkColor.
+ * @n_colors: return location for length of array.
+ *
+ * Parses a color palette string; the string is a colon-separated
+ * list of color names readable by gdk_color_parse().
+ *
+ * Return value: %TRUE if a palette was successfully parsed.
+ **/
+gboolean
+mate_color_selection_palette_from_string (const gchar *str,
+                                         GdkColor   **colors,
+                                         gint        *n_colors)
+{
+  GdkColor *retval;
+  gint count;
+  gchar *p;
+  gchar *start;
+  gchar *copy;
+
+  count = 0;
+  retval = NULL;
+  copy = g_strdup (str);
+
+  start = copy;
+  p = copy;
+  while (TRUE)
+    {
+      if (*p == ':' || *p == '\0')
+        {
+          gboolean done = TRUE;
+
+          if (start == p)
+            {
+              goto failed; /* empty entry */
+            }
+
+          if (*p)
+            {
+              *p = '\0';
+              done = FALSE;
+            }
+
+          retval = g_renew (GdkColor, retval, count + 1);
+          if (!gdk_color_parse (start, retval + count))
+            {
+              goto failed;
+            }
+
+          ++count;
+
+          if (done)
+            break;
+          else
+            start = p + 1;
+        }
+
+      ++p;
+    }
+
+  g_free (copy);
+
+  if (colors)
+    *colors = retval;
+  else
+    g_free (retval);
+
+  if (n_colors)
+    *n_colors = count;
+
+  return TRUE;
+
+ failed:
+  g_free (copy);
+  g_free (retval);
+
+  if (colors)
+    *colors = NULL;
+  if (n_colors)
+    *n_colors = 0;
+
+  return FALSE;
+}
+
+/**
+ * mate_color_selection_palette_to_string:
+ * @colors: (array length=n_colors): an array of colors.
+ * @n_colors: length of the array.
+ *
+ * Encodes a palette as a string, useful for persistent storage.
+ *
+ * Return value: allocated string encoding the palette.
+ **/
+gchar*
+mate_color_selection_palette_to_string (const GdkColor *colors,
+                                       gint            n_colors)
+{
+  gint i;
+  gchar **strs = NULL;
+  gchar *retval;
+
+  if (n_colors == 0)
+    return g_strdup ("");
+
+  strs = g_new0 (gchar*, n_colors + 1);
+
+  i = 0;
+  while (i < n_colors)
+    {
+      gchar *ptr;
+
+      strs[i] =
+        g_strdup_printf ("#%2X%2X%2X",
+                         colors[i].red / 256,
+                         colors[i].green / 256,
+                         colors[i].blue / 256);
+
+      for (ptr = strs[i]; *ptr; ptr++)
+        if (*ptr == ' ')
+          *ptr = '0';
+
+      ++i;
+    }
+
+  retval = g_strjoinv (":", strs);
+
+  g_strfreev (strs);
+
+  return retval;
+}
+
+/**
+ * mate_color_selection_set_change_palette_hook:
+ * @func: a function to call when the custom palette needs saving.
+ *
+ * Installs a global function to be called whenever the user tries to
+ * modify the palette in a color selection. This function should save
+ * the new palette contents, and update the GtkSettings property
+ * "gtk-color-palette" so all MateColorSelection widgets will be modified.
+ *
+ * Return value: the previous change palette hook (that was replaced).
+ *
+ * Deprecated: 2.4: This function does not work in multihead environments.
+ *     Use mate_color_selection_set_change_palette_with_screen_hook() instead.
+ *
+ **/
+MateColorSelectionChangePaletteFunc
+mate_color_selection_set_change_palette_hook (MateColorSelectionChangePaletteFunc func)
+{
+  MateColorSelectionChangePaletteFunc old;
+
+  old = noscreen_change_palette_hook;
+
+  noscreen_change_palette_hook = func;
+
+  return old;
+}
+
+/**
+ * mate_color_selection_set_change_palette_with_screen_hook:
+ * @func: a function to call when the custom palette needs saving.
+ *
+ * Installs a global function to be called whenever the user tries to
+ * modify the palette in a color selection. This function should save
+ * the new palette contents, and update the GtkSettings property
+ * "gtk-color-palette" so all MateColorSelection widgets will be modified.
+ *
+ * Return value: the previous change palette hook (that was replaced).
+ *
+ * Since: 1.9.1
+ **/
+MateColorSelectionChangePaletteWithScreenFunc
+mate_color_selection_set_change_palette_with_screen_hook (MateColorSelectionChangePaletteWithScreenFunc func)
+{
+  MateColorSelectionChangePaletteWithScreenFunc old;
+
+  old = change_palette_hook;
+
+  change_palette_hook = func;
+
+  return old;
+}
+
+static void
+make_control_relations (AtkObject *atk_obj,
+                        GtkWidget *widget)
+{
+  AtkObject *obj;
+
+  obj = gtk_widget_get_accessible (widget);
+  atk_object_add_relationship (atk_obj, ATK_RELATION_CONTROLLED_BY, obj);
+  atk_object_add_relationship (obj, ATK_RELATION_CONTROLLER_FOR, atk_obj);
+}
+
+static void
+make_all_relations (AtkObject *atk_obj,
+                    MateColorSelectionPrivate *priv)
+{
+  make_control_relations (atk_obj, priv->hue_spinbutton);
+  make_control_relations (atk_obj, priv->sat_spinbutton);
+  make_control_relations (atk_obj, priv->val_spinbutton);
+  make_control_relations (atk_obj, priv->red_spinbutton);
+  make_control_relations (atk_obj, priv->green_spinbutton);
+  make_control_relations (atk_obj, priv->blue_spinbutton);
+}
+
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/17.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/17.html new file mode 100644 index 0000000..0ca7cda --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/17.html @@ -0,0 +1,433 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+82
+83
+84
+85
+86
+87
+88
+89
+90
+91
+92
+93
+94
+95
+96
+97
+98
/* HSV color selector for GTK+
+ *
+ * Copyright (C) 1999 The Free Software Foundation
+ * Copyright (C) 2019-2021 MATE Developers
+ *
+ * Authors: Simon Budig <Simon.Budig@unix-ag.org> (original code)
+ *          Federico Mena-Quintero <federico@gimp.org> (cleanup for GTK+)
+ *          Jonathan Blandford <jrb@redhat.com> (cleanup for GTK+)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
+ * file for a list of people on the GTK+ Team.  See the ChangeLog
+ * files for a list of changes.  These files are distributed with
+ * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
+ *
+ * Modified to work internally in mate-desktop by Pablo Barciela 2019
+ */
+
+#ifndef __MATE_HSV_H__
+#define __MATE_HSV_H__
+
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+G_BEGIN_DECLS
+
+#define MATE_TYPE_HSV            (mate_hsv_get_type ())
+#define MATE_HSV(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), MATE_TYPE_HSV, MateHSV))
+#define MATE_HSV_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), MATE_TYPE_HSV, MateHSVClass))
+#define MATE_IS_HSV(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MATE_TYPE_HSV))
+#define MATE_IS_HSV_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MATE_TYPE_HSV))
+#define MATE_HSV_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), MATE_TYPE_HSV, MateHSVClass))
+
+typedef struct _MateHSV              MateHSV;
+typedef struct _MateHSVPrivate       MateHSVPrivate;
+typedef struct _MateHSVClass         MateHSVClass;
+
+struct _MateHSV
+{
+  GtkWidget parent_instance;
+
+  /*< private >*/
+  MateHSVPrivate *priv;
+};
+
+struct _MateHSVClass
+{
+  GtkWidgetClass parent_class;
+
+  /* Notification signals */
+  void (* changed) (MateHSV         *hsv);
+
+  /* Keybindings */
+  void (* move)    (MateHSV         *hsv,
+                    GtkDirectionType type);
+
+  /* Padding for future expansion */
+  void (*_gtk_reserved1) (void);
+  void (*_gtk_reserved2) (void);
+  void (*_gtk_reserved3) (void);
+  void (*_gtk_reserved4) (void);
+};
+
+GType      mate_hsv_get_type     (void) G_GNUC_CONST;
+GtkWidget* mate_hsv_new          (void);
+void       mate_hsv_set_color    (MateHSV    *hsv,
+				  double      h,
+				  double      s,
+				  double      v);
+void       mate_hsv_get_color    (MateHSV    *hsv,
+				  gdouble    *h,
+				  gdouble    *s,
+				  gdouble    *v);
+void       mate_hsv_set_metrics  (MateHSV    *hsv,
+				  gint        size,
+				  gint        ring_width);
+void       mate_hsv_get_metrics  (MateHSV    *hsv,
+				  gint       *size,
+				  gint       *ring_width);
+gboolean   mate_hsv_is_adjusting (MateHSV    *hsv);
+
+G_END_DECLS
+
+#endif /* __MATE_HSV_H__ */
+
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/18.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/18.html new file mode 100644 index 0000000..c24d213 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/18.html @@ -0,0 +1,725 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
/* GTK - The GIMP Toolkit
+ * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+/*
+ * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
+ * file for a list of people on the GTK+ Team.  See the ChangeLog
+ * files for a list of changes.  These files are distributed with
+ * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
+ */
+#include "config.h"<--- Include file: "config.h" not found.
+#include "private.h"
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n-lib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include "mate-colorsel.h"
+#include "mate-colorseldialog.h"
+
+enum {
+  PROP_0,
+  PROP_COLOR_SELECTION,
+  PROP_OK_BUTTON,
+  PROP_CANCEL_BUTTON,
+  PROP_HELP_BUTTON
+};
+
+/***************************/
+/* MateColorSelectionDialog */
+/***************************/
+
+static void mate_color_selection_dialog_buildable_interface_init     (GtkBuildableIface *iface);
+static GObject * mate_color_selection_dialog_buildable_get_internal_child (GtkBuildable *buildable,
+									  GtkBuilder   *builder,
+									  const gchar  *childname);
+
+G_DEFINE_TYPE_WITH_CODE (MateColorSelectionDialog, mate_color_selection_dialog,<--- There is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_CODE is a macro then please configure it.
+           GTK_TYPE_DIALOG,
+           G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
+                      mate_color_selection_dialog_buildable_interface_init))
+
+static GtkBuildableIface *parent_buildable_iface;
+
+static void
+mate_color_selection_dialog_get_property (GObject         *object,
+					 guint            prop_id,
+					 GValue          *value,
+					 GParamSpec      *pspec)
+{
+  MateColorSelectionDialog *colorsel;
+
+  colorsel = MATE_COLOR_SELECTION_DIALOG (object);
+
+  switch (prop_id)
+    {
+    case PROP_COLOR_SELECTION:
+      g_value_set_object (value, colorsel->colorsel);
+      break;
+    case PROP_OK_BUTTON:
+      g_value_set_object (value, colorsel->ok_button);
+      break;
+    case PROP_CANCEL_BUTTON:
+      g_value_set_object (value, colorsel->cancel_button);
+      break;
+    case PROP_HELP_BUTTON:
+      g_value_set_object (value, colorsel->help_button);
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+}
+
+static void
+mate_color_selection_dialog_class_init (MateColorSelectionDialogClass *klass)
+{
+  GObjectClass   *gobject_class = G_OBJECT_CLASS (klass);
+  gobject_class->get_property = mate_color_selection_dialog_get_property;
+
+  g_object_class_install_property (gobject_class,
+				   PROP_COLOR_SELECTION,
+				   g_param_spec_object ("color-selection",
+						     _("Color Selection"),
+						     _("The color selection embedded in the dialog."),
+						     GTK_TYPE_WIDGET,
+						     G_PARAM_READABLE));
+  g_object_class_install_property (gobject_class,
+				   PROP_OK_BUTTON,
+				   g_param_spec_object ("ok-button",
+						     _("OK Button"),
+						     _("The OK button of the dialog."),
+						     GTK_TYPE_WIDGET,
+						     G_PARAM_READABLE));
+  g_object_class_install_property (gobject_class,
+				   PROP_CANCEL_BUTTON,
+				   g_param_spec_object ("cancel-button",
+						     _("Cancel Button"),
+						     _("The cancel button of the dialog."),
+						     GTK_TYPE_WIDGET,
+						     G_PARAM_READABLE));
+  g_object_class_install_property (gobject_class,
+				   PROP_HELP_BUTTON,
+				   g_param_spec_object ("help-button",
+						     _("Help Button"),
+						     _("The help button of the dialog."),
+						     GTK_TYPE_WIDGET,
+						     G_PARAM_READABLE));
+}
+
+static GtkWidget*
+mate_add_dialog_button (GtkDialog      *dialog,
+                        const char     *label,
+                        const char     *icon,
+                        GtkResponseType response)
+{
+    GtkWidget *widget;
+    GtkWidget *image;
+
+    widget = gtk_button_new_with_mnemonic (label);
+    image = gtk_image_new_from_icon_name (icon, GTK_ICON_SIZE_BUTTON);
+    gtk_button_set_image (GTK_BUTTON (widget), image);
+    gtk_dialog_add_action_widget (dialog, widget, response);
+
+    return widget;
+}
+
+static void
+mate_color_selection_dialog_init (MateColorSelectionDialog *colorseldiag)
+{
+  GtkDialog *dialog = GTK_DIALOG (colorseldiag);
+
+  _mate_desktop_init_i18n ();
+
+  gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
+  gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (dialog)), 2); /* 2 * 5 + 2 = 12 */
+  gtk_container_set_border_width (GTK_CONTAINER (gtk_dialog_get_action_area (dialog)), 5);
+  gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_action_area (dialog)), 6);
+
+  colorseldiag->colorsel = mate_color_selection_new ();
+  gtk_container_set_border_width (GTK_CONTAINER (colorseldiag->colorsel), 5);
+  mate_color_selection_set_has_palette (MATE_COLOR_SELECTION(colorseldiag->colorsel), FALSE);
+  mate_color_selection_set_has_opacity_control (MATE_COLOR_SELECTION(colorseldiag->colorsel), FALSE);
+  gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (colorseldiag))), colorseldiag->colorsel);
+  gtk_widget_show (colorseldiag->colorsel);
+
+  colorseldiag->cancel_button = mate_add_dialog_button (GTK_DIALOG (colorseldiag),
+                                                        _("_Cancel"),
+                                                        "gtk-cancel",
+                                                        GTK_RESPONSE_CANCEL);
+
+  colorseldiag->ok_button = mate_add_dialog_button (GTK_DIALOG (colorseldiag),
+                                                    _("_OK"),
+                                                    "gtk-ok",
+                                                    GTK_RESPONSE_OK);
+
+  gtk_widget_set_can_default (colorseldiag->ok_button, TRUE);
+  gtk_widget_grab_default (colorseldiag->ok_button);
+
+  colorseldiag->help_button = mate_add_dialog_button (GTK_DIALOG (colorseldiag),
+                                                      _("Help"),
+                                                      "help-browser",
+                                                      GTK_RESPONSE_HELP);
+
+  gtk_widget_hide (colorseldiag->help_button);
+  gtk_widget_show (colorseldiag->cancel_button);
+  gtk_widget_show (colorseldiag->ok_button);
+
+  gtk_window_set_title (GTK_WINDOW (colorseldiag),
+                        _("Color Selection"));
+
+  //_gtk_dialog_set_ignore_separator (dialog, TRUE);
+}
+
+GtkWidget*
+mate_color_selection_dialog_new (const gchar *title)
+{
+  MateColorSelectionDialog *colorseldiag;
+
+  colorseldiag = g_object_new (MATE_TYPE_COLOR_SELECTION_DIALOG, NULL);
+
+  if (title)
+    gtk_window_set_title (GTK_WINDOW (colorseldiag), title);
+
+  gtk_window_set_resizable (GTK_WINDOW (colorseldiag), FALSE);
+
+  return GTK_WIDGET (colorseldiag);
+}
+
+/**
+ * mate_color_selection_dialog_get_color_selection:
+ * @colorsel: a #MateColorSelectionDialog
+ *
+ * Retrieves the #MateColorSelection widget embedded in the dialog.
+ *
+ * Returns: (transfer none): the embedded #MateColorSelection
+ *
+ * Since: 1.9.1
+ **/
+GtkWidget*
+mate_color_selection_dialog_get_color_selection (MateColorSelectionDialog *colorsel)
+{
+  g_return_val_if_fail (MATE_IS_COLOR_SELECTION_DIALOG (colorsel), NULL);
+
+  return colorsel->colorsel;
+}
+
+static void
+mate_color_selection_dialog_buildable_interface_init (GtkBuildableIface *iface)
+{
+  parent_buildable_iface = g_type_interface_peek_parent (iface);
+  iface->get_internal_child = mate_color_selection_dialog_buildable_get_internal_child;
+}
+
+static GObject *
+mate_color_selection_dialog_buildable_get_internal_child (GtkBuildable *buildable,
+							 GtkBuilder   *builder,
+							 const gchar  *childname)
+{
+    if (strcmp(childname, "ok_button") == 0)
+	return G_OBJECT (MATE_COLOR_SELECTION_DIALOG (buildable)->ok_button);
+    else if (strcmp(childname, "cancel_button") == 0)
+	return G_OBJECT (MATE_COLOR_SELECTION_DIALOG (buildable)->cancel_button);
+    else if (strcmp(childname, "help_button") == 0)
+	return G_OBJECT (MATE_COLOR_SELECTION_DIALOG(buildable)->help_button);
+    else if (strcmp(childname, "color_selection") == 0)
+	return G_OBJECT (MATE_COLOR_SELECTION_DIALOG(buildable)->colorsel);
+
+    return parent_buildable_iface->get_internal_child (buildable, builder, childname);
+}
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/19.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/19.html new file mode 100644 index 0000000..07d0a3b --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/19.html @@ -0,0 +1,533 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
/*
+ * mate-dconf.c: helper API for dconf
+ *
+ * Copyright (C) 2011 Novell, Inc.
+ * Copyright (C) 2013 Stefano Karapetsas
+ * Copyright (C) 2013-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ *
+ * Authors:
+ *  Vincent Untz <vuntz@gnome.org>
+ *  Stefano Karapetsas <stefano@karapetsas.com>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <dconf.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "mate-dconf.h"
+
+static DConfClient *
+mate_dconf_client_get (void)
+{
+    return dconf_client_new ();
+}
+
+/**
+ * mate_dconf_write_sync:
+ * @key: the key to write.
+ * @value: the value to write.
+ * @error: a variable to store the error, or NULL.
+ *
+ * Allow to write a value to dconf.
+ *
+ * Since: 1.7.1
+ */
+gboolean
+mate_dconf_write_sync (const gchar  *key,
+                       GVariant     *value,
+                       GError      **error)
+{
+    gboolean     ret;
+    DConfClient *client = mate_dconf_client_get ();
+
+    ret = dconf_client_write_sync (client, key, value, NULL, NULL, error);
+
+    g_object_unref (client);
+
+    return ret;
+}
+
+/**
+ * mate_dconf_recursive_reset:
+ * @dir: the dconf directory to reset.
+ * @error: a variable to store the error, or NULL.
+ *
+ * Allow to reset a dconf path.
+ *
+ * Since: 1.7.1
+ */
+gboolean
+mate_dconf_recursive_reset (const gchar  *dir,
+                            GError      **error)
+{
+    gboolean     ret;
+    DConfClient *client = mate_dconf_client_get ();
+
+    ret = dconf_client_write_sync (client, dir, NULL, NULL, NULL, error);
+
+    g_object_unref (client);
+
+    return ret;
+}
+
+/**
+ * mate_dconf_list_subdirs:
+ * @dir: the dconf directory.
+ * @remove_trailing_slash: whether to remove the trailing slash from
+ * paths.
+ *
+ * Returns the list of subdirectories of the given dconf directory.
+ *
+ * Return value: the list of subdirectories.
+ *
+ * Since: 1.7.1
+ */
+gchar **
+mate_dconf_list_subdirs (const gchar *dir,
+                         gboolean     remove_trailing_slash)
+{
+    GArray       *array;
+    gchar       **children;
+    int       len;
+    int       i;
+    DConfClient  *client = mate_dconf_client_get ();
+
+    array = g_array_new (TRUE, TRUE, sizeof (gchar *));
+
+    children = dconf_client_list (client, dir, &len);
+
+    g_object_unref (client);
+
+    for (i = 0; children[i] != NULL; i++) {
+        if (dconf_is_rel_dir (children[i], NULL)) {
+            char *val = g_strdup (children[i]);
+
+            if (remove_trailing_slash)
+                val[strlen (val) - 1] = '\0';
+
+            array = g_array_append_val (array, val);
+        }
+    }
+
+    g_strfreev (children);
+
+    return (gchar **) g_array_free (array, FALSE);
+}
+
+/**
+ * mate_dconf_sync:
+ *
+ * Ensure dconf daemon syncs the written values.
+ *
+ * Since: 1.7.1
+ */
+void mate_dconf_sync (void)
+{
+    DConfClient  *client = mate_dconf_client_get ();
+    dconf_client_sync (client);
+    g_object_unref (client);
+}
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/2.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/2.html new file mode 100644 index 0000000..6f99a45 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/2.html @@ -0,0 +1,393 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2005-2007 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "config.h"<--- Include file: "config.h" not found.
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdk/gdk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "gpm-common.h"
+
+/**
+ * gpm_help_display:
+ * @link_id: Subsection of mate-power-manager help section
+ **/
+void
+gpm_help_display (const gchar *link_id)
+{
+	GError *error = NULL;
+	gchar *uri;
+
+	if (link_id != NULL)
+		uri = g_strconcat ("help:mate-power-manager/", link_id, NULL);
+	else
+		uri = g_strdup ("help:mate-power-manager");
+
+	gtk_show_uri_on_window (NULL, uri, GDK_CURRENT_TIME, &error);
+
+	if (error != NULL) {
+		GtkWidget *d;
+		d = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+					    GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "%s", error->message);
+		gtk_dialog_run (GTK_DIALOG(d));
+		gtk_widget_destroy (d);
+		g_error_free (error);
+	}
+	g_free (uri);
+}
+
+/***************************************************************************
+ ***                          MAKE CHECK TESTS                           ***
+ ***************************************************************************/
+#ifdef EGG_TEST
+#include "egg-test.h"<--- Include file: "egg-test.h" not found.
+
+void
+gpm_common_test (gpointer data)
+{
+	EggTest *test = (EggTest *) data;
+	if (egg_test_start (test, "GpmCommon") == FALSE)
+		return;
+
+	egg_test_end (test);
+}
+
+#endif
+
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/20.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/20.html new file mode 100644 index 0000000..4379933 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/20.html @@ -0,0 +1,335 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
/*
+ * mate-dconf.h: helper API for dconf
+ *
+ * Copyright (C) 2011 Novell, Inc.
+ * Copyright (C) 2013 Stefano Karapetsas
+ * Copyright (C) 2013-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ *
+ * Authors:
+ *  Vincent Untz <vuntz@gnome.org>
+ *  Stefano Karapetsas <stefano@karapetsas.com>
+ */
+
+#ifndef __MATE_DCONF_H__
+#define __MATE_DCONF_H__
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+G_BEGIN_DECLS
+
+gboolean mate_dconf_write_sync (const gchar  *key,
+                                GVariant     *value,
+                                GError      **error);
+
+gboolean mate_dconf_recursive_reset (const gchar  *dir,
+                                     GError     **error);
+
+gchar **mate_dconf_list_subdirs (const gchar *dir,
+                                 gboolean     remove_trailing_slash);
+
+void mate_dconf_sync (void);
+
+G_END_DECLS
+
+#endif /* __MATE_DCONF_H__ */
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/21.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/21.html new file mode 100644 index 0000000..e1b4a38 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/21.html @@ -0,0 +1,8907 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
   1
+   2
+   3
+   4
+   5
+   6
+   7
+   8
+   9
+  10
+  11
+  12
+  13
+  14
+  15
+  16
+  17
+  18
+  19
+  20
+  21
+  22
+  23
+  24
+  25
+  26
+  27
+  28
+  29
+  30
+  31
+  32
+  33
+  34
+  35
+  36
+  37
+  38
+  39
+  40
+  41
+  42
+  43
+  44
+  45
+  46
+  47
+  48
+  49
+  50
+  51
+  52
+  53
+  54
+  55
+  56
+  57
+  58
+  59
+  60
+  61
+  62
+  63
+  64
+  65
+  66
+  67
+  68
+  69
+  70
+  71
+  72
+  73
+  74
+  75
+  76
+  77
+  78
+  79
+  80
+  81
+  82
+  83
+  84
+  85
+  86
+  87
+  88
+  89
+  90
+  91
+  92
+  93
+  94
+  95
+  96
+  97
+  98
+  99
+ 100
+ 101
+ 102
+ 103
+ 104
+ 105
+ 106
+ 107
+ 108
+ 109
+ 110
+ 111
+ 112
+ 113
+ 114
+ 115
+ 116
+ 117
+ 118
+ 119
+ 120
+ 121
+ 122
+ 123
+ 124
+ 125
+ 126
+ 127
+ 128
+ 129
+ 130
+ 131
+ 132
+ 133
+ 134
+ 135
+ 136
+ 137
+ 138
+ 139
+ 140
+ 141
+ 142
+ 143
+ 144
+ 145
+ 146
+ 147
+ 148
+ 149
+ 150
+ 151
+ 152
+ 153
+ 154
+ 155
+ 156
+ 157
+ 158
+ 159
+ 160
+ 161
+ 162
+ 163
+ 164
+ 165
+ 166
+ 167
+ 168
+ 169
+ 170
+ 171
+ 172
+ 173
+ 174
+ 175
+ 176
+ 177
+ 178
+ 179
+ 180
+ 181
+ 182
+ 183
+ 184
+ 185
+ 186
+ 187
+ 188
+ 189
+ 190
+ 191
+ 192
+ 193
+ 194
+ 195
+ 196
+ 197
+ 198
+ 199
+ 200
+ 201
+ 202
+ 203
+ 204
+ 205
+ 206
+ 207
+ 208
+ 209
+ 210
+ 211
+ 212
+ 213
+ 214
+ 215
+ 216
+ 217
+ 218
+ 219
+ 220
+ 221
+ 222
+ 223
+ 224
+ 225
+ 226
+ 227
+ 228
+ 229
+ 230
+ 231
+ 232
+ 233
+ 234
+ 235
+ 236
+ 237
+ 238
+ 239
+ 240
+ 241
+ 242
+ 243
+ 244
+ 245
+ 246
+ 247
+ 248
+ 249
+ 250
+ 251
+ 252
+ 253
+ 254
+ 255
+ 256
+ 257
+ 258
+ 259
+ 260
+ 261
+ 262
+ 263
+ 264
+ 265
+ 266
+ 267
+ 268
+ 269
+ 270
+ 271
+ 272
+ 273
+ 274
+ 275
+ 276
+ 277
+ 278
+ 279
+ 280
+ 281
+ 282
+ 283
+ 284
+ 285
+ 286
+ 287
+ 288
+ 289
+ 290
+ 291
+ 292
+ 293
+ 294
+ 295
+ 296
+ 297
+ 298
+ 299
+ 300
+ 301
+ 302
+ 303
+ 304
+ 305
+ 306
+ 307
+ 308
+ 309
+ 310
+ 311
+ 312
+ 313
+ 314
+ 315
+ 316
+ 317
+ 318
+ 319
+ 320
+ 321
+ 322
+ 323
+ 324
+ 325
+ 326
+ 327
+ 328
+ 329
+ 330
+ 331
+ 332
+ 333
+ 334
+ 335
+ 336
+ 337
+ 338
+ 339
+ 340
+ 341
+ 342
+ 343
+ 344
+ 345
+ 346
+ 347
+ 348
+ 349
+ 350
+ 351
+ 352
+ 353
+ 354
+ 355
+ 356
+ 357
+ 358
+ 359
+ 360
+ 361
+ 362
+ 363
+ 364
+ 365
+ 366
+ 367
+ 368
+ 369
+ 370
+ 371
+ 372
+ 373
+ 374
+ 375
+ 376
+ 377
+ 378
+ 379
+ 380
+ 381
+ 382
+ 383
+ 384
+ 385
+ 386
+ 387
+ 388
+ 389
+ 390
+ 391
+ 392
+ 393
+ 394
+ 395
+ 396
+ 397
+ 398
+ 399
+ 400
+ 401
+ 402
+ 403
+ 404
+ 405
+ 406
+ 407
+ 408
+ 409
+ 410
+ 411
+ 412
+ 413
+ 414
+ 415
+ 416
+ 417
+ 418
+ 419
+ 420
+ 421
+ 422
+ 423
+ 424
+ 425
+ 426
+ 427
+ 428
+ 429
+ 430
+ 431
+ 432
+ 433
+ 434
+ 435
+ 436
+ 437
+ 438
+ 439
+ 440
+ 441
+ 442
+ 443
+ 444
+ 445
+ 446
+ 447
+ 448
+ 449
+ 450
+ 451
+ 452
+ 453
+ 454
+ 455
+ 456
+ 457
+ 458
+ 459
+ 460
+ 461
+ 462
+ 463
+ 464
+ 465
+ 466
+ 467
+ 468
+ 469
+ 470
+ 471
+ 472
+ 473
+ 474
+ 475
+ 476
+ 477
+ 478
+ 479
+ 480
+ 481
+ 482
+ 483
+ 484
+ 485
+ 486
+ 487
+ 488
+ 489
+ 490
+ 491
+ 492
+ 493
+ 494
+ 495
+ 496
+ 497
+ 498
+ 499
+ 500
+ 501
+ 502
+ 503
+ 504
+ 505
+ 506
+ 507
+ 508
+ 509
+ 510
+ 511
+ 512
+ 513
+ 514
+ 515
+ 516
+ 517
+ 518
+ 519
+ 520
+ 521
+ 522
+ 523
+ 524
+ 525
+ 526
+ 527
+ 528
+ 529
+ 530
+ 531
+ 532
+ 533
+ 534
+ 535
+ 536
+ 537
+ 538
+ 539
+ 540
+ 541
+ 542
+ 543
+ 544
+ 545
+ 546
+ 547
+ 548
+ 549
+ 550
+ 551
+ 552
+ 553
+ 554
+ 555
+ 556
+ 557
+ 558
+ 559
+ 560
+ 561
+ 562
+ 563
+ 564
+ 565
+ 566
+ 567
+ 568
+ 569
+ 570
+ 571
+ 572
+ 573
+ 574
+ 575
+ 576
+ 577
+ 578
+ 579
+ 580
+ 581
+ 582
+ 583
+ 584
+ 585
+ 586
+ 587
+ 588
+ 589
+ 590
+ 591
+ 592
+ 593
+ 594
+ 595
+ 596
+ 597
+ 598
+ 599
+ 600
+ 601
+ 602
+ 603
+ 604
+ 605
+ 606
+ 607
+ 608
+ 609
+ 610
+ 611
+ 612
+ 613
+ 614
+ 615
+ 616
+ 617
+ 618
+ 619
+ 620
+ 621
+ 622
+ 623
+ 624
+ 625
+ 626
+ 627
+ 628
+ 629
+ 630
+ 631
+ 632
+ 633
+ 634
+ 635
+ 636
+ 637
+ 638
+ 639
+ 640
+ 641
+ 642
+ 643
+ 644
+ 645
+ 646
+ 647
+ 648
+ 649
+ 650
+ 651
+ 652
+ 653
+ 654
+ 655
+ 656
+ 657
+ 658
+ 659
+ 660
+ 661
+ 662
+ 663
+ 664
+ 665
+ 666
+ 667
+ 668
+ 669
+ 670
+ 671
+ 672
+ 673
+ 674
+ 675
+ 676
+ 677
+ 678
+ 679
+ 680
+ 681
+ 682
+ 683
+ 684
+ 685
+ 686
+ 687
+ 688
+ 689
+ 690
+ 691
+ 692
+ 693
+ 694
+ 695
+ 696
+ 697
+ 698
+ 699
+ 700
+ 701
+ 702
+ 703
+ 704
+ 705
+ 706
+ 707
+ 708
+ 709
+ 710
+ 711
+ 712
+ 713
+ 714
+ 715
+ 716
+ 717
+ 718
+ 719
+ 720
+ 721
+ 722
+ 723
+ 724
+ 725
+ 726
+ 727
+ 728
+ 729
+ 730
+ 731
+ 732
+ 733
+ 734
+ 735
+ 736
+ 737
+ 738
+ 739
+ 740
+ 741
+ 742
+ 743
+ 744
+ 745
+ 746
+ 747
+ 748
+ 749
+ 750
+ 751
+ 752
+ 753
+ 754
+ 755
+ 756
+ 757
+ 758
+ 759
+ 760
+ 761
+ 762
+ 763
+ 764
+ 765
+ 766
+ 767
+ 768
+ 769
+ 770
+ 771
+ 772
+ 773
+ 774
+ 775
+ 776
+ 777
+ 778
+ 779
+ 780
+ 781
+ 782
+ 783
+ 784
+ 785
+ 786
+ 787
+ 788
+ 789
+ 790
+ 791
+ 792
+ 793
+ 794
+ 795
+ 796
+ 797
+ 798
+ 799
+ 800
+ 801
+ 802
+ 803
+ 804
+ 805
+ 806
+ 807
+ 808
+ 809
+ 810
+ 811
+ 812
+ 813
+ 814
+ 815
+ 816
+ 817
+ 818
+ 819
+ 820
+ 821
+ 822
+ 823
+ 824
+ 825
+ 826
+ 827
+ 828
+ 829
+ 830
+ 831
+ 832
+ 833
+ 834
+ 835
+ 836
+ 837
+ 838
+ 839
+ 840
+ 841
+ 842
+ 843
+ 844
+ 845
+ 846
+ 847
+ 848
+ 849
+ 850
+ 851
+ 852
+ 853
+ 854
+ 855
+ 856
+ 857
+ 858
+ 859
+ 860
+ 861
+ 862
+ 863
+ 864
+ 865
+ 866
+ 867
+ 868
+ 869
+ 870
+ 871
+ 872
+ 873
+ 874
+ 875
+ 876
+ 877
+ 878
+ 879
+ 880
+ 881
+ 882
+ 883
+ 884
+ 885
+ 886
+ 887
+ 888
+ 889
+ 890
+ 891
+ 892
+ 893
+ 894
+ 895
+ 896
+ 897
+ 898
+ 899
+ 900
+ 901
+ 902
+ 903
+ 904
+ 905
+ 906
+ 907
+ 908
+ 909
+ 910
+ 911
+ 912
+ 913
+ 914
+ 915
+ 916
+ 917
+ 918
+ 919
+ 920
+ 921
+ 922
+ 923
+ 924
+ 925
+ 926
+ 927
+ 928
+ 929
+ 930
+ 931
+ 932
+ 933
+ 934
+ 935
+ 936
+ 937
+ 938
+ 939
+ 940
+ 941
+ 942
+ 943
+ 944
+ 945
+ 946
+ 947
+ 948
+ 949
+ 950
+ 951
+ 952
+ 953
+ 954
+ 955
+ 956
+ 957
+ 958
+ 959
+ 960
+ 961
+ 962
+ 963
+ 964
+ 965
+ 966
+ 967
+ 968
+ 969
+ 970
+ 971
+ 972
+ 973
+ 974
+ 975
+ 976
+ 977
+ 978
+ 979
+ 980
+ 981
+ 982
+ 983
+ 984
+ 985
+ 986
+ 987
+ 988
+ 989
+ 990
+ 991
+ 992
+ 993
+ 994
+ 995
+ 996
+ 997
+ 998
+ 999
+1000
+1001
+1002
+1003
+1004
+1005
+1006
+1007
+1008
+1009
+1010
+1011
+1012
+1013
+1014
+1015
+1016
+1017
+1018
+1019
+1020
+1021
+1022
+1023
+1024
+1025
+1026
+1027
+1028
+1029
+1030
+1031
+1032
+1033
+1034
+1035
+1036
+1037
+1038
+1039
+1040
+1041
+1042
+1043
+1044
+1045
+1046
+1047
+1048
+1049
+1050
+1051
+1052
+1053
+1054
+1055
+1056
+1057
+1058
+1059
+1060
+1061
+1062
+1063
+1064
+1065
+1066
+1067
+1068
+1069
+1070
+1071
+1072
+1073
+1074
+1075
+1076
+1077
+1078
+1079
+1080
+1081
+1082
+1083
+1084
+1085
+1086
+1087
+1088
+1089
+1090
+1091
+1092
+1093
+1094
+1095
+1096
+1097
+1098
+1099
+1100
+1101
+1102
+1103
+1104
+1105
+1106
+1107
+1108
+1109
+1110
+1111
+1112
+1113
+1114
+1115
+1116
+1117
+1118
+1119
+1120
+1121
+1122
+1123
+1124
+1125
+1126
+1127
+1128
+1129
+1130
+1131
+1132
+1133
+1134
+1135
+1136
+1137
+1138
+1139
+1140
+1141
+1142
+1143
+1144
+1145
+1146
+1147
+1148
+1149
+1150
+1151
+1152
+1153
+1154
+1155
+1156
+1157
+1158
+1159
+1160
+1161
+1162
+1163
+1164
+1165
+1166
+1167
+1168
+1169
+1170
+1171
+1172
+1173
+1174
+1175
+1176
+1177
+1178
+1179
+1180
+1181
+1182
+1183
+1184
+1185
+1186
+1187
+1188
+1189
+1190
+1191
+1192
+1193
+1194
+1195
+1196
+1197
+1198
+1199
+1200
+1201
+1202
+1203
+1204
+1205
+1206
+1207
+1208
+1209
+1210
+1211
+1212
+1213
+1214
+1215
+1216
+1217
+1218
+1219
+1220
+1221
+1222
+1223
+1224
+1225
+1226
+1227
+1228
+1229
+1230
+1231
+1232
+1233
+1234
+1235
+1236
+1237
+1238
+1239
+1240
+1241
+1242
+1243
+1244
+1245
+1246
+1247
+1248
+1249
+1250
+1251
+1252
+1253
+1254
+1255
+1256
+1257
+1258
+1259
+1260
+1261
+1262
+1263
+1264
+1265
+1266
+1267
+1268
+1269
+1270
+1271
+1272
+1273
+1274
+1275
+1276
+1277
+1278
+1279
+1280
+1281
+1282
+1283
+1284
+1285
+1286
+1287
+1288
+1289
+1290
+1291
+1292
+1293
+1294
+1295
+1296
+1297
+1298
+1299
+1300
+1301
+1302
+1303
+1304
+1305
+1306
+1307
+1308
+1309
+1310
+1311
+1312
+1313
+1314
+1315
+1316
+1317
+1318
+1319
+1320
+1321
+1322
+1323
+1324
+1325
+1326
+1327
+1328
+1329
+1330
+1331
+1332
+1333
+1334
+1335
+1336
+1337
+1338
+1339
+1340
+1341
+1342
+1343
+1344
+1345
+1346
+1347
+1348
+1349
+1350
+1351
+1352
+1353
+1354
+1355
+1356
+1357
+1358
+1359
+1360
+1361
+1362
+1363
+1364
+1365
+1366
+1367
+1368
+1369
+1370
+1371
+1372
+1373
+1374
+1375
+1376
+1377
+1378
+1379
+1380
+1381
+1382
+1383
+1384
+1385
+1386
+1387
+1388
+1389
+1390
+1391
+1392
+1393
+1394
+1395
+1396
+1397
+1398
+1399
+1400
+1401
+1402
+1403
+1404
+1405
+1406
+1407
+1408
+1409
+1410
+1411
+1412
+1413
+1414
+1415
+1416
+1417
+1418
+1419
+1420
+1421
+1422
+1423
+1424
+1425
+1426
+1427
+1428
+1429
+1430
+1431
+1432
+1433
+1434
+1435
+1436
+1437
+1438
+1439
+1440
+1441
+1442
+1443
+1444
+1445
+1446
+1447
+1448
+1449
+1450
+1451
+1452
+1453
+1454
+1455
+1456
+1457
+1458
+1459
+1460
+1461
+1462
+1463
+1464
+1465
+1466
+1467
+1468
+1469
+1470
+1471
+1472
+1473
+1474
+1475
+1476
+1477
+1478
+1479
+1480
+1481
+1482
+1483
+1484
+1485
+1486
+1487
+1488
+1489
+1490
+1491
+1492
+1493
+1494
+1495
+1496
+1497
+1498
+1499
+1500
+1501
+1502
+1503
+1504
+1505
+1506
+1507
+1508
+1509
+1510
+1511
+1512
+1513
+1514
+1515
+1516
+1517
+1518
+1519
+1520
+1521
+1522
+1523
+1524
+1525
+1526
+1527
+1528
+1529
+1530
+1531
+1532
+1533
+1534
+1535
+1536
+1537
+1538
+1539
+1540
+1541
+1542
+1543
+1544
+1545
+1546
+1547
+1548
+1549
+1550
+1551
+1552
+1553
+1554
+1555
+1556
+1557
+1558
+1559
+1560
+1561
+1562
+1563
+1564
+1565
+1566
+1567
+1568
+1569
+1570
+1571
+1572
+1573
+1574
+1575
+1576
+1577
+1578
+1579
+1580
+1581
+1582
+1583
+1584
+1585
+1586
+1587
+1588
+1589
+1590
+1591
+1592
+1593
+1594
+1595
+1596
+1597
+1598
+1599
+1600
+1601
+1602
+1603
+1604
+1605
+1606
+1607
+1608
+1609
+1610
+1611
+1612
+1613
+1614
+1615
+1616
+1617
+1618
+1619
+1620
+1621
+1622
+1623
+1624
+1625
+1626
+1627
+1628
+1629
+1630
+1631
+1632
+1633
+1634
+1635
+1636
+1637
+1638
+1639
+1640
+1641
+1642
+1643
+1644
+1645
+1646
+1647
+1648
+1649
+1650
+1651
+1652
+1653
+1654
+1655
+1656
+1657
+1658
+1659
+1660
+1661
+1662
+1663
+1664
+1665
+1666
+1667
+1668
+1669
+1670
+1671
+1672
+1673
+1674
+1675
+1676
+1677
+1678
+1679
+1680
+1681
+1682
+1683
+1684
+1685
+1686
+1687
+1688
+1689
+1690
+1691
+1692
+1693
+1694
+1695
+1696
+1697
+1698
+1699
+1700
+1701
+1702
+1703
+1704
+1705
+1706
+1707
+1708
+1709
+1710
+1711
+1712
+1713
+1714
+1715
+1716
+1717
+1718
+1719
+1720
+1721
+1722
+1723
+1724
+1725
+1726
+1727
+1728
+1729
+1730
+1731
+1732
+1733
+1734
+1735
+1736
+1737
+1738
+1739
+1740
+1741
+1742
+1743
+1744
+1745
+1746
+1747
+1748
+1749
+1750
+1751
+1752
+1753
+1754
+1755
+1756
+1757
+1758
+1759
+1760
+1761
+1762
+1763
+1764
+1765
+1766
+1767
+1768
+1769
+1770
+1771
+1772
+1773
+1774
+1775
+1776
+1777
+1778
+1779
+1780
+1781
+1782
+1783
+1784
+1785
+1786
+1787
+1788
+1789
+1790
+1791
+1792
+1793
+1794
+1795
+1796
+1797
+1798
+1799
+1800
+1801
+1802
+1803
+1804
+1805
+1806
+1807
+1808
+1809
+1810
+1811
+1812
+1813
+1814
+1815
+1816
+1817
+1818
+1819
+1820
+1821
+1822
+1823
+1824
+1825
+1826
+1827
+1828
+1829
+1830
+1831
+1832
+1833
+1834
+1835
+1836
+1837
+1838
+1839
+1840
+1841
+1842
+1843
+1844
+1845
+1846
+1847
+1848
+1849
+1850
+1851
+1852
+1853
+1854
+1855
+1856
+1857
+1858
+1859
+1860
+1861
+1862
+1863
+1864
+1865
+1866
+1867
+1868
+1869
+1870
+1871
+1872
+1873
+1874
+1875
+1876
+1877
+1878
+1879
+1880
+1881
+1882
+1883
+1884
+1885
+1886
+1887
+1888
+1889
+1890
+1891
+1892
+1893
+1894
+1895
+1896
+1897
+1898
+1899
+1900
+1901
+1902
+1903
+1904
+1905
+1906
+1907
+1908
+1909
+1910
+1911
+1912
+1913
+1914
+1915
+1916
+1917
+1918
+1919
+1920
+1921
+1922
+1923
+1924
+1925
+1926
+1927
+1928
+1929
+1930
+1931
+1932
+1933
+1934
+1935
+1936
+1937
+1938
+1939
+1940
+1941
+1942
+1943
+1944
+1945
+1946
+1947
+1948
+1949
+1950
+1951
+1952
+1953
+1954
+1955
+1956
+1957
+1958
+1959
+1960
+1961
+1962
+1963
+1964
+1965
+1966
+1967
+1968
+1969
+1970
+1971
+1972
+1973
+1974
+1975
+1976
+1977
+1978
+1979
+1980
+1981
+1982
+1983
+1984
+1985
+1986
+1987
+1988
+1989
+1990
+1991
+1992
+1993
+1994
+1995
+1996
+1997
+1998
+1999
+2000
+2001
+2002
+2003
+2004
+2005
+2006
+2007
+2008
+2009
+2010
+2011
+2012
+2013
+2014
+2015
+2016
+2017
+2018
+2019
+2020
+2021
+2022
+2023
+2024
+2025
+2026
+2027
+2028
+2029
+2030
+2031
+2032
+2033
+2034
+2035
+2036
+2037
+2038
+2039
+2040
+2041
+2042
+2043
+2044
+2045
+2046
+2047
+2048
+2049
+2050
+2051
+2052
+2053
+2054
+2055
+2056
+2057
+2058
+2059
+2060
+2061
+2062
+2063
+2064
+2065
+2066
+2067
+2068
+2069
+2070
+2071
+2072
+2073
+2074
+2075
+2076
+2077
+2078
+2079
+2080
+2081
+2082
+2083
+2084
+2085
+2086
+2087
+2088
+2089
+2090
+2091
+2092
+2093
+2094
+2095
+2096
+2097
+2098
+2099
+2100
+2101
+2102
+2103
+2104
+2105
+2106
+2107
+2108
+2109
+2110
+2111
+2112
+2113
+2114
+2115
+2116
+2117
+2118
+2119
+2120
+2121
+2122
+2123
+2124
+2125
+2126
+2127
+2128
+2129
+2130
+2131
+2132
+2133
+2134
+2135
+2136
+2137
+2138
+2139
+2140
+2141
+2142
+2143
+2144
+2145
+2146
+2147
+2148
+2149
+2150
+2151
+2152
+2153
+2154
+2155
+2156
+2157
+2158
+2159
+2160
+2161
+2162
+2163
+2164
+2165
+2166
+2167
+2168
+2169
+2170
+2171
+2172
+2173
+2174
+2175
+2176
+2177
+2178
+2179
+2180
+2181
+2182
+2183
+2184
+2185
+2186
+2187
+2188
+2189
+2190
+2191
+2192
+2193
+2194
+2195
+2196
+2197
+2198
+2199
+2200
+2201
+2202
+2203
+2204
+2205
+2206
+2207
+2208
+2209
+2210
+2211
+2212
+2213
+2214
+2215
+2216
+2217
+2218
+2219
+2220
+2221
+2222
+2223
+2224
+2225
+2226
+2227
+2228
+2229
+2230
+2231
+2232
+2233
+2234
+2235
+2236
+2237
+2238
+2239
+2240
+2241
+2242
+2243
+2244
+2245
+2246
+2247
+2248
+2249
+2250
+2251
+2252
+2253
+2254
+2255
+2256
+2257
+2258
+2259
+2260
+2261
+2262
+2263
+2264
+2265
+2266
+2267
+2268
+2269
+2270
+2271
+2272
+2273
+2274
+2275
+2276
+2277
+2278
+2279
+2280
+2281
+2282
+2283
+2284
+2285
+2286
+2287
+2288
+2289
+2290
+2291
+2292
+2293
+2294
+2295
+2296
+2297
+2298
+2299
+2300
+2301
+2302
+2303
+2304
+2305
+2306
+2307
+2308
+2309
+2310
+2311
+2312
+2313
+2314
+2315
+2316
+2317
+2318
+2319
+2320
+2321
+2322
+2323
+2324
+2325
+2326
+2327
+2328
+2329
+2330
+2331
+2332
+2333
+2334
+2335
+2336
+2337
+2338
+2339
+2340
+2341
+2342
+2343
+2344
+2345
+2346
+2347
+2348
+2349
+2350
+2351
+2352
+2353
+2354
+2355
+2356
+2357
+2358
+2359
+2360
+2361
+2362
+2363
+2364
+2365
+2366
+2367
+2368
+2369
+2370
+2371
+2372
+2373
+2374
+2375
+2376
+2377
+2378
+2379
+2380
+2381
+2382
+2383
+2384
+2385
+2386
+2387
+2388
+2389
+2390
+2391
+2392
+2393
+2394
+2395
+2396
+2397
+2398
+2399
+2400
+2401
+2402
+2403
+2404
+2405
+2406
+2407
+2408
+2409
+2410
+2411
+2412
+2413
+2414
+2415
+2416
+2417
+2418
+2419
+2420
+2421
+2422
+2423
+2424
+2425
+2426
+2427
+2428
+2429
+2430
+2431
+2432
+2433
+2434
+2435
+2436
+2437
+2438
+2439
+2440
+2441
+2442
+2443
+2444
+2445
+2446
+2447
+2448
+2449
+2450
+2451
+2452
+2453
+2454
+2455
+2456
+2457
+2458
+2459
+2460
+2461
+2462
+2463
+2464
+2465
+2466
+2467
+2468
+2469
+2470
+2471
+2472
+2473
+2474
+2475
+2476
+2477
+2478
+2479
+2480
+2481
+2482
+2483
+2484
+2485
+2486
+2487
+2488
+2489
+2490
+2491
+2492
+2493
+2494
+2495
+2496
+2497
+2498
+2499
+2500
+2501
+2502
+2503
+2504
+2505
+2506
+2507
+2508
+2509
+2510
+2511
+2512
+2513
+2514
+2515
+2516
+2517
+2518
+2519
+2520
+2521
+2522
+2523
+2524
+2525
+2526
+2527
+2528
+2529
+2530
+2531
+2532
+2533
+2534
+2535
+2536
+2537
+2538
+2539
+2540
+2541
+2542
+2543
+2544
+2545
+2546
+2547
+2548
+2549
+2550
+2551
+2552
+2553
+2554
+2555
+2556
+2557
+2558
+2559
+2560
+2561
+2562
+2563
+2564
+2565
+2566
+2567
+2568
+2569
+2570
+2571
+2572
+2573
+2574
+2575
+2576
+2577
+2578
+2579
+2580
+2581
+2582
+2583
+2584
+2585
+2586
+2587
+2588
+2589
+2590
+2591
+2592
+2593
+2594
+2595
+2596
+2597
+2598
+2599
+2600
+2601
+2602
+2603
+2604
+2605
+2606
+2607
+2608
+2609
+2610
+2611
+2612
+2613
+2614
+2615
+2616
+2617
+2618
+2619
+2620
+2621
+2622
+2623
+2624
+2625
+2626
+2627
+2628
+2629
+2630
+2631
+2632
+2633
+2634
+2635
+2636
+2637
+2638
+2639
+2640
+2641
+2642
+2643
+2644
+2645
+2646
+2647
+2648
+2649
+2650
+2651
+2652
+2653
+2654
+2655
+2656
+2657
+2658
+2659
+2660
+2661
+2662
+2663
+2664
+2665
+2666
+2667
+2668
+2669
+2670
+2671
+2672
+2673
+2674
+2675
+2676
+2677
+2678
+2679
+2680
+2681
+2682
+2683
+2684
+2685
+2686
+2687
+2688
+2689
+2690
+2691
+2692
+2693
+2694
+2695
+2696
+2697
+2698
+2699
+2700
+2701
+2702
+2703
+2704
+2705
+2706
+2707
+2708
+2709
+2710
+2711
+2712
+2713
+2714
+2715
+2716
+2717
+2718
+2719
+2720
+2721
+2722
+2723
+2724
+2725
+2726
+2727
+2728
+2729
+2730
+2731
+2732
+2733
+2734
+2735
+2736
+2737
+2738
+2739
+2740
+2741
+2742
+2743
+2744
+2745
+2746
+2747
+2748
+2749
+2750
+2751
+2752
+2753
+2754
+2755
+2756
+2757
+2758
+2759
+2760
+2761
+2762
+2763
+2764
+2765
+2766
+2767
+2768
+2769
+2770
+2771
+2772
+2773
+2774
+2775
+2776
+2777
+2778
+2779
+2780
+2781
+2782
+2783
+2784
+2785
+2786
+2787
+2788
+2789
+2790
+2791
+2792
+2793
+2794
+2795
+2796
+2797
+2798
+2799
+2800
+2801
+2802
+2803
+2804
+2805
+2806
+2807
+2808
+2809
+2810
+2811
+2812
+2813
+2814
+2815
+2816
+2817
+2818
+2819
+2820
+2821
+2822
+2823
+2824
+2825
+2826
+2827
+2828
+2829
+2830
+2831
+2832
+2833
+2834
+2835
+2836
+2837
+2838
+2839
+2840
+2841
+2842
+2843
+2844
+2845
+2846
+2847
+2848
+2849
+2850
+2851
+2852
+2853
+2854
+2855
+2856
+2857
+2858
+2859
+2860
+2861
+2862
+2863
+2864
+2865
+2866
+2867
+2868
+2869
+2870
+2871
+2872
+2873
+2874
+2875
+2876
+2877
+2878
+2879
+2880
+2881
+2882
+2883
+2884
+2885
+2886
+2887
+2888
+2889
+2890
+2891
+2892
+2893
+2894
+2895
+2896
+2897
+2898
+2899
+2900
+2901
+2902
+2903
+2904
+2905
+2906
+2907
+2908
+2909
+2910
+2911
+2912
+2913
+2914
+2915
+2916
+2917
+2918
+2919
+2920
+2921
+2922
+2923
+2924
+2925
+2926
+2927
+2928
+2929
+2930
+2931
+2932
+2933
+2934
+2935
+2936
+2937
+2938
+2939
+2940
+2941
+2942
+2943
+2944
+2945
+2946
+2947
+2948
+2949
+2950
+2951
+2952
+2953
+2954
+2955
+2956
+2957
+2958
+2959
+2960
+2961
+2962
+2963
+2964
+2965
+2966
+2967
+2968
+2969
+2970
+2971
+2972
+2973
+2974
+2975
+2976
+2977
+2978
+2979
+2980
+2981
+2982
+2983
+2984
+2985
+2986
+2987
+2988
+2989
+2990
+2991
+2992
+2993
+2994
+2995
+2996
+2997
+2998
+2999
+3000
+3001
+3002
+3003
+3004
+3005
+3006
+3007
+3008
+3009
+3010
+3011
+3012
+3013
+3014
+3015
+3016
+3017
+3018
+3019
+3020
+3021
+3022
+3023
+3024
+3025
+3026
+3027
+3028
+3029
+3030
+3031
+3032
+3033
+3034
+3035
+3036
+3037
+3038
+3039
+3040
+3041
+3042
+3043
+3044
+3045
+3046
+3047
+3048
+3049
+3050
+3051
+3052
+3053
+3054
+3055
+3056
+3057
+3058
+3059
+3060
+3061
+3062
+3063
+3064
+3065
+3066
+3067
+3068
+3069
+3070
+3071
+3072
+3073
+3074
+3075
+3076
+3077
+3078
+3079
+3080
+3081
+3082
+3083
+3084
+3085
+3086
+3087
+3088
+3089
+3090
+3091
+3092
+3093
+3094
+3095
+3096
+3097
+3098
+3099
+3100
+3101
+3102
+3103
+3104
+3105
+3106
+3107
+3108
+3109
+3110
+3111
+3112
+3113
+3114
+3115
+3116
+3117
+3118
+3119
+3120
+3121
+3122
+3123
+3124
+3125
+3126
+3127
+3128
+3129
+3130
+3131
+3132
+3133
+3134
+3135
+3136
+3137
+3138
+3139
+3140
+3141
+3142
+3143
+3144
+3145
+3146
+3147
+3148
+3149
+3150
+3151
+3152
+3153
+3154
+3155
+3156
+3157
+3158
+3159
+3160
+3161
+3162
+3163
+3164
+3165
+3166
+3167
+3168
+3169
+3170
+3171
+3172
+3173
+3174
+3175
+3176
+3177
+3178
+3179
+3180
+3181
+3182
+3183
+3184
+3185
+3186
+3187
+3188
+3189
+3190
+3191
+3192
+3193
+3194
+3195
+3196
+3197
+3198
+3199
+3200
+3201
+3202
+3203
+3204
+3205
+3206
+3207
+3208
+3209
+3210
+3211
+3212
+3213
+3214
+3215
+3216
+3217
+3218
+3219
+3220
+3221
+3222
+3223
+3224
+3225
+3226
+3227
+3228
+3229
+3230
+3231
+3232
+3233
+3234
+3235
+3236
+3237
+3238
+3239
+3240
+3241
+3242
+3243
+3244
+3245
+3246
+3247
+3248
+3249
+3250
+3251
+3252
+3253
+3254
+3255
+3256
+3257
+3258
+3259
+3260
+3261
+3262
+3263
+3264
+3265
+3266
+3267
+3268
+3269
+3270
+3271
+3272
+3273
+3274
+3275
+3276
+3277
+3278
+3279
+3280
+3281
+3282
+3283
+3284
+3285
+3286
+3287
+3288
+3289
+3290
+3291
+3292
+3293
+3294
+3295
+3296
+3297
+3298
+3299
+3300
+3301
+3302
+3303
+3304
+3305
+3306
+3307
+3308
+3309
+3310
+3311
+3312
+3313
+3314
+3315
+3316
+3317
+3318
+3319
+3320
+3321
+3322
+3323
+3324
+3325
+3326
+3327
+3328
+3329
+3330
+3331
+3332
+3333
+3334
+3335
+3336
+3337
+3338
+3339
+3340
+3341
+3342
+3343
+3344
+3345
+3346
+3347
+3348
+3349
+3350
+3351
+3352
+3353
+3354
+3355
+3356
+3357
+3358
+3359
+3360
+3361
+3362
+3363
+3364
+3365
+3366
+3367
+3368
+3369
+3370
+3371
+3372
+3373
+3374
+3375
+3376
+3377
+3378
+3379
+3380
+3381
+3382
+3383
+3384
+3385
+3386
+3387
+3388
+3389
+3390
+3391
+3392
+3393
+3394
+3395
+3396
+3397
+3398
+3399
+3400
+3401
+3402
+3403
+3404
+3405
+3406
+3407
+3408
+3409
+3410
+3411
+3412
+3413
+3414
+3415
+3416
+3417
+3418
+3419
+3420
+3421
+3422
+3423
+3424
+3425
+3426
+3427
+3428
+3429
+3430
+3431
+3432
+3433
+3434
+3435
+3436
+3437
+3438
+3439
+3440
+3441
+3442
+3443
+3444
+3445
+3446
+3447
+3448
+3449
+3450
+3451
+3452
+3453
+3454
+3455
+3456
+3457
+3458
+3459
+3460
+3461
+3462
+3463
+3464
+3465
+3466
+3467
+3468
+3469
+3470
+3471
+3472
+3473
+3474
+3475
+3476
+3477
+3478
+3479
+3480
+3481
+3482
+3483
+3484
+3485
+3486
+3487
+3488
+3489
+3490
+3491
+3492
+3493
+3494
+3495
+3496
+3497
+3498
+3499
+3500
+3501
+3502
+3503
+3504
+3505
+3506
+3507
+3508
+3509
+3510
+3511
+3512
+3513
+3514
+3515
+3516
+3517
+3518
+3519
+3520
+3521
+3522
+3523
+3524
+3525
+3526
+3527
+3528
+3529
+3530
+3531
+3532
+3533
+3534
+3535
+3536
+3537
+3538
+3539
+3540
+3541
+3542
+3543
+3544
+3545
+3546
+3547
+3548
+3549
+3550
+3551
+3552
+3553
+3554
+3555
+3556
+3557
+3558
+3559
+3560
+3561
+3562
+3563
+3564
+3565
+3566
+3567
+3568
+3569
+3570
+3571
+3572
+3573
+3574
+3575
+3576
+3577
+3578
+3579
+3580
+3581
+3582
+3583
+3584
+3585
+3586
+3587
+3588
+3589
+3590
+3591
+3592
+3593
+3594
+3595
+3596
+3597
+3598
+3599
+3600
+3601
+3602
+3603
+3604
+3605
+3606
+3607
+3608
+3609
+3610
+3611
+3612
+3613
+3614
+3615
+3616
+3617
+3618
+3619
+3620
+3621
+3622
+3623
+3624
+3625
+3626
+3627
+3628
+3629
+3630
+3631
+3632
+3633
+3634
+3635
+3636
+3637
+3638
+3639
+3640
+3641
+3642
+3643
+3644
+3645
+3646
+3647
+3648
+3649
+3650
+3651
+3652
+3653
+3654
+3655
+3656
+3657
+3658
+3659
+3660
+3661
+3662
+3663
+3664
+3665
+3666
+3667
+3668
+3669
+3670
+3671
+3672
+3673
+3674
+3675
+3676
+3677
+3678
+3679
+3680
+3681
+3682
+3683
+3684
+3685
+3686
+3687
+3688
+3689
+3690
+3691
+3692
+3693
+3694
+3695
+3696
+3697
+3698
+3699
+3700
+3701
+3702
+3703
+3704
+3705
+3706
+3707
+3708
+3709
+3710
+3711
+3712
+3713
+3714
+3715
+3716
+3717
+3718
+3719
+3720
+3721
+3722
+3723
+3724
+3725
+3726
+3727
+3728
+3729
+3730
+3731
+3732
+3733
+3734
+3735
+3736
+3737
+3738
+3739
+3740
+3741
+3742
+3743
+3744
+3745
+3746
+3747
+3748
+3749
+3750
+3751
+3752
+3753
+3754
+3755
+3756
+3757
+3758
+3759
+3760
+3761
+3762
+3763
+3764
+3765
+3766
+3767
+3768
+3769
+3770
+3771
+3772
+3773
+3774
+3775
+3776
+3777
+3778
+3779
+3780
+3781
+3782
+3783
+3784
+3785
+3786
+3787
+3788
+3789
+3790
+3791
+3792
+3793
+3794
+3795
+3796
+3797
+3798
+3799
+3800
+3801
+3802
+3803
+3804
+3805
+3806
+3807
+3808
+3809
+3810
+3811
+3812
+3813
+3814
+3815
+3816
+3817
+3818
+3819
+3820
+3821
+3822
+3823
+3824
+3825
+3826
+3827
+3828
+3829
+3830
+3831
+3832
+3833
+3834
+3835
+3836
+3837
+3838
+3839
+3840
+3841
+3842
+3843
+3844
+3845
+3846
+3847
+3848
+3849
+3850
+3851
+3852
+3853
+3854
+3855
+3856
+3857
+3858
+3859
+3860
+3861
+3862
+3863
+3864
+3865
+3866
+3867
+3868
+3869
+3870
+3871
+3872
+3873
+3874
+3875
+3876
+3877
+3878
+3879
+3880
+3881
+3882
+3883
+3884
+3885
+3886
/* -*- Mode: C; c-set-style: linux indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/* mate-desktop-item.c - MATE Desktop File Representation
+
+   Copyright (C) 1999, 2000 Red Hat Inc.
+   Copyright (C) 2001 Sid Vicious
+   All rights reserved.
+
+   This file is part of the Mate Library.
+
+   Developed by Elliot Lee <sopwith@redhat.com> and Sid Vicious
+
+   The Mate Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The Mate Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the Mate Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
+/*
+  @NOTATION@
+ */
+
+#include "config.h"<--- Include file: "config.h" not found.
+
+#include <limits.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <ctype.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/types.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <dirent.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <time.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n-lib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <locale.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <gio/gio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#ifdef HAVE_STARTUP_NOTIFICATION
+#define SN_API_NOT_YET_FROZEN
+#include <libsn/sn.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdk/gdk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdk/gdkx.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+
+#define MATE_DESKTOP_USE_UNSTABLE_API
+#undef MATE_DISABLE_DEPRECATED
+#include <mate-desktop-item.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <mate-desktop-utils.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "private.h"
+
+struct _MateDesktopItem {
+	int refcount;
+
+	/* all languages used */
+	GList *languages;
+
+	MateDesktopItemType type;
+
+	/* `modified' means that the ditem has been
+	 * modified since the last save. */
+	gboolean modified;
+
+	/* Keys of the main section only */
+	GList *keys;
+
+	GList *sections;
+
+	/* This includes ALL keys, including
+	 * other sections, separated by '/' */
+	GHashTable *main_hash;
+
+	char *location;
+
+	gint64 mtime;
+
+	guint32 launch_time;
+};
+
+/* If mtime is set to this, set_location won't update mtime,
+ * this is to be used internally only. */
+#define DONT_UPDATE_MTIME ((gint64)-2)
+
+typedef struct {
+	char *name;
+	GList *keys;
+} Section;
+
+typedef enum {
+	ENCODING_UNKNOWN,
+	ENCODING_UTF8,
+	ENCODING_LEGACY_MIXED
+} Encoding;
+
+/*
+ * IO reading utils, that look like the libc buffered io stuff
+ */
+
+#define READ_BUF_SIZE (32 * 1024)
+
+typedef struct {
+	GFile *file;
+	GFileInputStream *stream;
+	char *uri;
+	char *buf;
+	gboolean buf_needs_free;
+	gboolean past_first_read;
+	gboolean eof;
+	guint64 size;
+	gsize pos;
+} ReadBuf;
+
+static MateDesktopItem *ditem_load (ReadBuf           *rb,
+				     gboolean           no_translations,
+				     GError           **error);
+static gboolean          ditem_save (MateDesktopItem  *item,
+				     const char        *uri,
+				     GError           **error);
+
+static void mate_desktop_item_set_location_gfile (MateDesktopItem *item,
+						   GFile            *file);
+
+static MateDesktopItem *mate_desktop_item_new_from_gfile (GFile *file,
+							    MateDesktopItemLoadFlags flags,
+							    GError **error);
+
+static int
+readbuf_getc (ReadBuf *rb)
+{
+	if (rb->eof)
+		return EOF;
+
+	if (rb->size == 0 ||
+	    rb->pos == rb->size) {
+		gssize bytes_read;
+
+		if (rb->stream == NULL)
+			bytes_read = 0;
+		else
+			bytes_read = g_input_stream_read (G_INPUT_STREAM (rb->stream),
+							  rb->buf,
+							  READ_BUF_SIZE,
+							  NULL, NULL);
+
+		/* FIXME: handle errors other than EOF */
+		if (bytes_read <= 0) {
+			rb->eof = TRUE;
+			return EOF;
+		}
+
+		if (rb->size != 0)
+			rb->past_first_read = TRUE;
+		rb->size = bytes_read;
+		rb->pos = 0;
+
+	}
+
+	return (guchar) rb->buf[rb->pos++];
+}
+
+/* Note, does not include the trailing \n */
+static char *
+readbuf_gets (char *buf, gsize bufsize, ReadBuf *rb)
+{
+	int c;
+	gsize pos;
+
+	g_return_val_if_fail (buf != NULL, NULL);
+	g_return_val_if_fail (rb != NULL, NULL);
+
+	pos = 0;
+	buf[0] = '\0';
+
+	do {
+		c = readbuf_getc (rb);
+		if (c == EOF || c == '\n')
+			break;
+		buf[pos++] = c;
+	} while (pos < bufsize-1);
+
+	if (c == EOF && pos == 0)
+		return NULL;
+
+	buf[pos++] = '\0';
+
+	return buf;
+}
+
+static ReadBuf *
+readbuf_open (GFile *file, GError **error)
+{
+	GError *local_error;
+	GFileInputStream *stream;
+	char *uri;
+	ReadBuf *rb;
+
+	g_return_val_if_fail (file != NULL, NULL);
+
+	uri = g_file_get_uri (file);
+	local_error = NULL;
+	stream = g_file_read (file, NULL, &local_error);
+
+	if (stream == NULL) {
+		g_set_error (error,
+			     /* FIXME: better errors */
+			     MATE_DESKTOP_ITEM_ERROR,
+			     MATE_DESKTOP_ITEM_ERROR_CANNOT_OPEN,
+			     _("Error reading file '%s': %s"),
+			     uri, local_error->message);
+		g_error_free (local_error);
+		g_free (uri);
+		return NULL;
+	}
+
+	rb = g_new0 (ReadBuf, 1);
+	rb->stream = stream;
+	rb->file = g_file_dup (file);
+	rb->uri = uri;
+	rb->buf = g_malloc (READ_BUF_SIZE);
+	rb->buf_needs_free = TRUE;
+	/* rb->past_first_read = FALSE; */
+	/* rb->eof = FALSE; */
+	/* rb->size = 0; */
+	/* rb->pos = 0; */
+
+	return rb;
+}
+
+static ReadBuf *
+readbuf_new_from_string (const char *uri, const char *string, gssize length)
+{
+	ReadBuf *rb;
+
+	g_return_val_if_fail (string != NULL, NULL);
+	g_return_val_if_fail (length >= 0, NULL);
+
+	rb = g_new0 (ReadBuf, 1);
+	/* rb->file = NULL; */
+	/* rb->stream = NULL; */
+	rb->uri = g_strdup (uri);
+	rb->buf = (char *) string;
+	/* rb->buf_needs_free = FALSE; */
+	/* rb->past_first_read = FALSE; */
+	/* rb->eof = FALSE; */
+	rb->size = length;
+	/* rb->pos = 0; */
+
+	return rb;
+}
+
+static gboolean
+readbuf_rewind (ReadBuf *rb, GError **error)
+{
+	GError *local_error;
+
+	rb->eof = FALSE;
+	rb->pos = 0;
+
+	if (!rb->past_first_read)
+		return TRUE;
+
+	rb->size = 0;
+
+	if (g_seekable_seek (G_SEEKABLE (rb->stream),
+			     0, G_SEEK_SET, NULL, NULL))
+		return TRUE;
+
+	g_object_unref (rb->stream);
+	local_error = NULL;
+	rb->stream = g_file_read (rb->file, NULL, &local_error);
+
+	if (rb->stream == NULL) {
+		g_set_error (
+			error, MATE_DESKTOP_ITEM_ERROR,
+			MATE_DESKTOP_ITEM_ERROR_CANNOT_OPEN,
+			_("Error rewinding file '%s': %s"),
+			rb->uri, local_error->message);
+		g_error_free (local_error);
+
+		return FALSE;
+	}
+
+	return TRUE;
+}
+
+static void
+readbuf_close (ReadBuf *rb)
+{
+	if (rb->stream != NULL)
+		g_object_unref (rb->stream);
+	if (rb->file != NULL)
+		g_object_unref (rb->file);
+	g_free (rb->uri);
+	if (rb->buf_needs_free)
+		g_free (rb->buf);
+	g_free (rb);
+}
+
+static MateDesktopItemType
+type_from_string (const char *type)
+{
+	if (!type)
+		return MATE_DESKTOP_ITEM_TYPE_NULL;
+
+	switch (type [0]) {
+	case 'A':
+		if (!strcmp (type, "Application"))
+			return MATE_DESKTOP_ITEM_TYPE_APPLICATION;
+		break;
+	case 'L':
+		if (!strcmp (type, "Link"))
+			return MATE_DESKTOP_ITEM_TYPE_LINK;
+		break;
+	case 'F':
+		if (!strcmp (type, "FSDevice"))
+			return MATE_DESKTOP_ITEM_TYPE_FSDEVICE;
+		break;
+	case 'M':
+		if (!strcmp (type, "MimeType"))
+			return MATE_DESKTOP_ITEM_TYPE_MIME_TYPE;
+		break;
+	case 'D':
+		if (!strcmp (type, "Directory"))
+			return MATE_DESKTOP_ITEM_TYPE_DIRECTORY;
+		break;
+	case 'S':
+		if (!strcmp (type, "Service"))
+			return MATE_DESKTOP_ITEM_TYPE_SERVICE;
+
+		else if (!strcmp (type, "ServiceType"))
+			return MATE_DESKTOP_ITEM_TYPE_SERVICE_TYPE;
+		break;
+	default:
+		break;
+	}
+
+	return MATE_DESKTOP_ITEM_TYPE_OTHER;
+}
+
+/**
+ * mate_desktop_item_new:
+ *
+ * Creates a MateDesktopItem object. The reference count on the returned value is set to '1'.
+ *
+ * Returns: The new MateDesktopItem
+ */
+MateDesktopItem *
+mate_desktop_item_new (void)
+{
+	MateDesktopItem *retval;
+
+	_mate_desktop_init_i18n ();
+
+	retval = g_new0 (MateDesktopItem, 1);
+
+	retval->refcount++;
+
+	retval->main_hash = g_hash_table_new_full (g_str_hash, g_str_equal,
+						   (GDestroyNotify) g_free,
+						   (GDestroyNotify) g_free);
+
+	/* These are guaranteed to be set */
+	mate_desktop_item_set_string (retval,
+				       MATE_DESKTOP_ITEM_NAME,
+				       /* Translators: the "name" mentioned
+					* here is the name of an application or
+					* a document */
+				       _("No name"));
+	mate_desktop_item_set_string (retval,
+				       MATE_DESKTOP_ITEM_ENCODING,
+				       "UTF-8");
+	mate_desktop_item_set_string (retval,
+				       MATE_DESKTOP_ITEM_VERSION,
+				       "1.0");
+
+	retval->launch_time = 0;
+
+	return retval;
+}
+
+static Section *
+dup_section (Section *sec)
+{
+	GList *li;
+	Section *retval = g_new0 (Section, 1);
+
+	retval->name = g_strdup (sec->name);
+
+	retval->keys = g_list_copy (sec->keys);
+	for (li = retval->keys; li != NULL; li = li->next)
+		li->data = g_strdup (li->data);
+
+	return retval;
+}
+
+static void
+copy_string_hash (gpointer key, gpointer value, gpointer user_data)
+{
+	GHashTable *copy = user_data;
+	g_hash_table_replace (copy,
+			      g_strdup (key),
+			      g_strdup (value));
+}
+
+/**
+ * mate_desktop_item_copy:
+ * @item: The item to be copied
+ *
+ * Creates a copy of a MateDesktopItem.  The new copy has a refcount of 1.
+ * Note: Section stack is NOT copied.
+ *
+ * Returns: The new copy
+ */
+MateDesktopItem *
+mate_desktop_item_copy (const MateDesktopItem *item)
+{
+	GList *li;
+	MateDesktopItem *retval;
+
+	g_return_val_if_fail (item != NULL, NULL);
+	g_return_val_if_fail (item->refcount > 0, NULL);
+
+	retval = mate_desktop_item_new ();
+
+	retval->type = item->type;
+	retval->modified = item->modified;
+	retval->location = g_strdup (item->location);
+	retval->mtime = item->mtime;
+	retval->launch_time = item->launch_time;
+
+	/* Languages */
+	retval->languages = g_list_copy (item->languages);
+	for (li = retval->languages; li != NULL; li = li->next)
+		li->data = g_strdup (li->data);
+
+	/* Keys */
+	retval->keys = g_list_copy (item->keys);
+	for (li = retval->keys; li != NULL; li = li->next)
+		li->data = g_strdup (li->data);
+
+	/* Sections */
+	retval->sections = g_list_copy (item->sections);
+	for (li = retval->sections; li != NULL; li = li->next)
+		li->data = dup_section (li->data);
+
+	retval->main_hash = g_hash_table_new_full (g_str_hash, g_str_equal,
+						   (GDestroyNotify) g_free,
+						   (GDestroyNotify) g_free);
+
+	g_hash_table_foreach (item->main_hash,
+			      copy_string_hash,
+			      retval->main_hash);
+
+	return retval;
+}
+
+static void
+read_sort_order (MateDesktopItem *item, GFile *dir)
+{
+	GFile *child;
+	char buf[BUFSIZ];
+	GString *str;
+	ReadBuf *rb;
+
+	child = g_file_get_child (dir, ".order");
+
+	rb = readbuf_open (child, NULL);
+	g_object_unref (child);
+
+	if (rb == NULL)
+		return;
+
+	str = NULL;
+	while (readbuf_gets (buf, sizeof (buf), rb) != NULL) {
+		if (str == NULL)
+			str = g_string_new (buf);
+		else
+			g_string_append (str, buf);
+		g_string_append_c (str, ';');
+	}
+	readbuf_close (rb);
+	if (str != NULL) {
+		mate_desktop_item_set_string (item, MATE_DESKTOP_ITEM_SORT_ORDER,
+					       str->str);
+		g_string_free (str, TRUE);
+	}
+}
+
+static MateDesktopItem *
+make_fake_directory (GFile *dir)
+{
+	MateDesktopItem *item;
+	GFile *child;
+
+	item = mate_desktop_item_new ();
+	mate_desktop_item_set_entry_type (item,
+					   MATE_DESKTOP_ITEM_TYPE_DIRECTORY);
+
+	item->mtime = DONT_UPDATE_MTIME; /* it doesn't exist, we know that */
+	child = g_file_get_child (dir, ".directory");
+	mate_desktop_item_set_location_gfile (item, child);
+	item->mtime = 0;
+	g_object_unref (child);
+
+	read_sort_order (item, dir);
+
+	return item;
+}
+
+/**
+ * mate_desktop_item_new_from_file:
+ * @file: The filename or directory path to load the MateDesktopItem from
+ * @flags: Flags to influence the loading process
+ *
+ * This function loads 'file' and turns it into a MateDesktopItem.
+ *
+ * Returns: The newly loaded item.
+ */
+MateDesktopItem *
+mate_desktop_item_new_from_file (const char *file,
+				  MateDesktopItemLoadFlags flags,
+				  GError **error)
+{
+	MateDesktopItem *retval;
+	GFile *gfile;
+
+	g_return_val_if_fail (file != NULL, NULL);
+
+	gfile = g_file_new_for_path (file);
+	retval = mate_desktop_item_new_from_gfile (gfile, flags, error);
+	g_object_unref (gfile);
+
+	return retval;
+}
+
+/**
+ * mate_desktop_item_new_from_uri:
+ * @uri: URI to load the MateDesktopItem from
+ * @flags: Flags to influence the loading process
+ *
+ * This function loads 'uri' and turns it into a MateDesktopItem.
+ *
+ * Returns: The newly loaded item.
+ */
+MateDesktopItem *
+mate_desktop_item_new_from_uri (const char *uri,
+				 MateDesktopItemLoadFlags flags,
+				 GError **error)
+{
+	MateDesktopItem *retval;
+	GFile *file;
+
+	g_return_val_if_fail (uri != NULL, NULL);
+
+	file = g_file_new_for_uri (uri);
+	retval = mate_desktop_item_new_from_gfile (file, flags, error);
+	g_object_unref (file);
+
+	return retval;
+}
+
+static MateDesktopItem *
+mate_desktop_item_new_from_gfile (GFile *file,
+				   MateDesktopItemLoadFlags flags,
+				   GError **error)
+{
+	MateDesktopItem *retval;
+	GFile *subfn;
+	GFileInfo *info;
+	GFileType type;
+	GFile *parent;
+	gint64 mtime = 0;
+	ReadBuf *rb;
+
+	g_return_val_if_fail (file != NULL, NULL);
+
+	info = g_file_query_info (file,
+			          G_FILE_ATTRIBUTE_STANDARD_TYPE","G_FILE_ATTRIBUTE_TIME_MODIFIED,
+				  G_FILE_QUERY_INFO_NONE, NULL, error);
+	if (info == NULL)
+		return NULL;
+
+	type = g_file_info_get_file_type (info);
+
+	if (type != G_FILE_TYPE_REGULAR && type != G_FILE_TYPE_DIRECTORY) {
+		char *uri;
+
+		uri = g_file_get_uri (file);
+		g_set_error (error,
+			     /* FIXME: better errors */
+			     MATE_DESKTOP_ITEM_ERROR,
+			     MATE_DESKTOP_ITEM_ERROR_INVALID_TYPE,
+			     _("File '%s' is not a regular file or directory."),
+			     uri);
+
+		g_free (uri);
+		g_object_unref (info);
+
+		return NULL;
+	}
+
+	mtime = g_file_info_get_attribute_uint64 (info,
+						  G_FILE_ATTRIBUTE_TIME_MODIFIED);
+
+	g_object_unref (info);
+
+	if (type == G_FILE_TYPE_DIRECTORY) {
+		GFile *child;
+		GFileInfo *child_info;
+
+		child = g_file_get_child (file, ".directory");
+		child_info = g_file_query_info (child,
+						G_FILE_ATTRIBUTE_TIME_MODIFIED,
+						G_FILE_QUERY_INFO_NONE,
+						NULL, NULL);
+
+		if (child_info == NULL) {
+			g_object_unref (child);
+
+			if (flags & MATE_DESKTOP_ITEM_LOAD_ONLY_IF_EXISTS) {
+				return NULL;
+			} else {
+				return make_fake_directory (file);
+			}
+		}
+
+		mtime = g_file_info_get_attribute_uint64 (child_info,
+							  G_FILE_ATTRIBUTE_TIME_MODIFIED);
+		g_object_unref (child_info);
+
+		subfn = child;
+	} else {
+		subfn = g_file_dup (file);
+	}
+
+	rb = readbuf_open (subfn, error);
+
+	if (rb == NULL) {
+		g_object_unref (subfn);
+		return NULL;
+	}
+
+	retval = ditem_load (rb,
+			     (flags & MATE_DESKTOP_ITEM_LOAD_NO_TRANSLATIONS) != 0,
+			     error);
+
+	if (retval == NULL) {
+		g_object_unref (subfn);
+		return NULL;
+	}
+
+	if (flags & MATE_DESKTOP_ITEM_LOAD_ONLY_IF_EXISTS &&
+	    ! mate_desktop_item_exists (retval)) {
+		mate_desktop_item_unref (retval);
+		g_object_unref (subfn);
+		return NULL;
+	}
+
+	retval->mtime = DONT_UPDATE_MTIME;
+	mate_desktop_item_set_location_gfile (retval, subfn);
+	retval->mtime = mtime;
+
+	parent = g_file_get_parent (file);
+	if (parent != NULL) {
+		read_sort_order (retval, parent);
+		g_object_unref (parent);
+	}
+
+	g_object_unref (subfn);
+
+	return retval;
+}
+
+/**
+ * mate_desktop_item_new_from_string:
+ * @string: string to load the MateDesktopItem from
+ * @length: length of string, or -1 to use strlen
+ * @flags: Flags to influence the loading process
+ * @error: place to put errors
+ *
+ * This function turns the contents of the string into a MateDesktopItem.
+ *
+ * Returns: The newly loaded item.
+ */
+MateDesktopItem *
+mate_desktop_item_new_from_string (const char *uri,
+				    const char *string,
+				    gssize length,
+				    MateDesktopItemLoadFlags flags,
+				    GError **error)
+{
+	MateDesktopItem *retval;
+	ReadBuf *rb;
+
+	g_return_val_if_fail (string != NULL, NULL);
+	g_return_val_if_fail (length >= -1, NULL);
+
+	if (length == -1) {
+		length = strlen (string);
+	}
+
+	rb = readbuf_new_from_string (uri, string, length);
+
+	retval = ditem_load (rb,
+			     (flags & MATE_DESKTOP_ITEM_LOAD_NO_TRANSLATIONS) != 0,
+			     error);
+
+	if (retval == NULL) {
+		return NULL;
+	}
+
+	/* FIXME: Sort order? */
+
+	return retval;
+}
+
+static char *
+lookup_desktop_file_in_data_dir (const char *desktop_file,
+                                 const char *data_dir)
+{
+	char *path;
+
+	path = g_build_filename (data_dir, "applications", desktop_file, NULL);
+	if (!g_file_test (path, G_FILE_TEST_EXISTS)) {
+		g_free (path);
+		return NULL;
+	}
+	return path;
+}
+
+static char *
+file_from_basename (const char *basename)
+{
+	const char * const *system_data_dirs;
+	const char         *user_data_dir;
+	char               *retval;
+	int                 i;
+
+	user_data_dir = g_get_user_data_dir ();
+	system_data_dirs = g_get_system_data_dirs ();
+
+	if ((retval = lookup_desktop_file_in_data_dir (basename, user_data_dir))) {
+		return retval;
+	}
+	for (i = 0; system_data_dirs[i]; i++) {
+		if ((retval = lookup_desktop_file_in_data_dir (basename, system_data_dirs[i]))) {
+			return retval;
+		}
+	}
+	return NULL;
+}
+
+/**
+ * mate_desktop_item_new_from_basename:
+ * @basename: The basename of the MateDesktopItem to load.
+ * @flags: Flags to influence the loading process
+ *
+ * This function loads 'basename' from a system data directory and
+ * returns its MateDesktopItem.
+ *
+ * Returns: The newly loaded item.
+ */
+MateDesktopItem *
+mate_desktop_item_new_from_basename (const char *basename,
+                                      MateDesktopItemLoadFlags flags,
+                                      GError **error)
+{
+	MateDesktopItem *retval;
+	char *file;
+
+	g_return_val_if_fail (basename != NULL, NULL);
+
+	if (!(file = file_from_basename (basename))) {
+		g_set_error (error,
+			     MATE_DESKTOP_ITEM_ERROR,
+			     MATE_DESKTOP_ITEM_ERROR_CANNOT_OPEN,
+			     _("Cannot find file '%s'"),
+			     basename);
+		return NULL;
+	}
+
+	retval = mate_desktop_item_new_from_file (file, flags, error);
+	g_free (file);
+
+	return retval;
+}
+
+/**
+ * mate_desktop_item_save:
+ * @item: A desktop item
+ * @under: A new uri (location) for this #MateDesktopItem
+ * @force: Save even if it wasn't modified
+ * @error: #GError return
+ *
+ * Writes the specified item to disk.  If the 'under' is NULL, the original
+ * location is used.  It sets the location of this entry to point to the
+ * new location.
+ *
+ * Returns: boolean. %TRUE if the file was saved, %FALSE otherwise
+ */
+gboolean
+mate_desktop_item_save (MateDesktopItem *item,
+			 const char *under,
+			 gboolean force,
+			 GError **error)
+{
+	const char *uri;
+
+	if (under == NULL &&
+	    ! force &&
+	    ! item->modified)
+		return TRUE;
+
+	if (under == NULL)
+		uri = item->location;
+	else
+		uri = under;
+
+	if (uri == NULL) {
+		g_set_error (error,
+			     MATE_DESKTOP_ITEM_ERROR,
+			     MATE_DESKTOP_ITEM_ERROR_NO_FILENAME,
+			     _("No filename to save to"));
+		return FALSE;
+	}
+
+	if ( ! ditem_save (item, uri, error))
+		return FALSE;
+
+	item->modified = FALSE;
+	item->mtime = g_get_real_time () / G_USEC_PER_SEC;
+
+	return TRUE;
+}
+
+/**
+ * mate_desktop_item_ref:
+ * @item: A desktop item
+ *
+ * Description: Increases the reference count of the specified item.
+ *
+ * Returns: the newly referenced @item
+ */
+MateDesktopItem *
+mate_desktop_item_ref (MateDesktopItem *item)
+{
+	g_return_val_if_fail (item != NULL, NULL);
+
+	item->refcount++;
+
+	return item;
+}
+
+static void
+free_section (gpointer data)
+{
+	Section *section = data;
+
+	g_free (section->name);
+	section->name = NULL;
+
+	g_list_free_full (section->keys, g_free);
+	section->keys = NULL;
+
+	g_free (section);
+}
+
+/**
+ * mate_desktop_item_unref:
+ * @item: A desktop item
+ *
+ * Decreases the reference count of the specified item, and destroys the item if there are no more references left.
+ */
+void
+mate_desktop_item_unref (MateDesktopItem *item)
+{
+	g_return_if_fail (item != NULL);
+	g_return_if_fail (item->refcount > 0);
+
+	item->refcount--;
+
+	if(item->refcount != 0)
+		return;
+
+	g_list_free_full (item->languages, g_free);
+	item->languages = NULL;
+
+	g_list_free_full (item->keys, g_free);
+	item->keys = NULL;
+
+	g_list_free_full (item->sections, (GDestroyNotify) free_section);
+	item->sections = NULL;
+
+	g_hash_table_destroy (item->main_hash);
+	item->main_hash = NULL;
+
+	g_free (item->location);
+	item->location = NULL;
+
+	g_free (item);
+}
+
+static Section *
+find_section (MateDesktopItem *item, const char *section)
+{
+	GList *li;<--- Variable 'li' can be declared as pointer to const
+	Section *sec;
+
+	if (section == NULL)
+		return NULL;
+	if (strcmp (section, "Desktop Entry") == 0)
+		return NULL;
+
+	for (li = item->sections; li != NULL; li = li->next) {
+		sec = li->data;
+		if (strcmp (sec->name, section) == 0)
+			return sec;
+	}
+
+	sec = g_new0 (Section, 1);
+	sec->name = g_strdup (section);
+	sec->keys = NULL;
+
+	item->sections = g_list_append (item->sections, sec);
+
+	/* Don't mark the item modified, this is just an empty section,
+	 * it won't be saved even */
+
+	return sec;
+}
+
+static Section *
+section_from_key (MateDesktopItem *item, const char *key)
+{
+	char *p;<--- Variable 'p' can be declared as pointer to const
+	char *name;
+	Section *sec;
+
+	if (key == NULL)
+		return NULL;
+
+	p = strchr (key, '/');
+	if (p == NULL)
+		return NULL;
+
+	name = g_strndup (key, p - key);
+
+	sec = find_section (item, name);
+
+	g_free (name);
+
+	return sec;
+}
+
+static const char *
+key_basename (const char *key)
+{
+	char *p = strrchr (key, '/');
+	if (p != NULL)
+		return p+1;
+	else
+		return key;
+}
+
+static const char *
+lookup (const MateDesktopItem *item, const char *key)
+{
+	return g_hash_table_lookup (item->main_hash, key);
+}
+
+static const char *
+lookup_locale (const MateDesktopItem *item, const char *key, const char *locale)
+{
+	if (locale == NULL ||
+	    strcmp (locale, "C") == 0) {
+		return lookup (item, key);
+	} else {
+		const char *ret;
+		char *full = g_strdup_printf ("%s[%s]", key, locale);
+		ret = lookup (item, full);
+		g_free (full);
+		return ret;
+	}
+}
+
+static const char *
+lookup_best_locale (const MateDesktopItem *item, const char *key)
+{
+	const char * const *langs_pointer;
+	int                 i;
+
+	langs_pointer = g_get_language_names ();
+	for (i = 0; langs_pointer[i] != NULL; i++) {
+		const char *ret = NULL;
+
+		ret = lookup_locale (item, key, langs_pointer[i]);
+		if (ret != NULL)
+			return ret;
+	}
+
+	return NULL;
+}
+
+static void
+set (MateDesktopItem *item, const char *key, const char *value)
+{
+	Section *sec = section_from_key (item, key);
+
+	if (sec != NULL) {
+		if (value != NULL) {
+			if (g_hash_table_lookup (item->main_hash, key) == NULL)
+				sec->keys = g_list_append
+					(sec->keys,
+					 g_strdup (key_basename (key)));
+
+			g_hash_table_replace (item->main_hash,
+					      g_strdup (key),
+					      g_strdup (value));
+		} else {
+			GList *list = g_list_find_custom
+				(sec->keys, key_basename (key),
+				 (GCompareFunc)strcmp);
+			if (list != NULL) {
+				g_free (list->data);
+				sec->keys =
+					g_list_delete_link (sec->keys, list);
+			}
+			g_hash_table_remove (item->main_hash, key);
+		}
+	} else {
+		if (value != NULL) {
+			if (g_hash_table_lookup (item->main_hash, key) == NULL)
+				item->keys = g_list_append (item->keys,
+							    g_strdup (key));
+
+			g_hash_table_replace (item->main_hash,
+					      g_strdup (key),
+					      g_strdup (value));
+		} else {
+			GList *list = g_list_find_custom
+				(item->keys, key, (GCompareFunc)strcmp);
+			if (list != NULL) {
+				g_free (list->data);
+				item->keys =
+					g_list_delete_link (item->keys, list);
+			}
+			g_hash_table_remove (item->main_hash, key);
+		}
+	}
+	item->modified = TRUE;
+}
+
+static void
+set_locale (MateDesktopItem *item, const char *key,
+	    const char *locale, const char *value)
+{
+	if (locale == NULL ||
+	    strcmp (locale, "C") == 0) {
+		set (item, key, value);
+	} else {
+		char *full = g_strdup_printf ("%s[%s]", key, locale);
+		set (item, full, value);
+		g_free (full);
+
+		/* add the locale to the list of languages if it wasn't there
+		 * before */
+		if (g_list_find_custom (item->languages, locale,
+					(GCompareFunc)strcmp) == NULL)
+			item->languages = g_list_prepend (item->languages,
+							  g_strdup (locale));
+	}
+}
+
+static char **
+list_to_vector (GSList *list)
+{
+	int len = g_slist_length (list);
+	char **argv;
+	int i;
+	GSList *li;
+
+	argv = g_new0 (char *, len+1);
+
+	for (i = 0, li = list;
+	     li != NULL;
+	     li = li->next, i++) {
+		argv[i] = g_strdup (li->data);
+	}
+	argv[i] = NULL;
+
+	return argv;
+}
+
+static GSList *
+make_args (GList *files)
+{
+	GSList *list = NULL;
+	GList *li;
+
+	for (li = files; li != NULL; li = li->next) {
+		GFile *gfile;
+		const char *file = li->data;
+		if (file == NULL)
+			continue;
+		gfile = g_file_new_for_uri (file);
+		list = g_slist_prepend (list, gfile);
+	}
+
+	return g_slist_reverse (list);
+}
+
+static void
+free_args (GSList *list)
+{
+	GSList *li;
+
+	for (li = list; li != NULL; li = li->next) {
+		g_object_unref (G_FILE (li->data));
+		li->data = NULL;
+	}
+	g_slist_free (list);
+}
+
+static char *
+escape_single_quotes (const char *s,
+		      gboolean in_single_quotes,
+		      gboolean in_double_quotes)
+{
+	const char *p;
+	GString *gs;
+	const char *pre = "";
+	const char *post = "";
+
+	if ( ! in_single_quotes && ! in_double_quotes) {
+		pre = "'";
+		post = "'";
+	} else if ( ! in_single_quotes && in_double_quotes) {
+		pre = "\"'";
+		post = "'\"";
+	}
+
+	if (strchr (s, '\'') == NULL) {
+		return g_strconcat (pre, s, post, NULL);
+	}
+
+	gs = g_string_new (pre);
+
+	for (p = s; *p != '\0'; p++) {
+		if (*p == '\'')
+			g_string_append (gs, "'\\''");
+		else
+			g_string_append_c (gs, *p);
+	}
+
+	g_string_append (gs, post);
+
+	return g_string_free (gs, FALSE);
+}
+
+typedef enum {
+	URI_TO_STRING,
+	URI_TO_LOCAL_PATH,
+	URI_TO_LOCAL_DIRNAME,
+	URI_TO_LOCAL_BASENAME
+} ConversionType;
+
+static char *
+convert_uri (GFile          *file,
+	     ConversionType  conversion)
+{
+	char *retval = NULL;
+
+	switch (conversion) {
+	case URI_TO_STRING:
+		retval = g_file_get_uri (file);
+		break;
+	case URI_TO_LOCAL_PATH:
+		retval = g_file_get_path (file);
+		break;
+	case URI_TO_LOCAL_DIRNAME:
+		{
+			char *local_path;
+
+			local_path = g_file_get_path (file);
+			retval = g_path_get_dirname (local_path);
+			g_free (local_path);
+		}
+		break;
+	case URI_TO_LOCAL_BASENAME:
+		retval = g_file_get_basename (file);
+		break;
+	default:
+		g_assert_not_reached ();
+	}
+
+	return retval;
+}
+
+typedef enum {
+	ADDED_NONE = 0,
+	ADDED_SINGLE,
+	ADDED_ALL
+} AddedStatus;
+
+static AddedStatus
+append_all_converted (GString        *str,
+		      ConversionType  conversion,
+		      GSList         *args,
+		      gboolean        in_single_quotes,
+		      gboolean        in_double_quotes,
+		      AddedStatus     added_status)
+{
+	GSList *l;
+
+	for (l = args; l; l = l->next) {
+		char *converted;
+		char *escaped;
+
+		if (!(converted = convert_uri (l->data, conversion)))
+			continue;
+
+		g_string_append (str, " ");
+
+		escaped = escape_single_quotes (converted,
+						in_single_quotes,
+						in_double_quotes);
+		g_string_append (str, escaped);
+
+		g_free (escaped);
+		g_free (converted);
+	}
+
+	return ADDED_ALL;
+}
+
+static AddedStatus
+append_first_converted (GString         *str,
+			ConversionType   conversion,
+			GSList         **arg_ptr,
+			gboolean         in_single_quotes,
+			gboolean         in_double_quotes,
+			AddedStatus      added_status)
+{
+	GSList *l;
+	char   *converted = NULL;
+	char   *escaped;
+
+	for (l = *arg_ptr; l; l = l->next) {
+		if ((converted = convert_uri (l->data, conversion)))
+			break;
+
+		*arg_ptr = l->next;
+	}
+
+	if (!converted)
+		return added_status;
+
+	escaped = escape_single_quotes (converted, in_single_quotes, in_double_quotes);
+	g_string_append (str, escaped);
+	g_free (escaped);
+	g_free (converted);
+
+	return added_status != ADDED_ALL ? ADDED_SINGLE : added_status;
+}
+
+static gboolean
+do_percent_subst (const MateDesktopItem  *item,
+		  const char              *arg,
+		  GString                 *str,
+		  gboolean                 in_single_quotes,
+		  gboolean                 in_double_quotes,
+		  GSList                  *args,
+		  GSList                 **arg_ptr,
+		  AddedStatus             *added_status)
+{
+	char *esc;
+	const char *cs;
+
+	if (arg[0] != '%' || arg[1] == '\0') {
+		return FALSE;
+	}
+
+	switch (arg[1]) {
+	case '%':
+		g_string_append_c (str, '%');
+		break;
+	case 'U':
+		*added_status = append_all_converted (str,
+						      URI_TO_STRING,
+						      args,
+						      in_single_quotes,
+						      in_double_quotes,
+						      *added_status);
+		break;
+	case 'F':
+		*added_status = append_all_converted (str,
+						      URI_TO_LOCAL_PATH,
+						      args,
+						      in_single_quotes,
+						      in_double_quotes,
+						      *added_status);
+		break;
+	case 'N':
+		*added_status = append_all_converted (str,
+						      URI_TO_LOCAL_BASENAME,
+						      args,
+						      in_single_quotes,
+						      in_double_quotes,
+						      *added_status);
+		break;
+	case 'D':
+		*added_status = append_all_converted (str,
+						      URI_TO_LOCAL_DIRNAME,
+						      args,
+						      in_single_quotes,
+						      in_double_quotes,
+						      *added_status);
+		break;
+	case 'f':
+		*added_status = append_first_converted (str,
+							URI_TO_LOCAL_PATH,
+							arg_ptr,
+							in_single_quotes,
+							in_double_quotes,
+							*added_status);
+		break;
+	case 'u':
+		*added_status = append_first_converted (str,
+							URI_TO_STRING,
+							arg_ptr,
+							in_single_quotes,
+							in_double_quotes,
+							*added_status);
+		break;
+	case 'd':
+		*added_status = append_first_converted (str,
+							URI_TO_LOCAL_DIRNAME,
+							arg_ptr,
+							in_single_quotes,
+							in_double_quotes,
+							*added_status);
+		break;
+	case 'n':
+		*added_status = append_first_converted (str,
+							URI_TO_LOCAL_BASENAME,
+							arg_ptr,
+							in_single_quotes,
+							in_double_quotes,
+							*added_status);
+		break;
+	case 'm':
+		/* Note: v0.9.4 of the spec says this is deprecated
+		 * and replace with --miniicon iconname */
+		cs = mate_desktop_item_get_string (item, MATE_DESKTOP_ITEM_MINI_ICON);
+		if (cs != NULL) {
+			g_string_append (str, "--miniicon=");
+			esc = escape_single_quotes (cs, in_single_quotes, in_double_quotes);
+			g_string_append (str, esc);
+		}
+		break;
+	case 'i':
+		/* Note: v0.9.4 of the spec says replace with --icon iconname */
+		cs = mate_desktop_item_get_string (item, MATE_DESKTOP_ITEM_ICON);
+		if (cs != NULL) {
+			g_string_append (str, "--icon=");
+			esc = escape_single_quotes (cs, in_single_quotes, in_double_quotes);
+			g_string_append (str, esc);
+		}
+		break;
+	case 'c':
+		cs = mate_desktop_item_get_localestring (item, MATE_DESKTOP_ITEM_NAME);
+		if (cs != NULL) {
+			esc = escape_single_quotes (cs, in_single_quotes, in_double_quotes);
+			g_string_append (str, esc);
+			g_free (esc);
+		}
+		break;
+	case 'k':
+		if (item->location != NULL) {
+			esc = escape_single_quotes (item->location, in_single_quotes, in_double_quotes);
+			g_string_append (str, esc);
+			g_free (esc);
+		}
+		break;
+	case 'v':
+		cs = mate_desktop_item_get_localestring (item, MATE_DESKTOP_ITEM_DEV);
+		if (cs != NULL) {
+			esc = escape_single_quotes (cs, in_single_quotes, in_double_quotes);
+			g_string_append (str, esc);
+			g_free (esc);
+		}
+		break;
+	default:
+		/* Maintain special characters - e.g. "%20" */
+		if (g_ascii_isdigit (arg [1]))
+			g_string_append_c (str, '%');
+		return FALSE;
+	}
+
+	return TRUE;
+}
+
+static char *
+expand_string (const MateDesktopItem  *item,
+	       const char              *s,
+	       GSList                  *args,
+	       GSList                 **arg_ptr,
+	       AddedStatus             *added_status)
+{
+	const char *p;
+	gboolean escape = FALSE;
+	gboolean single_quot = FALSE;
+	gboolean double_quot = FALSE;
+	GString *gs = g_string_new (NULL);
+
+	for (p = s; *p != '\0'; p++) {
+		if (escape) {
+			escape = FALSE;
+			g_string_append_c (gs, *p);
+		} else if (*p == '\\') {
+			if ( ! single_quot)
+				escape = TRUE;
+			g_string_append_c (gs, *p);
+		} else if (*p == '\'') {
+			g_string_append_c (gs, *p);
+			if ( ! single_quot && ! double_quot) {
+				single_quot = TRUE;
+			} else if (single_quot) {
+				single_quot = FALSE;
+			}
+		} else if (*p == '"') {
+			g_string_append_c (gs, *p);
+			if ( ! single_quot && ! double_quot) {
+				double_quot = TRUE;
+			} else if (double_quot) {
+				double_quot = FALSE;
+			}
+		} else if (*p == '%') {
+			if (do_percent_subst (item, p, gs,
+					      single_quot, double_quot,
+					      args, arg_ptr,
+					      added_status)) {
+				p++;
+			}
+		} else {
+			g_string_append_c (gs, *p);
+		}
+	}
+	return g_string_free (gs, FALSE);
+}
+
+#ifdef HAVE_STARTUP_NOTIFICATION
+static void
+sn_error_trap_push (SnDisplay *display,
+		    Display   *xdisplay)
+{
+	GdkDisplay *gdkdisplay;
+
+	gdkdisplay = gdk_display_get_default ();
+	gdk_x11_display_error_trap_push (gdkdisplay);
+}
+
+static void
+sn_error_trap_pop (SnDisplay *display,
+		   Display   *xdisplay)
+{
+	GdkDisplay *gdkdisplay;
+
+	gdkdisplay = gdk_display_get_default ();
+	gdk_x11_display_error_trap_pop_ignored (gdkdisplay);
+}
+
+static char **
+make_spawn_environment_for_sn_context (SnLauncherContext *sn_context,
+				       char             **envp)
+{
+	char **retval;
+	char **freeme;
+	int    i, j;
+	int    desktop_startup_id_len;
+
+	retval = freeme = NULL;
+
+	if (envp == NULL) {
+		envp = freeme = g_listenv ();
+		for (i = 0; envp[i]; i++) {
+			char *name = envp[i];
+
+			envp[i] = g_strjoin ("=", name, g_getenv (name), NULL);
+			g_free (name);
+		}
+	} else {
+		for (i = 0; envp[i]; i++)
+			;
+	}
+
+	retval = g_new (char *, i + 2);
+
+	desktop_startup_id_len = strlen ("DESKTOP_STARTUP_ID");
+
+	for (i = 0, j = 0; envp[i]; i++) {
+		if (strncmp (envp[i], "DESKTOP_STARTUP_ID", desktop_startup_id_len) != 0) {
+			retval[j] = g_strdup (envp[i]);
+			++j;
+	        }
+	}
+
+	retval[j] = g_strdup_printf ("DESKTOP_STARTUP_ID=%s",
+				     sn_launcher_context_get_startup_id (sn_context));
+	++j;
+	retval[j] = NULL;
+
+	g_strfreev (freeme);
+
+	return retval;
+}
+
+/* This should be fairly long, as it's confusing to users if a startup
+ * ends when it shouldn't (it appears that the startup failed, and
+ * they have to relaunch the app). Also the timeout only matters when
+ * there are bugs and apps don't end their own startup sequence.
+ *
+ * This timeout is a "last resort" timeout that ignores whether the
+ * startup sequence has shown activity or not.  Marco and the
+ * tasklist have smarter, and correspondingly able-to-be-shorter
+ * timeouts. The reason our timeout is dumb is that we don't monitor
+ * the sequence (don't use an SnMonitorContext)
+ */
+#define STARTUP_TIMEOUT_LENGTH_SEC 30 /* seconds */
+#define STARTUP_TIMEOUT_LENGTH (STARTUP_TIMEOUT_LENGTH_SEC * 1000)
+
+typedef struct
+{
+	GdkScreen *screen;
+	GSList *contexts;
+	guint timeout_id;
+} StartupTimeoutData;
+
+static void
+free_startup_timeout (void *data)
+{
+	StartupTimeoutData *std = data;
+
+	g_slist_free_full (std->contexts, (GDestroyNotify) sn_launcher_context_unref);
+
+	if (std->timeout_id != 0) {
+		g_source_remove (std->timeout_id);
+		std->timeout_id = 0;
+	}
+
+	g_free (std);
+}
+
+static gboolean
+startup_timeout (void *data)
+{
+	StartupTimeoutData *std = data;
+	GSList *tmp;
+	int min_timeout;
+
+	min_timeout = STARTUP_TIMEOUT_LENGTH;
+
+#if GLIB_CHECK_VERSION(2,61,2)
+	gint64 now = g_get_real_time ();
+#else
+	GTimeVal now;
+	g_get_current_time (&now);
+#endif
+
+	tmp = std->contexts;
+	while (tmp != NULL) {
+		SnLauncherContext *sn_context = tmp->data;
+		GSList *next = tmp->next;
+		double elapsed;
+
+#if GLIB_CHECK_VERSION(2,61,2)
+		time_t tv_sec;
+		suseconds_t tv_usec;
+		gint64 tv;
+
+		sn_launcher_context_get_last_active_time (sn_context, &tv_sec, &tv_usec);
+		tv = (tv_sec * G_USEC_PER_SEC) + tv_usec;
+		elapsed = (double) (now - tv) / 1000.0;
+#else
+		long tv_sec, tv_usec;
+
+		sn_launcher_context_get_last_active_time (sn_context,
+							  &tv_sec, &tv_usec);
+
+		elapsed =
+			((((double)now.tv_sec - tv_sec) * G_USEC_PER_SEC +
+			  (now.tv_usec - tv_usec))) / 1000.0;
+#endif
+
+		if (elapsed >= STARTUP_TIMEOUT_LENGTH) {
+			std->contexts = g_slist_remove (std->contexts,
+							sn_context);
+			sn_launcher_context_complete (sn_context);
+			sn_launcher_context_unref (sn_context);
+		} else {
+			min_timeout = MIN (min_timeout, (STARTUP_TIMEOUT_LENGTH - elapsed));
+		}
+
+		tmp = next;
+	}
+
+	/* we'll use seconds for the timeout */
+	if (min_timeout < 1000)
+		min_timeout = 1000;
+
+	if (std->contexts == NULL) {
+		std->timeout_id = 0;
+	} else {
+		std->timeout_id = g_timeout_add_seconds (min_timeout / 1000,
+							 startup_timeout,
+							 std);
+	}
+
+	/* always remove this one, but we may have reinstalled another one. */
+	return FALSE;
+}
+
+static void
+add_startup_timeout (GdkScreen         *screen,
+		     SnLauncherContext *sn_context)
+{
+	StartupTimeoutData *data;
+
+	data = g_object_get_data (G_OBJECT (screen), "mate-startup-data");
+	if (data == NULL) {
+		data = g_new (StartupTimeoutData, 1);
+		data->screen = screen;
+		data->contexts = NULL;
+		data->timeout_id = 0;
+
+		g_object_set_data_full (G_OBJECT (screen), "mate-startup-data",
+					data, free_startup_timeout);
+	}
+
+	sn_launcher_context_ref (sn_context);
+	data->contexts = g_slist_prepend (data->contexts, sn_context);
+
+	if (data->timeout_id == 0) {
+		data->timeout_id = g_timeout_add_seconds (
+						STARTUP_TIMEOUT_LENGTH_SEC,
+						startup_timeout,
+						data);
+	}
+}
+#endif /* HAVE_STARTUP_NOTIFICATION */
+
+static inline char *
+stringify_uris (GSList *args)
+{
+	GString *str;
+
+	str = g_string_new (NULL);
+
+	append_all_converted (str, URI_TO_STRING, args, FALSE, FALSE, ADDED_NONE);
+
+	return g_string_free (str, FALSE);
+}
+
+static inline char *
+stringify_files (GSList *args)
+{
+	GString *str;
+
+	str = g_string_new (NULL);
+
+	append_all_converted (str, URI_TO_LOCAL_PATH, args, FALSE, FALSE, ADDED_NONE);
+
+	return g_string_free (str, FALSE);
+}
+
+static char **
+make_environment_for_screen (GdkScreen  *screen,
+			     char      **envp)
+{
+	GdkDisplay *display;
+	char      **retval;
+	char      **freeme;
+	char       *display_name;
+	int         display_index = -1;
+	int         i, env_len;
+
+	g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
+
+	retval = freeme = NULL;
+
+	if (envp == NULL) {
+		envp = freeme = g_listenv ();
+		for (i = 0; envp [i]; i++) {
+			char *name = envp[i];
+
+			envp[i] = g_strjoin ("=", name, g_getenv (name), NULL);
+			g_free (name);
+		}
+	}
+
+	for (env_len = 0; envp [env_len]; env_len++)
+		if (strncmp (envp [env_len], "DISPLAY", strlen ("DISPLAY")) == 0)
+			display_index = env_len;
+
+	retval = g_new (char *, env_len + 1);
+	retval [env_len] = NULL;
+
+	display = gdk_screen_get_display (screen);
+	display_name = g_strdup (gdk_display_get_name (display));
+
+	for (i = 0; i < env_len; i++)
+		if (i == display_index)
+			retval [i] = g_strconcat ("DISPLAY=", display_name, NULL);
+		else
+			retval [i] = g_strdup (envp[i]);
+
+	g_assert (i == env_len);
+
+	g_free (display_name);
+	g_strfreev (freeme);
+
+	return retval;
+}
+
+static void
+dummy_child_watch (GPid         pid,
+		   gint         status,
+		   gpointer user_data)
+{
+	/* Nothing, this is just to ensure we don't double fork
+	 * and break pkexec:
+	 * https://bugzilla.gnome.org/show_bug.cgi?id=675789
+	 */
+}
+
+static int
+ditem_execute (const MateDesktopItem *item,
+	       const char *exec,
+	       GList *file_list,
+	       GdkScreen *screen,
+	       int workspace,
+               char **envp,
+	       gboolean launch_only_one,
+	       gboolean use_current_dir,
+	       gboolean append_uris,
+	       gboolean append_paths,
+	       gboolean do_not_reap_child,
+	       GError **error)
+{
+	char **free_me = NULL;
+	char **real_argv;
+	int i, ret;
+	char **term_argv = NULL;
+	int term_argc = 0;
+	GSList *vector_list;
+	GSList *args, *arg_ptr;
+	AddedStatus added_status;
+	const char *working_dir = NULL;
+	char **temp_argv = NULL;
+	int temp_argc = 0;
+	char *new_exec, *uris, *temp;
+	char *exec_locale;
+	int launched = 0;
+	GPid pid;
+#ifdef HAVE_STARTUP_NOTIFICATION
+	GdkDisplay *gdkdisplay;
+	SnLauncherContext *sn_context;
+	SnDisplay *sn_display;
+	const char *startup_class;
+#endif
+
+	g_return_val_if_fail (item, -1);
+
+	if (item->type == MATE_DESKTOP_ITEM_TYPE_APPLICATION) {
+		working_dir = mate_desktop_item_get_string (item, MATE_DESKTOP_ITEM_PATH);
+		if (working_dir &&
+		    !g_file_test (working_dir, G_FILE_TEST_IS_DIR))
+			working_dir = NULL;
+	}
+
+	if (working_dir == NULL && !use_current_dir)
+		working_dir = g_get_home_dir ();
+
+	if (mate_desktop_item_get_boolean (item, MATE_DESKTOP_ITEM_TERMINAL)) {
+		const char *options =
+			mate_desktop_item_get_string (item, MATE_DESKTOP_ITEM_TERMINAL_OPTIONS);
+
+		if (options != NULL) {
+			g_shell_parse_argv (options,
+					    &term_argc,
+					    &term_argv,
+					    NULL /* error */);
+			/* ignore errors */
+		}
+
+		mate_desktop_prepend_terminal_to_vector (&term_argc, &term_argv);
+	}
+
+	args = make_args (file_list);
+	arg_ptr = make_args (file_list);
+
+#ifdef HAVE_STARTUP_NOTIFICATION
+	if (screen)
+		gdkdisplay = gdk_screen_get_display (screen);
+	else
+		gdkdisplay = gdk_display_get_default ();
+
+	sn_display = sn_display_new (GDK_DISPLAY_XDISPLAY (gdkdisplay),
+				     sn_error_trap_push,
+				     sn_error_trap_pop);
+
+	/* Only initiate notification if desktop file supports it.
+	 * (we could avoid setting up the SnLauncherContext if we aren't going
+	 * to initiate, but why bother)
+	 */
+
+	startup_class = mate_desktop_item_get_string (item,
+						       "StartupWMClass");
+	if (startup_class ||
+	    mate_desktop_item_get_boolean (item, "StartupNotify")) {
+		const char *name;
+		const char *icon;
+
+		sn_context = sn_launcher_context_new (sn_display,
+						      screen ? gdk_x11_screen_get_screen_number (screen) :
+						      DefaultScreen (GDK_DISPLAY_XDISPLAY (gdkdisplay)));
+
+		name = mate_desktop_item_get_localestring (item,
+							    MATE_DESKTOP_ITEM_NAME);
+
+		if (name == NULL)
+			name = mate_desktop_item_get_localestring (item,
+								    MATE_DESKTOP_ITEM_GENERIC_NAME);
+
+		if (name != NULL) {
+			char *description;
+
+			sn_launcher_context_set_name (sn_context, name);
+
+			description = g_strdup_printf (_("Starting %s"), name);
+
+			sn_launcher_context_set_description (sn_context, description);
+
+			g_free (description);
+		}
+
+		icon = mate_desktop_item_get_string (item,
+						      MATE_DESKTOP_ITEM_ICON);
+
+		if (icon != NULL)
+			sn_launcher_context_set_icon_name (sn_context, icon);
+
+		sn_launcher_context_set_workspace (sn_context, workspace);
+
+		if (startup_class != NULL)
+			sn_launcher_context_set_wmclass (sn_context,
+							 startup_class);
+	} else {
+		sn_context = NULL;
+	}
+#endif
+
+	if (screen) {
+		envp = make_environment_for_screen (screen, envp);
+		if (free_me)
+			g_strfreev (free_me);
+		free_me = envp;
+	}
+
+	exec_locale = g_filename_from_utf8 (exec, -1, NULL, NULL, NULL);
+
+	if (exec_locale == NULL) {
+		exec_locale = g_strdup ("");
+	}
+
+	do {
+		added_status = ADDED_NONE;
+		new_exec = expand_string (item,
+					  exec_locale,
+					  args, &arg_ptr, &added_status);
+
+		if (launched == 0 && added_status == ADDED_NONE && append_uris) {
+			uris = stringify_uris (args);
+			temp = g_strconcat (new_exec, " ", uris, NULL);
+			g_free (uris);
+			g_free (new_exec);
+			new_exec = temp;
+			added_status = ADDED_ALL;
+		}
+
+		/* append_uris and append_paths are mutually exlusive */
+		if (launched == 0 && added_status == ADDED_NONE && append_paths) {
+			uris = stringify_files (args);
+			temp = g_strconcat (new_exec, " ", uris, NULL);
+			g_free (uris);
+			g_free (new_exec);
+			new_exec = temp;
+			added_status = ADDED_ALL;
+		}
+
+		if (launched > 0 && added_status == ADDED_NONE) {
+			g_free (new_exec);
+			break;
+		}
+
+		if ( ! g_shell_parse_argv (new_exec,
+					   &temp_argc, &temp_argv, error)) {
+			/* The error now comes from g_shell_parse_argv */
+			g_free (new_exec);
+			ret = -1;
+			break;
+		}
+		g_free (new_exec);
+
+		vector_list = NULL;
+		for(i = 0; i < term_argc; i++)
+			vector_list = g_slist_append (vector_list,
+						      g_strdup (term_argv[i]));
+
+		for(i = 0; i < temp_argc; i++)
+			vector_list = g_slist_append (vector_list,
+						      g_strdup (temp_argv[i]));
+
+		g_strfreev (temp_argv);
+
+		real_argv = list_to_vector (vector_list);
+		g_slist_free_full (vector_list, g_free);
+
+#ifdef HAVE_STARTUP_NOTIFICATION
+		if (sn_context != NULL &&
+		    !sn_launcher_context_get_initiated (sn_context)) {
+			guint32 launch_time;
+
+			/* This means that we always use the first real_argv[0]
+			 * we select for the "binary name", but it's probably
+			 * OK to do that. Binary name isn't super-important
+			 * anyway, and we can't initiate twice, and we
+			 * must initiate prior to fork/exec.
+			 */
+
+			sn_launcher_context_set_binary_name (sn_context,
+							     real_argv[0]);
+
+			if (item->launch_time > 0)
+				launch_time = item->launch_time;
+			else
+				launch_time = gdk_x11_display_get_user_time (gdkdisplay);
+
+			sn_launcher_context_initiate (sn_context,
+						      g_get_prgname () ? g_get_prgname () : "unknown",
+						      real_argv[0],
+						      launch_time);
+
+			/* Don't allow accidental reuse of same timestamp */
+			((MateDesktopItem *)item)->launch_time = 0;
+
+			envp = make_spawn_environment_for_sn_context (sn_context, envp);
+			if (free_me)
+				g_strfreev (free_me);
+			free_me = envp;
+		}
+#endif
+
+		if ( ! g_spawn_async (working_dir,
+				      real_argv,
+				      envp,
+				      (do_not_reap_child ? G_SPAWN_DO_NOT_REAP_CHILD : 0) | G_SPAWN_SEARCH_PATH /* flags */,
+				      NULL, /* child_setup_func */
+				      NULL, /* child_setup_func_data */
+				      (do_not_reap_child ? &pid : NULL) /* child_pid */,
+				      error)) {
+			/* The error was set for us,
+			 * we just can't launch this thingie */
+			ret = -1;
+			g_strfreev (real_argv);
+			break;
+		} else if (do_not_reap_child) {
+			g_child_watch_add (pid, dummy_child_watch, NULL);
+		}
+
+		launched ++;
+
+		g_strfreev (real_argv);
+
+		if (arg_ptr != NULL)
+			arg_ptr = arg_ptr->next;
+
+	/* rinse, repeat until we run out of arguments (That
+	 * is if we were adding singles anyway) */
+	} while (added_status == ADDED_SINGLE &&
+		 arg_ptr != NULL &&
+		 ! launch_only_one);
+
+	g_free (exec_locale);
+#ifdef HAVE_STARTUP_NOTIFICATION
+	if (sn_context != NULL) {
+		if (ret < 0)
+			sn_launcher_context_complete (sn_context); /* end sequence */
+		else
+			add_startup_timeout (screen ? screen :
+					     gdk_display_get_default_screen (gdk_display_get_default ()),
+					     sn_context);
+		sn_launcher_context_unref (sn_context);
+	}
+
+	sn_display_unref (sn_display);
+#endif /* HAVE_STARTUP_NOTIFICATION */
+
+	free_args (args);
+
+	if (term_argv)
+		g_strfreev (term_argv);
+
+	if (free_me)
+		g_strfreev (free_me);
+
+	return ret;
+}
+
+/* strip any trailing &, return FALSE if bad things happen and
+   we end up with an empty string */
+static gboolean
+strip_the_amp (char *exec)
+{
+	size_t exec_len;
+
+	g_strstrip (exec);
+	if (*exec == '\0')
+		return FALSE;
+
+	exec_len = strlen (exec);
+	/* kill any trailing '&' */
+	if (exec[exec_len-1] == '&') {
+		exec[exec_len-1] = '\0';
+		g_strchomp (exec);
+	}
+
+	/* can't exactly launch an empty thing */
+	if (*exec == '\0')
+		return FALSE;
+
+	return TRUE;
+}
+
+static int
+mate_desktop_item_launch_on_screen_with_env (
+		const MateDesktopItem       *item,
+		GList                        *file_list,
+		MateDesktopItemLaunchFlags   flags,
+		GdkScreen                    *screen,
+		int                           workspace,
+		char                        **envp,
+		GError                      **error)
+{
+	const char *exec;
+	char *the_exec;
+	int ret;
+
+	exec = mate_desktop_item_get_string (item, MATE_DESKTOP_ITEM_EXEC);
+	/* This is a URL, so launch it as a url */
+	if (item->type == MATE_DESKTOP_ITEM_TYPE_LINK) {
+		const char *url;
+		gboolean    retval;
+
+		url = mate_desktop_item_get_string (item, MATE_DESKTOP_ITEM_URL);
+		/* Mate panel used to put this in Exec */
+		if (!(url && url[0] != '\0'))
+			url = exec;
+
+		if (!(url && url[0] != '\0')) {
+			g_set_error (error,
+				     MATE_DESKTOP_ITEM_ERROR,
+				     MATE_DESKTOP_ITEM_ERROR_NO_URL,
+				     _("No URL to launch"));
+			return -1;
+		}
+
+		retval = gtk_show_uri_on_window  (NULL,
+		                                  url,
+		                                  GDK_CURRENT_TIME,
+		                                  error);
+		return retval ? 0 : -1;
+	}
+
+	/* check the type, if there is one set */
+	if (item->type != MATE_DESKTOP_ITEM_TYPE_APPLICATION) {
+		g_set_error (error,
+			     MATE_DESKTOP_ITEM_ERROR,
+			     MATE_DESKTOP_ITEM_ERROR_NOT_LAUNCHABLE,
+			     _("Not a launchable item"));
+		return -1;
+	}
+
+	if (exec == NULL ||
+	    exec[0] == '\0') {
+		g_set_error (error,
+			     MATE_DESKTOP_ITEM_ERROR,
+			     MATE_DESKTOP_ITEM_ERROR_NO_EXEC_STRING,
+			     _("No command (Exec) to launch"));
+		return -1;
+	}
+
+	/* make a new copy and get rid of spaces */
+	the_exec = g_alloca (strlen (exec) + 1);
+	g_strlcpy (the_exec, exec, strlen (exec) + 1);
+
+	if ( ! strip_the_amp (the_exec)) {
+		g_set_error (error,
+			     MATE_DESKTOP_ITEM_ERROR,
+			     MATE_DESKTOP_ITEM_ERROR_BAD_EXEC_STRING,
+			     _("Bad command (Exec) to launch"));
+		return -1;
+	}
+
+	ret = ditem_execute (item, the_exec, file_list, screen, workspace, envp,
+			     (flags & MATE_DESKTOP_ITEM_LAUNCH_ONLY_ONE),
+			     (flags & MATE_DESKTOP_ITEM_LAUNCH_USE_CURRENT_DIR),
+			     (flags & MATE_DESKTOP_ITEM_LAUNCH_APPEND_URIS),
+			     (flags & MATE_DESKTOP_ITEM_LAUNCH_APPEND_PATHS),
+			     (flags & MATE_DESKTOP_ITEM_LAUNCH_DO_NOT_REAP_CHILD),
+			     error);
+
+	return ret;
+}
+
+/**
+ * mate_desktop_item_launch:
+ * @item: A desktop item
+ * @file_list:  Files/URIs to launch this item with, can be %NULL
+ * @flags: FIXME
+ * @error: FIXME
+ *
+ * This function runs the program listed in the specified 'item',
+ * optionally appending additional arguments to its command line.  It uses
+ * #g_shell_parse_argv to parse the the exec string into a vector which is
+ * then passed to #g_spawn_async for execution. This can return all
+ * the errors from MateURL, #g_shell_parse_argv and #g_spawn_async,
+ * in addition to it's own.  The files are
+ * only added if the entry defines one of the standard % strings in it's
+ * Exec field.
+ *
+ * Returns: The the pid of the process spawned.  If more then one
+ * process was spawned the last pid is returned.  On error -1
+ * is returned and @error is set.
+ */
+int
+mate_desktop_item_launch (const MateDesktopItem       *item,
+			   GList                        *file_list,
+			   MateDesktopItemLaunchFlags   flags,
+			   GError                      **error)
+{
+	return mate_desktop_item_launch_on_screen_with_env (
+			item, file_list, flags, NULL, -1, NULL, error);
+}
+
+/**
+ * mate_desktop_item_launch_with_env:
+ * @item: A desktop item
+ * @file_list:  Files/URIs to launch this item with, can be %NULL
+ * @flags: FIXME
+ * @envp: child's environment, or %NULL to inherit parent's
+ * @error: FIXME
+ *
+ * See mate_desktop_item_launch for a full description. This function
+ * additionally passes an environment vector for the child process
+ * which is to be launched.
+ *
+ * Returns: The the pid of the process spawned.  If more then one
+ * process was spawned the last pid is returned.  On error -1
+ * is returned and @error is set.
+ */
+int
+mate_desktop_item_launch_with_env (const MateDesktopItem       *item,
+				    GList                        *file_list,
+				    MateDesktopItemLaunchFlags   flags,
+				    char                        **envp,
+				    GError                      **error)
+{
+	return mate_desktop_item_launch_on_screen_with_env (
+			item, file_list, flags,
+			NULL, -1, envp, error);
+}
+
+/**
+ * mate_desktop_item_launch_on_screen:
+ * @item: A desktop item
+ * @file_list:  Files/URIs to launch this item with, can be %NULL
+ * @flags: FIXME
+ * @screen: the %GdkScreen on which the application should be launched
+ * @workspace: the workspace on which the app should be launched (-1 for current)
+ * @error: FIXME
+ *
+ * See mate_desktop_item_launch for a full description. This function
+ * additionally attempts to launch the application on a given screen
+ * and workspace.
+ *
+ * Returns: The the pid of the process spawned.  If more then one
+ * process was spawned the last pid is returned.  On error -1
+ * is returned and @error is set.
+ */
+int
+mate_desktop_item_launch_on_screen (const MateDesktopItem       *item,
+				     GList                        *file_list,
+				     MateDesktopItemLaunchFlags   flags,
+				     GdkScreen                    *screen,
+				     int                           workspace,
+				     GError                      **error)
+{
+	return mate_desktop_item_launch_on_screen_with_env (
+			item, file_list, flags,
+			screen, workspace, NULL, error);
+}
+
+/**
+ * mate_desktop_item_drop_uri_list:
+ * @item: A desktop item
+ * @uri_list: text as gotten from a text/uri-list
+ * @flags: FIXME
+ * @error: FIXME
+ *
+ * A list of files or urls dropped onto an icon, the proper (Url or File)
+ * exec is run you can pass directly string that you got as the
+ * text/uri-list.  This just parses the list and calls
+ *
+ * Returns: The value returned by #mate_execute_async() upon execution of
+ * the specified item or -1 on error.  If multiple instances are run, the
+ * return of the last one is returned.
+ */
+int
+mate_desktop_item_drop_uri_list (const MateDesktopItem *item,
+				  const char *uri_list,
+				  MateDesktopItemLaunchFlags flags,
+				  GError **error)
+{
+	return mate_desktop_item_drop_uri_list_with_env (item, uri_list,
+							  flags, NULL, error);
+}
+
+/**
+* mate_desktop_item_drop_uri_list_with_env:
+* @item: A desktop item
+* @uri_list: text as gotten from a text/uri-list
+* @flags: FIXME
+* @envp: child's environment
+* @error: FIXME
+*
+* See mate_desktop_item_drop_uri_list for a full description. This function
+* additionally passes an environment vector for the child process
+* which is to be launched.
+*
+* Returns: The value returned by #mate_execute_async() upon execution of
+* the specified item or -1 on error.  If multiple instances are run, the
+* return of the last one is returned.
+*/
+int
+mate_desktop_item_drop_uri_list_with_env (const MateDesktopItem *item,
+					   const char *uri_list,
+					   MateDesktopItemLaunchFlags flags,
+					   char                        **envp,
+					   GError **error)
+{
+	int ret;
+	char  *uri;
+	char **uris;
+	GList *list = NULL;
+
+	uris = g_uri_list_extract_uris (uri_list);
+
+	for (uri = uris[0]; uri != NULL; uri++) {
+		list = g_list_prepend (list, uri);
+	}
+	list = g_list_reverse (list);
+
+	ret =  mate_desktop_item_launch_with_env (
+			item, list, flags, envp, error);
+
+	g_strfreev (uris);
+	g_list_free (list);
+
+	return ret;
+}
+
+static gboolean
+exec_exists (const char *exec)
+{
+	if (g_path_is_absolute (exec)) {
+		if (access (exec, X_OK) == 0)
+			return TRUE;
+		else
+			return FALSE;
+	} else {
+		char *tryme;
+
+		tryme = g_find_program_in_path (exec);
+		if (tryme != NULL) {
+			g_free (tryme);
+			return TRUE;
+		}
+		return FALSE;
+	}
+}
+
+/**
+ * mate_desktop_item_exists:
+ * @item: A desktop item
+ *
+ * Attempt to figure out if the program that can be executed by this item
+ * actually exists.  First it tries the TryExec attribute to see if that
+ * contains a program that is in the path.  Then if there is no such
+ * attribute, it tries the first word of the Exec attribute.
+ *
+ * Returns: A boolean, %TRUE if it exists, %FALSE otherwise.
+ */
+gboolean
+mate_desktop_item_exists (const MateDesktopItem *item)
+{
+	const char *try_exec;
+	const char *exec;
+
+	g_return_val_if_fail (item != NULL, FALSE);
+
+	try_exec = lookup (item, MATE_DESKTOP_ITEM_TRY_EXEC);
+
+	if (try_exec != NULL &&
+	    ! exec_exists (try_exec)) {
+		return FALSE;
+	}
+
+	if (item->type == MATE_DESKTOP_ITEM_TYPE_APPLICATION) {
+		int argc;
+		char **argv;
+		const char *exe;
+
+		exec = lookup (item, MATE_DESKTOP_ITEM_EXEC);
+		if (exec == NULL)
+			return FALSE;
+
+		if ( ! g_shell_parse_argv (exec, &argc, &argv, NULL))
+			return FALSE;
+
+		if (argc < 1) {
+			g_strfreev (argv);
+			return FALSE;
+		}
+
+		exe = argv[0];
+
+		if ( ! exec_exists (exe)) {
+			g_strfreev (argv);
+			return FALSE;
+		}
+		g_strfreev (argv);
+	}
+
+	return TRUE;
+}
+
+/**
+ * mate_desktop_item_get_entry_type:
+ * @item: A desktop item
+ *
+ * Gets the type attribute (the 'Type' field) of the item.  This should
+ * usually be 'Application' for an application, but it can be 'Directory'
+ * for a directory description.  There are other types available as well.
+ * The type usually indicates how the desktop item should be handeled and
+ * how the 'Exec' field should be handeled.
+ *
+ * Returns: The type of the specified 'item'. The returned
+ * memory remains owned by the MateDesktopItem and should not be freed.
+ */
+MateDesktopItemType
+mate_desktop_item_get_entry_type (const MateDesktopItem *item)
+{
+	g_return_val_if_fail (item != NULL, 0);
+	g_return_val_if_fail (item->refcount > 0, 0);
+
+	return item->type;
+}
+
+void
+mate_desktop_item_set_entry_type (MateDesktopItem *item,
+				   MateDesktopItemType type)
+{
+	g_return_if_fail (item != NULL);
+	g_return_if_fail (item->refcount > 0);
+
+	item->type = type;
+
+	switch (type) {
+	case MATE_DESKTOP_ITEM_TYPE_NULL:
+		set (item, MATE_DESKTOP_ITEM_TYPE, NULL);
+		break;
+	case MATE_DESKTOP_ITEM_TYPE_APPLICATION:
+		set (item, MATE_DESKTOP_ITEM_TYPE, "Application");
+		break;
+	case MATE_DESKTOP_ITEM_TYPE_LINK:
+		set (item, MATE_DESKTOP_ITEM_TYPE, "Link");
+		break;
+	case MATE_DESKTOP_ITEM_TYPE_FSDEVICE:
+		set (item, MATE_DESKTOP_ITEM_TYPE, "FSDevice");
+		break;
+	case MATE_DESKTOP_ITEM_TYPE_MIME_TYPE:
+		set (item, MATE_DESKTOP_ITEM_TYPE, "MimeType");
+		break;
+	case MATE_DESKTOP_ITEM_TYPE_DIRECTORY:
+		set (item, MATE_DESKTOP_ITEM_TYPE, "Directory");
+		break;
+	case MATE_DESKTOP_ITEM_TYPE_SERVICE:
+		set (item, MATE_DESKTOP_ITEM_TYPE, "Service");
+		break;
+	case MATE_DESKTOP_ITEM_TYPE_SERVICE_TYPE:
+		set (item, MATE_DESKTOP_ITEM_TYPE, "ServiceType");
+		break;
+	default:
+		break;
+	}
+}
+
+/**
+ * mate_desktop_item_get_file_status:
+ * @item: A desktop item
+ *
+ * This function checks the modification time of the on-disk file to
+ * see if it is more recent than the in-memory data.
+ *
+ * Returns: An enum value that specifies whether the item has changed since being loaded.
+ */
+MateDesktopItemStatus
+mate_desktop_item_get_file_status (const MateDesktopItem *item)
+{
+	MateDesktopItemStatus retval;
+	GFile *file;
+	GFileInfo *info;
+
+	g_return_val_if_fail (item != NULL, MATE_DESKTOP_ITEM_DISAPPEARED);
+	g_return_val_if_fail (item->refcount > 0, MATE_DESKTOP_ITEM_DISAPPEARED);
+
+	if (item->location == NULL)
+		return MATE_DESKTOP_ITEM_DISAPPEARED;
+
+	file = g_file_new_for_uri (item->location);
+	info = g_file_query_info (file, G_FILE_ATTRIBUTE_TIME_MODIFIED,
+				  G_FILE_QUERY_INFO_NONE, NULL, NULL);
+
+	retval = MATE_DESKTOP_ITEM_UNCHANGED;
+
+	if (!g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_TIME_MODIFIED))
+		retval = MATE_DESKTOP_ITEM_DISAPPEARED;
+	else if (((guint64) item->mtime) < g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_TIME_MODIFIED))
+		retval = MATE_DESKTOP_ITEM_CHANGED;
+
+	g_object_unref (info);
+	g_object_unref (file);
+
+	return retval;
+}
+
+/**
+ * mate_desktop_item_find_icon:
+ * @icon_theme: a #GtkIconTheme
+ * @icon: icon name, something you'd get out of the Icon key
+ * @desired_size: FIXME
+ * @flags: FIXME
+ *
+ * Description:  This function goes and looks for the icon file.  If the icon
+ * is not an absolute filename, this will look for it in the standard places.
+ * If it can't find the icon, it will return %NULL
+ *
+ * Returns: A newly allocated string
+ */
+char *
+mate_desktop_item_find_icon (GtkIconTheme *icon_theme,
+			      const char *icon,
+			      int desired_size,
+			      int flags)
+{
+	GtkIconInfo *info;
+	char *full = NULL;
+
+	g_return_val_if_fail (icon_theme == NULL ||
+			      GTK_IS_ICON_THEME (icon_theme), NULL);
+
+	if (icon == NULL || strcmp(icon,"") == 0) {
+		return NULL;
+	} else if (g_path_is_absolute (icon)) {
+		if (g_file_test (icon, G_FILE_TEST_EXISTS)) {
+			return g_strdup (icon);
+		} else {
+			return NULL;
+		}
+	} else {
+		char *icon_no_extension;
+		char *p;
+
+		if (icon_theme == NULL)
+			icon_theme = gtk_icon_theme_get_default ();
+
+		icon_no_extension = g_strdup (icon);
+		p = strrchr (icon_no_extension, '.');
+		if (p &&
+		    (strcmp (p, ".png") == 0 ||
+		     strcmp (p, ".xpm") == 0 ||
+		     strcmp (p, ".svg") == 0)) {
+		    *p = 0;
+		}
+
+		info = gtk_icon_theme_lookup_icon (icon_theme,
+						   icon_no_extension,
+						   desired_size,
+						   0);
+
+		full = NULL;
+		if (info) {
+			full = g_strdup (gtk_icon_info_get_filename (info));
+			g_object_unref (info);
+		}
+		g_free (icon_no_extension);
+	}
+
+	return full;
+
+}
+
+/**
+ * mate_desktop_item_get_icon:
+ * @icon_theme: a #GtkIconTheme
+ * @item: A desktop item
+ *
+ * Description:  This function goes and looks for the icon file.  If the icon
+ * is not set as an absolute filename, this will look for it in the standard places.
+ * If it can't find the icon, it will return %NULL
+ *
+ * Returns: A newly allocated string
+ */
+char *
+mate_desktop_item_get_icon (const MateDesktopItem *item,
+			     GtkIconTheme *icon_theme)
+{
+	/* maybe this function should be deprecated in favour of find icon
+	 * -George */
+	const char *icon;
+
+	g_return_val_if_fail (item != NULL, NULL);
+	g_return_val_if_fail (item->refcount > 0, NULL);
+
+	icon = mate_desktop_item_get_string (item, MATE_DESKTOP_ITEM_ICON);
+
+	return mate_desktop_item_find_icon (icon_theme, icon,
+					     48 /* desired_size */,
+					     0 /* flags */);
+}
+
+/**
+ * mate_desktop_item_get_location:
+ * @item: A desktop item
+ *
+ * Returns: The file location associated with 'item'.
+ *
+ */
+const char *
+mate_desktop_item_get_location (const MateDesktopItem *item)
+{
+	g_return_val_if_fail (item != NULL, NULL);
+	g_return_val_if_fail (item->refcount > 0, NULL);
+
+	return item->location;
+}
+
+/**
+ * mate_desktop_item_set_location:
+ * @item: A desktop item
+ * @location: A uri string specifying the file location of this particular item.
+ *
+ * Set's the 'location' uri of this item.
+ */
+void
+mate_desktop_item_set_location (MateDesktopItem *item, const char *location)
+{
+	g_return_if_fail (item != NULL);
+	g_return_if_fail (item->refcount > 0);
+
+	if (item->location != NULL &&
+	    location != NULL &&
+	    strcmp (item->location, location) == 0)
+		return;
+
+	g_free (item->location);
+	item->location = g_strdup (location);
+
+	/* This is ugly, but useful internally */
+	if (item->mtime != DONT_UPDATE_MTIME) {
+		item->mtime = 0;
+
+		if (item->location) {
+			GFile     *file;
+			GFileInfo *info;
+
+			file = g_file_new_for_uri (item->location);
+
+			info = g_file_query_info (file,
+						  G_FILE_ATTRIBUTE_TIME_MODIFIED,
+						  G_FILE_QUERY_INFO_NONE,
+						  NULL, NULL);
+			if (info) {
+				if (g_file_info_has_attribute (info,
+							       G_FILE_ATTRIBUTE_TIME_MODIFIED))
+					item->mtime = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_TIME_MODIFIED);
+				g_object_unref (info);
+			}
+
+			g_object_unref (file);
+		}
+	}
+
+	/* Make sure that save actually saves */
+	item->modified = TRUE;
+}
+
+/**
+ * mate_desktop_item_set_location_file:
+ * @item: A desktop item
+ * @file: A local filename specifying the file location of this particular item.
+ *
+ * Set's the 'location' uri of this item to the given @file.
+ */
+void
+mate_desktop_item_set_location_file (MateDesktopItem *item, const char *file)
+{
+	g_return_if_fail (item != NULL);
+	g_return_if_fail (item->refcount > 0);
+
+	if (file != NULL) {
+		GFile *gfile;
+
+		gfile = g_file_new_for_path (file);
+		mate_desktop_item_set_location_gfile (item, gfile);
+		g_object_unref (gfile);
+	} else {
+		mate_desktop_item_set_location (item, NULL);
+	}
+}
+
+static void
+mate_desktop_item_set_location_gfile (MateDesktopItem *item, GFile *file)
+{
+	g_return_if_fail (item != NULL);
+	g_return_if_fail (item->refcount > 0);
+
+	if (file != NULL) {
+		char *uri;
+
+		uri = g_file_get_uri (file);
+		mate_desktop_item_set_location (item, uri);
+		g_free (uri);
+	} else {
+		mate_desktop_item_set_location (item, NULL);
+	}
+}
+
+/*
+ * Reading/Writing different sections, NULL is the standard section
+ */
+
+gboolean
+mate_desktop_item_attr_exists (const MateDesktopItem *item,
+				const char *attr)
+{
+	g_return_val_if_fail (item != NULL, FALSE);
+	g_return_val_if_fail (item->refcount > 0, FALSE);
+	g_return_val_if_fail (attr != NULL, FALSE);
+
+	return lookup (item, attr) != NULL;
+}
+
+/*
+ * String type
+ */
+const char *
+mate_desktop_item_get_string (const MateDesktopItem *item,
+			       const char *attr)
+{
+	g_return_val_if_fail (item != NULL, NULL);
+	g_return_val_if_fail (item->refcount > 0, NULL);
+	g_return_val_if_fail (attr != NULL, NULL);
+
+	return lookup (item, attr);
+}
+
+void
+mate_desktop_item_set_string (MateDesktopItem *item,
+			       const char *attr,
+			       const char *value)
+{
+	g_return_if_fail (item != NULL);
+	g_return_if_fail (item->refcount > 0);
+	g_return_if_fail (attr != NULL);
+
+	set (item, attr, value);
+
+	if (strcmp (attr, MATE_DESKTOP_ITEM_TYPE) == 0)
+		item->type = type_from_string (value);
+}
+
+/*
+ * LocaleString type
+ */
+const char* mate_desktop_item_get_localestring(const MateDesktopItem* item, const char* attr)
+{
+	g_return_val_if_fail(item != NULL, NULL);
+	g_return_val_if_fail(item->refcount > 0, NULL);
+	g_return_val_if_fail(attr != NULL, NULL);
+
+	return lookup_best_locale(item, attr);
+}
+
+const char* mate_desktop_item_get_localestring_lang(const MateDesktopItem* item, const char* attr, const char* language)
+{
+	g_return_val_if_fail(item != NULL, NULL);
+	g_return_val_if_fail(item->refcount > 0, NULL);
+	g_return_val_if_fail(attr != NULL, NULL);
+
+	return lookup_locale(item, attr, language);
+}
+
+/**
+ * mate_desktop_item_get_string_locale:
+ * @item: A desktop item
+ * @attr: An attribute name
+ *
+ * Returns the current locale that is used for the given attribute.
+ * This might not be the same for all attributes. For example, if your
+ * locale is "en_US.ISO8859-1" but attribute FOO only has "en_US" then
+ * that would be returned for attr = "FOO". If attribute BAR has
+ * "en_US.ISO8859-1" then that would be returned for "BAR".
+ *
+ * Returns: a string equal to the current locale or NULL
+ * if the attribute is invalid or there is no matching locale.
+ */
+const char *
+mate_desktop_item_get_attr_locale (const MateDesktopItem *item,
+				    const char             *attr)
+{
+	const char * const *langs_pointer;
+	int                 i;
+
+	langs_pointer = g_get_language_names ();
+	for (i = 0; langs_pointer[i] != NULL; i++) {
+		const char *value = NULL;
+
+		value = lookup_locale (item, attr, langs_pointer[i]);
+		if (value)
+			return langs_pointer[i];
+	}
+
+	return NULL;
+}
+
+GList *
+mate_desktop_item_get_languages (const MateDesktopItem *item,
+				  const char *attr)
+{
+	GList *li;
+	GList *list = NULL;
+
+	g_return_val_if_fail (item != NULL, NULL);
+	g_return_val_if_fail (item->refcount > 0, NULL);
+
+	for (li = item->languages; li != NULL; li = li->next) {
+		char *language = li->data;
+		if (attr == NULL ||
+		    lookup_locale (item, attr, language) != NULL) {
+			list = g_list_prepend (list, language);
+		}
+	}
+
+	return g_list_reverse (list);
+}
+
+static const char *
+get_language (void)
+{
+	const char * const *langs_pointer;
+	int                 i;
+
+	langs_pointer = g_get_language_names ();
+	for (i = 0; langs_pointer[i] != NULL; i++) {
+		/* find first without encoding  */
+		if (strchr (langs_pointer[i], '.') == NULL) {
+			return langs_pointer[i];
+		}
+	}
+	return NULL;
+}
+
+void
+mate_desktop_item_set_localestring (MateDesktopItem *item,
+				     const char *attr,
+				     const char *value)
+{
+	g_return_if_fail (item != NULL);
+	g_return_if_fail (item->refcount > 0);
+	g_return_if_fail (attr != NULL);
+
+	set_locale (item, attr, get_language (), value);
+}
+
+void
+mate_desktop_item_set_localestring_lang (MateDesktopItem *item,
+					  const char *attr,
+					  const char *language,
+					  const char *value)
+{
+	g_return_if_fail (item != NULL);
+	g_return_if_fail (item->refcount > 0);
+	g_return_if_fail (attr != NULL);
+
+	set_locale (item, attr, language, value);
+}
+
+void
+mate_desktop_item_clear_localestring (MateDesktopItem *item,
+				       const char *attr)
+{
+	GList *l;<--- Variable 'l' can be declared as pointer to const
+
+	g_return_if_fail (item != NULL);
+	g_return_if_fail (item->refcount > 0);
+	g_return_if_fail (attr != NULL);
+
+	for (l = item->languages; l != NULL; l = l->next)
+		set_locale (item, attr, l->data, NULL);
+
+	set (item, attr, NULL);
+}
+
+/*
+ * Strings, Regexps types
+ */
+
+char **
+mate_desktop_item_get_strings (const MateDesktopItem *item,
+				const char *attr)
+{
+	const char *value;
+
+	g_return_val_if_fail (item != NULL, NULL);
+	g_return_val_if_fail (item->refcount > 0, NULL);
+	g_return_val_if_fail (attr != NULL, NULL);
+
+	value = lookup (item, attr);
+	if (value == NULL)
+		return NULL;
+
+	/* FIXME: there's no way to escape semicolons apparently */
+	return g_strsplit (value, ";", -1);
+}
+
+void
+mate_desktop_item_set_strings (MateDesktopItem *item,
+				const char *attr,
+				char **strings)
+{
+	char *str, *str2;
+
+	g_return_if_fail (item != NULL);
+	g_return_if_fail (item->refcount > 0);
+	g_return_if_fail (attr != NULL);
+
+	str = g_strjoinv (";", strings);
+	str2 = g_strconcat (str, ";", NULL);
+	/* FIXME: there's no way to escape semicolons apparently */
+	set (item, attr, str2);
+	g_free (str);
+	g_free (str2);
+}
+
+/*
+ * Boolean type
+ */
+gboolean
+mate_desktop_item_get_boolean (const MateDesktopItem *item,
+				const char *attr)
+{
+	const char *value;
+
+	g_return_val_if_fail (item != NULL, FALSE);
+	g_return_val_if_fail (item->refcount > 0, FALSE);
+	g_return_val_if_fail (attr != NULL, FALSE);
+
+	value = lookup (item, attr);
+	if (value == NULL)
+		return FALSE;
+
+	return (value[0] == 'T' ||
+		value[0] == 't' ||
+		value[0] == 'Y' ||
+		value[0] == 'y' ||
+		atoi (value) != 0);
+}
+
+void
+mate_desktop_item_set_boolean (MateDesktopItem *item,
+				const char *attr,
+				gboolean value)
+{
+	g_return_if_fail (item != NULL);
+	g_return_if_fail (item->refcount > 0);
+	g_return_if_fail (attr != NULL);
+
+	set (item, attr, value ? "true" : "false");
+}
+
+void
+mate_desktop_item_set_launch_time (MateDesktopItem *item,
+				    guint32           timestamp)
+{
+	g_return_if_fail (item != NULL);
+
+	item->launch_time = timestamp;
+}
+
+/*
+ * Clearing attributes
+ */
+void
+mate_desktop_item_clear_section (MateDesktopItem *item,
+				  const char *section)
+{
+	Section *sec;
+	GList *li;
+
+	g_return_if_fail (item != NULL);
+	g_return_if_fail (item->refcount > 0);
+
+	sec = find_section (item, section);
+
+	if (sec == NULL) {
+		for (li = item->keys; li != NULL; li = li->next) {
+			g_hash_table_remove (item->main_hash, li->data);
+			g_free (li->data);
+			li->data = NULL;
+		}
+		g_list_free (item->keys);
+		item->keys = NULL;
+	} else {
+		for (li = sec->keys; li != NULL; li = li->next) {
+			char *key = li->data;
+			char *full = g_strdup_printf ("%s/%s",
+						      sec->name, key);
+			g_hash_table_remove (item->main_hash, full);
+			g_free (full);
+			g_free (key);
+			li->data = NULL;
+		}
+		g_list_free (sec->keys);
+		sec->keys = NULL;
+	}
+	item->modified = TRUE;
+}
+
+/************************************************************
+ * Parser:                                                  *
+ ************************************************************/
+
+static gboolean G_GNUC_CONST
+standard_is_boolean (const char * key)
+{
+	static GHashTable *bools = NULL;
+
+	if (bools == NULL) {
+		bools = g_hash_table_new (g_str_hash, g_str_equal);
+		g_hash_table_insert (bools,
+				     MATE_DESKTOP_ITEM_NO_DISPLAY,
+				     MATE_DESKTOP_ITEM_NO_DISPLAY);
+		g_hash_table_insert (bools,
+				     MATE_DESKTOP_ITEM_HIDDEN,
+				     MATE_DESKTOP_ITEM_HIDDEN);
+		g_hash_table_insert (bools,
+				     MATE_DESKTOP_ITEM_TERMINAL,
+				     MATE_DESKTOP_ITEM_TERMINAL);
+		g_hash_table_insert (bools,
+				     MATE_DESKTOP_ITEM_READ_ONLY,
+				     MATE_DESKTOP_ITEM_READ_ONLY);
+	}
+
+	return g_hash_table_lookup (bools, key) != NULL;
+}
+
+static gboolean G_GNUC_CONST
+standard_is_strings (const char *key)
+{
+	static GHashTable *strings = NULL;
+
+	if (strings == NULL) {
+		strings = g_hash_table_new (g_str_hash, g_str_equal);
+		g_hash_table_insert (strings,
+				     MATE_DESKTOP_ITEM_FILE_PATTERN,
+				     MATE_DESKTOP_ITEM_FILE_PATTERN);
+		g_hash_table_insert (strings,
+				     MATE_DESKTOP_ITEM_ACTIONS,
+				     MATE_DESKTOP_ITEM_ACTIONS);
+		g_hash_table_insert (strings,
+				     MATE_DESKTOP_ITEM_MIME_TYPE,
+				     MATE_DESKTOP_ITEM_MIME_TYPE);
+		g_hash_table_insert (strings,
+				     MATE_DESKTOP_ITEM_PATTERNS,
+				     MATE_DESKTOP_ITEM_PATTERNS);
+		g_hash_table_insert (strings,
+				     MATE_DESKTOP_ITEM_SORT_ORDER,
+				     MATE_DESKTOP_ITEM_SORT_ORDER);
+	}
+
+	return g_hash_table_lookup (strings, key) != NULL;
+}
+
+/* If no need to cannonize, returns NULL */
+static char *
+cannonize (const char *key, const char *value)
+{
+	if (standard_is_boolean (key)) {
+		if (value[0] == 'T' ||
+		    value[0] == 't' ||
+		    value[0] == 'Y' ||
+		    value[0] == 'y' ||
+		    atoi (value) != 0) {
+			return g_strdup ("true");
+		} else {
+			return g_strdup ("false");
+		}
+	} else if (standard_is_strings (key)) {
+		int len = strlen (value);
+		if (len == 0 || value[len-1] != ';') {
+			return g_strconcat (value, ";", NULL);
+		}
+	}
+	/* XXX: Perhaps we should canonize numeric values as well, but this
+	 * has caused some subtle problems before so it needs to be done
+	 * carefully if at all */
+	return NULL;
+}
+
+static char *
+decode_string_and_dup (const char *s)
+{
+	char *p = g_malloc (strlen (s) + 1);
+	char *q = p;
+
+	do {
+		if (*s == '\\'){
+			switch (*(++s)){
+			case 's':
+				*p++ = ' ';
+				break;
+			case 't':
+				*p++ = '\t';
+				break;
+			case 'n':
+				*p++ = '\n';
+				break;
+			case '\\':
+				*p++ = '\\';
+				break;
+			case 'r':
+				*p++ = '\r';
+				break;
+			default:
+				*p++ = '\\';
+				*p++ = *s;
+				break;
+			}
+		} else {
+			*p++ = *s;
+		}
+	} while (*s++);
+
+	return q;
+}
+
+static char *
+escape_string_and_dup (const char *s)
+{
+	char *return_value, *p;
+	const char *q;
+	int len = 0;
+
+	if (s == NULL)
+		return g_strdup("");
+
+	q = s;
+	while (*q){
+		len++;
+		if (strchr ("\n\r\t\\", *q) != NULL)
+			len++;
+		q++;
+	}
+	return_value = p = (char *) g_malloc (len + 1);
+	do {
+		switch (*s){
+		case '\t':
+			*p++ = '\\';
+			*p++ = 't';
+			break;
+		case '\n':
+			*p++ = '\\';
+			*p++ = 'n';
+			break;
+		case '\r':
+			*p++ = '\\';
+			*p++ = 'r';
+			break;
+		case '\\':
+			*p++ = '\\';
+			*p++ = '\\';
+			break;
+		default:
+			*p++ = *s;
+		}
+	} while (*s++);
+	return return_value;
+}
+
+static gboolean
+check_locale (const char *locale)
+{
+	GIConv cd = g_iconv_open ("UTF-8", locale);
+	if ((GIConv)-1 == cd)
+		return FALSE;
+	g_iconv_close (cd);
+	return TRUE;
+}
+
+static void
+insert_locales (GHashTable *encodings, char *enc, ...)
+{
+	va_list args;
+	char *s;
+
+	va_start (args, enc);
+	for (;;) {
+		s = va_arg (args, char *);
+		if (s == NULL)
+			break;
+		g_hash_table_insert (encodings, s, enc);
+	}
+	va_end (args);
+}
+
+/* make a standard conversion table from the desktop standard spec */
+static GHashTable *
+init_encodings (void)
+{
+	GHashTable *encodings = g_hash_table_new (g_str_hash, g_str_equal);
+
+	/* "C" is plain ascii */
+	insert_locales (encodings, "ASCII", "C", NULL);
+
+	insert_locales (encodings, "ARMSCII-8", "by", NULL);
+	insert_locales (encodings, "BIG5", "zh_TW", NULL);
+	insert_locales (encodings, "CP1251", "be", "bg", NULL);
+	if (check_locale ("EUC-CN")) {
+		insert_locales (encodings, "EUC-CN", "zh_CN", NULL);
+	} else {
+		insert_locales (encodings, "GB2312", "zh_CN", NULL);
+	}
+	insert_locales (encodings, "EUC-JP", "ja", NULL);
+	insert_locales (encodings, "EUC-KR", "ko", NULL);
+	/*insert_locales (encodings, "GEORGIAN-ACADEMY", NULL);*/
+	insert_locales (encodings, "GEORGIAN-PS", "ka", NULL);
+	insert_locales (encodings, "ISO-8859-1", "br", "ca", "da", "de", "en", "es", "eu", "fi", "fr", "gl", "it", "nl", "wa", "no", "pt", "pt", "sv", NULL);
+	insert_locales (encodings, "ISO-8859-2", "cs", "hr", "hu", "pl", "ro", "sk", "sl", "sq", "sr", NULL);
+	insert_locales (encodings, "ISO-8859-3", "eo", NULL);
+	insert_locales (encodings, "ISO-8859-5", "mk", "sp", NULL);
+	insert_locales (encodings, "ISO-8859-7", "el", NULL);
+	insert_locales (encodings, "ISO-8859-9", "tr", NULL);
+	insert_locales (encodings, "ISO-8859-13", "lt", "lv", "mi", NULL);
+	insert_locales (encodings, "ISO-8859-14", "ga", "cy", NULL);
+	insert_locales (encodings, "ISO-8859-15", "et", NULL);
+	insert_locales (encodings, "KOI8-R", "ru", NULL);
+	insert_locales (encodings, "KOI8-U", "uk", NULL);
+	if (check_locale ("TCVN-5712")) {
+		insert_locales (encodings, "TCVN-5712", "vi", NULL);
+	} else {
+		insert_locales (encodings, "TCVN", "vi", NULL);
+	}
+	insert_locales (encodings, "TIS-620", "th", NULL);
+	/*insert_locales (encodings, "VISCII", NULL);*/
+
+	return encodings;
+}
+
+static const char *
+get_encoding_from_locale (const char *locale)
+{
+	char lang[3];
+	const char *encoding;
+	static GHashTable *encodings = NULL;
+
+	if (locale == NULL)
+		return NULL;
+
+	/* if locale includes encoding, use it */
+	encoding = strchr (locale, '.');
+	if (encoding != NULL) {
+		return encoding+1;
+	}
+
+	if (encodings == NULL)
+		encodings = init_encodings ();
+
+	/* first try the entire locale (at this point ll_CC) */
+	encoding = g_hash_table_lookup (encodings, locale);
+	if (encoding != NULL)
+		return encoding;
+
+	/* Try just the language */
+	strncpy (lang, locale, 2);
+	lang[2] = '\0';
+	return g_hash_table_lookup (encodings, lang);
+}
+
+static Encoding
+get_encoding (ReadBuf *rb)
+{
+	gboolean old_kde = FALSE;
+	char     buf [BUFSIZ];
+	gboolean all_valid_utf8 = TRUE;
+
+	while (readbuf_gets (buf, sizeof (buf), rb) != NULL) {
+		if (strncmp (MATE_DESKTOP_ITEM_ENCODING,
+			     buf,
+			     strlen (MATE_DESKTOP_ITEM_ENCODING)) == 0) {
+			char *p = &buf[strlen (MATE_DESKTOP_ITEM_ENCODING)];
+			if (*p == ' ')
+				p++;
+			if (*p != '=')
+				continue;
+			p++;
+			if (*p == ' ')
+				p++;
+			if (strcmp (p, "UTF-8") == 0) {
+				return ENCODING_UTF8;
+			} else if (strcmp (p, "Legacy-Mixed") == 0) {
+				return ENCODING_LEGACY_MIXED;
+			} else {
+				/* According to the spec we're not supposed
+				 * to read a file like this */
+				return ENCODING_UNKNOWN;
+			}
+		} else if (strcmp ("[KDE Desktop Entry]", buf) == 0) {
+			old_kde = TRUE;
+			/* don't break yet, we still want to support
+			 * Encoding even here */
+		}
+		if (all_valid_utf8 && ! g_utf8_validate (buf, -1, NULL))
+			all_valid_utf8 = FALSE;
+	}
+
+	if (old_kde)
+		return ENCODING_LEGACY_MIXED;
+
+	/* try to guess by location */
+	if (rb->uri != NULL && strstr (rb->uri, "mate/apps/") != NULL) {
+		/* old mate */
+		return ENCODING_LEGACY_MIXED;
+	}
+
+	/* A dilemma, new KDE files are in UTF-8 but have no Encoding
+	 * info, at this time we really can't tell.  The best thing to
+	 * do right now is to just assume UTF-8 if the whole file
+	 * validates as utf8 I suppose */
+
+	if (all_valid_utf8)
+		return ENCODING_UTF8;
+	else
+		return ENCODING_LEGACY_MIXED;
+}
+
+static char *
+decode_string (const char *value, Encoding encoding, const char *locale)
+{
+	char *retval = NULL;
+
+	/* if legacy mixed, then convert */
+	if (locale != NULL && encoding == ENCODING_LEGACY_MIXED) {
+		const char *char_encoding = get_encoding_from_locale (locale);
+		char *utf8_string;
+		if (char_encoding == NULL)
+			return NULL;
+		if (strcmp (char_encoding, "ASCII") == 0) {
+			return decode_string_and_dup (value);
+		}
+		utf8_string = g_convert (value, -1, "UTF-8", char_encoding,
+					NULL, NULL, NULL);
+		if (utf8_string == NULL)
+			return NULL;
+		retval = decode_string_and_dup (utf8_string);
+		g_free (utf8_string);
+		return retval;
+	/* if utf8, then validate */
+	} else if (locale != NULL && encoding == ENCODING_UTF8) {
+		if ( ! g_utf8_validate (value, -1, NULL))
+			/* invalid utf8, ignore this key */
+			return NULL;
+		return decode_string_and_dup (value);
+	} else {
+		/* Meaning this is not a localized string */
+		return decode_string_and_dup (value);
+	}
+}
+
+static char *
+snarf_locale_from_key (const char *key)
+{
+	const char *brace;
+	char *locale, *p;
+
+	brace = strchr (key, '[');
+	if (brace == NULL)
+		return NULL;
+
+	locale = g_strdup (brace + 1);
+	if (*locale == '\0') {
+		g_free (locale);
+		return NULL;
+	}
+	p = strchr (locale, ']');
+	if (p == NULL) {
+		g_free (locale);
+		return NULL;
+	}
+	*p = '\0';
+	return locale;
+}
+
+static void
+insert_key (MateDesktopItem *item,
+	    Section *cur_section,
+	    Encoding encoding,
+	    const char *key,
+	    const char *value,
+	    gboolean old_kde,
+	    gboolean no_translations)
+{
+	char *k;
+	char *val;
+	/* we always store everything in UTF-8 */
+	if (cur_section == NULL &&
+	    strcmp (key, MATE_DESKTOP_ITEM_ENCODING) == 0) {
+		k = g_strdup (key);
+		val = g_strdup ("UTF-8");
+	} else {
+		char *locale = snarf_locale_from_key (key);
+		/* If we're ignoring translations */
+		if (no_translations && locale != NULL) {
+			g_free (locale);
+			return;
+		}
+		val = decode_string (value, encoding, locale);
+
+		/* Ignore this key, it's whacked */
+		if (val == NULL) {
+			g_free (locale);
+			return;
+		}
+
+		g_strchomp (val);
+
+		/* For old KDE entries, we can also split by a comma
+		 * on sort order, so convert to semicolons */
+		if (old_kde &&
+		    cur_section == NULL &&
+		    strcmp (key, MATE_DESKTOP_ITEM_SORT_ORDER) == 0 &&
+		    strchr (val, ';') == NULL) {
+			int i;
+			for (i = 0; val[i] != '\0'; i++) {
+				if (val[i] == ',')
+					val[i] = ';';
+			}
+		}
+
+		/* Check some types, not perfect, but catches a lot
+		 * of things */
+		if (cur_section == NULL) {
+			char *cannon = cannonize (key, val);
+			if (cannon != NULL) {
+				g_free (val);
+				val = cannon;
+			}
+		}
+
+		k = g_strdup (key);
+
+		/* Take care of the language part */
+		if (locale != NULL &&
+		    strcmp (locale, "C") == 0) {
+			char *p;
+			/* Whack C locale */
+			p = strchr (k, '[');
+			*p = '\0';
+			g_free (locale);
+		} else if (locale != NULL) {
+			char *p, *brace;<--- Variable 'brace' can be declared as pointer to const
+
+			/* Whack the encoding part */
+			p = strchr (locale, '.');
+			if (p != NULL)
+				*p = '\0';
+
+			if (g_list_find_custom (item->languages, locale,
+						(GCompareFunc)strcmp) == NULL) {
+				item->languages = g_list_prepend
+					(item->languages, locale);
+			} else {
+				g_free (locale);
+			}
+
+			/* Whack encoding from encoding in the key */
+			brace = strchr (k, '[');
+			p = strchr (brace, '.');
+			if (p != NULL) {
+				*p = ']';
+				*(p+1) = '\0';
+			}
+		}
+	}
+
+	if (cur_section == NULL) {
+		/* only add to list if we haven't seen it before */
+		if (g_hash_table_lookup (item->main_hash, k) == NULL) {
+			item->keys = g_list_prepend (item->keys,
+						     g_strdup (k));
+		}
+		/* later duplicates override earlier ones */
+		g_hash_table_replace (item->main_hash, k, val);
+	} else {
+		char *full = g_strdup_printf
+			("%s/%s",
+			 cur_section->name, k);
+		/* only add to list if we haven't seen it before */
+		if (g_hash_table_lookup (item->main_hash, full) == NULL) {
+			cur_section->keys =
+				g_list_prepend (cur_section->keys, k);
+		}
+		/* later duplicates override earlier ones */
+		g_hash_table_replace (item->main_hash,
+				      full, val);
+	}
+}
+
+static void
+setup_type (MateDesktopItem *item, const char *uri)
+{
+	const char *type = g_hash_table_lookup (item->main_hash,
+						MATE_DESKTOP_ITEM_TYPE);
+	if (type == NULL && uri != NULL) {
+		char *base = g_path_get_basename (uri);
+		if (base != NULL &&
+		    strcmp (base, ".directory") == 0) {
+			/* This gotta be a directory */
+			g_hash_table_replace (item->main_hash,
+					      g_strdup (MATE_DESKTOP_ITEM_TYPE),
+					      g_strdup ("Directory"));
+			item->keys = g_list_prepend
+				(item->keys, g_strdup (MATE_DESKTOP_ITEM_TYPE));
+			item->type = MATE_DESKTOP_ITEM_TYPE_DIRECTORY;
+		} else {
+			item->type = MATE_DESKTOP_ITEM_TYPE_NULL;
+		}
+		g_free (base);
+	} else {
+		item->type = type_from_string (type);
+	}
+}
+
+/* fallback to find something suitable for C locale */
+static char *
+try_english_key (MateDesktopItem *item, const char *key)<--- Parameter 'item' can be declared as pointer to const
+{
+	char *str;
+	char *locales[] = { "en_US", "en_GB", "en_AU", "en", NULL };
+	int i;
+
+	str = NULL;
+	for (i = 0; locales[i] != NULL && str == NULL; i++) {
+		str = g_strdup (lookup_locale (item, key, locales[i]));
+	}
+	if (str != NULL) {
+		/* We need a 7-bit ascii string, so whack all
+		 * above 127 chars */
+		guchar *p;
+		for (p = (guchar *)str; *p != '\0'; p++) {
+			if (*p > 127)
+				*p = '?';
+		}
+	}
+	return str;
+}
+
+static void
+sanitize (MateDesktopItem *item, const char *uri)
+{
+	const char *type;
+
+	type = lookup (item, MATE_DESKTOP_ITEM_TYPE);
+
+	/* understand old mate style url exec thingies */
+	if (type != NULL && strcmp (type, "URL") == 0) {
+		const char *exec = lookup (item, MATE_DESKTOP_ITEM_EXEC);
+		set (item, MATE_DESKTOP_ITEM_TYPE, "Link");
+		if (exec != NULL) {
+			/* Note, this must be in this order */
+			set (item, MATE_DESKTOP_ITEM_URL, exec);
+			set (item, MATE_DESKTOP_ITEM_EXEC, NULL);
+		}
+	}
+
+	/* we make sure we have Name, Encoding and Version */
+	if (lookup (item, MATE_DESKTOP_ITEM_NAME) == NULL) {
+		char *name = try_english_key (item, MATE_DESKTOP_ITEM_NAME);
+		/* If no name, use the basename */
+		if (name == NULL && uri != NULL)
+			name = g_path_get_basename (uri);
+		/* If no uri either, use same default as mate_desktop_item_new */
+		if (name == NULL) {
+		       /* Translators: the "name" mentioned here is the name of
+			* an application or a document */
+			name = g_strdup (_("No name"));
+		}
+		g_hash_table_replace (item->main_hash,
+				      g_strdup (MATE_DESKTOP_ITEM_NAME),
+				      name);
+		item->keys = g_list_prepend
+			(item->keys, g_strdup (MATE_DESKTOP_ITEM_NAME));
+	}
+	if (lookup (item, MATE_DESKTOP_ITEM_ENCODING) == NULL) {
+		/* We store everything in UTF-8 so write that down */
+		g_hash_table_replace (item->main_hash,
+				      g_strdup (MATE_DESKTOP_ITEM_ENCODING),
+				      g_strdup ("UTF-8"));
+		item->keys = g_list_prepend
+			(item->keys, g_strdup (MATE_DESKTOP_ITEM_ENCODING));
+	}
+	if (lookup (item, MATE_DESKTOP_ITEM_VERSION) == NULL) {
+		/* this is the version that we follow, so write it down */
+		g_hash_table_replace (item->main_hash,
+				      g_strdup (MATE_DESKTOP_ITEM_VERSION),
+				      g_strdup ("1.0"));
+		item->keys = g_list_prepend
+			(item->keys, g_strdup (MATE_DESKTOP_ITEM_VERSION));
+	}
+}
+
+enum {
+	FirstBrace,
+	OnSecHeader,
+	IgnoreToEOL,
+	IgnoreToEOLFirst,
+	KeyDef,
+	KeyDefOnKey,
+	KeyValue
+};
+
+static MateDesktopItem *
+ditem_load (ReadBuf *rb,
+	    gboolean no_translations,
+	    GError **error)
+{
+	int state;
+	char CharBuffer [1024];
+	char *next = CharBuffer;
+	int c;
+	Encoding encoding;
+	MateDesktopItem *item;
+	Section *cur_section = NULL;
+	char *key = NULL;
+	gboolean old_kde = FALSE;
+
+	encoding = get_encoding (rb);
+	if (encoding == ENCODING_UNKNOWN) {
+		/* spec says, don't read this file */
+		g_set_error (error,
+			     MATE_DESKTOP_ITEM_ERROR,
+			     MATE_DESKTOP_ITEM_ERROR_UNKNOWN_ENCODING,
+			     _("Unknown encoding of: %s"),
+			     rb->uri);
+		readbuf_close (rb);
+		return NULL;
+	}
+
+	/* Rewind since get_encoding goes through the file */
+	if (! readbuf_rewind (rb, error)) {
+		readbuf_close (rb);
+		/* spec says, don't read this file */
+		return NULL;
+	}
+
+	item = mate_desktop_item_new ();
+	item->modified = FALSE;
+
+	/* Note: location and mtime are filled in by the new_from_file
+	 * function since it has those values */
+
+#define OVERFLOW (next == &CharBuffer [sizeof(CharBuffer)-1])
+
+	state = FirstBrace;
+	while ((c = readbuf_getc (rb)) != EOF) {
+		if (c == '\r')		/* Ignore Carriage Return */
+			continue;
+
+		switch (state) {
+
+		case OnSecHeader:
+			if (c == ']' || OVERFLOW) {
+				*next = '\0';
+				next = CharBuffer;
+
+				/* keys were inserted in reverse */
+				if (cur_section != NULL &&
+				    cur_section->keys != NULL) {
+					cur_section->keys = g_list_reverse
+						(cur_section->keys);
+				}
+				if (strcmp (CharBuffer,
+					    "KDE Desktop Entry") == 0) {
+					/* Main section */
+					cur_section = NULL;
+					old_kde = TRUE;
+				} else if (strcmp (CharBuffer,
+						   "Desktop Entry") == 0) {
+					/* Main section */
+					cur_section = NULL;
+				} else {
+					cur_section = g_new0 (Section, 1);
+					cur_section->name =
+						g_strdup (CharBuffer);
+					cur_section->keys = NULL;
+					item->sections = g_list_prepend
+						(item->sections, cur_section);
+				}
+				state = IgnoreToEOL;
+			} else if (c == '[') {
+				/* FIXME: probably error out instead of ignoring this */
+			} else {
+				*next++ = c;
+			}
+			break;
+
+		case IgnoreToEOL:
+		case IgnoreToEOLFirst:
+			if (c == '\n'){
+				if (state == IgnoreToEOLFirst)
+					state = FirstBrace;
+				else
+					state = KeyDef;
+				next = CharBuffer;
+			}
+			break;
+
+		case FirstBrace:
+		case KeyDef:
+		case KeyDefOnKey:
+			if (c == '#') {
+				if (state == FirstBrace)
+					state = IgnoreToEOLFirst;
+				else
+					state = IgnoreToEOL;
+				break;
+			}
+
+			if (c == '[' && state != KeyDefOnKey){
+				state = OnSecHeader;
+				next = CharBuffer;
+				g_free (key);
+				key = NULL;
+				break;
+			}
+			/* On first pass, don't allow dangling keys */
+			if (state == FirstBrace)
+				break;
+
+			if ((c == ' ' && state != KeyDefOnKey) || c == '\t')
+				break;
+
+			if (c == '\n' || OVERFLOW) { /* Abort Definition */
+				next = CharBuffer;
+				state = KeyDef;
+				break;
+			}
+
+			if (c == '=' || OVERFLOW){
+				*next = '\0';
+
+				g_free (key);
+				key = g_strdup (CharBuffer);
+				state = KeyValue;
+				next = CharBuffer;
+			} else {
+				*next++ = c;
+				state = KeyDefOnKey;
+			}
+			break;
+
+		case KeyValue:
+			if (OVERFLOW || c == '\n'){
+				*next = '\0';
+
+				insert_key (item, cur_section, encoding,
+					    key, CharBuffer, old_kde,
+					    no_translations);
+
+				g_free (key);
+				key = NULL;
+
+				state = (c == '\n') ? KeyDef : IgnoreToEOL;
+				next = CharBuffer;
+			} else {
+				*next++ = c;
+			}
+			break;
+
+		} /* switch */
+
+	} /* while ((c = getc_unlocked (f)) != EOF) */
+	if (c == EOF && state == KeyValue) {
+		*next = '\0';
+
+		insert_key (item, cur_section, encoding,
+			    key, CharBuffer, old_kde,
+			    no_translations);
+
+		g_free (key);
+		key = NULL;
+	}
+
+#undef OVERFLOW
+
+	/* keys were inserted in reverse */
+	if (cur_section != NULL &&
+	    cur_section->keys != NULL) {
+		cur_section->keys = g_list_reverse (cur_section->keys);
+	}
+	/* keys were inserted in reverse */
+	item->keys = g_list_reverse (item->keys);
+	/* sections were inserted in reverse */
+	item->sections = g_list_reverse (item->sections);
+
+	/* sanitize some things */
+	sanitize (item, rb->uri);
+
+	/* make sure that we set up the type */
+	setup_type (item, rb->uri);
+
+	readbuf_close (rb);
+
+	return item;
+}
+
+static void stream_printf (GFileOutputStream *stream,
+			   const char *format, ...) G_GNUC_PRINTF (2, 3);
+
+static void
+stream_printf (GFileOutputStream *stream, const char *format, ...)
+{
+    va_list args;
+    gchar *s;
+
+    va_start (args, format);
+    s = g_strdup_vprintf (format, args);
+    va_end (args);
+
+    /* FIXME: what about errors */
+    g_output_stream_write (G_OUTPUT_STREAM (stream), s, strlen (s),
+		    	   NULL, NULL);
+    g_free (s);
+}
+
+static void
+dump_section (MateDesktopItem *item, GFileOutputStream *stream, Section *section)
+{
+	GList *li;
+
+	stream_printf (stream, "[%s]\n", section->name);
+	for (li = section->keys; li != NULL; li = li->next) {
+		const char *key = li->data;
+		char *full = g_strdup_printf ("%s/%s", section->name, key);
+		const char *value = g_hash_table_lookup (item->main_hash, full);
+		if (value != NULL) {
+			char *val = escape_string_and_dup (value);
+			stream_printf (stream, "%s=%s\n", key, val);
+			g_free (val);
+		}
+		g_free (full);
+	}
+}
+
+static gboolean
+ditem_save (MateDesktopItem *item, const char *uri, GError **error)
+{
+	GList *li;
+	GFile *file;
+	GFileOutputStream *stream;
+
+	file = g_file_new_for_uri (uri);
+	stream = g_file_replace (file, NULL, FALSE, G_FILE_CREATE_NONE,
+				 NULL, error);
+	if (stream == NULL)
+		return FALSE;
+
+	stream_printf (stream, "[Desktop Entry]\n");
+	for (li = item->keys; li != NULL; li = li->next) {
+		const char *key = li->data;
+		const char *value = g_hash_table_lookup (item->main_hash, key);
+		if (value != NULL) {
+			char *val = escape_string_and_dup (value);
+			stream_printf (stream, "%s=%s\n", key, val);
+			g_free (val);
+		}
+	}
+
+	if (item->sections != NULL)
+		stream_printf (stream, "\n");
+
+	for (li = item->sections; li != NULL; li = li->next) {
+		Section *section = li->data;
+
+		/* Don't write empty sections */
+		if (section->keys == NULL)
+			continue;
+
+		dump_section (item, stream, section);
+
+		if (li->next != NULL)
+			stream_printf (stream, "\n");
+	}
+
+	g_object_unref (stream);
+	g_object_unref (file);
+
+	return TRUE;
+}
+
+static gpointer
+_mate_desktop_item_copy (gpointer boxed)
+{
+	return mate_desktop_item_copy (boxed);
+}
+
+static void
+_mate_desktop_item_free (gpointer boxed)
+{
+	mate_desktop_item_unref (boxed);
+}
+
+GType
+mate_desktop_item_get_type (void)
+{
+	static GType type = 0;
+
+	if (type == 0) {
+		type = g_boxed_type_register_static ("MateDesktopItem",
+						     _mate_desktop_item_copy,
+						     _mate_desktop_item_free);
+	}
+
+	return type;
+}
+
+GQuark
+mate_desktop_item_error_quark (void)
+{
+	static GQuark q = 0;
+	if (q == 0)
+		q = g_quark_from_static_string ("mate-desktop-item-error-quark");
+
+	return q;
+}
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/22.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/22.html new file mode 100644 index 0000000..0049a4f --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/22.html @@ -0,0 +1,2941 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
   1
+   2
+   3
+   4
+   5
+   6
+   7
+   8
+   9
+  10
+  11
+  12
+  13
+  14
+  15
+  16
+  17
+  18
+  19
+  20
+  21
+  22
+  23
+  24
+  25
+  26
+  27
+  28
+  29
+  30
+  31
+  32
+  33
+  34
+  35
+  36
+  37
+  38
+  39
+  40
+  41
+  42
+  43
+  44
+  45
+  46
+  47
+  48
+  49
+  50
+  51
+  52
+  53
+  54
+  55
+  56
+  57
+  58
+  59
+  60
+  61
+  62
+  63
+  64
+  65
+  66
+  67
+  68
+  69
+  70
+  71
+  72
+  73
+  74
+  75
+  76
+  77
+  78
+  79
+  80
+  81
+  82
+  83
+  84
+  85
+  86
+  87
+  88
+  89
+  90
+  91
+  92
+  93
+  94
+  95
+  96
+  97
+  98
+  99
+ 100
+ 101
+ 102
+ 103
+ 104
+ 105
+ 106
+ 107
+ 108
+ 109
+ 110
+ 111
+ 112
+ 113
+ 114
+ 115
+ 116
+ 117
+ 118
+ 119
+ 120
+ 121
+ 122
+ 123
+ 124
+ 125
+ 126
+ 127
+ 128
+ 129
+ 130
+ 131
+ 132
+ 133
+ 134
+ 135
+ 136
+ 137
+ 138
+ 139
+ 140
+ 141
+ 142
+ 143
+ 144
+ 145
+ 146
+ 147
+ 148
+ 149
+ 150
+ 151
+ 152
+ 153
+ 154
+ 155
+ 156
+ 157
+ 158
+ 159
+ 160
+ 161
+ 162
+ 163
+ 164
+ 165
+ 166
+ 167
+ 168
+ 169
+ 170
+ 171
+ 172
+ 173
+ 174
+ 175
+ 176
+ 177
+ 178
+ 179
+ 180
+ 181
+ 182
+ 183
+ 184
+ 185
+ 186
+ 187
+ 188
+ 189
+ 190
+ 191
+ 192
+ 193
+ 194
+ 195
+ 196
+ 197
+ 198
+ 199
+ 200
+ 201
+ 202
+ 203
+ 204
+ 205
+ 206
+ 207
+ 208
+ 209
+ 210
+ 211
+ 212
+ 213
+ 214
+ 215
+ 216
+ 217
+ 218
+ 219
+ 220
+ 221
+ 222
+ 223
+ 224
+ 225
+ 226
+ 227
+ 228
+ 229
+ 230
+ 231
+ 232
+ 233
+ 234
+ 235
+ 236
+ 237
+ 238
+ 239
+ 240
+ 241
+ 242
+ 243
+ 244
+ 245
+ 246
+ 247
+ 248
+ 249
+ 250
+ 251
+ 252
+ 253
+ 254
+ 255
+ 256
+ 257
+ 258
+ 259
+ 260
+ 261
+ 262
+ 263
+ 264
+ 265
+ 266
+ 267
+ 268
+ 269
+ 270
+ 271
+ 272
+ 273
+ 274
+ 275
+ 276
+ 277
+ 278
+ 279
+ 280
+ 281
+ 282
+ 283
+ 284
+ 285
+ 286
+ 287
+ 288
+ 289
+ 290
+ 291
+ 292
+ 293
+ 294
+ 295
+ 296
+ 297
+ 298
+ 299
+ 300
+ 301
+ 302
+ 303
+ 304
+ 305
+ 306
+ 307
+ 308
+ 309
+ 310
+ 311
+ 312
+ 313
+ 314
+ 315
+ 316
+ 317
+ 318
+ 319
+ 320
+ 321
+ 322
+ 323
+ 324
+ 325
+ 326
+ 327
+ 328
+ 329
+ 330
+ 331
+ 332
+ 333
+ 334
+ 335
+ 336
+ 337
+ 338
+ 339
+ 340
+ 341
+ 342
+ 343
+ 344
+ 345
+ 346
+ 347
+ 348
+ 349
+ 350
+ 351
+ 352
+ 353
+ 354
+ 355
+ 356
+ 357
+ 358
+ 359
+ 360
+ 361
+ 362
+ 363
+ 364
+ 365
+ 366
+ 367
+ 368
+ 369
+ 370
+ 371
+ 372
+ 373
+ 374
+ 375
+ 376
+ 377
+ 378
+ 379
+ 380
+ 381
+ 382
+ 383
+ 384
+ 385
+ 386
+ 387
+ 388
+ 389
+ 390
+ 391
+ 392
+ 393
+ 394
+ 395
+ 396
+ 397
+ 398
+ 399
+ 400
+ 401
+ 402
+ 403
+ 404
+ 405
+ 406
+ 407
+ 408
+ 409
+ 410
+ 411
+ 412
+ 413
+ 414
+ 415
+ 416
+ 417
+ 418
+ 419
+ 420
+ 421
+ 422
+ 423
+ 424
+ 425
+ 426
+ 427
+ 428
+ 429
+ 430
+ 431
+ 432
+ 433
+ 434
+ 435
+ 436
+ 437
+ 438
+ 439
+ 440
+ 441
+ 442
+ 443
+ 444
+ 445
+ 446
+ 447
+ 448
+ 449
+ 450
+ 451
+ 452
+ 453
+ 454
+ 455
+ 456
+ 457
+ 458
+ 459
+ 460
+ 461
+ 462
+ 463
+ 464
+ 465
+ 466
+ 467
+ 468
+ 469
+ 470
+ 471
+ 472
+ 473
+ 474
+ 475
+ 476
+ 477
+ 478
+ 479
+ 480
+ 481
+ 482
+ 483
+ 484
+ 485
+ 486
+ 487
+ 488
+ 489
+ 490
+ 491
+ 492
+ 493
+ 494
+ 495
+ 496
+ 497
+ 498
+ 499
+ 500
+ 501
+ 502
+ 503
+ 504
+ 505
+ 506
+ 507
+ 508
+ 509
+ 510
+ 511
+ 512
+ 513
+ 514
+ 515
+ 516
+ 517
+ 518
+ 519
+ 520
+ 521
+ 522
+ 523
+ 524
+ 525
+ 526
+ 527
+ 528
+ 529
+ 530
+ 531
+ 532
+ 533
+ 534
+ 535
+ 536
+ 537
+ 538
+ 539
+ 540
+ 541
+ 542
+ 543
+ 544
+ 545
+ 546
+ 547
+ 548
+ 549
+ 550
+ 551
+ 552
+ 553
+ 554
+ 555
+ 556
+ 557
+ 558
+ 559
+ 560
+ 561
+ 562
+ 563
+ 564
+ 565
+ 566
+ 567
+ 568
+ 569
+ 570
+ 571
+ 572
+ 573
+ 574
+ 575
+ 576
+ 577
+ 578
+ 579
+ 580
+ 581
+ 582
+ 583
+ 584
+ 585
+ 586
+ 587
+ 588
+ 589
+ 590
+ 591
+ 592
+ 593
+ 594
+ 595
+ 596
+ 597
+ 598
+ 599
+ 600
+ 601
+ 602
+ 603
+ 604
+ 605
+ 606
+ 607
+ 608
+ 609
+ 610
+ 611
+ 612
+ 613
+ 614
+ 615
+ 616
+ 617
+ 618
+ 619
+ 620
+ 621
+ 622
+ 623
+ 624
+ 625
+ 626
+ 627
+ 628
+ 629
+ 630
+ 631
+ 632
+ 633
+ 634
+ 635
+ 636
+ 637
+ 638
+ 639
+ 640
+ 641
+ 642
+ 643
+ 644
+ 645
+ 646
+ 647
+ 648
+ 649
+ 650
+ 651
+ 652
+ 653
+ 654
+ 655
+ 656
+ 657
+ 658
+ 659
+ 660
+ 661
+ 662
+ 663
+ 664
+ 665
+ 666
+ 667
+ 668
+ 669
+ 670
+ 671
+ 672
+ 673
+ 674
+ 675
+ 676
+ 677
+ 678
+ 679
+ 680
+ 681
+ 682
+ 683
+ 684
+ 685
+ 686
+ 687
+ 688
+ 689
+ 690
+ 691
+ 692
+ 693
+ 694
+ 695
+ 696
+ 697
+ 698
+ 699
+ 700
+ 701
+ 702
+ 703
+ 704
+ 705
+ 706
+ 707
+ 708
+ 709
+ 710
+ 711
+ 712
+ 713
+ 714
+ 715
+ 716
+ 717
+ 718
+ 719
+ 720
+ 721
+ 722
+ 723
+ 724
+ 725
+ 726
+ 727
+ 728
+ 729
+ 730
+ 731
+ 732
+ 733
+ 734
+ 735
+ 736
+ 737
+ 738
+ 739
+ 740
+ 741
+ 742
+ 743
+ 744
+ 745
+ 746
+ 747
+ 748
+ 749
+ 750
+ 751
+ 752
+ 753
+ 754
+ 755
+ 756
+ 757
+ 758
+ 759
+ 760
+ 761
+ 762
+ 763
+ 764
+ 765
+ 766
+ 767
+ 768
+ 769
+ 770
+ 771
+ 772
+ 773
+ 774
+ 775
+ 776
+ 777
+ 778
+ 779
+ 780
+ 781
+ 782
+ 783
+ 784
+ 785
+ 786
+ 787
+ 788
+ 789
+ 790
+ 791
+ 792
+ 793
+ 794
+ 795
+ 796
+ 797
+ 798
+ 799
+ 800
+ 801
+ 802
+ 803
+ 804
+ 805
+ 806
+ 807
+ 808
+ 809
+ 810
+ 811
+ 812
+ 813
+ 814
+ 815
+ 816
+ 817
+ 818
+ 819
+ 820
+ 821
+ 822
+ 823
+ 824
+ 825
+ 826
+ 827
+ 828
+ 829
+ 830
+ 831
+ 832
+ 833
+ 834
+ 835
+ 836
+ 837
+ 838
+ 839
+ 840
+ 841
+ 842
+ 843
+ 844
+ 845
+ 846
+ 847
+ 848
+ 849
+ 850
+ 851
+ 852
+ 853
+ 854
+ 855
+ 856
+ 857
+ 858
+ 859
+ 860
+ 861
+ 862
+ 863
+ 864
+ 865
+ 866
+ 867
+ 868
+ 869
+ 870
+ 871
+ 872
+ 873
+ 874
+ 875
+ 876
+ 877
+ 878
+ 879
+ 880
+ 881
+ 882
+ 883
+ 884
+ 885
+ 886
+ 887
+ 888
+ 889
+ 890
+ 891
+ 892
+ 893
+ 894
+ 895
+ 896
+ 897
+ 898
+ 899
+ 900
+ 901
+ 902
+ 903
+ 904
+ 905
+ 906
+ 907
+ 908
+ 909
+ 910
+ 911
+ 912
+ 913
+ 914
+ 915
+ 916
+ 917
+ 918
+ 919
+ 920
+ 921
+ 922
+ 923
+ 924
+ 925
+ 926
+ 927
+ 928
+ 929
+ 930
+ 931
+ 932
+ 933
+ 934
+ 935
+ 936
+ 937
+ 938
+ 939
+ 940
+ 941
+ 942
+ 943
+ 944
+ 945
+ 946
+ 947
+ 948
+ 949
+ 950
+ 951
+ 952
+ 953
+ 954
+ 955
+ 956
+ 957
+ 958
+ 959
+ 960
+ 961
+ 962
+ 963
+ 964
+ 965
+ 966
+ 967
+ 968
+ 969
+ 970
+ 971
+ 972
+ 973
+ 974
+ 975
+ 976
+ 977
+ 978
+ 979
+ 980
+ 981
+ 982
+ 983
+ 984
+ 985
+ 986
+ 987
+ 988
+ 989
+ 990
+ 991
+ 992
+ 993
+ 994
+ 995
+ 996
+ 997
+ 998
+ 999
+1000
+1001
+1002
+1003
+1004
+1005
+1006
+1007
+1008
+1009
+1010
+1011
+1012
+1013
+1014
+1015
+1016
+1017
+1018
+1019
+1020
+1021
+1022
+1023
+1024
+1025
+1026
+1027
+1028
+1029
+1030
+1031
+1032
+1033
+1034
+1035
+1036
+1037
+1038
+1039
+1040
+1041
+1042
+1043
+1044
+1045
+1046
+1047
+1048
+1049
+1050
+1051
+1052
+1053
+1054
+1055
+1056
+1057
+1058
+1059
+1060
+1061
+1062
+1063
+1064
+1065
+1066
+1067
+1068
+1069
+1070
+1071
+1072
+1073
+1074
+1075
+1076
+1077
+1078
+1079
+1080
+1081
+1082
+1083
+1084
+1085
+1086
+1087
+1088
+1089
+1090
+1091
+1092
+1093
+1094
+1095
+1096
+1097
+1098
+1099
+1100
+1101
+1102
+1103
+1104
+1105
+1106
+1107
+1108
+1109
+1110
+1111
+1112
+1113
+1114
+1115
+1116
+1117
+1118
+1119
+1120
+1121
+1122
+1123
+1124
+1125
+1126
+1127
+1128
+1129
+1130
+1131
+1132
+1133
+1134
+1135
+1136
+1137
+1138
+1139
+1140
+1141
+1142
+1143
+1144
+1145
+1146
+1147
+1148
+1149
+1150
+1151
+1152
+1153
+1154
+1155
+1156
+1157
+1158
+1159
+1160
+1161
+1162
+1163
+1164
+1165
+1166
+1167
+1168
+1169
+1170
+1171
+1172
+1173
+1174
+1175
+1176
+1177
+1178
+1179
+1180
+1181
+1182
+1183
+1184
+1185
+1186
+1187
+1188
+1189
+1190
+1191
+1192
+1193
+1194
+1195
+1196
+1197
+1198
+1199
+1200
+1201
+1202
+1203
+1204
+1205
+1206
+1207
+1208
+1209
+1210
+1211
+1212
+1213
+1214
+1215
+1216
+1217
+1218
+1219
+1220
+1221
+1222
+1223
+1224
+1225
+1226
+1227
+1228
+1229
+1230
+1231
+1232
+1233
+1234
+1235
+1236
+1237
+1238
+1239
+1240
+1241
+1242
+1243
+1244
+1245
+1246
+1247
+1248
+1249
+1250
+1251
+1252
+1253
+1254
+1255
+1256
+1257
+1258
+1259
+1260
+1261
+1262
+1263
+1264
+1265
+1266
+1267
+1268
+1269
+1270
+1271
+1272
+1273
+1274
+1275
+1276
+1277
+1278
+1279
+1280
+1281
+1282
+1283
+1284
+1285
+1286
+1287
+1288
+1289
+1290
+1291
+1292
+1293
+1294
+1295
+1296
+1297
+1298
+1299
+1300
+1301
+1302
+1303
+1304
+1305
+1306
+1307
+1308
+1309
+1310
+1311
+1312
+1313
+1314
+1315
+1316
+1317
+1318
+1319
+1320
+1321
+1322
+1323
+1324
+1325
+1326
+1327
+1328
+1329
+1330
+1331
+1332
+1333
+1334
+1335
+1336
+1337
+1338
+1339
+1340
+1341
+1342
+1343
+1344
+1345
+1346
+1347
+1348
+1349
+1350
+1351
+1352
/*
+ * mate-thumbnail.c: Utilities for handling thumbnails
+ *
+ * Copyright (C) 2002 Red Hat, Inc.
+ * Copyright (C) 2010 Carlos Garcia Campos <carlosgc@gnome.org>
+ *
+ * This file is part of the Mate Library.
+ *
+ * The Mate Library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * The Mate Library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with the Mate Library; see the file COPYING.LIB.  If not,
+ * write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Author: Alexander Larsson <alexl@redhat.com>
+ */
+
+#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gstdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <gdk-pixbuf/gdk-pixbuf.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#define MATE_DESKTOP_USE_UNSTABLE_API
+#include "mate-desktop-thumbnail.h"
+
+static void
+thumbnailers_directory_changed (GFileMonitor                 *monitor,
+                                GFile                        *file,
+                                GFile                        *other_file,
+                                GFileMonitorEvent             event_type,
+                                MateDesktopThumbnailFactory  *factory);
+
+struct _MateDesktopThumbnailFactoryPrivate {
+  MateDesktopThumbnailSize size;
+
+  GMutex lock;
+
+  GList *thumbnailers;
+  GHashTable *mime_types_map;
+  GList *monitors;
+
+  GSettings *settings;
+  gboolean loaded : 1;
+  gboolean disabled : 1;
+  gchar **disabled_types;
+};
+
+static const char *appname = "mate-thumbnail-factory";
+
+G_DEFINE_TYPE_WITH_PRIVATE (MateDesktopThumbnailFactory,<--- There is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
+                            mate_desktop_thumbnail_factory,
+                            G_TYPE_OBJECT)
+
+#define parent_class mate_desktop_thumbnail_factory_parent_class
+
+#define THUMBNAILER_ENTRY_GROUP "Thumbnailer Entry"
+#define THUMBNAILER_EXTENSION   ".thumbnailer"
+
+typedef struct {
+    volatile gint ref_count;
+    gchar  *path;
+    gchar  *try_exec;
+    gchar  *command;
+    gchar **mime_types;
+} Thumbnailer;
+
+static Thumbnailer *
+thumbnailer_ref (Thumbnailer *thumb)
+{
+  g_return_val_if_fail (thumb != NULL, NULL);
+  g_return_val_if_fail (thumb->ref_count > 0, NULL);
+
+  g_atomic_int_inc (&thumb->ref_count);
+  return thumb;
+}
+
+static void
+thumbnailer_unref (Thumbnailer *thumb)
+{
+  g_return_if_fail (thumb != NULL);
+  g_return_if_fail (thumb->ref_count > 0);
+
+  if (g_atomic_int_dec_and_test (&thumb->ref_count))
+    {
+      g_free (thumb->path);
+      g_free (thumb->try_exec);
+      g_free (thumb->command);
+      g_strfreev (thumb->mime_types);
+      g_slice_free (Thumbnailer, thumb);
+    }
+}
+
+static Thumbnailer *
+thumbnailer_load (Thumbnailer *thumb)
+{
+  GKeyFile *key_file;
+  GError *error = NULL;
+
+  key_file = g_key_file_new ();
+  if (!g_key_file_load_from_file (key_file, thumb->path, 0, &error))
+    {
+      g_warning ("Failed to load thumbnailer from \"%s\": %s\n", thumb->path, error->message);
+      g_error_free (error);
+      thumbnailer_unref (thumb);
+      g_key_file_free (key_file);
+
+      return NULL;
+    }
+
+  if (!g_key_file_has_group (key_file, THUMBNAILER_ENTRY_GROUP))
+    {
+      g_warning ("Invalid thumbnailer: missing group \"%s\"\n", THUMBNAILER_ENTRY_GROUP);
+      thumbnailer_unref (thumb);
+      g_key_file_free (key_file);
+
+      return NULL;
+    }
+
+  thumb->command = g_key_file_get_string (key_file, THUMBNAILER_ENTRY_GROUP, "Exec", NULL);
+  if (!thumb->command)
+    {
+      g_warning ("Invalid thumbnailer: missing Exec key\n");
+      thumbnailer_unref (thumb);
+      g_key_file_free (key_file);
+
+      return NULL;
+    }
+
+  thumb->mime_types = g_key_file_get_string_list (key_file, THUMBNAILER_ENTRY_GROUP, "MimeType", NULL, NULL);
+  if (!thumb->mime_types)
+    {
+      g_warning ("Invalid thumbnailer: missing MimeType key\n");
+      thumbnailer_unref (thumb);
+      g_key_file_free (key_file);
+
+      return NULL;
+    }
+
+  thumb->try_exec = g_key_file_get_string (key_file, THUMBNAILER_ENTRY_GROUP, "TryExec", NULL);
+
+  g_key_file_free (key_file);
+
+  return thumb;
+}
+
+static Thumbnailer *
+thumbnailer_reload (Thumbnailer *thumb)
+{
+  g_return_val_if_fail (thumb != NULL, NULL);
+
+  g_free (thumb->command);
+  thumb->command = NULL;
+  g_strfreev (thumb->mime_types);
+  thumb->mime_types = NULL;
+  g_free (thumb->try_exec);
+  thumb->try_exec = NULL;
+
+  return thumbnailer_load (thumb);
+}
+
+static Thumbnailer *
+thumbnailer_new (const gchar *path)
+{
+  Thumbnailer *thumb;
+
+  thumb = g_slice_new0 (Thumbnailer);
+  thumb->ref_count = 1;
+  thumb->path = g_strdup (path);
+
+  return thumbnailer_load (thumb);
+}
+
+static gboolean
+thumbnailer_try_exec (Thumbnailer *thumb)
+{
+  gchar *path;
+  gboolean retval;
+
+  if (G_UNLIKELY (!thumb))
+    return FALSE;
+
+  /* TryExec is optional, but Exec isn't, so we assume
+   * the thumbnailer can be run when TryExec is not present
+   */
+  if (!thumb->try_exec)
+    return TRUE;
+
+  path = g_find_program_in_path (thumb->try_exec);
+  retval = path != NULL;
+  g_free (path);
+
+  return retval;
+}
+
+static gpointer
+init_thumbnailers_dirs (gpointer data)
+{
+  const gchar * const *data_dirs;
+  GPtrArray *thumbs_dirs;
+  guint i;
+
+  data_dirs = g_get_system_data_dirs ();
+  thumbs_dirs = g_ptr_array_new ();
+
+  g_ptr_array_add (thumbs_dirs, g_build_filename (g_get_user_data_dir (), "thumbnailers", NULL));
+  for (i = 0; data_dirs[i] != NULL; i++)
+    g_ptr_array_add (thumbs_dirs, g_build_filename (data_dirs[i], "thumbnailers", NULL));
+  g_ptr_array_add (thumbs_dirs, NULL);
+
+  return g_ptr_array_free (thumbs_dirs, FALSE);
+}
+
+static const gchar * const *
+get_thumbnailers_dirs (void)
+{
+  static GOnce once_init = G_ONCE_INIT;
+  return g_once (&once_init, init_thumbnailers_dirs, NULL);
+}
+
+/* These should be called with the lock held */
+static void
+mate_desktop_thumbnail_factory_register_mime_types (MateDesktopThumbnailFactory *factory,
+                                                     Thumbnailer                  *thumb)
+{
+  MateDesktopThumbnailFactoryPrivate *priv = factory->priv;
+  gint i;
+
+  for (i = 0; thumb->mime_types[i]; i++)
+    {
+      if (!g_hash_table_lookup (priv->mime_types_map, thumb->mime_types[i]))
+        g_hash_table_insert (priv->mime_types_map,
+                             g_strdup (thumb->mime_types[i]),
+                             thumbnailer_ref (thumb));
+    }
+}
+
+static void
+mate_desktop_thumbnail_factory_add_thumbnailer (MateDesktopThumbnailFactory *factory,
+                                                 Thumbnailer                  *thumb)
+{
+  MateDesktopThumbnailFactoryPrivate *priv = factory->priv;
+
+  mate_desktop_thumbnail_factory_register_mime_types (factory, thumb);
+  priv->thumbnailers = g_list_prepend (priv->thumbnailers, thumb);
+}
+
+static gboolean
+mate_desktop_thumbnail_factory_is_disabled (MateDesktopThumbnailFactory *factory,
+                                             const gchar                  *mime_type)
+{
+  MateDesktopThumbnailFactoryPrivate *priv = factory->priv;
+  guint i;
+
+  if (priv->disabled)
+    return TRUE;
+
+  if (!priv->disabled_types)
+    return FALSE;
+
+  for (i = 0; priv->disabled_types[i]; i++)
+    {
+      if (g_strcmp0 (priv->disabled_types[i], mime_type) == 0)
+        return TRUE;
+    }
+
+  return FALSE;
+}
+
+static gboolean
+remove_thumbnailer_from_mime_type_map (gchar       *key,
+                                       Thumbnailer *value,
+                                       gchar       *path)
+{
+  return (strcmp (value->path, path) == 0);
+}
+
+static void
+update_or_create_thumbnailer (MateDesktopThumbnailFactory *factory,
+                              const gchar                 *path)
+{
+  MateDesktopThumbnailFactoryPrivate *priv = factory->priv;
+  GList *l;
+  Thumbnailer *thumb;
+  gboolean found = FALSE;
+
+  g_mutex_lock (&priv->lock);
+
+  for (l = priv->thumbnailers; l && !found; l = g_list_next (l))
+    {
+      thumb = (Thumbnailer *)l->data;
+
+      if (strcmp (thumb->path, path) == 0)
+        {
+          found = TRUE;
+
+          /* First remove the mime_types associated to this thumbnailer */
+          g_hash_table_foreach_remove (priv->mime_types_map,
+                                       (GHRFunc)remove_thumbnailer_from_mime_type_map,
+                                       (gpointer)path);
+          if (!thumbnailer_reload (thumb))
+              priv->thumbnailers = g_list_delete_link (priv->thumbnailers, l);
+          else
+              mate_desktop_thumbnail_factory_register_mime_types (factory, thumb);
+        }
+    }
+
+  if (!found)
+    {
+      thumb = thumbnailer_new (path);
+      if (thumb)
+        mate_desktop_thumbnail_factory_add_thumbnailer (factory, thumb);
+    }
+
+  g_mutex_unlock (&priv->lock);
+}
+
+static void
+remove_thumbnailer (MateDesktopThumbnailFactory *factory,
+                    const gchar                 *path)
+{
+  MateDesktopThumbnailFactoryPrivate *priv = factory->priv;
+  GList *l;
+  Thumbnailer *thumb;
+
+  g_mutex_lock (&priv->lock);
+
+  for (l = priv->thumbnailers; l; l = g_list_next (l))
+    {
+      thumb = (Thumbnailer *)l->data;
+
+      if (strcmp (thumb->path, path) == 0)
+        {
+          priv->thumbnailers = g_list_delete_link (priv->thumbnailers, l);
+          g_hash_table_foreach_remove (priv->mime_types_map,
+                                       (GHRFunc)remove_thumbnailer_from_mime_type_map,
+                                       (gpointer)path);
+          thumbnailer_unref (thumb);
+
+          break;
+        }
+    }
+
+  g_mutex_unlock (&priv->lock);
+}
+
+static void
+remove_thumbnailers_for_dir (MateDesktopThumbnailFactory *factory,
+                             const gchar                 *thumbnailer_dir,
+                             GFileMonitor                *monitor)
+{
+  MateDesktopThumbnailFactoryPrivate *priv = factory->priv;
+  GList *l;
+  Thumbnailer *thumb;
+
+  g_mutex_lock (&priv->lock);
+
+  /* Remove all the thumbnailers inside this @thumbnailer_dir. */
+  for (l = priv->thumbnailers; l; l = g_list_next (l))
+    {
+      thumb = (Thumbnailer *)l->data;
+
+      if (g_str_has_prefix (thumb->path, thumbnailer_dir) == TRUE)
+        {
+          priv->thumbnailers = g_list_delete_link (priv->thumbnailers, l);
+          g_hash_table_foreach_remove (priv->mime_types_map,
+                                       (GHRFunc)remove_thumbnailer_from_mime_type_map,
+                                       (gpointer)thumb->path);
+          thumbnailer_unref (thumb);
+
+          break;
+        }
+    }
+
+  /* Remove the monitor for @thumbnailer_dir. */
+  priv->monitors = g_list_remove (priv->monitors, monitor);
+  g_signal_handlers_disconnect_by_func (monitor, thumbnailers_directory_changed, factory);
+
+  g_mutex_unlock (&priv->lock);
+}
+
+static void
+mate_desktop_thumbnail_factory_load_thumbnailers_for_dir (MateDesktopThumbnailFactory *factory,
+                                                          const gchar                 *path)
+{
+  MateDesktopThumbnailFactoryPrivate *priv = factory->priv;
+  GDir *dir;
+  GFile *dir_file;
+  GFileMonitor *monitor;
+  const gchar *dirent;
+
+  dir = g_dir_open (path, 0, NULL);
+  if (!dir)
+      return;
+
+  /* Monitor dir */
+  dir_file = g_file_new_for_path (path);
+  monitor = g_file_monitor_directory (dir_file,
+                                      G_FILE_MONITOR_NONE,
+                                      NULL, NULL);
+  if (monitor)
+    {
+      g_signal_connect (monitor, "changed",
+                        G_CALLBACK (thumbnailers_directory_changed),
+                        factory);
+      priv->monitors = g_list_prepend (priv->monitors, monitor);
+    }
+  g_object_unref (dir_file);
+
+  while ((dirent = g_dir_read_name (dir)))
+    {
+      Thumbnailer *thumb;
+      gchar       *filename;
+
+      if (!g_str_has_suffix (dirent, THUMBNAILER_EXTENSION))
+          continue;
+
+      filename = g_build_filename (path, dirent, NULL);
+      thumb = thumbnailer_new (filename);
+      g_free (filename);
+
+      if (thumb)
+          mate_desktop_thumbnail_factory_add_thumbnailer (factory, thumb);
+    }
+
+  g_dir_close (dir);
+}
+
+static void
+thumbnailers_directory_changed (GFileMonitor                *monitor,
+                                GFile                       *file,
+                                GFile                       *other_file,
+                                GFileMonitorEvent            event_type,
+                                MateDesktopThumbnailFactory *factory)
+{
+  gchar *path;
+
+  switch (event_type)
+    {
+    case G_FILE_MONITOR_EVENT_CREATED:
+    case G_FILE_MONITOR_EVENT_CHANGED:
+    case G_FILE_MONITOR_EVENT_DELETED:
+      path = g_file_get_path (file);
+      if (!g_str_has_suffix (path, THUMBNAILER_EXTENSION))
+        {
+          g_free (path);
+          return;
+        }
+
+      if (event_type == G_FILE_MONITOR_EVENT_DELETED)
+        remove_thumbnailer (factory, path);
+      else
+        update_or_create_thumbnailer (factory, path);
+
+      g_free (path);
+      break;
+    case G_FILE_MONITOR_EVENT_UNMOUNTED:
+    case G_FILE_MONITOR_EVENT_MOVED:
+      path = g_file_get_path (file);
+      remove_thumbnailers_for_dir (factory, path, monitor);
+
+      if (event_type == G_FILE_MONITOR_EVENT_MOVED)
+          mate_desktop_thumbnail_factory_load_thumbnailers_for_dir (factory, path);
+
+      g_free (path);
+      break;
+    case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT:
+    case G_FILE_MONITOR_EVENT_ATTRIBUTE_CHANGED:
+    case G_FILE_MONITOR_EVENT_PRE_UNMOUNT:
+    default:
+      break;
+    }
+}
+
+static void
+mate_desktop_thumbnail_factory_load_thumbnailers (MateDesktopThumbnailFactory *factory)
+{
+  MateDesktopThumbnailFactoryPrivate *priv = factory->priv;
+  const gchar * const *dirs;
+  guint i;
+
+  if (priv->loaded)
+    return;
+
+  dirs = get_thumbnailers_dirs ();
+  for (i = 0; dirs[i]; i++)
+    {
+      mate_desktop_thumbnail_factory_load_thumbnailers_for_dir (factory, dirs[i]);
+    }
+
+  priv->loaded = TRUE;
+}
+
+static void
+external_thumbnailers_disabled_all_changed_cb (GSettings                   *settings,
+                                               const gchar                 *key,
+                                               MateDesktopThumbnailFactory *factory)
+{
+  MateDesktopThumbnailFactoryPrivate *priv = factory->priv;
+
+  g_mutex_lock (&priv->lock);
+
+  priv->disabled = g_settings_get_boolean (priv->settings, "disable-all");
+  if (priv->disabled)
+    {
+      g_strfreev (priv->disabled_types);
+      priv->disabled_types = NULL;
+    }
+  else
+    {
+      priv->disabled_types = g_settings_get_strv (priv->settings, "disable");
+      mate_desktop_thumbnail_factory_load_thumbnailers (factory);
+    }
+
+  g_mutex_unlock (&priv->lock);
+}
+
+static void
+external_thumbnailers_disabled_changed_cb (GSettings                   *settings,
+                                           const gchar                 *key,
+                                           MateDesktopThumbnailFactory *factory)
+{
+  MateDesktopThumbnailFactoryPrivate *priv = factory->priv;
+
+  g_mutex_lock (&priv->lock);
+
+  if (!priv->disabled)
+    {
+      g_strfreev (priv->disabled_types);
+      priv->disabled_types = g_settings_get_strv (priv->settings, "disable");
+    }
+
+  g_mutex_unlock (&priv->lock);
+}
+
+static void
+mate_desktop_thumbnail_factory_init (MateDesktopThumbnailFactory *factory)
+{
+  MateDesktopThumbnailFactoryPrivate *priv;
+
+  factory->priv = mate_desktop_thumbnail_factory_get_instance_private (factory);
+
+  priv = factory->priv;
+
+  priv->size = MATE_DESKTOP_THUMBNAIL_SIZE_NORMAL;
+
+  priv->mime_types_map = g_hash_table_new_full (g_str_hash,
+                                                g_str_equal,
+                                                (GDestroyNotify)g_free,
+                                                (GDestroyNotify)thumbnailer_unref);
+
+  g_mutex_init (&priv->lock);
+
+  priv->settings = g_settings_new ("org.mate.thumbnailers");
+
+  g_signal_connect (priv->settings, "changed::disable-all",
+                    G_CALLBACK (external_thumbnailers_disabled_all_changed_cb),
+                    factory);
+  g_signal_connect (priv->settings, "changed::disable",
+                    G_CALLBACK (external_thumbnailers_disabled_changed_cb),
+                    factory);
+
+  priv->disabled = g_settings_get_boolean (priv->settings, "disable-all");
+
+  if (!priv->disabled)
+    priv->disabled_types = g_settings_get_strv (priv->settings, "disable");
+
+  if (!priv->disabled)
+    mate_desktop_thumbnail_factory_load_thumbnailers (factory);
+}
+
+static void
+mate_desktop_thumbnail_factory_finalize (GObject *object)
+{
+  MateDesktopThumbnailFactory *factory;
+  MateDesktopThumbnailFactoryPrivate *priv;
+
+  factory = MATE_DESKTOP_THUMBNAIL_FACTORY (object);
+
+  priv = factory->priv;
+
+  if (priv->thumbnailers)
+    {
+      g_list_free_full (priv->thumbnailers, (GDestroyNotify)thumbnailer_unref);
+      priv->thumbnailers = NULL;
+    }
+
+  g_clear_pointer (&priv->mime_types_map, g_hash_table_destroy);
+
+  if (priv->monitors)
+    {
+      g_list_free_full (priv->monitors, (GDestroyNotify)g_object_unref);
+      priv->monitors = NULL;
+    }
+
+  g_mutex_clear (&priv->lock);
+
+  g_clear_pointer (&priv->disabled_types, g_strfreev);
+
+  if (priv->settings)
+    {
+      g_signal_handlers_disconnect_by_func (priv->settings,
+                                            external_thumbnailers_disabled_all_changed_cb,
+                                            factory);
+      g_signal_handlers_disconnect_by_func (priv->settings,
+                                            external_thumbnailers_disabled_changed_cb,
+                                            factory);
+      g_clear_object (&priv->settings);
+    }
+
+  if (G_OBJECT_CLASS (parent_class)->finalize)
+    (* G_OBJECT_CLASS (parent_class)->finalize) (object);
+}
+
+static void
+mate_desktop_thumbnail_factory_class_init (MateDesktopThumbnailFactoryClass *class)
+{
+  GObjectClass *gobject_class;
+
+  gobject_class = G_OBJECT_CLASS (class);
+
+  gobject_class->finalize = mate_desktop_thumbnail_factory_finalize;
+}
+
+/**
+ * mate_desktop_thumbnail_factory_new:
+ * @size: The thumbnail size to use
+ *
+ * Creates a new #MateDesktopThumbnailFactory.
+ *
+ * This function must be called on the main thread.
+ *
+ * Return value: a new #MateDesktopThumbnailFactory
+ *
+ * Since: 2.2
+ **/
+MateDesktopThumbnailFactory *
+mate_desktop_thumbnail_factory_new (MateDesktopThumbnailSize size)
+{
+  MateDesktopThumbnailFactory *factory;
+
+  factory = g_object_new (MATE_DESKTOP_TYPE_THUMBNAIL_FACTORY, NULL);
+
+  factory->priv->size = size;
+
+  return factory;
+}
+
+static char *
+thumbnail_filename (const char *uri)
+{
+  GChecksum *checksum;
+  guint8 digest[16];
+  gsize digest_len = sizeof (digest);
+  char *file;
+
+  checksum = g_checksum_new (G_CHECKSUM_MD5);
+  g_checksum_update (checksum, (const guchar *) uri, strlen (uri));
+
+  g_checksum_get_digest (checksum, digest, &digest_len);
+  g_assert (digest_len == 16);
+
+  file = g_strconcat (g_checksum_get_string (checksum), ".png", NULL);
+
+  g_checksum_free (checksum);
+
+  return file;
+}
+
+static char *
+thumbnail_path (const char               *uri,
+                MateDesktopThumbnailSize  size)
+{
+  char *path, *file;
+
+  file = thumbnail_filename (uri);
+  path = g_build_filename (g_get_user_cache_dir (),
+                           "thumbnails",
+                           size == MATE_DESKTOP_THUMBNAIL_SIZE_LARGE ? "large" : "normal",
+                           file,
+                           NULL);
+  g_free (file);
+  return path;
+}
+
+static char *
+thumbnail_failed_path (const char *uri)
+{
+  char *path, *file;
+
+  file = thumbnail_filename (uri);
+  /* XXX: appname is only used for failed thumbnails. Is this a mistake? */
+  path = g_build_filename (g_get_user_cache_dir (),
+                           "thumbnails",
+                           "fail",
+                           appname,
+                           file,
+                           NULL);
+  g_free (file);
+  return path;
+}
+
+static char *
+validate_thumbnail_path (char                     *path,
+                         const char               *uri,
+                         time_t                    mtime,
+                         MateDesktopThumbnailSize  size)
+{
+  GdkPixbuf *pixbuf;
+
+  pixbuf = gdk_pixbuf_new_from_file (path, NULL);
+  if (pixbuf == NULL ||
+      !mate_desktop_thumbnail_is_valid (pixbuf, uri, mtime)) {
+      g_free (path);
+      return NULL;
+  }
+
+  g_clear_object (&pixbuf);
+
+  return path;
+}
+
+static char *
+lookup_thumbnail_path (const char               *uri,
+                       time_t                    mtime,
+                       MateDesktopThumbnailSize  size)
+{
+  char *path = thumbnail_path (uri, size);
+  return validate_thumbnail_path (path, uri, mtime, size);
+}
+
+static char *
+lookup_failed_thumbnail_path (const char               *uri,
+                              time_t                    mtime,
+                              MateDesktopThumbnailSize  size)
+{
+  char *path = thumbnail_failed_path (uri);
+  return validate_thumbnail_path (path, uri, mtime, size);
+}
+
+/**
+ * mate_desktop_thumbnail_factory_lookup:
+ * @factory: a #MateDesktopThumbnailFactory
+ * @uri: the uri of a file
+ * @mtime: the mtime of the file
+ *
+ * Tries to locate an existing thumbnail for the file specified.
+ *
+ * Usage of this function is threadsafe.
+ *
+ * Return value: (transfer full): The absolute path of the thumbnail, or %NULL if none exist.
+ *
+ * Since: 2.2
+ **/
+char *
+mate_desktop_thumbnail_factory_lookup (MateDesktopThumbnailFactory *factory,
+                                       const char                  *uri,
+                                       time_t                       mtime)
+{
+  MateDesktopThumbnailFactoryPrivate *priv = factory->priv;
+
+  g_return_val_if_fail (uri != NULL, NULL);
+
+  return lookup_thumbnail_path (uri, mtime, priv->size);
+}
+
+/**
+ * mate_desktop_thumbnail_factory_has_valid_failed_thumbnail:
+ * @factory: a #MateDesktopThumbnailFactory
+ * @uri: the uri of a file
+ * @mtime: the mtime of the file
+ *
+ * Tries to locate an failed thumbnail for the file specified. Writing
+ * and looking for failed thumbnails is important to avoid to try to
+ * thumbnail e.g. broken images several times.
+ *
+ * Usage of this function is threadsafe.
+ *
+ * Return value: TRUE if there is a failed thumbnail for the file.
+ *
+ * Since: 2.2
+ **/
+gboolean
+mate_desktop_thumbnail_factory_has_valid_failed_thumbnail (MateDesktopThumbnailFactory *factory,
+                                                           const char                  *uri,
+                                                           time_t                       mtime)
+{
+  char *path;
+
+  g_return_val_if_fail (uri != NULL, FALSE);
+
+  path = lookup_failed_thumbnail_path (uri, mtime, factory->priv->size);
+  if (path == NULL)
+    return FALSE;
+
+  g_free (path);
+
+  return TRUE;
+}
+
+/**
+ * mate_desktop_thumbnail_factory_can_thumbnail:
+ * @factory: a #MateDesktopThumbnailFactory
+ * @uri: the uri of a file
+ * @mime_type: the mime type of the file
+ * @mtime: the mtime of the file
+ *
+ * Returns TRUE if this MateDesktopThumbnailFactory can (at least try) to thumbnail
+ * this file. Thumbnails or files with failed thumbnails won't be thumbnailed.
+ *
+ * Usage of this function is threadsafe.
+ *
+ * Return value: TRUE if the file can be thumbnailed.
+ *
+ * Since: 2.2
+ **/
+gboolean
+mate_desktop_thumbnail_factory_can_thumbnail (MateDesktopThumbnailFactory *factory,
+                                              const char                  *uri,
+                                              const char                  *mime_type,
+                                              time_t                       mtime)
+{
+  gboolean have_script = FALSE;
+
+  /* Don't thumbnail thumbnails */
+  if (uri &&
+      strncmp (uri, "file:/", 6) == 0 &&
+      (strstr (uri, "/.thumbnails/") != NULL ||
+      strstr (uri, "/.cache/thumbnails/") != NULL))
+    return FALSE;
+
+  if (!mime_type)
+    return FALSE;
+
+  g_mutex_lock (&factory->priv->lock);
+  if (!mate_desktop_thumbnail_factory_is_disabled (factory, mime_type))
+    {
+      Thumbnailer *thumb;
+
+      thumb = g_hash_table_lookup (factory->priv->mime_types_map, mime_type);
+      have_script = thumbnailer_try_exec (thumb);
+    }
+  g_mutex_unlock (&factory->priv->lock);
+
+  if (uri && (have_script ))
+    {
+      return !mate_desktop_thumbnail_factory_has_valid_failed_thumbnail (factory,
+                                                                         uri,
+                                                                         mtime);
+    }
+
+  return FALSE;
+}
+
+static char *
+expand_thumbnailing_elem (const char *elem,
+                          const int   size,
+                          const char *inuri,
+                          const char *outfile,
+                          gboolean   *got_input,
+                          gboolean   *got_output)
+{
+  GString *str;
+  const char *p, *last;
+  char *localfile;
+
+  str = g_string_new (NULL);
+
+  last = elem;
+  while ((p = strchr (last, '%')) != NULL)
+    {
+      g_string_append_len (str, last, p - last);
+      p++;
+
+      switch (*p) {
+      case 'u':
+       g_string_append (str, inuri);
+       *got_input = TRUE;
+       p++;
+       break;
+      case 'i':
+       localfile = g_filename_from_uri (inuri, NULL, NULL);
+       if (localfile)
+         {
+           g_string_append (str, localfile);
+           *got_input = TRUE;
+           g_free (localfile);
+         }
+       p++;
+       break;
+      case 'o':
+       g_string_append (str, outfile);
+       *got_output = TRUE;
+       p++;
+       break;
+      case 's':
+       g_string_append_printf (str, "%d", size);
+       p++;
+       break;
+      case '%':
+       g_string_append_c (str, '%');
+       p++;
+       break;
+      case 0:
+      default:
+        break;
+      }
+      last = p;
+    }
+  g_string_append (str, last);
+
+  return g_string_free (str, FALSE);
+}
+
+static char **
+expand_thumbnailing_script (const char  *script,
+                            const int    size,
+                            const char  *inuri,
+                            const char  *outfile,
+                            GError     **error)
+{
+  GPtrArray *array;
+  char **script_elems;
+  guint i;
+  gboolean got_in, got_out;
+
+  if (!g_shell_parse_argv (script, NULL, &script_elems, error))
+    return NULL;
+
+  array = g_ptr_array_new_with_free_func (g_free);
+
+  got_in = got_out = FALSE;
+  for (i = 0; script_elems[i] != NULL; i++)
+    {
+      char *expanded;
+
+      expanded = expand_thumbnailing_elem (script_elems[i],
+                                           size,
+                                           inuri,
+                                           outfile,
+                                           &got_in,
+                                           &got_out);
+
+      g_ptr_array_add (array, expanded);
+    }
+  g_strfreev (script_elems);
+
+  if (!got_in)
+    {
+      g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+                           "Input file could not be set");
+      goto bail;
+    }
+  else if (!got_out)
+    {
+      g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+                           "Output file could not be set");
+      goto bail;
+    }
+
+  g_ptr_array_add (array, NULL);
+
+  return (char **) g_ptr_array_free (array, FALSE);
+
+bail:
+  g_ptr_array_free (array, TRUE);
+  return NULL;
+}
+
+static GdkPixbuf *
+get_preview_thumbnail (const char *uri,
+                       int         size)
+{
+    GdkPixbuf *pixbuf;
+    GFile *file;
+    GFileInfo *file_info;
+    GInputStream *input_stream;
+    GObject *object;
+
+    g_return_val_if_fail (uri != NULL, NULL);
+
+    input_stream = NULL;
+
+    file = g_file_new_for_uri (uri);
+
+    /* First see if we can get an input stream via preview::icon  */
+    file_info = g_file_query_info (file,
+                                   G_FILE_ATTRIBUTE_PREVIEW_ICON,
+                                   G_FILE_QUERY_INFO_NONE,
+                                   NULL,  /* GCancellable */
+                                   NULL); /* return location for GError */
+    g_object_unref (file);
+
+    if (file_info == NULL)
+      return NULL;
+
+    object = g_file_info_get_attribute_object (file_info,
+                                               G_FILE_ATTRIBUTE_PREVIEW_ICON);
+    if (object)
+        g_object_ref (object);
+    g_object_unref (file_info);
+
+    if (!object)
+      return NULL;
+    if (!G_IS_LOADABLE_ICON (object)) {
+      g_object_unref (object);
+      return NULL;
+    }
+
+    input_stream = g_loadable_icon_load (G_LOADABLE_ICON (object),
+                                         0,     /* size */
+                                         NULL,  /* return location for type */
+                                         NULL,  /* GCancellable */
+                                         NULL); /* return location for GError */
+    g_object_unref (object);
+
+    if (!input_stream)
+      return NULL;
+
+    pixbuf = gdk_pixbuf_new_from_stream_at_scale (input_stream,
+                                                  size, size,
+                                                  TRUE, NULL, NULL);
+    g_object_unref (input_stream);
+
+    return pixbuf;
+}
+
+/**
+ * mate_desktop_thumbnail_factory_generate_thumbnail:
+ * @factory: a #MateDesktopThumbnailFactory
+ * @uri: the uri of a file
+ * @mime_type: the mime type of the file
+ *
+ * Tries to generate a thumbnail for the specified file. If it succeeds
+ * it returns a pixbuf that can be used as a thumbnail.
+ *
+ * Usage of this function is threadsafe.
+ *
+ * Return value: (transfer full): thumbnail pixbuf if thumbnailing succeeded, %NULL otherwise.
+ *
+ * Since: 2.2
+ **/
+GdkPixbuf *
+mate_desktop_thumbnail_factory_generate_thumbnail (MateDesktopThumbnailFactory *factory,
+                                                   const char                  *uri,
+                                                   const char                  *mime_type)
+{
+  GdkPixbuf *pixbuf;
+  char *script;
+  int size;
+  int exit_status;
+  char *tmpname;
+
+  g_return_val_if_fail (uri != NULL, NULL);
+  g_return_val_if_fail (mime_type != NULL, NULL);
+
+  /* Doesn't access any volatile fields in factory, so it's threadsafe */
+
+  size = 128;
+  if (factory->priv->size == MATE_DESKTOP_THUMBNAIL_SIZE_LARGE)
+    size = 256;
+
+  pixbuf = NULL;
+
+  pixbuf = get_preview_thumbnail (uri, size);
+  if (pixbuf != NULL)
+    return pixbuf;
+
+  script = NULL;
+  g_mutex_lock (&factory->priv->lock);
+  if (!mate_desktop_thumbnail_factory_is_disabled (factory, mime_type))
+    {
+      Thumbnailer *thumb;
+
+      thumb = g_hash_table_lookup (factory->priv->mime_types_map, mime_type);
+      if (thumb)
+        script = g_strdup (thumb->command);
+    }
+  g_mutex_unlock (&factory->priv->lock);
+
+  if (script)
+    {
+      int fd;
+
+      fd = g_file_open_tmp (".mate_desktop_thumbnail.XXXXXX", &tmpname, NULL);
+
+      if (fd != -1)
+    {
+      char **expanded_script;
+      GError *error = NULL;
+
+      close (fd);
+
+      expanded_script = expand_thumbnailing_script (script, size, uri, tmpname, &error);
+      if (expanded_script == NULL)
+        {
+          g_warning ("Failed to expand script '%s': %s", script, error->message);
+          g_error_free (error);
+        }
+      else
+        {
+          gboolean ret;
+
+          ret = g_spawn_sync (NULL, expanded_script, NULL, G_SPAWN_SEARCH_PATH,
+                              NULL, NULL, NULL, NULL, &exit_status, NULL);
+          if (ret && exit_status == 0)
+            pixbuf = gdk_pixbuf_new_from_file (tmpname, NULL);
+
+          g_strfreev (expanded_script);
+        }
+
+      g_unlink (tmpname);
+      g_free (tmpname);
+    }
+
+      g_free (script);
+    }
+
+  return pixbuf;
+}
+
+static gboolean
+save_thumbnail (GdkPixbuf  *pixbuf,
+                char       *path,
+                const char *uri,
+                time_t      mtime)
+{
+  char *dirname;
+  char *tmp_path = NULL;
+  int tmp_fd;
+  gchar *mtime_str;
+  gboolean ret = FALSE;
+  GError *error = NULL;
+  const char *width, *height;
+
+  if (pixbuf == NULL)
+    return FALSE;
+
+  dirname = g_path_get_dirname (path);
+
+  if (g_mkdir_with_parents (dirname, 0700) != 0)
+
+    goto out;
+
+  tmp_path = g_strconcat (path, ".XXXXXX", NULL);
+  tmp_fd = g_mkstemp (tmp_path);
+
+  if (tmp_fd == -1)
+    goto out;
+  close (tmp_fd);
+
+  mtime_str = g_strdup_printf ("%" G_GINT64_FORMAT,  (gint64) mtime);
+  width = gdk_pixbuf_get_option (pixbuf, "tEXt::Thumb::Image::Width");
+  height = gdk_pixbuf_get_option (pixbuf, "tEXt::Thumb::Image::Height");
+
+  error = NULL;
+  if (width != NULL && height != NULL)
+    ret = gdk_pixbuf_save (pixbuf,
+                           tmp_path,
+                           "png", &error,
+                           "tEXt::Thumb::Image::Width", width,
+                           "tEXt::Thumb::Image::Height", height,
+                           "tEXt::Thumb::URI", uri,
+                           "tEXt::Thumb::MTime", mtime_str,
+                           "tEXt::Software", "MATE::ThumbnailFactory",
+                           NULL);
+  else
+    ret = gdk_pixbuf_save (pixbuf,
+                           tmp_path,
+                           "png", &error,
+                           "tEXt::Thumb::URI", uri,
+                           "tEXt::Thumb::MTime", mtime_str,
+                           "tEXt::Software", "MATE::ThumbnailFactory",
+                           NULL);
+  g_free (mtime_str);
+
+  if (!ret)
+    goto out;
+
+  g_chmod (tmp_path, 0600);
+  g_rename (tmp_path, path);
+
+ out:
+  if (error != NULL)
+    {
+      g_warning ("Failed to create thumbnail %s: %s", tmp_path, error->message);
+      g_error_free (error);
+    }
+  g_unlink (tmp_path);
+  g_free (tmp_path);
+  g_free (dirname);
+  return ret;
+}
+
+static GdkPixbuf *
+make_failed_thumbnail (void)
+{
+  GdkPixbuf *pixbuf;
+
+  pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, 1, 1);
+  gdk_pixbuf_fill (pixbuf, 0x00000000);
+  return pixbuf;
+}
+
+/**
+ * mate_desktop_thumbnail_factory_save_thumbnail:
+ * @factory: a #MateDesktopThumbnailFactory
+ * @thumbnail: the thumbnail as a pixbuf
+ * @uri: the uri of a file
+ * @original_mtime: the modification time of the original file
+ *
+ * Saves @thumbnail at the right place. If the save fails a
+ * failed thumbnail is written.
+ *
+ * Usage of this function is threadsafe.
+ *
+ * Since: 2.2
+ **/
+void
+mate_desktop_thumbnail_factory_save_thumbnail (MateDesktopThumbnailFactory *factory,
+                                               GdkPixbuf                   *thumbnail,
+                                               const char                  *uri,
+                                               time_t                       original_mtime)
+{
+  char *path;
+
+  path = thumbnail_path (uri, factory->priv->size);
+  if (!save_thumbnail (thumbnail, path, uri, original_mtime))
+    {
+      thumbnail = make_failed_thumbnail ();
+      g_free (path);
+      path = thumbnail_failed_path (uri);
+      save_thumbnail (thumbnail, path, uri, original_mtime);
+      g_object_unref (thumbnail);
+    }
+  g_free (path);
+}
+
+/**
+ * mate_desktop_thumbnail_factory_create_failed_thumbnail:
+ * @factory: a #MateDesktopThumbnailFactory
+ * @uri: the uri of a file
+ * @mtime: the modification time of the file
+ *
+ * Creates a failed thumbnail for the file so that we don't try
+ * to re-thumbnail the file later.
+ *
+ * Usage of this function is threadsafe.
+ *
+ * Since: 2.2
+ **/
+void
+mate_desktop_thumbnail_factory_create_failed_thumbnail (MateDesktopThumbnailFactory *factory,
+                                                        const char                  *uri,
+                                                        time_t                      mtime)
+{
+  char *path;
+  GdkPixbuf *pixbuf;
+
+  path = thumbnail_failed_path (uri);
+  pixbuf = make_failed_thumbnail ();
+  save_thumbnail (pixbuf, path, uri, mtime);
+
+  g_free (path);
+  g_object_unref (pixbuf);
+}
+
+/**
+ * mate_desktop_thumbnail_path_for_uri:
+ * @uri: an uri
+ * @size: a thumbnail size
+ *
+ * Returns the filename that a thumbnail of size @size for @uri would have.
+ *
+ * Return value: an absolute filename
+ *
+ * Since: 2.2
+ **/
+char *
+mate_desktop_thumbnail_path_for_uri (const char               *uri,
+                                     MateDesktopThumbnailSize  size)
+{
+  return thumbnail_path (uri, size);
+}
+
+/**
+ * mate_desktop_thumbnail_has_uri:
+ * @pixbuf: an loaded thumbnail pixbuf
+ * @uri: a uri
+ *
+ * Returns whether the thumbnail has the correct uri embedded in the
+ * Thumb::URI option in the png.
+ *
+ * Return value: TRUE if the thumbnail is for @uri
+ *
+ * Since: 2.2
+ **/
+gboolean
+mate_desktop_thumbnail_has_uri (GdkPixbuf          *pixbuf,
+                                const char         *uri)
+{
+  const char *thumb_uri;
+
+  thumb_uri = gdk_pixbuf_get_option (pixbuf, "tEXt::Thumb::URI");
+  return (g_strcmp0 (uri, thumb_uri) == 0);
+}
+
+/**
+ * mate_desktop_thumbnail_is_valid:
+ * @pixbuf: an loaded thumbnail #GdkPixbuf
+ * @uri: a uri
+ * @mtime: the mtime
+ *
+ * Returns whether the thumbnail has the correct uri and mtime embedded in the
+ * png options.
+ *
+ * Return value: TRUE if the thumbnail has the right @uri and @mtime
+ *
+ * Since: 2.2
+ **/
+gboolean
+mate_desktop_thumbnail_is_valid (GdkPixbuf          *pixbuf,
+                                 const char         *uri,
+                                 time_t              mtime)
+{
+  const char *thumb_uri, *thumb_mtime_str;
+  time_t thumb_mtime;
+
+  thumb_uri = gdk_pixbuf_get_option (pixbuf, "tEXt::Thumb::URI");
+  if (g_strcmp0 (uri, thumb_uri) != 0)
+    return FALSE;
+
+  thumb_mtime_str = gdk_pixbuf_get_option (pixbuf, "tEXt::Thumb::MTime");
+  if (!thumb_mtime_str)
+    return FALSE;
+  thumb_mtime = (time_t)g_ascii_strtoll (thumb_mtime_str, (gchar**)NULL, 10);
+  if (mtime != thumb_mtime)
+    return FALSE;
+
+  return TRUE;
+}
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/23.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/23.html new file mode 100644 index 0000000..1b03571 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/23.html @@ -0,0 +1,439 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
/*
+ * mate-thumbnail.h: Utilities for handling thumbnails
+ *
+ * Copyright (C) 2002 Red Hat, Inc.
+ *
+ * This file is part of the Mate Library.
+ *
+ * The Mate Library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * The Mate Library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with the Mate Library; see the file COPYING.LIB.  If not,
+ * write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA  02110-1301, USA.
+ *
+ * Author: Alexander Larsson <alexl@redhat.com>
+ */
+
+#ifndef MATE_DESKTOP_THUMBNAIL_H
+#define MATE_DESKTOP_THUMBNAIL_H
+
+#ifndef MATE_DESKTOP_USE_UNSTABLE_API
+#error    MateDesktopThumbnail is unstable API. You must define MATE_DESKTOP_USE_UNSTABLE_API before including mate-desktop-thumbnail.h
+#endif
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <time.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdk-pixbuf/gdk-pixbuf.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+G_BEGIN_DECLS
+
+typedef enum {
+  MATE_DESKTOP_THUMBNAIL_SIZE_NORMAL,
+  MATE_DESKTOP_THUMBNAIL_SIZE_LARGE
+} MateDesktopThumbnailSize;
+
+#define MATE_DESKTOP_TYPE_THUMBNAIL_FACTORY    (mate_desktop_thumbnail_factory_get_type ())
+#define MATE_DESKTOP_THUMBNAIL_FACTORY(obj)    (G_TYPE_CHECK_INSTANCE_CAST ((obj), MATE_DESKTOP_TYPE_THUMBNAIL_FACTORY, MateDesktopThumbnailFactory))
+#define MATE_DESKTOP_THUMBNAIL_FACTORY_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), MATE_DESKTOP_TYPE_THUMBNAIL_FACTORY, MateDesktopThumbnailFactoryClass))
+#define MATE_DESKTOP_IS_THUMBNAIL_FACTORY(obj)    (G_TYPE_INSTANCE_CHECK_TYPE ((obj), MATE_DESKTOP_TYPE_THUMBNAIL_FACTORY))
+#define MATE_DESKTOP_IS_THUMBNAIL_FACTORY_CLASS(klass)    (G_TYPE_CLASS_CHECK_CLASS_TYPE ((klass), MATE_DESKTOP_TYPE_THUMBNAIL_FACTORY))
+
+typedef struct _MateDesktopThumbnailFactory        MateDesktopThumbnailFactory;
+typedef struct _MateDesktopThumbnailFactoryClass   MateDesktopThumbnailFactoryClass;
+typedef struct _MateDesktopThumbnailFactoryPrivate MateDesktopThumbnailFactoryPrivate;
+
+struct _MateDesktopThumbnailFactory {
+    GObject parent;
+
+    MateDesktopThumbnailFactoryPrivate *priv;
+};
+
+struct _MateDesktopThumbnailFactoryClass {
+    GObjectClass parent;
+};
+
+GType      mate_desktop_thumbnail_factory_get_type (void);
+MateDesktopThumbnailFactory *mate_desktop_thumbnail_factory_new      (MateDesktopThumbnailSize     size);
+
+char *     mate_desktop_thumbnail_factory_lookup   (MateDesktopThumbnailFactory *factory,
+                                                    const char                  *uri,
+                                                    time_t                       mtime);
+
+gboolean   mate_desktop_thumbnail_factory_has_valid_failed_thumbnail (MateDesktopThumbnailFactory *factory,
+                                                                      const char                  *uri,
+                                                                      time_t                       mtime);
+gboolean   mate_desktop_thumbnail_factory_can_thumbnail (MateDesktopThumbnailFactory *factory,
+                                                         const char                  *uri,
+                                                         const char                  *mime_type,
+                                                         time_t                       mtime);
+GdkPixbuf *  mate_desktop_thumbnail_factory_generate_thumbnail (MateDesktopThumbnailFactory *factory,
+                                                                const char                  *uri,
+                                                                const char                  *mime_type);
+void       mate_desktop_thumbnail_factory_save_thumbnail (MateDesktopThumbnailFactory *factory,
+                                                          GdkPixbuf                   *thumbnail,
+                                                          const char                  *uri,
+                                                          time_t                       original_mtime);
+void       mate_desktop_thumbnail_factory_create_failed_thumbnail (MateDesktopThumbnailFactory *factory,
+                                                                   const char                  *uri,
+                                                                   time_t                       mtime);
+
+/* Thumbnailing utils: */
+gboolean   mate_desktop_thumbnail_has_uri           (GdkPixbuf          *pixbuf,
+                                                     const char         *uri);
+gboolean   mate_desktop_thumbnail_is_valid          (GdkPixbuf          *pixbuf,
+                                                     const char         *uri,
+                                                     time_t              mtime);
+char *     mate_desktop_thumbnail_path_for_uri      (const char         *uri,
+                                                     MateDesktopThumbnailSize  size);
+
+G_END_DECLS
+
+#endif /* MATE_DESKTOP_THUMBNAIL_H */
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/24.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/24.html new file mode 100644 index 0000000..e470e85 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/24.html @@ -0,0 +1,1159 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
/* -*- Mode: C; c-set-style: linux indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/* mate-desktop-utils.c - Utilities for the MATE Desktop
+
+   Copyright (C) 1998 Tom Tromey
+   All rights reserved.
+
+   This file is part of the Mate Library.
+
+   The Mate Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The Mate Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the Mate Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
+/*
+  @NOTATION@
+ */
+
+#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gio/gio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n-lib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdk/gdk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#define MATE_DESKTOP_USE_UNSTABLE_API
+#include <mate-desktop-utils.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "private.h"
+
+static void
+gtk_style_shade (GdkRGBA *a,
+                 GdkRGBA *b,
+                 gdouble  k);
+
+static void
+rgb_to_hls (gdouble *r,
+            gdouble *g,
+            gdouble *b);
+
+static void
+hls_to_rgb (gdouble *h,
+            gdouble *l,
+            gdouble *s);
+
+/**
+ * mate_desktop_prepend_terminal_to_vector:
+ * @argc: a pointer to the vector size
+ * @argv: a pointer to the vector
+ *
+ * Prepends a terminal (either the one configured as default in the user's
+ * MATE setup, or one of the common xterm emulators) to the passed in vector,
+ * modifying it in the process.  The vector should be allocated with #g_malloc,
+ * as this will #g_free the original vector.  Also all elements must have been
+ * allocated separately.  That is the standard glib/MATE way of doing vectors
+ * however.  If the integer that @argc points to is negative, the size will
+ * first be computed.  Also note that passing in pointers to a vector that is
+ * empty, will just create a new vector for you.
+ **/
+void
+mate_desktop_prepend_terminal_to_vector (int *argc, char ***argv)
+{
+        char **real_argv;
+        int real_argc;
+        int i, j;
+	char **term_argv = NULL;
+	int term_argc = 0;
+	GSettings *settings;
+
+	gchar *terminal;
+
+	char **the_argv;
+
+        g_return_if_fail (argc != NULL);
+        g_return_if_fail (argv != NULL);
+
+        _mate_desktop_init_i18n ();
+
+	/* sanity */
+        if(*argv == NULL)
+                *argc = 0;
+
+	the_argv = *argv;
+
+	/* compute size if not given */
+	if (*argc < 0) {
+		for (i = 0; the_argv[i] != NULL; i++)
+			;
+		*argc = i;
+	}
+
+	settings = g_settings_new ("org.mate.applications-terminal");
+	terminal = g_settings_get_string (settings, "exec");
+
+	if (terminal && *terminal != '\0') {
+		gchar *command_line;
+		gchar *exec_flag;
+
+		exec_flag = g_settings_get_string (settings, "exec-arg");
+
+		if (!exec_flag || *exec_flag == '\0')
+			command_line = g_strdup (terminal);
+		else
+			command_line = g_strdup_printf ("%s %s", terminal,
+							exec_flag);
+
+		g_shell_parse_argv (command_line,
+				    &term_argc,
+				    &term_argv,
+				    NULL /* error */);
+
+		g_free (command_line);
+		g_free (exec_flag);
+	}
+	g_free (terminal);
+	g_object_unref (settings);
+
+	if (term_argv == NULL) {
+		char *check;
+
+		term_argc = 2;
+		term_argv = g_new0 (char *, 3);
+
+		check = g_find_program_in_path ("mate-terminal");
+		if (check != NULL) {<--- first condition
+			term_argv[0] = check;
+			/* Note that mate-terminal takes -x and
+			 * as -e in mate-terminal is broken we use that. */
+			term_argv[1] = g_strdup ("-x");
+		} else {
+			if (check == NULL)<--- else if condition is opposite to first condition
+				check = g_find_program_in_path ("nxterm");
+			if (check == NULL)
+				check = g_find_program_in_path ("color-xterm");
+			if (check == NULL)
+				check = g_find_program_in_path ("rxvt");
+			if (check == NULL)
+				check = g_find_program_in_path ("xterm");
+			if (check == NULL)
+				check = g_find_program_in_path ("dtterm");
+			if (check == NULL) {
+				g_warning (_("Cannot find a terminal, using "
+					     "xterm, even if it may not work"));
+				check = g_strdup ("xterm");
+			}
+			term_argv[0] = check;
+			term_argv[1] = g_strdup ("-e");
+		}
+	}
+
+        real_argc = term_argc + *argc;
+        real_argv = g_new (char *, real_argc + 1);
+
+        for (i = 0; i < term_argc; i++)
+                real_argv[i] = term_argv[i];
+
+        for (j = 0; j < *argc; j++, i++)
+                real_argv[i] = (char *)the_argv[j];
+
+	real_argv[i] = NULL;
+
+	g_free (*argv);
+	*argv = real_argv;
+	*argc = real_argc;
+
+	/* we use g_free here as we sucked all the inner strings
+	 * out from it into real_argv */
+	g_free (term_argv);
+}
+
+/**
+ * mate_gdk_spawn_command_line_on_screen:
+ * @screen: a GdkScreen
+ * @command: a command line
+ * @error: return location for errors
+ *
+ * This is a replacement for gdk_spawn_command_line_on_screen, deprecated
+ * in GDK 2.24 and removed in GDK 3.0.
+ *
+ * gdk_spawn_command_line_on_screen is like g_spawn_command_line_async(),
+ * except the child process is spawned in such an environment that on
+ * calling gdk_display_open() it would be returned a GdkDisplay with
+ * screen as the default screen.
+ *
+ * This is useful for applications which wish to launch an application
+ * on a specific screen.
+ *
+ * Returns: TRUE on success, FALSE if error is set.
+ *
+ * Since: 1.7.1
+ **/
+gboolean
+mate_gdk_spawn_command_line_on_screen (GdkScreen *screen, const gchar *command, GError **error)
+{
+	GAppInfo *appinfo = NULL;
+	GdkAppLaunchContext *context = NULL;
+	gboolean res = FALSE;
+
+	appinfo = g_app_info_create_from_commandline (command, NULL, G_APP_INFO_CREATE_NONE, error);
+
+	if (appinfo) {
+		context = gdk_display_get_app_launch_context (gdk_screen_get_display (screen));
+		res = g_app_info_launch (appinfo, NULL, G_APP_LAUNCH_CONTEXT (context), error);
+		g_object_unref (context);
+		g_object_unref (appinfo);
+	}
+
+	return res;
+}
+
+void
+_mate_desktop_init_i18n (void) {
+	static gboolean initialized = FALSE;
+
+	if (!initialized) {
+		bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR);
+#ifdef HAVE_BIND_TEXTDOMAIN_CODESET
+		bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+#endif
+		initialized = TRUE;
+	}
+}
+
+/**
+ * gtk_style_shade:
+ * @a:  the starting colour
+ * @b:  [out] the resulting colour
+ * @k:  amount to scale lightness and saturation by
+ *
+ * Takes a colour "a", scales the lightness and saturation by a certain amount,
+ * and sets "b" to the resulting colour.
+ * gtkstyle.c cut-and-pastage.
+ */
+static void
+gtk_style_shade (GdkRGBA *a,<--- Parameter 'a' can be declared as pointer to const
+                 GdkRGBA *b,
+                 gdouble  k)
+{
+	gdouble red;
+	gdouble green;
+	gdouble blue;
+
+	red = a->red;
+	green = a->green;
+	blue = a->blue;
+
+	rgb_to_hls (&red, &green, &blue);
+
+	green *= k;
+	if (green > 1.0)
+		green = 1.0;
+	else if (green < 0.0)
+		green = 0.0;
+
+	blue *= k;
+	if (blue > 1.0)
+		blue = 1.0;
+	else if (blue < 0.0)
+		blue = 0.0;
+
+	hls_to_rgb (&red, &green, &blue);
+
+	b->red = red;
+	b->green = green;
+	b->blue = blue;
+}
+
+/**
+ * rgb_to_hls:
+ * @r:  on input, red; on output, hue
+ * @g:  on input, green; on output, lightness
+ * @b:  on input, blue; on output, saturation
+ *
+ * Converts a red/green/blue triplet to a hue/lightness/saturation triplet.
+ */
+static void
+rgb_to_hls (gdouble *r,
+            gdouble *g,
+            gdouble *b)
+{
+	gdouble min;
+	gdouble max;
+	gdouble red;
+	gdouble green;
+	gdouble blue;
+	gdouble h, l, s;
+	gdouble delta;
+
+	red = *r;
+	green = *g;
+	blue = *b;
+
+	if (red > green)
+	{
+		if (red > blue)
+			max = red;
+		else
+			max = blue;
+
+		if (green < blue)
+			min = green;
+		else
+			min = blue;
+	}
+	else
+	{
+		if (green > blue)
+			max = green;
+		else
+			max = blue;
+
+		if (red < blue)
+			min = red;
+		else
+			min = blue;
+	}
+
+	l = (max + min) / 2;
+	s = 0;
+	h = 0;
+
+	if (max != min)
+	{
+		if (l <= 0.5)
+			s = (max - min) / (max + min);
+		else
+			s = (max - min) / (2 - max - min);
+
+		delta = max -min;
+		if (red == max)
+			h = (green - blue) / delta;
+		else if (green == max)
+			h = 2 + (blue - red) / delta;
+		else if (blue == max)
+			h = 4 + (red - green) / delta;
+
+		h *= 60;
+		if (h < 0.0)
+			h += 360;
+	}
+
+	*r = h;
+	*g = l;
+	*b = s;
+}
+
+/**
+ * hls_to_rgb:
+ * @h: on input, hue; on output, red
+ * @l: on input, lightness; on output, green
+ * @s  on input, saturation; on output, blue
+ *
+ * Converts a hue/lightness/saturation triplet to a red/green/blue triplet.
+ */
+static void
+hls_to_rgb (gdouble *h,
+            gdouble *l,
+            gdouble *s)
+{
+	gdouble hue;
+	gdouble lightness;
+	gdouble saturation;
+	gdouble m1, m2;
+	gdouble r, g, b;
+
+	lightness = *l;
+	saturation = *s;
+
+	if (lightness <= 0.5)
+		m2 = lightness * (1 + saturation);
+	else
+		m2 = lightness + saturation - lightness * saturation;
+	m1 = 2 * lightness - m2;
+
+	if (saturation == 0)
+	{
+		*h = lightness;
+		*l = lightness;
+		*s = lightness;
+	}
+	else
+	{
+		hue = *h + 120;
+		while (hue > 360)
+			hue -= 360;
+		while (hue < 0)
+			hue += 360;
+
+		if (hue < 60)
+			r = m1 + (m2 - m1) * hue / 60;
+		else if (hue < 180)
+			r = m2;
+		else if (hue < 240)
+			r = m1 + (m2 - m1) * (240 - hue) / 60;
+		else
+			r = m1;
+
+		hue = *h;
+		while (hue > 360)
+			hue -= 360;
+		while (hue < 0)
+			hue += 360;
+
+		if (hue < 60)
+			g = m1 + (m2 - m1) * hue / 60;
+		else if (hue < 180)
+			g = m2;
+		else if (hue < 240)
+			g = m1 + (m2 - m1) * (240 - hue) / 60;
+		else
+			g = m1;
+
+		hue = *h - 120;
+		while (hue > 360)
+			hue -= 360;
+		while (hue < 0)
+			hue += 360;
+
+		if (hue < 60)
+			b = m1 + (m2 - m1) * hue / 60;
+		else if (hue < 180)
+			b = m2;
+		else if (hue < 240)
+			b = m1 + (m2 - m1) * (240 - hue) / 60;
+		else
+			b = m1;
+
+		*h = r;
+		*l = g;
+		*s = b;
+	}
+}
+
+/* Based on set_color() in gtkstyle.c */
+#define LIGHTNESS_MULT 1.3
+#define DARKNESS_MULT  0.7
+void
+mate_desktop_gtk_style_get_light_color (GtkStyleContext *style,
+                                        GtkStateFlags    state,
+                                        GdkRGBA         *color)
+{
+	gtk_style_context_get_background_color (style, state, color);
+	gtk_style_shade (color, color, LIGHTNESS_MULT);
+}
+
+void
+mate_desktop_gtk_style_get_dark_color (GtkStyleContext *style,
+                                       GtkStateFlags    state,
+                                       GdkRGBA         *color)
+{
+	gtk_style_context_get_background_color (style, state, color);
+	gtk_style_shade (color, color, DARKNESS_MULT);
+}
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/25.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/25.html new file mode 100644 index 0000000..2db0016 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/25.html @@ -0,0 +1,339 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
/*
+ * mate-gsettings.h: helper API for GSettings
+ *
+ * Copyright (C) 2013 Stefano Karapetsas
+ * Copyright (C) 2013-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ *
+ * Authors:
+ *  Stefano Karapetsas <stefano@karapetsas.com>
+ */
+
+#ifndef __MATE_GSETTINGS_H__
+#define __MATE_GSETTINGS_H__
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gio/gio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+G_BEGIN_DECLS
+
+gboolean mate_gsettings_schema_exists (const gchar* schema);
+
+gboolean mate_gsettings_is_valid_keyname (const gchar  *key,
+                                          GError      **error);
+
+gboolean mate_gsettings_append_strv (GSettings         *settings,
+                                     const gchar       *key,
+                                     const gchar       *value);
+
+gboolean mate_gsettings_remove_all_from_strv (GSettings         *settings,
+                                              const gchar       *key,
+                                              const gchar       *value);
+
+GSList*  mate_gsettings_strv_to_gslist (const gchar *const *array);
+
+G_END_DECLS
+
+#endif /* __MATE_GSETTINGS_H__ */
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/26.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/26.html new file mode 100644 index 0000000..16c9a72 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/26.html @@ -0,0 +1,3107 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
   1
+   2
+   3
+   4
+   5
+   6
+   7
+   8
+   9
+  10
+  11
+  12
+  13
+  14
+  15
+  16
+  17
+  18
+  19
+  20
+  21
+  22
+  23
+  24
+  25
+  26
+  27
+  28
+  29
+  30
+  31
+  32
+  33
+  34
+  35
+  36
+  37
+  38
+  39
+  40
+  41
+  42
+  43
+  44
+  45
+  46
+  47
+  48
+  49
+  50
+  51
+  52
+  53
+  54
+  55
+  56
+  57
+  58
+  59
+  60
+  61
+  62
+  63
+  64
+  65
+  66
+  67
+  68
+  69
+  70
+  71
+  72
+  73
+  74
+  75
+  76
+  77
+  78
+  79
+  80
+  81
+  82
+  83
+  84
+  85
+  86
+  87
+  88
+  89
+  90
+  91
+  92
+  93
+  94
+  95
+  96
+  97
+  98
+  99
+ 100
+ 101
+ 102
+ 103
+ 104
+ 105
+ 106
+ 107
+ 108
+ 109
+ 110
+ 111
+ 112
+ 113
+ 114
+ 115
+ 116
+ 117
+ 118
+ 119
+ 120
+ 121
+ 122
+ 123
+ 124
+ 125
+ 126
+ 127
+ 128
+ 129
+ 130
+ 131
+ 132
+ 133
+ 134
+ 135
+ 136
+ 137
+ 138
+ 139
+ 140
+ 141
+ 142
+ 143
+ 144
+ 145
+ 146
+ 147
+ 148
+ 149
+ 150
+ 151
+ 152
+ 153
+ 154
+ 155
+ 156
+ 157
+ 158
+ 159
+ 160
+ 161
+ 162
+ 163
+ 164
+ 165
+ 166
+ 167
+ 168
+ 169
+ 170
+ 171
+ 172
+ 173
+ 174
+ 175
+ 176
+ 177
+ 178
+ 179
+ 180
+ 181
+ 182
+ 183
+ 184
+ 185
+ 186
+ 187
+ 188
+ 189
+ 190
+ 191
+ 192
+ 193
+ 194
+ 195
+ 196
+ 197
+ 198
+ 199
+ 200
+ 201
+ 202
+ 203
+ 204
+ 205
+ 206
+ 207
+ 208
+ 209
+ 210
+ 211
+ 212
+ 213
+ 214
+ 215
+ 216
+ 217
+ 218
+ 219
+ 220
+ 221
+ 222
+ 223
+ 224
+ 225
+ 226
+ 227
+ 228
+ 229
+ 230
+ 231
+ 232
+ 233
+ 234
+ 235
+ 236
+ 237
+ 238
+ 239
+ 240
+ 241
+ 242
+ 243
+ 244
+ 245
+ 246
+ 247
+ 248
+ 249
+ 250
+ 251
+ 252
+ 253
+ 254
+ 255
+ 256
+ 257
+ 258
+ 259
+ 260
+ 261
+ 262
+ 263
+ 264
+ 265
+ 266
+ 267
+ 268
+ 269
+ 270
+ 271
+ 272
+ 273
+ 274
+ 275
+ 276
+ 277
+ 278
+ 279
+ 280
+ 281
+ 282
+ 283
+ 284
+ 285
+ 286
+ 287
+ 288
+ 289
+ 290
+ 291
+ 292
+ 293
+ 294
+ 295
+ 296
+ 297
+ 298
+ 299
+ 300
+ 301
+ 302
+ 303
+ 304
+ 305
+ 306
+ 307
+ 308
+ 309
+ 310
+ 311
+ 312
+ 313
+ 314
+ 315
+ 316
+ 317
+ 318
+ 319
+ 320
+ 321
+ 322
+ 323
+ 324
+ 325
+ 326
+ 327
+ 328
+ 329
+ 330
+ 331
+ 332
+ 333
+ 334
+ 335
+ 336
+ 337
+ 338
+ 339
+ 340
+ 341
+ 342
+ 343
+ 344
+ 345
+ 346
+ 347
+ 348
+ 349
+ 350
+ 351
+ 352
+ 353
+ 354
+ 355
+ 356
+ 357
+ 358
+ 359
+ 360
+ 361
+ 362
+ 363
+ 364
+ 365
+ 366
+ 367
+ 368
+ 369
+ 370
+ 371
+ 372
+ 373
+ 374
+ 375
+ 376
+ 377
+ 378
+ 379
+ 380
+ 381
+ 382
+ 383
+ 384
+ 385
+ 386
+ 387
+ 388
+ 389
+ 390
+ 391
+ 392
+ 393
+ 394
+ 395
+ 396
+ 397
+ 398
+ 399
+ 400
+ 401
+ 402
+ 403
+ 404
+ 405
+ 406
+ 407
+ 408
+ 409
+ 410
+ 411
+ 412
+ 413
+ 414
+ 415
+ 416
+ 417
+ 418
+ 419
+ 420
+ 421
+ 422
+ 423
+ 424
+ 425
+ 426
+ 427
+ 428
+ 429
+ 430
+ 431
+ 432
+ 433
+ 434
+ 435
+ 436
+ 437
+ 438
+ 439
+ 440
+ 441
+ 442
+ 443
+ 444
+ 445
+ 446
+ 447
+ 448
+ 449
+ 450
+ 451
+ 452
+ 453
+ 454
+ 455
+ 456
+ 457
+ 458
+ 459
+ 460
+ 461
+ 462
+ 463
+ 464
+ 465
+ 466
+ 467
+ 468
+ 469
+ 470
+ 471
+ 472
+ 473
+ 474
+ 475
+ 476
+ 477
+ 478
+ 479
+ 480
+ 481
+ 482
+ 483
+ 484
+ 485
+ 486
+ 487
+ 488
+ 489
+ 490
+ 491
+ 492
+ 493
+ 494
+ 495
+ 496
+ 497
+ 498
+ 499
+ 500
+ 501
+ 502
+ 503
+ 504
+ 505
+ 506
+ 507
+ 508
+ 509
+ 510
+ 511
+ 512
+ 513
+ 514
+ 515
+ 516
+ 517
+ 518
+ 519
+ 520
+ 521
+ 522
+ 523
+ 524
+ 525
+ 526
+ 527
+ 528
+ 529
+ 530
+ 531
+ 532
+ 533
+ 534
+ 535
+ 536
+ 537
+ 538
+ 539
+ 540
+ 541
+ 542
+ 543
+ 544
+ 545
+ 546
+ 547
+ 548
+ 549
+ 550
+ 551
+ 552
+ 553
+ 554
+ 555
+ 556
+ 557
+ 558
+ 559
+ 560
+ 561
+ 562
+ 563
+ 564
+ 565
+ 566
+ 567
+ 568
+ 569
+ 570
+ 571
+ 572
+ 573
+ 574
+ 575
+ 576
+ 577
+ 578
+ 579
+ 580
+ 581
+ 582
+ 583
+ 584
+ 585
+ 586
+ 587
+ 588
+ 589
+ 590
+ 591
+ 592
+ 593
+ 594
+ 595
+ 596
+ 597
+ 598
+ 599
+ 600
+ 601
+ 602
+ 603
+ 604
+ 605
+ 606
+ 607
+ 608
+ 609
+ 610
+ 611
+ 612
+ 613
+ 614
+ 615
+ 616
+ 617
+ 618
+ 619
+ 620
+ 621
+ 622
+ 623
+ 624
+ 625
+ 626
+ 627
+ 628
+ 629
+ 630
+ 631
+ 632
+ 633
+ 634
+ 635
+ 636
+ 637
+ 638
+ 639
+ 640
+ 641
+ 642
+ 643
+ 644
+ 645
+ 646
+ 647
+ 648
+ 649
+ 650
+ 651
+ 652
+ 653
+ 654
+ 655
+ 656
+ 657
+ 658
+ 659
+ 660
+ 661
+ 662
+ 663
+ 664
+ 665
+ 666
+ 667
+ 668
+ 669
+ 670
+ 671
+ 672
+ 673
+ 674
+ 675
+ 676
+ 677
+ 678
+ 679
+ 680
+ 681
+ 682
+ 683
+ 684
+ 685
+ 686
+ 687
+ 688
+ 689
+ 690
+ 691
+ 692
+ 693
+ 694
+ 695
+ 696
+ 697
+ 698
+ 699
+ 700
+ 701
+ 702
+ 703
+ 704
+ 705
+ 706
+ 707
+ 708
+ 709
+ 710
+ 711
+ 712
+ 713
+ 714
+ 715
+ 716
+ 717
+ 718
+ 719
+ 720
+ 721
+ 722
+ 723
+ 724
+ 725
+ 726
+ 727
+ 728
+ 729
+ 730
+ 731
+ 732
+ 733
+ 734
+ 735
+ 736
+ 737
+ 738
+ 739
+ 740
+ 741
+ 742
+ 743
+ 744
+ 745
+ 746
+ 747
+ 748
+ 749
+ 750
+ 751
+ 752
+ 753
+ 754
+ 755
+ 756
+ 757
+ 758
+ 759
+ 760
+ 761
+ 762
+ 763
+ 764
+ 765
+ 766
+ 767
+ 768
+ 769
+ 770
+ 771
+ 772
+ 773
+ 774
+ 775
+ 776
+ 777
+ 778
+ 779
+ 780
+ 781
+ 782
+ 783
+ 784
+ 785
+ 786
+ 787
+ 788
+ 789
+ 790
+ 791
+ 792
+ 793
+ 794
+ 795
+ 796
+ 797
+ 798
+ 799
+ 800
+ 801
+ 802
+ 803
+ 804
+ 805
+ 806
+ 807
+ 808
+ 809
+ 810
+ 811
+ 812
+ 813
+ 814
+ 815
+ 816
+ 817
+ 818
+ 819
+ 820
+ 821
+ 822
+ 823
+ 824
+ 825
+ 826
+ 827
+ 828
+ 829
+ 830
+ 831
+ 832
+ 833
+ 834
+ 835
+ 836
+ 837
+ 838
+ 839
+ 840
+ 841
+ 842
+ 843
+ 844
+ 845
+ 846
+ 847
+ 848
+ 849
+ 850
+ 851
+ 852
+ 853
+ 854
+ 855
+ 856
+ 857
+ 858
+ 859
+ 860
+ 861
+ 862
+ 863
+ 864
+ 865
+ 866
+ 867
+ 868
+ 869
+ 870
+ 871
+ 872
+ 873
+ 874
+ 875
+ 876
+ 877
+ 878
+ 879
+ 880
+ 881
+ 882
+ 883
+ 884
+ 885
+ 886
+ 887
+ 888
+ 889
+ 890
+ 891
+ 892
+ 893
+ 894
+ 895
+ 896
+ 897
+ 898
+ 899
+ 900
+ 901
+ 902
+ 903
+ 904
+ 905
+ 906
+ 907
+ 908
+ 909
+ 910
+ 911
+ 912
+ 913
+ 914
+ 915
+ 916
+ 917
+ 918
+ 919
+ 920
+ 921
+ 922
+ 923
+ 924
+ 925
+ 926
+ 927
+ 928
+ 929
+ 930
+ 931
+ 932
+ 933
+ 934
+ 935
+ 936
+ 937
+ 938
+ 939
+ 940
+ 941
+ 942
+ 943
+ 944
+ 945
+ 946
+ 947
+ 948
+ 949
+ 950
+ 951
+ 952
+ 953
+ 954
+ 955
+ 956
+ 957
+ 958
+ 959
+ 960
+ 961
+ 962
+ 963
+ 964
+ 965
+ 966
+ 967
+ 968
+ 969
+ 970
+ 971
+ 972
+ 973
+ 974
+ 975
+ 976
+ 977
+ 978
+ 979
+ 980
+ 981
+ 982
+ 983
+ 984
+ 985
+ 986
+ 987
+ 988
+ 989
+ 990
+ 991
+ 992
+ 993
+ 994
+ 995
+ 996
+ 997
+ 998
+ 999
+1000
+1001
+1002
+1003
+1004
+1005
+1006
+1007
+1008
+1009
+1010
+1011
+1012
+1013
+1014
+1015
+1016
+1017
+1018
+1019
+1020
+1021
+1022
+1023
+1024
+1025
+1026
+1027
+1028
+1029
+1030
+1031
+1032
+1033
+1034
+1035
+1036
+1037
+1038
+1039
+1040
+1041
+1042
+1043
+1044
+1045
+1046
+1047
+1048
+1049
+1050
+1051
+1052
+1053
+1054
+1055
+1056
+1057
+1058
+1059
+1060
+1061
+1062
+1063
+1064
+1065
+1066
+1067
+1068
+1069
+1070
+1071
+1072
+1073
+1074
+1075
+1076
+1077
+1078
+1079
+1080
+1081
+1082
+1083
+1084
+1085
+1086
+1087
+1088
+1089
+1090
+1091
+1092
+1093
+1094
+1095
+1096
+1097
+1098
+1099
+1100
+1101
+1102
+1103
+1104
+1105
+1106
+1107
+1108
+1109
+1110
+1111
+1112
+1113
+1114
+1115
+1116
+1117
+1118
+1119
+1120
+1121
+1122
+1123
+1124
+1125
+1126
+1127
+1128
+1129
+1130
+1131
+1132
+1133
+1134
+1135
+1136
+1137
+1138
+1139
+1140
+1141
+1142
+1143
+1144
+1145
+1146
+1147
+1148
+1149
+1150
+1151
+1152
+1153
+1154
+1155
+1156
+1157
+1158
+1159
+1160
+1161
+1162
+1163
+1164
+1165
+1166
+1167
+1168
+1169
+1170
+1171
+1172
+1173
+1174
+1175
+1176
+1177
+1178
+1179
+1180
+1181
+1182
+1183
+1184
+1185
+1186
+1187
+1188
+1189
+1190
+1191
+1192
+1193
+1194
+1195
+1196
+1197
+1198
+1199
+1200
+1201
+1202
+1203
+1204
+1205
+1206
+1207
+1208
+1209
+1210
+1211
+1212
+1213
+1214
+1215
+1216
+1217
+1218
+1219
+1220
+1221
+1222
+1223
+1224
+1225
+1226
+1227
+1228
+1229
+1230
+1231
+1232
+1233
+1234
+1235
+1236
+1237
+1238
+1239
+1240
+1241
+1242
+1243
+1244
+1245
+1246
+1247
+1248
+1249
+1250
+1251
+1252
+1253
+1254
+1255
+1256
+1257
+1258
+1259
+1260
+1261
+1262
+1263
+1264
+1265
+1266
+1267
+1268
+1269
+1270
+1271
+1272
+1273
+1274
+1275
+1276
+1277
+1278
+1279
+1280
+1281
+1282
+1283
+1284
+1285
+1286
+1287
+1288
+1289
+1290
+1291
+1292
+1293
+1294
+1295
+1296
+1297
+1298
+1299
+1300
+1301
+1302
+1303
+1304
+1305
+1306
+1307
+1308
+1309
+1310
+1311
+1312
+1313
+1314
+1315
+1316
+1317
+1318
+1319
+1320
+1321
+1322
+1323
+1324
+1325
+1326
+1327
+1328
+1329
+1330
+1331
+1332
+1333
+1334
+1335
+1336
+1337
+1338
+1339
+1340
+1341
+1342
+1343
+1344
+1345
+1346
+1347
+1348
+1349
+1350
+1351
+1352
+1353
+1354
+1355
+1356
+1357
+1358
+1359
+1360
+1361
+1362
+1363
+1364
+1365
+1366
+1367
+1368
+1369
+1370
+1371
+1372
+1373
+1374
+1375
+1376
+1377
+1378
+1379
+1380
+1381
+1382
+1383
+1384
+1385
+1386
+1387
+1388
+1389
+1390
+1391
+1392
+1393
+1394
+1395
+1396
+1397
+1398
+1399
+1400
+1401
+1402
+1403
+1404
+1405
+1406
+1407
+1408
+1409
+1410
+1411
+1412
+1413
+1414
+1415
+1416
+1417
+1418
+1419
+1420
+1421
+1422
+1423
+1424
+1425
+1426
+1427
+1428
+1429
+1430
+1431
+1432
+1433
+1434
+1435
/* HSV color selector for GTK+
+ *
+ * Copyright (C) 1999 The Free Software Foundation
+ * Copyright (C) 2019-2021 MATE Developers
+ *
+ * Authors: Simon Budig <Simon.Budig@unix-ag.org> (original code)
+ *          Federico Mena-Quintero <federico@gimp.org> (cleanup for GTK+)
+ *          Jonathan Blandford <jrb@redhat.com> (cleanup for GTK+)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
+ * file for a list of people on the GTK+ Team.  See the ChangeLog
+ * files for a list of changes.  These files are distributed with
+ * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
+ *
+ * Modified to work internally in mate-desktop by Pablo Barciela 2019
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"<--- Include file: "config.h" not found.
+#endif
+
+#include "mate-hsv.h"
+
+#include <math.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#define I_(string) g_intern_static_string (string)
+
+/**
+ * SECTION:mate-hsv
+ * @Short_description: A “color wheel” widget
+ * @Title: MateHSV
+ *
+ * #MateHSV is the “color wheel” part of a complete color selector widget.
+ * It allows to select a color by determining its HSV components in an
+ * intuitive way. Moving the selection around the outer ring changes the hue,
+ * and moving the selection point inside the inner triangle changes value and
+ * saturation.
+ */
+
+/* Default width/height */
+#define DEFAULT_SIZE 100
+
+/* Default ring width */
+#define DEFAULT_RING_WIDTH 10
+
+/* Dragging modes */
+typedef enum {
+  DRAG_NONE,
+  DRAG_H,
+  DRAG_SV
+} DragMode;
+
+/* Private part of the MateHSV structure */
+struct _MateHSVPrivate
+{
+  /* Color value */
+  double h;
+  double s;
+  double v;
+
+  /* Size and ring width */
+  int size;
+  int ring_width;
+
+  /* Window for capturing events */
+  GdkWindow *window;
+
+  /* Dragging mode */
+  DragMode mode;
+
+  guint focus_on_ring : 1;
+};
+
+/* Signal IDs */
+
+enum {
+  CHANGED,
+  MOVE,
+  LAST_SIGNAL
+};
+
+static void     mate_hsv_destroy              (GtkWidget          *widget);
+static void     mate_hsv_realize              (GtkWidget          *widget);
+static void     mate_hsv_unrealize            (GtkWidget          *widget);
+static void     mate_hsv_get_preferred_width  (GtkWidget          *widget,
+                                               gint               *minimum,
+                                               gint               *natural);
+static void     mate_hsv_get_preferred_height (GtkWidget          *widget,
+                                               gint               *minimum,
+                                               gint               *natural);
+static void     mate_hsv_size_allocate        (GtkWidget          *widget,
+                                               GtkAllocation      *allocation);
+static gboolean mate_hsv_button_press         (GtkWidget          *widget,
+                                               GdkEventButton     *event);
+static gboolean mate_hsv_button_release       (GtkWidget          *widget,
+                                               GdkEventButton     *event);
+static gboolean mate_hsv_motion               (GtkWidget          *widget,
+                                               GdkEventMotion     *event);
+static gboolean mate_hsv_draw                 (GtkWidget          *widget,
+                                               cairo_t            *cr);
+static gboolean mate_hsv_grab_broken          (GtkWidget          *widget,
+                                               GdkEventGrabBroken *event);
+static gboolean mate_hsv_focus                (GtkWidget          *widget,
+                                               GtkDirectionType    direction);
+static void     mate_hsv_move                 (MateHSV            *hsv,
+                                               GtkDirectionType    dir);
+
+static guint hsv_signals[LAST_SIGNAL];
+
+G_DEFINE_TYPE_WITH_PRIVATE (MateHSV, mate_hsv, GTK_TYPE_WIDGET)<--- There is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
+
+/* Class initialization function for the HSV color selector */
+static void
+mate_hsv_class_init (MateHSVClass *class)
+{
+  GObjectClass    *gobject_class;
+  GtkWidgetClass  *widget_class;
+  MateHSVClass    *hsv_class;
+  GtkBindingSet   *binding_set;
+
+  gobject_class = (GObjectClass *) class;
+  widget_class = (GtkWidgetClass *) class;
+  hsv_class = MATE_HSV_CLASS (class);
+
+  widget_class->destroy = mate_hsv_destroy;
+  widget_class->realize = mate_hsv_realize;
+  widget_class->unrealize = mate_hsv_unrealize;
+  widget_class->get_preferred_width = mate_hsv_get_preferred_width;
+  widget_class->get_preferred_height = mate_hsv_get_preferred_height;
+  widget_class->size_allocate = mate_hsv_size_allocate;
+  widget_class->button_press_event = mate_hsv_button_press;
+  widget_class->button_release_event = mate_hsv_button_release;
+  widget_class->motion_notify_event = mate_hsv_motion;
+  widget_class->draw = mate_hsv_draw;
+  widget_class->focus = mate_hsv_focus;
+  widget_class->grab_broken_event = mate_hsv_grab_broken;
+
+  gtk_widget_class_set_accessible_role (widget_class, ATK_ROLE_COLOR_CHOOSER);
+
+  hsv_class->move = mate_hsv_move;
+
+  hsv_signals[CHANGED] =
+    g_signal_new (I_("changed"),
+                  G_OBJECT_CLASS_TYPE (gobject_class),
+                  G_SIGNAL_RUN_FIRST,
+                  G_STRUCT_OFFSET (MateHSVClass, changed),
+                  NULL, NULL,
+                  NULL,
+                  G_TYPE_NONE, 0);
+
+  hsv_signals[MOVE] =
+    g_signal_new (I_("move"),
+                  G_OBJECT_CLASS_TYPE (gobject_class),
+                  G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+                  G_STRUCT_OFFSET (MateHSVClass, move),
+                  NULL, NULL,
+                  NULL,
+                  G_TYPE_NONE, 1,
+                  GTK_TYPE_DIRECTION_TYPE);
+
+  binding_set = gtk_binding_set_by_class (class);
+
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_Up, 0,
+                                "move", 1,
+                                G_TYPE_ENUM, GTK_DIR_UP);
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Up, 0,
+                                "move", 1,
+                                G_TYPE_ENUM, GTK_DIR_UP);
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_Down, 0,
+                                "move", 1,
+                                G_TYPE_ENUM, GTK_DIR_DOWN);
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Down, 0,
+                                "move", 1,
+                                G_TYPE_ENUM, GTK_DIR_DOWN);
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_Right, 0,
+                                "move", 1,
+                                G_TYPE_ENUM, GTK_DIR_RIGHT);
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Right, 0,
+                                "move", 1,
+                                G_TYPE_ENUM, GTK_DIR_RIGHT);
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_Left, 0,
+                                "move", 1,
+                                G_TYPE_ENUM, GTK_DIR_LEFT);
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Left, 0,
+                                "move", 1,
+                                G_TYPE_ENUM, GTK_DIR_LEFT);
+}
+
+static void
+mate_hsv_init (MateHSV *hsv)
+{
+  MateHSVPrivate *priv;
+
+  priv = mate_hsv_get_instance_private (hsv);
+  hsv->priv = priv;
+
+  gtk_widget_set_has_window (GTK_WIDGET (hsv), FALSE);
+  gtk_widget_set_can_focus (GTK_WIDGET (hsv), TRUE);
+
+  priv->h = 0.0;
+  priv->s = 0.0;
+  priv->v = 0.0;
+
+  priv->size = DEFAULT_SIZE;
+  priv->ring_width = DEFAULT_RING_WIDTH;
+}
+
+static void
+mate_hsv_destroy (GtkWidget *widget)
+{
+  GTK_WIDGET_CLASS (mate_hsv_parent_class)->destroy (widget);
+}
+
+static void
+mate_hsv_realize (GtkWidget *widget)
+{
+  MateHSV *hsv = MATE_HSV (widget);
+  MateHSVPrivate *priv = hsv->priv;
+  GtkAllocation allocation;
+  GdkWindow *parent_window;
+  GdkWindowAttr attr;
+  int attr_mask;
+
+  gtk_widget_set_realized (widget, TRUE);
+
+  gtk_widget_get_allocation (widget, &allocation);
+
+  attr.window_type = GDK_WINDOW_CHILD;
+  attr.x = allocation.x;
+  attr.y = allocation.y;
+  attr.width = allocation.width;
+  attr.height = allocation.height;
+  attr.wclass = GDK_INPUT_ONLY;
+  attr.event_mask = gtk_widget_get_events (widget);
+  attr.event_mask |= (GDK_KEY_PRESS_MASK
+                      | GDK_BUTTON_PRESS_MASK
+                      | GDK_BUTTON_RELEASE_MASK
+                      | GDK_POINTER_MOTION_MASK
+                      | GDK_ENTER_NOTIFY_MASK
+                      | GDK_LEAVE_NOTIFY_MASK);
+  attr_mask = GDK_WA_X | GDK_WA_Y;
+
+  parent_window = gtk_widget_get_parent_window (widget);
+  gtk_widget_set_window (widget, parent_window);
+  g_object_ref (parent_window);
+
+  priv->window = gdk_window_new (parent_window, &attr, attr_mask);
+  gdk_window_set_user_data (priv->window, hsv);
+  gdk_window_show (priv->window);
+}
+
+static void
+mate_hsv_unrealize (GtkWidget *widget)
+{
+  MateHSV *hsv = MATE_HSV (widget);
+  MateHSVPrivate *priv = hsv->priv;
+
+  gdk_window_set_user_data (priv->window, NULL);
+  gdk_window_destroy (priv->window);
+  priv->window = NULL;
+
+  GTK_WIDGET_CLASS (mate_hsv_parent_class)->unrealize (widget);
+}
+
+static void
+mate_hsv_get_preferred_width (GtkWidget *widget,
+                              gint      *minimum,
+                              gint      *natural)
+{
+  MateHSV *hsv = MATE_HSV (widget);
+  MateHSVPrivate *priv = hsv->priv;
+  gint focus_width;
+  gint focus_pad;
+
+  gtk_widget_style_get (widget,
+                        "focus-line-width", &focus_width,
+                        "focus-padding", &focus_pad,
+                        NULL);
+
+  *minimum = priv->size + 2 * (focus_width + focus_pad);
+  *natural = priv->size + 2 * (focus_width + focus_pad);
+}
+
+static void
+mate_hsv_get_preferred_height (GtkWidget *widget,
+                               gint      *minimum,
+                               gint      *natural)
+{
+  MateHSV *hsv = MATE_HSV (widget);
+  MateHSVPrivate *priv = hsv->priv;
+  gint focus_width;
+  gint focus_pad;
+
+  gtk_widget_style_get (widget,
+                        "focus-line-width", &focus_width,
+                        "focus-padding", &focus_pad,
+                        NULL);
+
+  *minimum = priv->size + 2 * (focus_width + focus_pad);
+  *natural = priv->size + 2 * (focus_width + focus_pad);
+}
+
+static void
+mate_hsv_size_allocate (GtkWidget     *widget,
+                        GtkAllocation *allocation)
+{
+  MateHSV *hsv = MATE_HSV (widget);
+  MateHSVPrivate *priv = hsv->priv;
+
+  gtk_widget_set_allocation (widget, allocation);
+
+  if (gtk_widget_get_realized (widget))
+    gdk_window_move_resize (priv->window,
+                            allocation->x,
+                            allocation->y,
+                            allocation->width,
+                            allocation->height);
+}
+
+/* Utility functions */
+
+#define INTENSITY(r, g, b) ((r) * 0.30 + (g) * 0.59 + (b) * 0.11)
+
+/* Converts from HSV to RGB */
+static void
+hsv_to_rgb (gdouble *h,
+            gdouble *s,
+            gdouble *v)
+{
+  gdouble hue, saturation, value;
+  gdouble f, p, q, t;
+
+  if (*s == 0.0)
+    {
+      *h = *v;
+      *s = *v;
+      *v = *v; /* heh */
+    }
+  else
+    {
+      hue = *h * 6.0;
+      saturation = *s;
+      value = *v;
+
+      if (hue == 6.0)
+        hue = 0.0;
+
+      f = hue - (int) hue;
+      p = value * (1.0 - saturation);
+      q = value * (1.0 - saturation * f);
+      t = value * (1.0 - saturation * (1.0 - f));
+
+      switch ((int) hue)
+        {
+        case 0:
+          *h = value;
+          *s = t;
+          *v = p;
+          break;
+
+        case 1:
+          *h = q;
+          *s = value;
+          *v = p;
+          break;
+
+        case 2:
+          *h = p;
+          *s = value;
+          *v = t;
+          break;
+
+        case 3:
+          *h = p;
+          *s = q;
+          *v = value;
+          break;
+
+        case 4:
+          *h = t;
+          *s = p;
+          *v = value;
+          break;
+
+        case 5:
+          *h = value;
+          *s = p;
+          *v = q;
+          break;
+
+        default:
+          g_assert_not_reached ();
+        }
+    }
+}
+
+/* Computes the vertices of the saturation/value triangle */
+static void
+compute_triangle (MateHSV *hsv,
+                  gint    *hx,
+                  gint    *hy,
+                  gint    *sx,
+                  gint    *sy,
+                  gint    *vx,
+                  gint    *vy)
+{
+  MateHSVPrivate *priv = hsv->priv;
+  GtkWidget *widget = GTK_WIDGET (hsv);
+  gdouble center_x;
+  gdouble center_y;
+  gdouble inner, outer;
+  gdouble angle;
+
+  center_x = gtk_widget_get_allocated_width (widget) / 2.0;
+  center_y = gtk_widget_get_allocated_height (widget) / 2.0;
+  outer = priv->size / 2.0;
+  inner = outer - priv->ring_width;
+  angle = priv->h * 2.0 * G_PI;
+
+  *hx = floor (center_x + cos (angle) * inner + 0.5);
+  *hy = floor (center_y - sin (angle) * inner + 0.5);
+  *sx = floor (center_x + cos (angle + 2.0 * G_PI / 3.0) * inner + 0.5);
+  *sy = floor (center_y - sin (angle + 2.0 * G_PI / 3.0) * inner + 0.5);
+  *vx = floor (center_x + cos (angle + 4.0 * G_PI / 3.0) * inner + 0.5);
+  *vy = floor (center_y - sin (angle + 4.0 * G_PI / 3.0) * inner + 0.5);
+}
+
+/* Computes whether a point is inside the hue ring */
+static gboolean
+is_in_ring (MateHSV *hsv,
+            gdouble  x,
+            gdouble  y)
+{
+  MateHSVPrivate *priv = hsv->priv;
+  GtkWidget *widget = GTK_WIDGET (hsv);
+  gdouble dx, dy, dist;
+  gdouble center_x;
+  gdouble center_y;
+  gdouble inner, outer;
+
+  center_x = gtk_widget_get_allocated_width (widget) / 2.0;
+  center_y = gtk_widget_get_allocated_height (widget) / 2.0;
+  outer = priv->size / 2.0;
+  inner = outer - priv->ring_width;
+
+  dx = x - center_x;
+  dy = center_y - y;
+  dist = dx * dx + dy * dy;
+
+  return (dist >= inner * inner && dist <= outer * outer);
+}
+
+/* Computes a saturation/value pair based on the mouse coordinates */
+static void
+compute_sv (MateHSV  *hsv,
+            gdouble   x,
+            gdouble   y,
+            gdouble  *s,
+            gdouble  *v)
+{
+  GtkWidget *widget = GTK_WIDGET (hsv);
+  int ihx, ihy, isx, isy, ivx, ivy;
+  double hx, hy, sx, sy, vx, vy;
+  double center_x;
+  double center_y;
+
+  compute_triangle (hsv, &ihx, &ihy, &isx, &isy, &ivx, &ivy);
+  center_x = gtk_widget_get_allocated_width (widget) / 2.0;
+  center_y = gtk_widget_get_allocated_height (widget) / 2.0;
+  hx = ihx - center_x;
+  hy = center_y - ihy;
+  sx = isx - center_x;
+  sy = center_y - isy;
+  vx = ivx - center_x;
+  vy = center_y - ivy;
+  x -= center_x;
+  y = center_y - y;
+
+  if (vx * (x - sx) + vy * (y - sy) < 0.0)
+    {
+      *s = 1.0;
+      *v = (((x - sx) * (hx - sx) + (y - sy) * (hy-sy))
+            / ((hx - sx) * (hx - sx) + (hy - sy) * (hy - sy)));
+
+      if (*v < 0.0)
+        *v = 0.0;
+      else if (*v > 1.0)
+        *v = 1.0;
+    }
+  else if (hx * (x - sx) + hy * (y - sy) < 0.0)
+    {
+      *s = 0.0;
+      *v = (((x - sx) * (vx - sx) + (y - sy) * (vy - sy))
+            / ((vx - sx) * (vx - sx) + (vy - sy) * (vy - sy)));
+
+      if (*v < 0.0)
+        *v = 0.0;
+      else if (*v > 1.0)
+        *v = 1.0;
+    }
+  else if (sx * (x - hx) + sy * (y - hy) < 0.0)
+    {
+      *v = 1.0;
+      *s = (((x - vx) * (hx - vx) + (y - vy) * (hy - vy)) /
+            ((hx - vx) * (hx - vx) + (hy - vy) * (hy - vy)));
+
+      if (*s < 0.0)
+        *s = 0.0;
+      else if (*s > 1.0)
+        *s = 1.0;
+    }
+  else
+    {
+      *v = (((x - sx) * (hy - vy) - (y - sy) * (hx - vx))
+            / ((vx - sx) * (hy - vy) - (vy - sy) * (hx - vx)));
+
+      if (*v<= 0.0)
+        {
+          *v = 0.0;
+          *s = 0.0;
+        }
+      else
+        {
+          if (*v > 1.0)
+            *v = 1.0;
+
+          if (fabs (hy - vy) < fabs (hx - vx))
+            *s = (x - sx - *v * (vx - sx)) / (*v * (hx - vx));
+          else
+            *s = (y - sy - *v * (vy - sy)) / (*v * (hy - vy));
+
+          if (*s < 0.0)
+            *s = 0.0;
+          else if (*s > 1.0)
+            *s = 1.0;
+        }
+    }
+}
+
+/* Computes whether a point is inside the saturation/value triangle */
+static gboolean
+is_in_triangle (MateHSV *hsv,
+                gdouble  x,
+                gdouble  y)
+{
+  int hx, hy, sx, sy, vx, vy;
+  double det, s, v;
+
+  compute_triangle (hsv, &hx, &hy, &sx, &sy, &vx, &vy);
+
+  det = (vx - sx) * (hy - sy) - (vy - sy) * (hx - sx);
+
+  s = ((x - sx) * (hy - sy) - (y - sy) * (hx - sx)) / det;
+  v = ((vx - sx) * (y - sy) - (vy - sy) * (x - sx)) / det;
+
+  return (s >= 0.0 && v >= 0.0 && s + v <= 1.0);
+}
+
+/* Computes a value based on the mouse coordinates */
+static double
+compute_v (MateHSV *hsv,
+           gdouble  x,
+           gdouble  y)
+{
+  GtkWidget *widget = GTK_WIDGET (hsv);
+  double center_x;
+  double center_y;
+  double dx, dy;
+  double angle;
+
+  center_x = gtk_widget_get_allocated_width (widget) / 2.0;
+  center_y = gtk_widget_get_allocated_height (widget) / 2.0;
+  dx = x - center_x;
+  dy = center_y - y;
+
+  angle = atan2 (dy, dx);
+  if (angle < 0.0)
+    angle += 2.0 * G_PI;
+
+  return angle / (2.0 * G_PI);
+}
+
+/* Event handlers */
+
+static void
+set_cross_grab (MateHSV   *hsv,
+                GdkDevice *device,
+                guint32    time)
+{
+  MateHSVPrivate *priv = hsv->priv;
+  GdkCursor *cursor;
+
+  cursor = gdk_cursor_new_for_display (gtk_widget_get_display (GTK_WIDGET (hsv)),
+                                       GDK_CROSSHAIR);
+  gdk_seat_grab (gdk_device_get_seat (device),
+                 priv->window,
+                 GDK_SEAT_CAPABILITY_ALL_POINTING,
+                 FALSE,
+                 cursor,
+                 NULL,
+                 NULL,
+                 NULL);
+  g_object_unref (cursor);
+}
+
+static gboolean
+mate_hsv_grab_broken (GtkWidget          *widget,
+                      GdkEventGrabBroken *event)
+{
+  MateHSV *hsv = MATE_HSV (widget);
+  MateHSVPrivate *priv = hsv->priv;
+
+  priv->mode = DRAG_NONE;
+
+  return TRUE;
+}
+
+static gint
+mate_hsv_button_press (GtkWidget      *widget,
+                       GdkEventButton *event)
+{
+  MateHSV *hsv = MATE_HSV (widget);
+  MateHSVPrivate *priv = hsv->priv;
+  double x, y;
+
+  if (priv->mode != DRAG_NONE || event->button != GDK_BUTTON_PRIMARY)
+    return FALSE;
+
+  x = event->x;
+  y = event->y;
+
+  if (is_in_ring (hsv, x, y))
+    {
+      priv->mode = DRAG_H;
+      set_cross_grab (hsv, gdk_event_get_device ((GdkEvent *) event), event->time);
+
+      mate_hsv_set_color (hsv,
+                         compute_v (hsv, x, y),
+                         priv->s,
+                         priv->v);
+
+      gtk_widget_grab_focus (widget);
+      priv->focus_on_ring = TRUE;
+
+      return TRUE;
+    }
+
+  if (is_in_triangle (hsv, x, y))
+    {
+      gdouble s, v;
+
+      priv->mode = DRAG_SV;
+      set_cross_grab (hsv, gdk_event_get_device ((GdkEvent *) event), event->time);
+
+      compute_sv (hsv, x, y, &s, &v);
+      mate_hsv_set_color (hsv, priv->h, s, v);
+
+      gtk_widget_grab_focus (widget);
+      priv->focus_on_ring = FALSE;
+
+      return TRUE;
+    }
+
+  return FALSE;
+}
+
+static gint
+mate_hsv_button_release (GtkWidget      *widget,
+                         GdkEventButton *event)
+{
+  MateHSV *hsv = MATE_HSV (widget);
+  MateHSVPrivate *priv = hsv->priv;
+  DragMode mode;
+  gdouble x, y;
+
+  if (priv->mode == DRAG_NONE || event->button != GDK_BUTTON_PRIMARY)
+    return FALSE;
+
+  /* Set the drag mode to DRAG_NONE so that signal handlers for "catched"
+   * can see that this is the final color state.
+   */
+  mode = priv->mode;
+  priv->mode = DRAG_NONE;
+
+  x = event->x;
+  y = event->y;
+
+  if (mode == DRAG_H)
+    {
+      mate_hsv_set_color (hsv, compute_v (hsv, x, y), priv->s, priv->v);
+    }
+  else if (mode == DRAG_SV)
+    {
+      gdouble s, v;
+
+      compute_sv (hsv, x, y, &s, &v);
+      mate_hsv_set_color (hsv, priv->h, s, v);
+    }
+  else
+    {
+      g_assert_not_reached ();
+    }
+
+  gdk_seat_ungrab (gdk_device_get_seat (gdk_event_get_device ((GdkEvent *) event)));
+
+  return TRUE;
+}
+
+static gint
+mate_hsv_motion (GtkWidget      *widget,
+                 GdkEventMotion *event)
+{
+  MateHSV *hsv = MATE_HSV (widget);
+  MateHSVPrivate *priv = hsv->priv;
+  gdouble x, y;
+
+  if (priv->mode == DRAG_NONE)
+    return FALSE;
+
+  gdk_event_request_motions (event);
+  x = event->x;
+  y = event->y;
+
+  if (priv->mode == DRAG_H)
+    {
+      mate_hsv_set_color (hsv, compute_v (hsv, x, y), priv->s, priv->v);
+      return TRUE;
+    }
+  else if (priv->mode == DRAG_SV)
+    {
+      gdouble s, v;
+
+      compute_sv (hsv, x, y, &s, &v);
+      mate_hsv_set_color (hsv, priv->h, s, v);
+      return TRUE;
+    }
+
+  g_assert_not_reached ();
+
+  return FALSE;
+}
+
+/* Redrawing */
+
+/* Paints the hue ring */
+static void
+paint_ring (MateHSV *hsv,
+            cairo_t *cr)
+{
+  MateHSVPrivate *priv = hsv->priv;
+  GtkWidget *widget = GTK_WIDGET (hsv);
+  int xx, yy, width, height;
+  gdouble dx, dy, dist;
+  gdouble center_x;
+  gdouble center_y;
+  gdouble inner, outer;
+  guint32 *buf, *p;
+  gdouble angle;
+  gdouble hue;
+  gdouble r, g, b;
+  cairo_surface_t *source;
+  cairo_t *source_cr;
+  gint stride;
+
+  width = gtk_widget_get_allocated_width (widget);
+  height = gtk_widget_get_allocated_height (widget);
+
+  center_x = width / 2.0;
+  center_y = height / 2.0;
+
+  outer = priv->size / 2.0;
+  inner = outer - priv->ring_width;
+
+  /* Create an image initialized with the ring colors */
+
+  stride = cairo_format_stride_for_width (CAIRO_FORMAT_RGB24, width);
+  buf = g_new (guint32, height * stride / 4);
+
+  for (yy = 0; yy < height; yy++)
+    {
+      p = buf + yy * width;
+
+      dy = -(yy - center_y);
+
+      for (xx = 0; xx < width; xx++)
+        {
+          dx = xx - center_x;
+
+          dist = dx * dx + dy * dy;
+          if (dist < ((inner-1) * (inner-1)) || dist > ((outer+1) * (outer+1)))
+            {
+              *p++ = 0;
+              continue;
+            }
+
+          angle = atan2 (dy, dx);
+          if (angle < 0.0)
+            angle += 2.0 * G_PI;
+
+          hue = angle / (2.0 * G_PI);
+
+          r = hue;
+          g = 1.0;
+          b = 1.0;
+          hsv_to_rgb (&r, &g, &b);
+
+          *p++ = (((int)(r * 255.0) << 16) |
+                  ((int)(g * 255.0) << 8) |
+                  (int)(b * 255.0));
+        }
+    }
+
+  source = cairo_image_surface_create_for_data ((unsigned char *)buf,
+                                                CAIRO_FORMAT_RGB24,
+                                                width, height, stride);
+
+  /* Now draw the value marker onto the source image, so that it
+   * will get properly clipped at the edges of the ring
+   */
+  source_cr = cairo_create (source);
+
+  r = priv->h;
+  g = 1.0;
+  b = 1.0;
+  hsv_to_rgb (&r, &g, &b);
+
+  if (INTENSITY (r, g, b) > 0.5)
+    cairo_set_source_rgb (source_cr, 0., 0., 0.);
+  else
+    cairo_set_source_rgb (source_cr, 1., 1., 1.);
+
+  cairo_move_to (source_cr, center_x, center_y);
+  cairo_line_to (source_cr,
+                 center_x + cos (priv->h * 2.0 * G_PI) * priv->size / 2,
+                 center_y - sin (priv->h * 2.0 * G_PI) * priv->size / 2);
+  cairo_stroke (source_cr);
+  cairo_destroy (source_cr);
+
+  /* Draw the ring using the source image */
+
+  cairo_save (cr);
+
+  cairo_set_source_surface (cr, source, 0, 0);
+  cairo_surface_destroy (source);
+
+  cairo_set_line_width (cr, priv->ring_width);
+  cairo_new_path (cr);
+  cairo_arc (cr,
+             center_x, center_y,
+             priv->size / 2. - priv->ring_width / 2.,
+             0, 2 * G_PI);
+  cairo_stroke (cr);
+
+  cairo_restore (cr);
+
+  g_free (buf);
+}
+
+/* Converts an HSV triplet to an integer RGB triplet */
+static void
+get_color (gdouble h,
+           gdouble s,
+           gdouble v,
+           gint   *r,
+           gint   *g,
+           gint   *b)
+{
+  hsv_to_rgb (&h, &s, &v);
+
+  *r = floor (h * 255 + 0.5);
+  *g = floor (s * 255 + 0.5);
+  *b = floor (v * 255 + 0.5);
+}
+
+#define SWAP(a, b, t) ((t) = (a), (a) = (b), (b) = (t))
+
+#define LERP(a, b, v1, v2, i) (((v2) - (v1) != 0)                                       \
+                               ? ((a) + ((b) - (a)) * ((i) - (v1)) / ((v2) - (v1)))     \
+                               : (a))
+
+/* Number of pixels we extend out from the edges when creating
+ * color source to avoid artifacts
+ */
+#define PAD 3
+
+/* Paints the HSV triangle */
+static void
+paint_triangle (MateHSV  *hsv,
+                cairo_t  *cr,
+                gboolean  draw_focus)
+{
+  MateHSVPrivate *priv = hsv->priv;
+  GtkWidget *widget = GTK_WIDGET (hsv);
+  gint hx, hy, sx, sy, vx, vy; /* HSV vertices */
+  gint x1, y1, r1, g1, b1; /* First vertex in scanline order */
+  gint x2, y2, r2, g2, b2; /* Second vertex */
+  gint x3, y3, r3, g3, b3; /* Third vertex */
+  gint t;
+  guint32 *buf, *p, c;
+  gint xl, xr, rl, rr, gl, gr, bl, br; /* Scanline data */
+  gint xx, yy;
+  gint x_interp, y_interp;
+  gint x_start, x_end;
+  cairo_surface_t *source;
+  gdouble r, g, b;
+  gint stride;
+  int width, height;
+  GtkStyleContext *context;
+
+  width = gtk_widget_get_allocated_width (widget);
+  height = gtk_widget_get_allocated_height (widget);
+  /* Compute triangle's vertices */
+
+  compute_triangle (hsv, &hx, &hy, &sx, &sy, &vx, &vy);
+
+  x1 = hx;
+  y1 = hy;
+  get_color (priv->h, 1.0, 1.0, &r1, &g1, &b1);
+
+  x2 = sx;
+  y2 = sy;
+  get_color (priv->h, 1.0, 0.0, &r2, &g2, &b2);
+
+  x3 = vx;
+  y3 = vy;
+  get_color (priv->h, 0.0, 1.0, &r3, &g3, &b3);
+
+  if (y2 > y3)
+    {
+      SWAP (x2, x3, t);
+      SWAP (y2, y3, t);
+      SWAP (r2, r3, t);
+      SWAP (g2, g3, t);
+      SWAP (b2, b3, t);
+    }
+
+  if (y1 > y3)
+    {
+      SWAP (x1, x3, t);
+      SWAP (y1, y3, t);
+      SWAP (r1, r3, t);
+      SWAP (g1, g3, t);
+      SWAP (b1, b3, t);
+    }
+
+  if (y1 > y2)
+    {
+      SWAP (x1, x2, t);
+      SWAP (y1, y2, t);
+      SWAP (r1, r2, t);
+      SWAP (g1, g2, t);
+      SWAP (b1, b2, t);
+    }
+
+  /* Shade the triangle */
+
+  stride = cairo_format_stride_for_width (CAIRO_FORMAT_RGB24, width);
+  buf = g_new (guint32, height * stride / 4);
+
+  for (yy = 0; yy < height; yy++)
+    {
+      p = buf + yy * width;
+
+      if (yy >= y1 - PAD && yy < y3 + PAD) {
+        y_interp = CLAMP (yy, y1, y3);
+
+        if (y_interp < y2)
+          {
+            xl = LERP (x1, x2, y1, y2, y_interp);
+
+            rl = LERP (r1, r2, y1, y2, y_interp);
+            gl = LERP (g1, g2, y1, y2, y_interp);
+            bl = LERP (b1, b2, y1, y2, y_interp);
+          }
+        else
+          {
+            xl = LERP (x2, x3, y2, y3, y_interp);
+
+            rl = LERP (r2, r3, y2, y3, y_interp);
+            gl = LERP (g2, g3, y2, y3, y_interp);
+            bl = LERP (b2, b3, y2, y3, y_interp);
+          }
+
+        xr = LERP (x1, x3, y1, y3, y_interp);
+
+        rr = LERP (r1, r3, y1, y3, y_interp);
+        gr = LERP (g1, g3, y1, y3, y_interp);
+        br = LERP (b1, b3, y1, y3, y_interp);
+
+        if (xl > xr)
+          {
+            SWAP (xl, xr, t);
+            SWAP (rl, rr, t);
+            SWAP (gl, gr, t);
+            SWAP (bl, br, t);
+          }
+
+        x_start = MAX (xl - PAD, 0);
+        x_end = MIN (xr + PAD, width);
+        x_start = MIN (x_start, x_end);
+
+        c = (rl << 16) | (gl << 8) | bl;
+
+        for (xx = 0; xx < x_start; xx++)
+          *p++ = c;
+
+        for (; xx < x_end; xx++)
+          {
+            x_interp = CLAMP (xx, xl, xr);
+
+            *p++ = ((LERP (rl, rr, xl, xr, x_interp) << 16) |
+                    (LERP (gl, gr, xl, xr, x_interp) << 8) |
+                    LERP (bl, br, xl, xr, x_interp));
+          }
+
+        c = (rr << 16) | (gr << 8) | br;
+
+        for (; xx < width; xx++)
+          *p++ = c;
+      }
+    }
+
+  source = cairo_image_surface_create_for_data ((unsigned char *)buf,
+                                                CAIRO_FORMAT_RGB24,
+                                                width, height, stride);
+
+  /* Draw a triangle with the image as a source */
+
+  cairo_set_source_surface (cr, source, 0, 0);
+  cairo_surface_destroy (source);
+
+  cairo_move_to (cr, x1, y1);
+  cairo_line_to (cr, x2, y2);
+  cairo_line_to (cr, x3, y3);
+  cairo_close_path (cr);
+  cairo_fill (cr);
+
+  g_free (buf);
+
+  /* Draw value marker */
+
+  xx = floor (sx + (vx - sx) * priv->v + (hx - vx) * priv->s * priv->v + 0.5);
+  yy = floor (sy + (vy - sy) * priv->v + (hy - vy) * priv->s * priv->v + 0.5);
+
+  r = priv->h;
+  g = priv->s;
+  b = priv->v;
+  hsv_to_rgb (&r, &g, &b);
+
+  context = gtk_widget_get_style_context (widget);
+
+  gtk_style_context_save (context);
+
+  if (INTENSITY (r, g, b) > 0.5)
+    {
+      gtk_style_context_add_class (context, "light-area-focus");
+      cairo_set_source_rgb (cr, 0., 0., 0.);
+    }
+  else
+    {
+      gtk_style_context_add_class (context, "dark-area-focus");
+      cairo_set_source_rgb (cr, 1., 1., 1.);
+    }
+
+#define RADIUS 4
+#define FOCUS_RADIUS 6
+
+  cairo_new_path (cr);
+  cairo_arc (cr, xx, yy, RADIUS, 0, 2 * G_PI);
+  cairo_stroke (cr);
+
+  /* Draw focus outline */
+
+  if (draw_focus && !priv->focus_on_ring)
+    {
+      gint focus_width;
+      gint focus_pad;
+
+      gtk_widget_style_get (widget,
+                            "focus-line-width", &focus_width,
+                            "focus-padding", &focus_pad,
+                            NULL);
+
+      gtk_render_focus (context, cr,
+                        xx - FOCUS_RADIUS - focus_width - focus_pad,
+                        yy - FOCUS_RADIUS - focus_width - focus_pad,
+                        2 * (FOCUS_RADIUS + focus_width + focus_pad),
+                        2 * (FOCUS_RADIUS + focus_width + focus_pad));
+    }
+
+  gtk_style_context_restore (context);
+}
+
+/* Paints the contents of the HSV color selector */
+static gboolean
+mate_hsv_draw (GtkWidget *widget,
+               cairo_t   *cr)
+{
+  MateHSV *hsv = MATE_HSV (widget);
+  MateHSVPrivate *priv = hsv->priv;
+  gboolean draw_focus;
+
+  draw_focus = gtk_widget_has_visible_focus (widget);
+
+  paint_ring (hsv, cr);
+  paint_triangle (hsv, cr, draw_focus);
+
+  if (draw_focus && priv->focus_on_ring)
+    {
+      GtkStyleContext *context;
+
+      context = gtk_widget_get_style_context (widget);
+
+      gtk_render_focus (context, cr, 0, 0,
+                        gtk_widget_get_allocated_width (widget),
+                        gtk_widget_get_allocated_height (widget));
+    }
+
+  return FALSE;
+}
+
+static gboolean
+mate_hsv_focus (GtkWidget       *widget,
+                GtkDirectionType dir)
+{
+  MateHSV *hsv = MATE_HSV (widget);
+  MateHSVPrivate *priv = hsv->priv;
+
+  if (!gtk_widget_has_focus (widget))
+    {
+      if (dir == GTK_DIR_TAB_BACKWARD)
+        priv->focus_on_ring = FALSE;
+      else
+        priv->focus_on_ring = TRUE;
+
+      gtk_widget_grab_focus (GTK_WIDGET (hsv));
+      return TRUE;
+    }
+
+  switch (dir)
+    {
+    case GTK_DIR_UP:
+      if (priv->focus_on_ring)
+        return FALSE;
+      else
+        priv->focus_on_ring = TRUE;
+      break;
+
+    case GTK_DIR_DOWN:
+      if (priv->focus_on_ring)
+        priv->focus_on_ring = FALSE;
+      else
+        return FALSE;
+      break;
+
+    case GTK_DIR_LEFT:
+    case GTK_DIR_TAB_BACKWARD:
+      if (priv->focus_on_ring)
+        return FALSE;
+      else
+        priv->focus_on_ring = TRUE;
+      break;
+
+    case GTK_DIR_RIGHT:
+    case GTK_DIR_TAB_FORWARD:
+      if (priv->focus_on_ring)
+        priv->focus_on_ring = FALSE;
+      else
+        return FALSE;
+      break;
+    }
+
+  gtk_widget_queue_draw (GTK_WIDGET (hsv));
+
+  return TRUE;
+}
+
+/**
+ * mate_hsv_new:
+ *
+ * Creates a new HSV color selector.
+ *
+ * Returns: A newly-created HSV color selector.
+ */
+GtkWidget*
+mate_hsv_new (void)
+{
+  return g_object_new (MATE_TYPE_HSV, NULL);
+}
+
+/**
+ * mate_hsv_set_color:
+ * @hsv: An HSV color selector
+ * @h: Hue
+ * @s: Saturation
+ * @v: Value
+ *
+ * Sets the current color in an HSV color selector.
+ * Color component values must be in the [0.0, 1.0] range.
+ */
+void
+mate_hsv_set_color (MateHSV *hsv,
+                    gdouble  h,
+                    gdouble  s,
+                    gdouble  v)
+{
+  MateHSVPrivate *priv;
+
+  g_return_if_fail (MATE_IS_HSV (hsv));
+  g_return_if_fail (h >= 0.0 && h <= 1.0);
+  g_return_if_fail (s >= 0.0 && s <= 1.0);
+  g_return_if_fail (v >= 0.0 && v <= 1.0);
+
+  priv = hsv->priv;
+
+  priv->h = h;
+  priv->s = s;
+  priv->v = v;
+
+  g_signal_emit (hsv, hsv_signals[CHANGED], 0);
+
+  gtk_widget_queue_draw (GTK_WIDGET (hsv));
+}
+
+/**
+ * mate_hsv_get_color:
+ * @hsv: An HSV color selector
+ * @h: (out): Return value for the hue
+ * @s: (out): Return value for the saturation
+ * @v: (out): Return value for the value
+ *
+ * Queries the current color in an HSV color selector.
+ * Returned values will be in the [0.0, 1.0] range.
+ */
+void
+mate_hsv_get_color (MateHSV *hsv,
+                    double  *h,
+                    double  *s,
+                    double  *v)
+{
+  MateHSVPrivate *priv;
+
+  g_return_if_fail (MATE_IS_HSV (hsv));
+
+  priv = hsv->priv;
+
+  if (h)
+    *h = priv->h;
+
+  if (s)
+    *s = priv->s;
+
+  if (v)
+    *v = priv->v;
+}
+
+/**
+ * mate_hsv_set_metrics:
+ * @hsv: An HSV color selector
+ * @size: Diameter for the hue ring
+ * @ring_width: Width of the hue ring
+ *
+ * Sets the size and ring width of an HSV color selector.
+ */
+void
+mate_hsv_set_metrics (MateHSV *hsv,
+                      gint     size,
+                      gint     ring_width)
+{
+  MateHSVPrivate *priv;
+  int same_size;
+
+  g_return_if_fail (MATE_IS_HSV (hsv));
+  g_return_if_fail (size > 0);
+  g_return_if_fail (ring_width > 0);
+  g_return_if_fail (2 * ring_width + 1 <= size);
+
+  priv = hsv->priv;
+
+  same_size = (priv->size == size);
+
+  priv->size = size;
+  priv->ring_width = ring_width;
+
+  if (same_size)
+    gtk_widget_queue_draw (GTK_WIDGET (hsv));
+  else
+    gtk_widget_queue_resize (GTK_WIDGET (hsv));
+}
+
+/**
+ * mate_hsv_get_metrics:
+ * @hsv: An HSV color selector
+ * @size: (out): Return value for the diameter of the hue ring
+ * @ring_width: (out): Return value for the width of the hue ring
+ *
+ * Queries the size and ring width of an HSV color selector.
+ */
+void
+mate_hsv_get_metrics (MateHSV *hsv,
+                      gint    *size,
+                      gint    *ring_width)
+{
+  MateHSVPrivate *priv;
+
+  g_return_if_fail (MATE_IS_HSV (hsv));
+
+  priv = hsv->priv;
+
+  if (size)
+    *size = priv->size;
+
+  if (ring_width)
+    *ring_width = priv->ring_width;
+}
+
+/**
+ * mate_hsv_is_adjusting:
+ * @hsv: A #MateHSV
+ *
+ * An HSV color selector can be said to be adjusting if multiple rapid
+ * changes are being made to its value, for example, when the user is
+ * adjusting the value with the mouse. This function queries whether
+ * the HSV color selector is being adjusted or not.
+ *
+ * Returns: %TRUE if clients can ignore changes to the color value,
+ *     since they may be transitory, or %FALSE if they should consider
+ *     the color value status to be final.
+ */
+gboolean
+mate_hsv_is_adjusting (MateHSV *hsv)
+{
+  MateHSVPrivate *priv;
+
+  g_return_val_if_fail (MATE_IS_HSV (hsv), FALSE);
+
+  priv = hsv->priv;
+
+  return priv->mode != DRAG_NONE;
+}
+
+static void
+mate_hsv_move (MateHSV         *hsv,
+               GtkDirectionType dir)
+{
+  MateHSVPrivate *priv = hsv->priv;
+  gdouble hue, sat, val;
+  gint hx, hy, sx, sy, vx, vy; /* HSV vertices */
+  gint x, y; /* position in triangle */
+
+  hue = priv->h;
+  sat = priv->s;
+  val = priv->v;
+
+  compute_triangle (hsv, &hx, &hy, &sx, &sy, &vx, &vy);
+
+  x = floor (sx + (vx - sx) * priv->v + (hx - vx) * priv->s * priv->v + 0.5);
+  y = floor (sy + (vy - sy) * priv->v + (hy - vy) * priv->s * priv->v + 0.5);
+
+#define HUE_DELTA 0.002
+  switch (dir)
+    {
+    case GTK_DIR_UP:
+      if (priv->focus_on_ring)
+        hue += HUE_DELTA;
+      else
+        {
+          y -= 1;
+          compute_sv (hsv, x, y, &sat, &val);
+        }
+      break;
+
+    case GTK_DIR_DOWN:
+      if (priv->focus_on_ring)
+        hue -= HUE_DELTA;
+      else
+        {
+          y += 1;
+          compute_sv (hsv, x, y, &sat, &val);
+        }
+      break;
+
+    case GTK_DIR_LEFT:
+      if (priv->focus_on_ring)
+        hue += HUE_DELTA;
+      else
+        {
+          x -= 1;
+          compute_sv (hsv, x, y, &sat, &val);
+        }
+      break;
+
+    case GTK_DIR_RIGHT:
+      if (priv->focus_on_ring)
+        hue -= HUE_DELTA
+          ;
+      else
+        {
+          x += 1;
+          compute_sv (hsv, x, y, &sat, &val);
+        }
+      break;
+
+    default:
+      /* we don't care about the tab directions */
+      break;
+    }
+
+  /* Wrap */
+  if (hue < 0.0)
+    hue = 1.0;
+  else if (hue > 1.0)
+    hue = 0.0;
+
+  mate_hsv_set_color (hsv, hue, sat, val);
+}
+
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/27.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/27.html new file mode 100644 index 0000000..c91a31e --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/27.html @@ -0,0 +1,1341 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
/*
+ * Copyright (C) 2023 zhuyaliang.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"<--- Include file: "config.h" not found.
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gstdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "mate-image-menu-item.h"
+
+struct _MateImageMenuItem
+{
+    GtkMenuItem  menu_item;
+    GtkWidget   *image;
+    gchar       *label;
+};
+
+enum {
+    PROP_0,
+    PROP_IMAGE,
+};
+
+G_DEFINE_TYPE (MateImageMenuItem, mate_image_menu_item, GTK_TYPE_MENU_ITEM)<--- There is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE is a macro then please configure it.
+
+static void
+mate_image_menu_item_destroy (GtkWidget *widget)
+{
+    MateImageMenuItem *image_menu_item = MATE_IMAGE_MENU_ITEM (widget);
+
+    if (image_menu_item->image)
+        gtk_container_remove (GTK_CONTAINER (image_menu_item),
+                              image_menu_item->image);
+
+    GTK_WIDGET_CLASS (mate_image_menu_item_parent_class)->destroy (widget);
+}
+
+static void
+mate_image_menu_item_get_preferred_width (GtkWidget *widget,
+                                          gint      *minimum,
+                                          gint      *natural)
+{
+    MateImageMenuItem *image_menu_item = MATE_IMAGE_MENU_ITEM (widget);
+    GtkPackDirection pack_dir;
+    GtkWidget *parent;
+
+    parent = gtk_widget_get_parent (widget);
+
+    if (GTK_IS_MENU_BAR (parent))
+        pack_dir = gtk_menu_bar_get_child_pack_direction (GTK_MENU_BAR (parent));
+    else
+        pack_dir = GTK_PACK_DIRECTION_LTR;
+
+    GTK_WIDGET_CLASS (mate_image_menu_item_parent_class)->get_preferred_width (widget, minimum, natural);
+
+    if ((pack_dir == GTK_PACK_DIRECTION_TTB || pack_dir == GTK_PACK_DIRECTION_BTT) &&
+        image_menu_item->image &&
+        gtk_widget_get_visible (image_menu_item->image))
+    {
+        gint child_minimum, child_natural;
+
+        gtk_widget_get_preferred_width (image_menu_item->image, &child_minimum, &child_natural);
+
+        *minimum = MAX (*minimum, child_minimum);
+        *natural = MAX (*natural, child_natural);
+    }
+}
+
+static void
+mate_image_menu_item_get_preferred_height (GtkWidget *widget,
+                                           gint      *minimum,
+                                           gint      *natural)
+{
+    MateImageMenuItem *image_menu_item = MATE_IMAGE_MENU_ITEM (widget);
+    gint child_height = 0;
+    GtkPackDirection pack_dir;
+    GtkWidget *parent;
+
+    parent = gtk_widget_get_parent (widget);
+
+    if (GTK_IS_MENU_BAR (parent))
+        pack_dir = gtk_menu_bar_get_child_pack_direction (GTK_MENU_BAR (parent));
+    else
+        pack_dir = GTK_PACK_DIRECTION_LTR;
+
+    if (image_menu_item->image && gtk_widget_get_visible (image_menu_item->image))
+    {
+        GtkRequisition child_requisition;
+
+        gtk_widget_get_preferred_size (image_menu_item->image, &child_requisition, NULL);
+
+        child_height = child_requisition.height;
+    }
+
+    GTK_WIDGET_CLASS (mate_image_menu_item_parent_class)->get_preferred_height (widget, minimum, natural);
+
+    if (pack_dir == GTK_PACK_DIRECTION_RTL || pack_dir == GTK_PACK_DIRECTION_LTR)
+    {
+        *minimum = MAX (*minimum, child_height);
+        *natural = MAX (*natural, child_height);
+    }
+}
+
+static void
+mate_image_menu_item_get_preferred_height_for_width (GtkWidget *widget,
+                                                     gint       width,
+                                                     gint      *minimum,
+                                                     gint      *natural)
+{
+    MateImageMenuItem *image_menu_item = MATE_IMAGE_MENU_ITEM (widget);
+    gint child_height = 0;
+    GtkPackDirection pack_dir;
+    GtkWidget *parent;
+
+    parent = gtk_widget_get_parent (widget);
+
+    if (GTK_IS_MENU_BAR (parent))
+        pack_dir = gtk_menu_bar_get_child_pack_direction (GTK_MENU_BAR (parent));
+    else
+        pack_dir = GTK_PACK_DIRECTION_LTR;
+
+    if (image_menu_item->image && gtk_widget_get_visible (image_menu_item->image))
+    {
+        GtkRequisition child_requisition;
+
+        gtk_widget_get_preferred_size (image_menu_item->image, &child_requisition, NULL);
+
+        child_height = child_requisition.height;
+    }
+
+    GTK_WIDGET_CLASS (mate_image_menu_item_parent_class)->get_preferred_height_for_width (widget, width, minimum, natural);
+
+    if (pack_dir == GTK_PACK_DIRECTION_RTL || pack_dir == GTK_PACK_DIRECTION_LTR)
+    {
+        *minimum = MAX (*minimum, child_height);
+        *natural = MAX (*natural, child_height);
+    }
+}
+
+static void
+mate_image_menu_item_size_allocate (GtkWidget     *widget,
+                                    GtkAllocation *allocation)
+{
+    MateImageMenuItem *image_menu_item = MATE_IMAGE_MENU_ITEM (widget);
+    GtkAllocation widget_allocation;
+    GtkRequisition image_requisition;
+    GtkPackDirection pack_dir;
+    GtkTextDirection text_dir;
+    GtkAllocation image_allocation;
+    GtkStyleContext *context;
+    GtkStateFlags state;
+    GtkBorder padding;
+    GtkWidget *parent;
+    gint toggle_size;
+    gint x;
+    gint y;
+
+    parent = gtk_widget_get_parent (widget);
+
+    if (GTK_IS_MENU_BAR (parent))
+        pack_dir = gtk_menu_bar_get_child_pack_direction (GTK_MENU_BAR (parent));
+    else
+        pack_dir = GTK_PACK_DIRECTION_LTR;
+
+    GTK_WIDGET_CLASS (mate_image_menu_item_parent_class)->size_allocate (widget, allocation);
+
+    if (!image_menu_item->image || !gtk_widget_get_visible (image_menu_item->image))
+        return;
+
+    gtk_widget_get_allocation (widget, &widget_allocation);
+    gtk_widget_get_preferred_size (image_menu_item->image, &image_requisition, NULL);
+
+    context = gtk_widget_get_style_context (widget);
+    state = gtk_style_context_get_state (context);
+    gtk_style_context_get_padding (context, state, &padding);
+
+    toggle_size = 0;
+    gtk_menu_item_toggle_size_request (GTK_MENU_ITEM (image_menu_item), &toggle_size);
+
+    text_dir = gtk_widget_get_direction (widget);
+
+    if (pack_dir == GTK_PACK_DIRECTION_LTR || pack_dir == GTK_PACK_DIRECTION_RTL)
+    {
+        if ((text_dir == GTK_TEXT_DIR_LTR) == (pack_dir == GTK_PACK_DIRECTION_LTR))
+        {
+            x = padding.left + (toggle_size - image_requisition.width) / 2;
+        }
+        else
+        {
+            x = widget_allocation.width - padding.right - toggle_size +
+                (toggle_size - image_requisition.width) / 2;
+        }
+
+        y = (widget_allocation.height - image_requisition.height) / 2;
+    }
+    else
+    {
+        if ((text_dir == GTK_TEXT_DIR_LTR) == (pack_dir == GTK_PACK_DIRECTION_TTB))
+        {
+            y = padding.top + (toggle_size - image_requisition.height) / 2;
+        }
+        else
+        {
+            y = widget_allocation.height - padding.bottom - toggle_size +
+                (toggle_size - image_requisition.height) / 2;
+        }
+
+        x = (widget_allocation.width - image_requisition.width) / 2;
+    }
+
+    image_allocation.x = widget_allocation.x + MAX (0, x);
+    image_allocation.y = widget_allocation.y + MAX (0, y);
+    image_allocation.width = image_requisition.width;
+    image_allocation.height = image_requisition.height;
+
+    gtk_widget_size_allocate (image_menu_item->image, &image_allocation);
+}
+
+static void
+mate_image_menu_item_add (GtkContainer *container,
+                          GtkWidget    *widget)
+{
+    GTK_CONTAINER_CLASS (mate_image_menu_item_parent_class)->add (container, widget);
+}
+
+static void
+mate_image_menu_item_forall (GtkContainer   *container,
+                             gboolean        include_internals,
+                             GtkCallback     callback,
+                             gpointer        callback_data)
+{
+    MateImageMenuItem *image_menu_item = MATE_IMAGE_MENU_ITEM (container);
+
+    GTK_CONTAINER_CLASS (mate_image_menu_item_parent_class)->forall (container,
+                                                                     include_internals,
+                                                                     callback,
+                                                                     callback_data);
+
+    if (include_internals && image_menu_item->image)
+        (* callback) (image_menu_item->image, callback_data);
+}
+
+static void
+mate_image_menu_item_remove (GtkContainer *container,
+                             GtkWidget    *child)
+{
+    MateImageMenuItem *image_menu_item = MATE_IMAGE_MENU_ITEM (container);
+
+    if (child == image_menu_item->image)
+    {
+        gboolean widget_was_visible;
+
+        widget_was_visible = gtk_widget_get_visible (child);
+
+        gtk_widget_unparent (child);
+        image_menu_item->image = NULL;
+
+        if (widget_was_visible &&
+            gtk_widget_get_visible (GTK_WIDGET (container)))
+            gtk_widget_queue_resize (GTK_WIDGET (container));
+
+        g_object_notify (G_OBJECT (image_menu_item), "image");
+    }
+    else
+    {
+        GTK_CONTAINER_CLASS (mate_image_menu_item_parent_class)->remove (container, child);
+    }
+}
+
+static void
+mate_image_menu_item_toggle_size_request (GtkMenuItem *menu_item,
+                                          gint        *requisition)
+{
+    MateImageMenuItem *image_menu_item = MATE_IMAGE_MENU_ITEM (menu_item);
+    GtkPackDirection pack_dir;
+    GtkWidget *parent;
+    GtkWidget *widget = GTK_WIDGET (menu_item);
+
+    parent = gtk_widget_get_parent (widget);
+
+    if (GTK_IS_MENU_BAR (parent))
+        pack_dir = gtk_menu_bar_get_child_pack_direction (GTK_MENU_BAR (parent));
+    else
+        pack_dir = GTK_PACK_DIRECTION_LTR;
+
+    *requisition = 0;
+
+    if (image_menu_item->image && gtk_widget_get_visible (image_menu_item->image))
+    {
+        GtkRequisition image_requisition;
+        guint toggle_spacing;
+
+        gtk_widget_get_preferred_size (image_menu_item->image, &image_requisition, NULL);
+
+        gtk_widget_style_get (GTK_WIDGET (menu_item),
+                             "toggle-spacing", &toggle_spacing,
+                              NULL);
+
+        if (pack_dir == GTK_PACK_DIRECTION_LTR || pack_dir == GTK_PACK_DIRECTION_RTL)
+        {
+            if (image_requisition.width > 0)
+              *requisition = image_requisition.width + toggle_spacing;
+        }
+        else
+        {
+            if (image_requisition.height > 0)
+              *requisition = image_requisition.height + toggle_spacing;
+        }
+    }
+}
+
+static void
+mate_image_menu_item_set_label (GtkMenuItem *menu_item,
+                                const gchar *label)
+{
+    MateImageMenuItem *image_menu_item = MATE_IMAGE_MENU_ITEM (menu_item);
+
+    if (image_menu_item->label != label)
+    {
+        g_free (image_menu_item->label);
+        image_menu_item->label = g_strdup (label);
+        GTK_MENU_ITEM_CLASS (mate_image_menu_item_parent_class)->set_label (menu_item, label);
+        g_object_notify (G_OBJECT (menu_item), "label");
+    }
+}
+
+static const gchar *
+mate_image_menu_item_get_label (GtkMenuItem *menu_item)
+{
+    MateImageMenuItem *image_menu_item = MATE_IMAGE_MENU_ITEM (menu_item);
+
+    return image_menu_item->label;
+}
+
+static void
+mate_image_menu_item_finalize (GObject *object)
+{
+    MateImageMenuItem *image_menu_item = MATE_IMAGE_MENU_ITEM (object);
+
+    g_free (image_menu_item->label);
+    image_menu_item->label  = NULL;
+
+    G_OBJECT_CLASS (mate_image_menu_item_parent_class)->finalize (object);
+}
+
+static void
+mate_image_menu_item_set_property (GObject      *object,
+                                   guint         prop_id,
+                                   const GValue *value,
+                                   GParamSpec   *pspec)
+{
+    MateImageMenuItem *image_menu_item = MATE_IMAGE_MENU_ITEM (object);
+
+    switch (prop_id)
+    {
+        case PROP_IMAGE:
+            mate_image_menu_item_set_image (image_menu_item, (GtkWidget *) g_value_get_object (value));
+            break;
+
+        default:
+            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+            break;
+    }
+}
+
+static void
+mate_image_menu_item_get_property (GObject    *object,
+                                   guint       prop_id,
+                                   GValue     *value,
+                                   GParamSpec *pspec)
+{
+    MateImageMenuItem *image_menu_item = MATE_IMAGE_MENU_ITEM (object);
+
+    switch (prop_id)
+    {
+        case PROP_IMAGE:
+            g_value_set_object (value, mate_image_menu_item_get_image (image_menu_item));
+            break;
+        default:
+            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+            break;
+    }
+}
+
+static void
+mate_image_menu_item_class_init (MateImageMenuItemClass *class)
+{
+    GObjectClass *gobject_class = (GObjectClass*) class;
+    GtkWidgetClass *widget_class = (GtkWidgetClass*) class;
+    GtkMenuItemClass *menu_item_class = (GtkMenuItemClass*) class;
+    GtkContainerClass *container_class = (GtkContainerClass*) class;
+
+    widget_class->destroy = mate_image_menu_item_destroy;
+    widget_class->get_preferred_width = mate_image_menu_item_get_preferred_width;
+    widget_class->get_preferred_height = mate_image_menu_item_get_preferred_height;
+    widget_class->get_preferred_height_for_width = mate_image_menu_item_get_preferred_height_for_width;
+    widget_class->size_allocate = mate_image_menu_item_size_allocate;
+
+    container_class->add    = mate_image_menu_item_add;
+    container_class->forall = mate_image_menu_item_forall;
+    container_class->remove = mate_image_menu_item_remove;
+
+    menu_item_class->toggle_size_request = mate_image_menu_item_toggle_size_request;
+    menu_item_class->set_label           = mate_image_menu_item_set_label;
+    menu_item_class->get_label           = mate_image_menu_item_get_label;
+
+    gobject_class->finalize     = mate_image_menu_item_finalize;
+    gobject_class->set_property = mate_image_menu_item_set_property;
+    gobject_class->get_property = mate_image_menu_item_get_property;
+
+  /**
+   * MateImageMenuItem:image:
+   *
+   * Child widget to appear next to the menu text.
+   *
+   */
+    g_object_class_install_property (gobject_class,
+                                     PROP_IMAGE,
+                                     g_param_spec_object ("image",
+                                                          _("Image widget"),
+                                                          _("Child widget to appear next to the menu text"),
+                                                          GTK_TYPE_WIDGET,
+                                                          G_PARAM_READWRITE | G_PARAM_DEPRECATED));
+}
+
+static void
+mate_image_menu_item_init (MateImageMenuItem *image_menu_item)
+{
+    image_menu_item->image = NULL;
+    image_menu_item->label  = NULL;
+}
+
+/**
+ * mate_image_menu_item_new:
+ *
+ * Creates a new #MateImageMenuItem with an empty label.
+ *
+ * Returns: a new #MateImageMenuItem
+ *
+ */
+GtkWidget*
+mate_image_menu_item_new (void)
+{
+    return g_object_new (MATE_TYPE_IMAGE_MENU_ITEM, NULL);
+}
+
+/**
+ * mate_image_menu_item_new_with_label:
+ * @label: the text of the menu item.
+ *
+ * Creates a new #MateImageMenuItem containing a label.
+ *
+ * Returns: a new #MateImageMenuItem.
+ *
+ */
+GtkWidget*
+mate_image_menu_item_new_with_label (const gchar *label)
+{
+    return g_object_new (MATE_TYPE_IMAGE_MENU_ITEM,
+                         "label", label,
+                         NULL);
+}
+
+/**
+ * mate_image_menu_item_new_with_mnemonic:
+ * @label: the text of the menu item, with an underscore in front of the
+ *         mnemonic character
+ *
+ * Creates a new #MateImageMenuItem containing a label. The label
+ * will be created using gtk_label_new_with_mnemonic(), so underscores
+ * in @label indicate the mnemonic for the menu item.
+ *
+ * Returns: a new #MateImageMenuItem
+ *
+ */
+GtkWidget*
+mate_image_menu_item_new_with_mnemonic (const gchar *label)
+{
+    return g_object_new (MATE_TYPE_IMAGE_MENU_ITEM,
+                         "use-underline", TRUE,
+                         "label", label,
+                         NULL);
+}
+
+/**
+ * mate_image_menu_item_set_image:
+ * @image_menu_item: a #MateImageMenuItem.
+ * @image: (allow-none): a widget to set as the image for the menu item.
+ *
+ * Sets the image of @image_menu_item to the given widget.
+ * Note that it depends on the show-menu-images setting whether
+ * the image will be displayed or not.
+ *
+ */
+void
+mate_image_menu_item_set_image (MateImageMenuItem *image_menu_item,
+                                GtkWidget         *image)
+{
+    g_return_if_fail (MATE_IS_IMAGE_MENU_ITEM (image_menu_item));
+
+    if (image == image_menu_item->image)
+        return;
+
+    if (image_menu_item->image)
+        gtk_container_remove (GTK_CONTAINER (image_menu_item),
+                              image_menu_item->image);
+
+    image_menu_item->image = image;
+
+    if (image == NULL)
+        return;
+
+    gtk_widget_set_parent (image, GTK_WIDGET (image_menu_item));
+    g_object_set (image,
+                  "visible", TRUE,
+                  "no-show-all", TRUE,
+                  NULL);
+    gtk_image_set_pixel_size (GTK_IMAGE (image), 16);
+
+    g_object_notify (G_OBJECT (image_menu_item), "image");
+}
+
+/**
+ * mate_image_menu_item_get_image:
+ * @image_menu_item: a #MateImageMenuItem
+ *
+ * Gets the widget that is currently set as the image of @image_menu_item.
+ * See mate_image_menu_item_set_image().
+ *
+ * Returns: (transfer none): the widget set as image of @image_menu_item
+ *
+ **/
+GtkWidget*
+mate_image_menu_item_get_image (MateImageMenuItem *image_menu_item)
+{
+    g_return_val_if_fail (MATE_IS_IMAGE_MENU_ITEM (image_menu_item), NULL);
+
+    return image_menu_item->image;
+}
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/28.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/28.html new file mode 100644 index 0000000..2ad2ed5 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/28.html @@ -0,0 +1,321 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
/*
+ * Copyright (C) 2023 zhuyaliang.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __MATE_IMAGE_MENU_ITEM_H__
+#define __MATE_IMAGE_MENU_ITEM_H__
+
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+G_BEGIN_DECLS
+
+#define MATE_TYPE_IMAGE_MENU_ITEM            (mate_image_menu_item_get_type ())
+
+G_DECLARE_FINAL_TYPE (MateImageMenuItem, mate_image_menu_item, MATE, IMAGE_MENU_ITEM, GtkMenuItem);
+
+GtkWidget* mate_image_menu_item_new               (void);
+
+GtkWidget* mate_image_menu_item_new_with_label    (const gchar       *label);
+
+GtkWidget* mate_image_menu_item_new_with_mnemonic (const gchar       *label);
+
+void       mate_image_menu_item_set_image         (MateImageMenuItem *image_menu_item,
+                                                   GtkWidget         *image);
+
+GtkWidget* mate_image_menu_item_get_image         (MateImageMenuItem *image_menu_item);
+
+G_END_DECLS
+
+#endif /* __GTK_IMAGE_MENU_ITEM_H__ */
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/29.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/29.html new file mode 100644 index 0000000..bbad13c --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/29.html @@ -0,0 +1,2915 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
   1
+   2
+   3
+   4
+   5
+   6
+   7
+   8
+   9
+  10
+  11
+  12
+  13
+  14
+  15
+  16
+  17
+  18
+  19
+  20
+  21
+  22
+  23
+  24
+  25
+  26
+  27
+  28
+  29
+  30
+  31
+  32
+  33
+  34
+  35
+  36
+  37
+  38
+  39
+  40
+  41
+  42
+  43
+  44
+  45
+  46
+  47
+  48
+  49
+  50
+  51
+  52
+  53
+  54
+  55
+  56
+  57
+  58
+  59
+  60
+  61
+  62
+  63
+  64
+  65
+  66
+  67
+  68
+  69
+  70
+  71
+  72
+  73
+  74
+  75
+  76
+  77
+  78
+  79
+  80
+  81
+  82
+  83
+  84
+  85
+  86
+  87
+  88
+  89
+  90
+  91
+  92
+  93
+  94
+  95
+  96
+  97
+  98
+  99
+ 100
+ 101
+ 102
+ 103
+ 104
+ 105
+ 106
+ 107
+ 108
+ 109
+ 110
+ 111
+ 112
+ 113
+ 114
+ 115
+ 116
+ 117
+ 118
+ 119
+ 120
+ 121
+ 122
+ 123
+ 124
+ 125
+ 126
+ 127
+ 128
+ 129
+ 130
+ 131
+ 132
+ 133
+ 134
+ 135
+ 136
+ 137
+ 138
+ 139
+ 140
+ 141
+ 142
+ 143
+ 144
+ 145
+ 146
+ 147
+ 148
+ 149
+ 150
+ 151
+ 152
+ 153
+ 154
+ 155
+ 156
+ 157
+ 158
+ 159
+ 160
+ 161
+ 162
+ 163
+ 164
+ 165
+ 166
+ 167
+ 168
+ 169
+ 170
+ 171
+ 172
+ 173
+ 174
+ 175
+ 176
+ 177
+ 178
+ 179
+ 180
+ 181
+ 182
+ 183
+ 184
+ 185
+ 186
+ 187
+ 188
+ 189
+ 190
+ 191
+ 192
+ 193
+ 194
+ 195
+ 196
+ 197
+ 198
+ 199
+ 200
+ 201
+ 202
+ 203
+ 204
+ 205
+ 206
+ 207
+ 208
+ 209
+ 210
+ 211
+ 212
+ 213
+ 214
+ 215
+ 216
+ 217
+ 218
+ 219
+ 220
+ 221
+ 222
+ 223
+ 224
+ 225
+ 226
+ 227
+ 228
+ 229
+ 230
+ 231
+ 232
+ 233
+ 234
+ 235
+ 236
+ 237
+ 238
+ 239
+ 240
+ 241
+ 242
+ 243
+ 244
+ 245
+ 246
+ 247
+ 248
+ 249
+ 250
+ 251
+ 252
+ 253
+ 254
+ 255
+ 256
+ 257
+ 258
+ 259
+ 260
+ 261
+ 262
+ 263
+ 264
+ 265
+ 266
+ 267
+ 268
+ 269
+ 270
+ 271
+ 272
+ 273
+ 274
+ 275
+ 276
+ 277
+ 278
+ 279
+ 280
+ 281
+ 282
+ 283
+ 284
+ 285
+ 286
+ 287
+ 288
+ 289
+ 290
+ 291
+ 292
+ 293
+ 294
+ 295
+ 296
+ 297
+ 298
+ 299
+ 300
+ 301
+ 302
+ 303
+ 304
+ 305
+ 306
+ 307
+ 308
+ 309
+ 310
+ 311
+ 312
+ 313
+ 314
+ 315
+ 316
+ 317
+ 318
+ 319
+ 320
+ 321
+ 322
+ 323
+ 324
+ 325
+ 326
+ 327
+ 328
+ 329
+ 330
+ 331
+ 332
+ 333
+ 334
+ 335
+ 336
+ 337
+ 338
+ 339
+ 340
+ 341
+ 342
+ 343
+ 344
+ 345
+ 346
+ 347
+ 348
+ 349
+ 350
+ 351
+ 352
+ 353
+ 354
+ 355
+ 356
+ 357
+ 358
+ 359
+ 360
+ 361
+ 362
+ 363
+ 364
+ 365
+ 366
+ 367
+ 368
+ 369
+ 370
+ 371
+ 372
+ 373
+ 374
+ 375
+ 376
+ 377
+ 378
+ 379
+ 380
+ 381
+ 382
+ 383
+ 384
+ 385
+ 386
+ 387
+ 388
+ 389
+ 390
+ 391
+ 392
+ 393
+ 394
+ 395
+ 396
+ 397
+ 398
+ 399
+ 400
+ 401
+ 402
+ 403
+ 404
+ 405
+ 406
+ 407
+ 408
+ 409
+ 410
+ 411
+ 412
+ 413
+ 414
+ 415
+ 416
+ 417
+ 418
+ 419
+ 420
+ 421
+ 422
+ 423
+ 424
+ 425
+ 426
+ 427
+ 428
+ 429
+ 430
+ 431
+ 432
+ 433
+ 434
+ 435
+ 436
+ 437
+ 438
+ 439
+ 440
+ 441
+ 442
+ 443
+ 444
+ 445
+ 446
+ 447
+ 448
+ 449
+ 450
+ 451
+ 452
+ 453
+ 454
+ 455
+ 456
+ 457
+ 458
+ 459
+ 460
+ 461
+ 462
+ 463
+ 464
+ 465
+ 466
+ 467
+ 468
+ 469
+ 470
+ 471
+ 472
+ 473
+ 474
+ 475
+ 476
+ 477
+ 478
+ 479
+ 480
+ 481
+ 482
+ 483
+ 484
+ 485
+ 486
+ 487
+ 488
+ 489
+ 490
+ 491
+ 492
+ 493
+ 494
+ 495
+ 496
+ 497
+ 498
+ 499
+ 500
+ 501
+ 502
+ 503
+ 504
+ 505
+ 506
+ 507
+ 508
+ 509
+ 510
+ 511
+ 512
+ 513
+ 514
+ 515
+ 516
+ 517
+ 518
+ 519
+ 520
+ 521
+ 522
+ 523
+ 524
+ 525
+ 526
+ 527
+ 528
+ 529
+ 530
+ 531
+ 532
+ 533
+ 534
+ 535
+ 536
+ 537
+ 538
+ 539
+ 540
+ 541
+ 542
+ 543
+ 544
+ 545
+ 546
+ 547
+ 548
+ 549
+ 550
+ 551
+ 552
+ 553
+ 554
+ 555
+ 556
+ 557
+ 558
+ 559
+ 560
+ 561
+ 562
+ 563
+ 564
+ 565
+ 566
+ 567
+ 568
+ 569
+ 570
+ 571
+ 572
+ 573
+ 574
+ 575
+ 576
+ 577
+ 578
+ 579
+ 580
+ 581
+ 582
+ 583
+ 584
+ 585
+ 586
+ 587
+ 588
+ 589
+ 590
+ 591
+ 592
+ 593
+ 594
+ 595
+ 596
+ 597
+ 598
+ 599
+ 600
+ 601
+ 602
+ 603
+ 604
+ 605
+ 606
+ 607
+ 608
+ 609
+ 610
+ 611
+ 612
+ 613
+ 614
+ 615
+ 616
+ 617
+ 618
+ 619
+ 620
+ 621
+ 622
+ 623
+ 624
+ 625
+ 626
+ 627
+ 628
+ 629
+ 630
+ 631
+ 632
+ 633
+ 634
+ 635
+ 636
+ 637
+ 638
+ 639
+ 640
+ 641
+ 642
+ 643
+ 644
+ 645
+ 646
+ 647
+ 648
+ 649
+ 650
+ 651
+ 652
+ 653
+ 654
+ 655
+ 656
+ 657
+ 658
+ 659
+ 660
+ 661
+ 662
+ 663
+ 664
+ 665
+ 666
+ 667
+ 668
+ 669
+ 670
+ 671
+ 672
+ 673
+ 674
+ 675
+ 676
+ 677
+ 678
+ 679
+ 680
+ 681
+ 682
+ 683
+ 684
+ 685
+ 686
+ 687
+ 688
+ 689
+ 690
+ 691
+ 692
+ 693
+ 694
+ 695
+ 696
+ 697
+ 698
+ 699
+ 700
+ 701
+ 702
+ 703
+ 704
+ 705
+ 706
+ 707
+ 708
+ 709
+ 710
+ 711
+ 712
+ 713
+ 714
+ 715
+ 716
+ 717
+ 718
+ 719
+ 720
+ 721
+ 722
+ 723
+ 724
+ 725
+ 726
+ 727
+ 728
+ 729
+ 730
+ 731
+ 732
+ 733
+ 734
+ 735
+ 736
+ 737
+ 738
+ 739
+ 740
+ 741
+ 742
+ 743
+ 744
+ 745
+ 746
+ 747
+ 748
+ 749
+ 750
+ 751
+ 752
+ 753
+ 754
+ 755
+ 756
+ 757
+ 758
+ 759
+ 760
+ 761
+ 762
+ 763
+ 764
+ 765
+ 766
+ 767
+ 768
+ 769
+ 770
+ 771
+ 772
+ 773
+ 774
+ 775
+ 776
+ 777
+ 778
+ 779
+ 780
+ 781
+ 782
+ 783
+ 784
+ 785
+ 786
+ 787
+ 788
+ 789
+ 790
+ 791
+ 792
+ 793
+ 794
+ 795
+ 796
+ 797
+ 798
+ 799
+ 800
+ 801
+ 802
+ 803
+ 804
+ 805
+ 806
+ 807
+ 808
+ 809
+ 810
+ 811
+ 812
+ 813
+ 814
+ 815
+ 816
+ 817
+ 818
+ 819
+ 820
+ 821
+ 822
+ 823
+ 824
+ 825
+ 826
+ 827
+ 828
+ 829
+ 830
+ 831
+ 832
+ 833
+ 834
+ 835
+ 836
+ 837
+ 838
+ 839
+ 840
+ 841
+ 842
+ 843
+ 844
+ 845
+ 846
+ 847
+ 848
+ 849
+ 850
+ 851
+ 852
+ 853
+ 854
+ 855
+ 856
+ 857
+ 858
+ 859
+ 860
+ 861
+ 862
+ 863
+ 864
+ 865
+ 866
+ 867
+ 868
+ 869
+ 870
+ 871
+ 872
+ 873
+ 874
+ 875
+ 876
+ 877
+ 878
+ 879
+ 880
+ 881
+ 882
+ 883
+ 884
+ 885
+ 886
+ 887
+ 888
+ 889
+ 890
+ 891
+ 892
+ 893
+ 894
+ 895
+ 896
+ 897
+ 898
+ 899
+ 900
+ 901
+ 902
+ 903
+ 904
+ 905
+ 906
+ 907
+ 908
+ 909
+ 910
+ 911
+ 912
+ 913
+ 914
+ 915
+ 916
+ 917
+ 918
+ 919
+ 920
+ 921
+ 922
+ 923
+ 924
+ 925
+ 926
+ 927
+ 928
+ 929
+ 930
+ 931
+ 932
+ 933
+ 934
+ 935
+ 936
+ 937
+ 938
+ 939
+ 940
+ 941
+ 942
+ 943
+ 944
+ 945
+ 946
+ 947
+ 948
+ 949
+ 950
+ 951
+ 952
+ 953
+ 954
+ 955
+ 956
+ 957
+ 958
+ 959
+ 960
+ 961
+ 962
+ 963
+ 964
+ 965
+ 966
+ 967
+ 968
+ 969
+ 970
+ 971
+ 972
+ 973
+ 974
+ 975
+ 976
+ 977
+ 978
+ 979
+ 980
+ 981
+ 982
+ 983
+ 984
+ 985
+ 986
+ 987
+ 988
+ 989
+ 990
+ 991
+ 992
+ 993
+ 994
+ 995
+ 996
+ 997
+ 998
+ 999
+1000
+1001
+1002
+1003
+1004
+1005
+1006
+1007
+1008
+1009
+1010
+1011
+1012
+1013
+1014
+1015
+1016
+1017
+1018
+1019
+1020
+1021
+1022
+1023
+1024
+1025
+1026
+1027
+1028
+1029
+1030
+1031
+1032
+1033
+1034
+1035
+1036
+1037
+1038
+1039
+1040
+1041
+1042
+1043
+1044
+1045
+1046
+1047
+1048
+1049
+1050
+1051
+1052
+1053
+1054
+1055
+1056
+1057
+1058
+1059
+1060
+1061
+1062
+1063
+1064
+1065
+1066
+1067
+1068
+1069
+1070
+1071
+1072
+1073
+1074
+1075
+1076
+1077
+1078
+1079
+1080
+1081
+1082
+1083
+1084
+1085
+1086
+1087
+1088
+1089
+1090
+1091
+1092
+1093
+1094
+1095
+1096
+1097
+1098
+1099
+1100
+1101
+1102
+1103
+1104
+1105
+1106
+1107
+1108
+1109
+1110
+1111
+1112
+1113
+1114
+1115
+1116
+1117
+1118
+1119
+1120
+1121
+1122
+1123
+1124
+1125
+1126
+1127
+1128
+1129
+1130
+1131
+1132
+1133
+1134
+1135
+1136
+1137
+1138
+1139
+1140
+1141
+1142
+1143
+1144
+1145
+1146
+1147
+1148
+1149
+1150
+1151
+1152
+1153
+1154
+1155
+1156
+1157
+1158
+1159
+1160
+1161
+1162
+1163
+1164
+1165
+1166
+1167
+1168
+1169
+1170
+1171
+1172
+1173
+1174
+1175
+1176
+1177
+1178
+1179
+1180
+1181
+1182
+1183
+1184
+1185
+1186
+1187
+1188
+1189
+1190
+1191
+1192
+1193
+1194
+1195
+1196
+1197
+1198
+1199
+1200
+1201
+1202
+1203
+1204
+1205
+1206
+1207
+1208
+1209
+1210
+1211
+1212
+1213
+1214
+1215
+1216
+1217
+1218
+1219
+1220
+1221
+1222
+1223
+1224
+1225
+1226
+1227
+1228
+1229
+1230
+1231
+1232
+1233
+1234
+1235
+1236
+1237
+1238
+1239
+1240
+1241
+1242
+1243
+1244
+1245
+1246
+1247
+1248
+1249
+1250
+1251
+1252
+1253
+1254
+1255
+1256
+1257
+1258
+1259
+1260
+1261
+1262
+1263
+1264
+1265
+1266
+1267
+1268
+1269
+1270
+1271
+1272
+1273
+1274
+1275
+1276
+1277
+1278
+1279
+1280
+1281
+1282
+1283
+1284
+1285
+1286
+1287
+1288
+1289
+1290
+1291
+1292
+1293
+1294
+1295
+1296
+1297
+1298
+1299
+1300
+1301
+1302
+1303
+1304
+1305
+1306
+1307
+1308
+1309
+1310
+1311
+1312
+1313
+1314
+1315
+1316
+1317
+1318
+1319
+1320
+1321
+1322
+1323
+1324
+1325
+1326
+1327
+1328
+1329
+1330
+1331
+1332
+1333
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright 2008  Red Hat, Inc,
+ *           2007  William Jon McCann <mccann@jhu.edu>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Written by : William Jon McCann <mccann@jhu.edu>
+ *              Ray Strode <rstrode@redhat.com>
+ */
+
+#include "config.h"<--- Include file: "config.h" not found.
+
+#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <errno.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <dirent.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <locale.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <langinfo.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/stat.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gstdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#define MATE_DESKTOP_USE_UNSTABLE_API
+#include "mate-languages.h"
+
+#include <langinfo.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#ifndef __LC_LAST
+#define __LC_LAST       13
+#endif
+
+#define ISO_CODES_DATADIR ISO_CODES_PREFIX "/share/xml/iso-codes"
+#define ISO_CODES_LOCALESDIR ISO_CODES_PREFIX "/share/locale"
+
+typedef struct _MateLocale {
+        char *id;
+        char *name;
+        char *language_code;
+        char *territory_code;
+        char *codeset;
+        char *modifier;
+} MateLocale;
+
+static GHashTable *mate_languages_map;
+static GHashTable *mate_territories_map;
+static GHashTable *mate_available_locales_map;
+static GHashTable *mate_language_count_map;
+static GHashTable *mate_territory_count_map;
+
+static char * construct_language_name (const char *language,
+                                       const char *territory,
+                                       const char *codeset,
+                                       const char *modifier);
+
+static gboolean language_name_is_valid (const char *language_name);
+
+static void
+mate_locale_free (MateLocale *locale)
+{
+        if (locale == NULL) {
+                return;
+        }
+
+        g_free (locale->id);
+        g_free (locale->name);
+        g_free (locale->codeset);
+        g_free (locale->modifier);
+        g_free (locale->language_code);
+        g_free (locale->territory_code);
+        g_free (locale);
+}
+
+static char *
+normalize_codeset (const char *codeset)
+{
+        if (codeset == NULL)
+                return NULL;
+
+        if (g_str_equal (codeset, "UTF-8") ||
+            g_str_equal (codeset, "utf8"))
+                return g_strdup ("UTF-8");
+
+        return g_strdup (codeset);
+}
+
+/**
+ * mate_parse_locale:
+ * @locale: a locale string
+ * @language_codep: (out) (allow-none) (transfer full): location to
+ * store the language code, or %NULL
+ * @country_codep: (out) (allow-none) (transfer full): location to
+ * store the country code, or %NULL
+ * @codesetp: (out) (allow-none) (transfer full): location to
+ * store the codeset, or %NULL
+ * @modifierp: (out) (allow-none) (transfer full): location to
+ * store the modifier, or %NULL
+ *
+ * Extracts the various components of a locale string of the form
+ * [language[_country][.codeset][@modifier]]. See
+ * http://en.wikipedia.org/wiki/Locale.
+ *
+ * Return value: %TRUE if parsing was successful.
+ *
+ * Since: 1.22
+ */
+gboolean
+mate_parse_locale (const char *locale,
+                    char      **language_codep,
+                    char      **country_codep,
+                    char      **codesetp,
+                    char      **modifierp)
+{
+        static GRegex *re = NULL;
+        GMatchInfo *match_info;
+        gboolean    res;
+        gchar      *normalized_codeset = NULL;
+        gchar      *normalized_name = NULL;
+        gboolean    retval;
+
+        match_info = NULL;
+        retval = FALSE;
+
+        if (re == NULL) {
+                GError *error = NULL;
+                re = g_regex_new ("^(?P<language>[^_.@[:space:]]+)"
+                                  "(_(?P<territory>[[:upper:]]+))?"
+                                  "(\\.(?P<codeset>[-_0-9a-zA-Z]+))?"
+                                  "(@(?P<modifier>[[:ascii:]]+))?$",
+                                  0, 0, &error);
+                if (re == NULL) {
+                        g_warning ("%s", error->message);
+                        g_error_free (error);
+                        goto out;
+                }
+        }
+
+        if (!g_regex_match (re, locale, 0, &match_info) ||
+            g_match_info_is_partial_match (match_info)) {
+                g_warning ("locale '%s' isn't valid\n", locale);
+                goto out;
+        }
+
+        res = g_match_info_matches (match_info);
+        if (! res) {
+                g_warning ("Unable to parse locale: %s", locale);
+                goto out;
+        }
+
+        retval = TRUE;
+
+        if (language_codep != NULL) {
+                *language_codep = g_match_info_fetch_named (match_info, "language");
+        }
+
+        if (country_codep != NULL) {
+                *country_codep = g_match_info_fetch_named (match_info, "territory");
+
+                if (*country_codep != NULL &&
+                    *country_codep[0] == '\0') {
+                        g_free (*country_codep);
+                        *country_codep = NULL;
+                }
+        }
+
+        if (codesetp != NULL) {
+                *codesetp = g_match_info_fetch_named (match_info, "codeset");
+
+                if (*codesetp != NULL &&
+                    *codesetp[0] == '\0') {
+                        g_free (*codesetp);
+                        *codesetp = NULL;
+                }
+        }
+
+        if (modifierp != NULL) {
+                *modifierp = g_match_info_fetch_named (match_info, "modifier");
+
+                if (*modifierp != NULL &&
+                    *modifierp[0] == '\0') {
+                        g_free (*modifierp);
+                        *modifierp = NULL;
+                }
+        }
+
+        if (codesetp != NULL && *codesetp != NULL) {
+                normalized_codeset = normalize_codeset (*codesetp);
+                normalized_name = construct_language_name (language_codep ? *language_codep : NULL,
+                                                           country_codep ? *country_codep : NULL,
+                                                           normalized_codeset,
+                                                           modifierp ? *modifierp : NULL);
+
+                if (language_name_is_valid (normalized_name)) {
+                        g_free (*codesetp);
+                        *codesetp = normalized_codeset;
+                } else {
+                        g_free (normalized_codeset);
+                }
+                g_free (normalized_name);
+        }
+
+ out:
+        g_match_info_free (match_info);
+
+        return retval;
+}
+
+static char *
+construct_language_name (const char *language,
+                         const char *territory,
+                         const char *codeset,
+                         const char *modifier)
+{
+        char *name;
+
+        g_assert (language != NULL && language[0] != 0);
+        g_assert (territory == NULL || territory[0] != 0);
+        g_assert (codeset == NULL || codeset[0] != 0);
+        g_assert (modifier == NULL || modifier[0] != 0);
+
+        name = g_strdup_printf ("%s%s%s%s%s%s%s",
+                                language,
+                                territory != NULL? "_" : "",
+                                territory != NULL? territory : "",
+                                codeset != NULL? "." : "",
+                                codeset != NULL? codeset : "",
+                                modifier != NULL? "@" : "",
+                                modifier != NULL? modifier : "");
+
+        return name;
+}
+
+/**
+ * mate_normalize_locale:
+ * @locale: a locale string
+ *
+ * Gets the normalized locale string in the form
+ * [language[_country][.codeset][@modifier]] for @name.
+ *
+ * Return value: (transfer full): normalized locale string. Caller
+ * takes ownership.
+ *
+ * Since: 1.22
+ */
+char *
+mate_normalize_locale (const char *locale)
+{
+        char *normalized_name;
+        gboolean valid;
+        g_autofree char *language_code = NULL;
+        g_autofree char *territory_code = NULL;
+        g_autofree char *codeset = NULL;
+        g_autofree char *modifier = NULL;
+
+        if (locale[0] == '\0') {
+                return NULL;
+        }
+
+        valid = mate_parse_locale (locale,
+                                    &language_code,
+                                    &territory_code,
+                                    &codeset, &modifier);
+        if (!valid)
+                return NULL;
+
+        normalized_name = construct_language_name (language_code,
+                                                   territory_code,
+                                                   codeset, modifier);
+        return normalized_name;
+}
+
+static gboolean
+language_name_is_valid (const char *language_name)
+{
+        gboolean  is_valid;
+        int lc_type_id = LC_MESSAGES;
+        g_autofree char *old_locale = NULL;
+
+        old_locale = g_strdup (setlocale (lc_type_id, NULL));
+        is_valid = setlocale (lc_type_id, language_name) != NULL;
+        setlocale (lc_type_id, old_locale);
+
+        return is_valid;
+}
+
+static void
+language_name_get_codeset_details (const char  *language_name,
+                                   char       **pcodeset,
+                                   gboolean    *is_utf8)
+{
+        g_autofree char *old_locale = NULL;
+        g_autofree char *codeset = NULL;
+
+        old_locale = g_strdup (setlocale (LC_CTYPE, NULL));
+
+        if (setlocale (LC_CTYPE, language_name) == NULL)
+                return;
+
+        codeset = nl_langinfo (CODESET);
+
+        if (pcodeset != NULL) {
+                *pcodeset = g_strdup (codeset);
+        }
+
+        if (is_utf8 != NULL) {
+                codeset = normalize_codeset (codeset);
+
+                *is_utf8 = strcmp (codeset, "UTF-8") == 0;
+        }
+
+        setlocale (LC_CTYPE, old_locale);
+}
+
+static gboolean
+locale_dir_has_mo_files (const gchar* path)
+{
+        GDir        *dir;
+        const char  *name;
+        gboolean     has_translations;
+
+        has_translations = FALSE;
+        dir = g_dir_open (path, 0, NULL);
+
+        if (dir == NULL) {
+                goto out;
+        }
+
+        do {
+                name = g_dir_read_name (dir);
+
+                if (name == NULL) {
+                        break;
+                }
+
+                if (g_str_has_suffix (name, ".mo")) {
+                        has_translations = TRUE;
+                        break;
+                }
+        } while (name != NULL);
+        g_dir_close (dir);
+
+ out:
+        return has_translations;
+}
+
+/**
+ * mate_language_has_translations:
+ * @code: an ISO 639 code string
+ *
+ * Returns %TRUE if there are translations for language @code.
+ *
+ * Return value: %TRUE if there are translations for language @code.
+ *
+ * Since: 1.22
+ */
+gboolean
+mate_language_has_translations (const char *code)
+{
+        gboolean has_translations;
+        gchar *path;
+
+        path = g_build_filename (MATELOCALEDIR, code, "LC_MESSAGES", NULL);
+        has_translations = locale_dir_has_mo_files (path);
+
+        if (!has_translations) {
+                const char * const *system_data_dirs;
+                int i = 0;
+
+                system_data_dirs = g_get_system_data_dirs ();
+                while ((system_data_dirs[i] != NULL) && (has_translations == FALSE)) {
+                        g_free (path);
+                        path = g_build_filename (system_data_dirs[i], "locale", code, "LC_MESSAGES", NULL);
+                        has_translations = locale_dir_has_mo_files (path);
+                        ++i;
+                }
+        }
+
+        g_free (path);
+        return has_translations;
+}
+
+static gboolean
+add_locale (const char *language_name,
+            gboolean    utf8_only)
+{
+        MateLocale *locale;
+        MateLocale *old_locale;<--- Variable 'old_locale' can be declared as pointer to const
+        g_autofree char *name = NULL;
+        gboolean   is_utf8 = FALSE;
+        gboolean   valid = FALSE;
+
+        g_return_val_if_fail (language_name != NULL, FALSE);
+        g_return_val_if_fail (*language_name != '\0', FALSE);
+
+        language_name_get_codeset_details (language_name, NULL, &is_utf8);
+
+        if (is_utf8) {
+                name = g_strdup (language_name);
+        } else if (utf8_only) {
+
+                if (strchr (language_name, '.'))
+                        return FALSE;
+
+                /* If the locale name has no dot, assume that its
+                 * encoding part is missing and try again after adding
+                 * ".UTF-8". This catches locale names like "de_DE".
+                 */
+                name = g_strdup_printf ("%s.UTF-8", language_name);
+
+                language_name_get_codeset_details (name, NULL, &is_utf8);
+                if (!is_utf8)
+                        return FALSE;
+        } else {
+                name = g_strdup (language_name);
+        }
+
+        if (!language_name_is_valid (name)) {
+                g_debug ("Ignoring '%s' as a locale, since it's invalid", name);
+                return FALSE;
+        }
+
+        locale = g_new0 (MateLocale, 1);
+        valid = mate_parse_locale (name,
+                                    &locale->language_code,
+                                    &locale->territory_code,
+                                    &locale->codeset,
+                                    &locale->modifier);
+        if (!valid) {
+                mate_locale_free (locale);
+                return FALSE;
+        }
+
+        locale->id = construct_language_name (locale->language_code, locale->territory_code,
+                                              NULL, locale->modifier);
+        locale->name = construct_language_name (locale->language_code, locale->territory_code,
+                                                locale->codeset, locale->modifier);
+
+        if (!mate_language_has_translations (locale->name) &&
+            !mate_language_has_translations (locale->id) &&
+            !mate_language_has_translations (locale->language_code) &&
+            utf8_only) {
+                g_debug ("Ignoring '%s' as a locale, since it lacks translations", locale->name);
+                mate_locale_free (locale);
+                return FALSE;
+        }
+
+        if (!utf8_only) {
+                g_free (locale->id);
+                locale->id = g_strdup (locale->name);
+        }
+
+        old_locale = g_hash_table_lookup (mate_available_locales_map, locale->id);
+        if (old_locale != NULL) {
+                if (strlen (old_locale->name) > strlen (locale->name)) {
+                        mate_locale_free (locale);
+                        return FALSE;
+                }
+        }
+
+        g_hash_table_insert (mate_available_locales_map, g_strdup (locale->id), locale);
+
+        return TRUE;
+}
+
+static int
+select_dirs (const struct dirent *dirent)
+{
+        int result = 0;
+
+        if (strcmp (dirent->d_name, ".") != 0 && strcmp (dirent->d_name, "..") != 0) {
+                mode_t mode = 0;
+
+#ifdef _DIRENT_HAVE_D_TYPE
+                if (dirent->d_type != DT_UNKNOWN && dirent->d_type != DT_LNK) {
+                        mode = DTTOIF (dirent->d_type);
+                } else
+#endif
+                        {
+                                struct stat st;
+                                g_autofree char *path = NULL;
+
+                                path = g_build_filename (MATELOCALEDIR, dirent->d_name, NULL);
+                                if (g_stat (path, &st) == 0) {
+                                        mode = st.st_mode;
+                                }
+                        }
+
+                result = S_ISDIR (mode);
+        }
+
+        return result;
+}
+
+static gboolean
+collect_locales_from_directory (void)
+{
+        gboolean found_locales = FALSE;
+        struct dirent **dirents;
+        int             ndirents;
+        int             cnt;
+
+        ndirents = scandir (MATELOCALEDIR, &dirents, select_dirs, alphasort);
+
+        for (cnt = 0; cnt < ndirents; ++cnt) {
+                if (add_locale (dirents[cnt]->d_name, TRUE))
+                        found_locales = TRUE;
+        }
+
+        if (ndirents > 0) {
+                free (dirents);
+        }
+        return found_locales;
+}
+
+static gboolean
+collect_locales_from_localebin (void)
+{
+        gboolean found_locales = FALSE;
+        const gchar *argv[] = { "locale", "-a", NULL };
+        gchar **linep;
+        g_auto (GStrv) lines = NULL;
+        g_autofree gchar *output = NULL;
+
+        if (g_spawn_sync (NULL, (gchar **) argv, NULL,
+                          G_SPAWN_SEARCH_PATH|G_SPAWN_STDERR_TO_DEV_NULL,
+                          NULL, NULL, &output, NULL, NULL, NULL) == FALSE)
+                return FALSE;
+
+        g_return_val_if_fail (output != NULL, FALSE);
+
+        lines = g_strsplit (output, "\n", 0);
+        if (lines) {
+                linep = lines;
+                while (*linep) {
+                        if (*linep[0] && add_locale (*linep, TRUE))
+                                found_locales = TRUE;
+                        linep++;
+                }
+        }
+
+        return found_locales;
+}
+
+static void
+fill_count_map (GHashTable *count_map,
+                const char *code)
+{
+        int count;
+        gpointer pointer;
+
+        if (code == NULL)
+                return;
+
+        if ((pointer = g_hash_table_lookup (count_map, code)) != NULL)
+                count = GPOINTER_TO_INT (pointer) + 1;
+        else
+                count = 1;
+
+        g_hash_table_insert (count_map, g_strdup (code), GINT_TO_POINTER (count));
+}
+
+static void
+count_languages_and_territories (void)
+{
+	gpointer value;
+	GHashTableIter iter;
+
+	mate_language_count_map = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+	mate_territory_count_map = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+
+        g_hash_table_iter_init (&iter, mate_available_locales_map);
+        while (g_hash_table_iter_next (&iter, NULL, &value)) {
+                MateLocale *locale = (MateLocale *) value;<--- Variable 'locale' can be declared as pointer to const
+                fill_count_map (mate_language_count_map, locale->language_code);
+                fill_count_map (mate_territory_count_map, locale->territory_code);
+        }
+}
+
+static void
+collect_locales (void)
+{
+        gboolean found_localebin_locales = FALSE;
+        gboolean found_dir_locales = FALSE;
+
+        if (mate_available_locales_map == NULL) {
+                mate_available_locales_map = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify) mate_locale_free);
+        }
+
+        found_localebin_locales = collect_locales_from_localebin ();
+
+        found_dir_locales = collect_locales_from_directory ();
+
+        if (!(found_localebin_locales || found_dir_locales)) {
+                g_warning ("Could not read list of available locales from libc, "
+                           "guessing possible locales from available translations, "
+                           "but list may be incomplete!");
+        }
+
+	count_languages_and_territories ();
+}
+
+static gint
+get_language_count (const char *language)
+{
+        gint count = 0;
+        gpointer pointer;
+
+        if (mate_language_count_map == NULL)
+                collect_locales ();
+
+        if ((pointer = g_hash_table_lookup (mate_language_count_map, language)) != NULL)
+                count = GPOINTER_TO_INT (pointer);
+
+        return count;
+}
+
+static gboolean
+is_unique_language (const char *language)
+{
+        return get_language_count (language) == 1;
+}
+
+static gint
+get_territory_count (const char *territory)
+{
+        gint count = 0;
+        gpointer pointer;
+
+        if (mate_territory_count_map == NULL)
+                collect_locales ();
+
+        if ((pointer = g_hash_table_lookup (mate_territory_count_map, territory)) != NULL)
+                count = GPOINTER_TO_INT (pointer);
+
+        return count;
+}
+
+static gboolean
+is_unique_territory (const char *territory)
+{
+        return get_territory_count (territory) == 1;
+}
+
+static gboolean
+is_fallback_language (const char *code)
+{
+        const char *fallback_language_names[] = { "C", "POSIX", NULL };
+        int i;
+
+        for (i = 0; fallback_language_names[i] != NULL; i++) {
+                if (strcmp (code, fallback_language_names[i]) == 0) {
+                        return TRUE;
+                }
+        }
+
+        return FALSE;
+}
+
+static const char *
+get_language (const char *code)
+{
+        const char *name;
+        int         len;
+
+        g_assert (code != NULL);
+
+        if (is_fallback_language (code)) {
+                return "Unspecified";
+        }
+
+        len = strlen (code);
+        if (len != 2 && len != 3) {
+                return NULL;
+        }
+
+        name = (const char *) g_hash_table_lookup (mate_languages_map, code);
+
+        return name;
+}
+
+static char *
+get_first_item_in_semicolon_list (const char *list)
+{
+        char **items;
+        char  *item;
+
+        /* Some entries in iso codes have multiple values, separated
+         * by semicolons.  Not really sure which one to pick, so
+         * we just arbitrarily pick the first one.
+         */
+        items = g_strsplit (list, "; ", 2);
+
+        item = g_strdup (items[0]);
+        g_strfreev (items);
+
+        return item;
+}
+
+static char *
+capitalize_utf8_string (const char *str)
+{
+        char first[8] = { 0 };
+
+        if (!str)
+                return NULL;
+
+        g_unichar_to_utf8 (g_unichar_totitle (g_utf8_get_char (str)), first);
+
+        return g_strconcat (first, g_utf8_offset_to_pointer (str, 1), NULL);
+}
+
+static char *
+get_translated_language (const char *code,
+                         const char *locale)
+{
+        const char *language;
+        char *name;
+
+        language = get_language (code);
+
+        name = NULL;
+        if (language != NULL) {
+                const char  *translated_name;
+                g_autofree char *old_locale = NULL;
+
+                if (locale != NULL) {
+                        old_locale = g_strdup (setlocale (LC_MESSAGES, NULL));
+                        setlocale (LC_MESSAGES, locale);
+                }
+
+                if (is_fallback_language (code)) {
+                        name = g_strdup (_("Unspecified"));
+                } else {
+                        g_autofree char *tmp = NULL;
+                        translated_name = dgettext ("iso_639", language);
+                        tmp = get_first_item_in_semicolon_list (translated_name);
+                        name = capitalize_utf8_string (tmp);
+                }
+
+                if (locale != NULL) {
+                        setlocale (LC_MESSAGES, old_locale);
+                }
+        }
+
+        return name;
+}
+
+static const char *
+get_territory (const char *code)
+{
+        const char *name;
+        int         len;
+
+        g_assert (code != NULL);
+
+        len = strlen (code);
+        if (len != 2 && len != 3) {
+                return NULL;
+        }
+
+        name = (const char *) g_hash_table_lookup (mate_territories_map, code);
+
+        return name;
+}
+
+static char *
+get_translated_territory (const char *code,
+                          const char *locale)
+{
+        const char *territory;
+        char       *name;
+
+        territory = get_territory (code);
+
+        name = NULL;
+        if (territory != NULL) {
+                const char *translated_territory;
+                g_autofree char *old_locale = NULL;
+                g_autofree char *tmp = NULL;
+
+                if (locale != NULL) {
+                        old_locale = g_strdup (setlocale (LC_MESSAGES, NULL));
+                        setlocale (LC_MESSAGES, locale);
+                }
+
+                translated_territory = dgettext ("iso_3166", territory);
+                tmp = get_first_item_in_semicolon_list (translated_territory);
+                name = capitalize_utf8_string (tmp);
+
+                if (locale != NULL) {
+                        setlocale (LC_MESSAGES, old_locale);
+                }
+        }
+
+        return name;
+}
+
+static void
+languages_parse_start_tag (GMarkupParseContext      *ctx,
+                           const char               *element_name,
+                           const char              **attr_names,
+                           const char              **attr_values,
+                           gpointer                  user_data,
+                           GError                  **error)
+{
+        const char *ccode_longB;
+        const char *ccode_longT;
+        const char *ccode;
+        const char *ccode_id;
+        const char *lang_name;
+
+        if (! (g_str_equal (element_name, "iso_639_entry") || g_str_equal (element_name, "iso_639_3_entry"))
+            || attr_names == NULL || attr_values == NULL) {
+                return;
+        }
+
+        ccode = NULL;
+        ccode_longB = NULL;
+        ccode_longT = NULL;
+        ccode_id = NULL;
+        lang_name = NULL;
+
+        while (*attr_names && *attr_values) {
+                if (g_str_equal (*attr_names, "iso_639_1_code")) {
+                        /* skip if empty */
+                        if (**attr_values) {
+                                if (strlen (*attr_values) != 2) {
+                                        return;
+                                }
+                                ccode = *attr_values;
+                        }
+                } else if (g_str_equal (*attr_names, "iso_639_2B_code")) {
+                        /* skip if empty */
+                        if (**attr_values) {
+                                if (strlen (*attr_values) != 3) {
+                                        return;
+                                }
+                                ccode_longB = *attr_values;
+                        }
+                } else if (g_str_equal (*attr_names, "iso_639_2T_code")) {
+                        /* skip if empty */
+                        if (**attr_values) {
+                                if (strlen (*attr_values) != 3) {
+                                        return;
+                                }
+                                ccode_longT = *attr_values;
+                        }
+                } else if (g_str_equal (*attr_names, "id")) {
+                        /* skip if empty */
+                        if (**attr_values) {
+                                if (strlen (*attr_values) != 2 &&
+                                    strlen (*attr_values) != 3) {
+                                        return;
+                                }
+                                ccode_id = *attr_values;
+                        }
+                } else if (g_str_equal (*attr_names, "name")) {
+                        lang_name = *attr_values;
+                }
+
+                ++attr_names;
+                ++attr_values;
+        }
+
+        if (lang_name == NULL) {
+                return;
+        }
+
+        if (ccode != NULL) {
+                g_hash_table_insert (mate_languages_map,
+                                     g_strdup (ccode),
+                                     g_strdup (lang_name));
+        }
+        if (ccode_longB != NULL) {
+                g_hash_table_insert (mate_languages_map,
+                                     g_strdup (ccode_longB),
+                                     g_strdup (lang_name));
+        }
+        if (ccode_longT != NULL) {
+                g_hash_table_insert (mate_languages_map,
+                                     g_strdup (ccode_longT),
+                                     g_strdup (lang_name));
+        }
+        if (ccode_id != NULL) {
+                g_hash_table_insert (mate_languages_map,
+                                     g_strdup (ccode_id),
+                                     g_strdup (lang_name));
+        }
+}
+
+static void
+territories_parse_start_tag (GMarkupParseContext      *ctx,
+                             const char               *element_name,
+                             const char              **attr_names,
+                             const char              **attr_values,
+                             gpointer                  user_data,
+                             GError                  **error)
+{
+        const char *acode_2;
+        const char *acode_3;
+        const char *ncode;
+        const char *territory_common_name;
+        const char *territory_name;
+
+        if (! g_str_equal (element_name, "iso_3166_entry") || attr_names == NULL || attr_values == NULL) {
+                return;
+        }
+
+        acode_2 = NULL;
+        acode_3 = NULL;
+        ncode = NULL;
+        territory_common_name = NULL;
+        territory_name = NULL;
+
+        while (*attr_names && *attr_values) {
+                if (g_str_equal (*attr_names, "alpha_2_code")) {
+                        /* skip if empty */
+                        if (**attr_values) {
+                                if (strlen (*attr_values) != 2) {
+                                        return;
+                                }
+                                acode_2 = *attr_values;
+                        }
+                } else if (g_str_equal (*attr_names, "alpha_3_code")) {
+                        /* skip if empty */
+                        if (**attr_values) {
+                                if (strlen (*attr_values) != 3) {
+                                        return;
+                                }
+                                acode_3 = *attr_values;
+                        }
+                } else if (g_str_equal (*attr_names, "numeric_code")) {
+                        /* skip if empty */
+                        if (**attr_values) {
+                                if (strlen (*attr_values) != 3) {
+                                        return;
+                                }
+                                ncode = *attr_values;
+                        }
+                } else if (g_str_equal (*attr_names, "common_name")) {
+                        /* skip if empty */
+                        if (**attr_values) {
+                                territory_common_name = *attr_values;
+                        }
+                } else if (g_str_equal (*attr_names, "name")) {
+                        territory_name = *attr_values;
+                }
+
+                ++attr_names;
+                ++attr_values;
+        }
+
+        if (territory_common_name != NULL) {
+                territory_name = territory_common_name;
+        }
+
+        if (territory_name == NULL) {
+                return;
+        }
+
+        if (acode_2 != NULL) {
+                g_hash_table_insert (mate_territories_map,
+                                     g_strdup (acode_2),
+                                     g_strdup (territory_name));
+        }
+        if (acode_3 != NULL) {
+                g_hash_table_insert (mate_territories_map,
+                                     g_strdup (acode_3),
+                                     g_strdup (territory_name));
+        }
+        if (ncode != NULL) {
+                g_hash_table_insert (mate_territories_map,
+                                     g_strdup (ncode),
+                                     g_strdup (territory_name));
+        }
+}
+
+static void
+languages_variant_init (const char *variant)
+{
+        gboolean res;
+        gsize    buf_len;
+        g_autofree char *buf = NULL;
+        g_autofree char *filename = NULL;
+        g_autoptr (GError) error = NULL;
+
+        bindtextdomain (variant, ISO_CODES_LOCALESDIR);
+        bind_textdomain_codeset (variant, "UTF-8");
+
+        error = NULL;
+        filename = g_strdup_printf (ISO_CODES_DATADIR "/%s.xml", variant);
+        res = g_file_get_contents (filename,
+                                   &buf,
+                                   &buf_len,
+                                   &error);
+        if (res) {
+                g_autoptr (GMarkupParseContext) ctx = NULL;
+                GMarkupParser        parser = { languages_parse_start_tag, NULL, NULL, NULL, NULL };
+
+                ctx = g_markup_parse_context_new (&parser, 0, NULL, NULL);
+
+                error = NULL;
+                res = g_markup_parse_context_parse (ctx, buf, buf_len, &error);
+
+                if (! res) {
+                        g_warning ("Failed to parse '%s': %s\n",
+                                   filename,
+                                   error->message);
+                }
+        } else {
+                g_warning ("Failed to load '%s': %s\n",
+                           filename,
+                           error->message);
+        }
+}
+
+static void
+languages_init (void)
+{
+        if (mate_languages_map)
+                return;
+
+        mate_languages_map = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
+
+        languages_variant_init ("iso_639");
+        languages_variant_init ("iso_639_3");
+}
+
+static void
+territories_init (void)
+{
+        gboolean res;
+        gsize    buf_len;
+        g_autofree char *buf = NULL;
+        g_autoptr (GError) error = NULL;
+
+        if (mate_territories_map)
+                return;
+
+        bindtextdomain ("iso_3166", ISO_CODES_LOCALESDIR);
+        bind_textdomain_codeset ("iso_3166", "UTF-8");
+
+        mate_territories_map = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
+
+        error = NULL;
+        res = g_file_get_contents (ISO_CODES_DATADIR "/iso_3166.xml",
+                                   &buf,
+                                   &buf_len,
+                                   &error);
+        if (res) {
+                g_autoptr (GMarkupParseContext) ctx = NULL;
+                GMarkupParser        parser = { territories_parse_start_tag, NULL, NULL, NULL, NULL };
+
+                ctx = g_markup_parse_context_new (&parser, 0, NULL, NULL);
+
+                error = NULL;
+                res = g_markup_parse_context_parse (ctx, buf, buf_len, &error);
+
+                if (! res) {
+                        g_warning ("Failed to parse '%s': %s\n",
+                                   ISO_CODES_DATADIR "/iso_3166.xml",
+                                   error->message);
+                }
+        } else {
+                g_warning ("Failed to load '%s': %s\n",
+                           ISO_CODES_DATADIR "/iso_3166.xml",
+                           error->message);
+        }
+}
+
+/**
+ * mate_get_language_from_locale:
+ * @locale: a locale string
+ * @translation: (allow-none): a locale string
+ *
+ * Gets the language description for @locale. If @translation is
+ * provided the returned string is translated accordingly.
+ *
+ * Return value: (transfer full): the language description. Caller
+ * takes ownership.
+ *
+ * Since: 1.22
+ */
+char *
+mate_get_language_from_locale (const char *locale,
+                                const char *translation)
+{
+        GString *full_language;
+        g_autofree char *language_code = NULL;
+        g_autofree char *territory_code = NULL;
+        g_autofree char *codeset_code = NULL;
+        g_autofree char *langinfo_codeset = NULL;
+        g_autofree char *translated_language = NULL;
+        g_autofree char *translated_territory = NULL;
+        gboolean is_utf8 = TRUE;
+
+        g_return_val_if_fail (locale != NULL, NULL);
+        g_return_val_if_fail (*locale != '\0', NULL);
+
+        full_language = g_string_new (NULL);
+
+        languages_init ();
+        territories_init ();
+
+        mate_parse_locale (locale,
+                            &language_code,
+                            &territory_code,
+                            &codeset_code,
+                            NULL);
+
+        if (language_code == NULL) {
+                goto out;
+        }
+
+        translated_language = get_translated_language (language_code, translation);
+        if (translated_language == NULL) {
+                goto out;
+        }
+
+        full_language = g_string_append (full_language, translated_language);
+
+	if (is_unique_language (language_code)) {
+		goto out;
+	}
+
+        if (territory_code != NULL) {
+                translated_territory = get_translated_territory (territory_code, translation);
+        }
+        if (translated_territory != NULL) {
+                g_string_append_printf (full_language,
+                                        " (%s)",
+                                        translated_territory);
+        }
+
+        language_name_get_codeset_details (locale, &langinfo_codeset, &is_utf8);
+
+        if (codeset_code == NULL && langinfo_codeset != NULL) {
+                codeset_code = g_strdup (langinfo_codeset);
+        }
+
+        if (!is_utf8 && codeset_code) {
+                g_string_append_printf (full_language,
+                                        " [%s]",
+                                        codeset_code);
+        }
+
+ out:
+        if (full_language->len == 0) {
+                g_string_free (full_language, TRUE);
+                return NULL;
+        }
+
+        return g_string_free (full_language, FALSE);
+}
+
+/**
+ * mate_get_country_from_locale:
+ * @locale: a locale string
+ * @translation: (allow-none): a locale string
+ *
+ * Gets the country description for @locale. If @translation is
+ * provided the returned string is translated accordingly.
+ *
+ * Return value: (transfer full): the country description. Caller
+ * takes ownership.
+ *
+ * Since: 1.22
+ */
+char *
+mate_get_country_from_locale (const char *locale,
+                               const char *translation)
+{
+        GString *full_name;
+        g_autofree char *language_code = NULL;
+        g_autofree char *territory_code = NULL;
+        g_autofree char *codeset_code = NULL;
+        g_autofree char *langinfo_codeset = NULL;
+        g_autofree char *translated_language = NULL;
+        g_autofree char *translated_territory = NULL;
+        gboolean is_utf8 = TRUE;
+
+        g_return_val_if_fail (locale != NULL, NULL);
+        g_return_val_if_fail (*locale != '\0', NULL);
+
+        full_name = g_string_new (NULL);
+
+        languages_init ();
+        territories_init ();
+
+        mate_parse_locale (locale,
+                            &language_code,
+                            &territory_code,
+                            &codeset_code,
+                            NULL);
+
+        if (territory_code == NULL) {
+                goto out;
+        }
+
+        translated_territory = get_translated_territory (territory_code, translation);
+        g_string_append (full_name, translated_territory);
+
+	if (is_unique_territory (territory_code)) {
+		goto out;
+	}
+
+        if (language_code != NULL) {
+                translated_language = get_translated_language (language_code, translation);
+        }
+        if (translated_language != NULL) {
+                g_string_append_printf (full_name,
+                                        " (%s)",
+                                        translated_language);
+        }
+
+        language_name_get_codeset_details (translation, &langinfo_codeset, &is_utf8);
+
+        if (codeset_code == NULL && langinfo_codeset != NULL) {
+                codeset_code = g_strdup (langinfo_codeset);
+        }
+
+        if (!is_utf8 && codeset_code) {
+                g_string_append_printf (full_name,
+                                        " [%s]",
+                                        codeset_code);
+        }
+
+ out:
+        if (full_name->len == 0) {
+                g_string_free (full_name, TRUE);
+                return NULL;
+        }
+
+        return g_string_free (full_name, FALSE);
+}
+
+/**
+ * mate_get_all_locales:
+ *
+ * Gets all locales.
+ *
+ * Return value: (array zero-terminated=1) (element-type utf8) (transfer full):
+ *   a newly allocated %NULL-terminated string array containing the
+ *   all locales. Free with g_strfreev().
+ *
+ * Since: 1.22
+ */
+char **
+mate_get_all_locales (void)
+{
+        GHashTableIter iter;
+        gpointer key, value;
+        GPtrArray *array;
+
+        if (mate_available_locales_map == NULL) {
+                collect_locales ();
+        }
+
+        array = g_ptr_array_new ();
+        g_hash_table_iter_init (&iter, mate_available_locales_map);
+        while (g_hash_table_iter_next (&iter, &key, &value)) {
+                MateLocale *locale;
+
+                locale = (MateLocale *) value;
+
+                g_ptr_array_add (array, g_strdup (locale->name));
+        }
+        g_ptr_array_add (array, NULL);
+
+        return (char **) g_ptr_array_free (array, FALSE);
+}
+
+/**
+ * mate_get_language_from_code:
+ * @code: an ISO 639 code string
+ * @translation: (allow-none): a locale string
+ *
+ * Gets the language name for @code. If @locale is provided the
+ * returned string is translated accordingly.
+ *
+ * Return value: (transfer full): the language name. Caller takes
+ * ownership.
+ *
+ * Since: 1.22
+ */
+char *
+mate_get_language_from_code (const char *code,
+                              const char *translation)
+{
+        g_return_val_if_fail (code != NULL, NULL);
+
+        languages_init ();
+
+        return get_translated_language (code, translation);
+}
+
+/**
+ * mate_get_country_from_code:
+ * @code: an ISO 3166 code string
+ * @translation: (allow-none): a locale string
+ *
+ * Gets the country name for @code. If @locale is provided the
+ * returned string is translated accordingly.
+ *
+ * Return value: (transfer full): the country name. Caller takes
+ * ownership.
+ *
+ * Since: 1.22
+ */
+char *
+mate_get_country_from_code (const char *code,
+                             const char *translation)
+{
+        g_return_val_if_fail (code != NULL, NULL);
+
+        territories_init ();
+
+        return get_translated_territory (code, translation);
+}
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/3.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/3.html new file mode 100644 index 0000000..f061262 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/3.html @@ -0,0 +1,393 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2005-2007 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "config.h"<--- Include file: "config.h" not found.
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdk/gdk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "gpm-common.h"
+
+/**
+ * gpm_help_display:
+ * @link_id: Subsection of mate-power-manager help section
+ **/
+void
+gpm_help_display (const gchar *link_id)
+{
+	GError *error = NULL;
+	gchar *uri;
+
+	if (link_id != NULL)
+		uri = g_strconcat ("help:mate-power-manager/", link_id, NULL);
+	else
+		uri = g_strdup ("help:mate-power-manager");
+
+	gtk_show_uri_on_window (NULL, uri, GDK_CURRENT_TIME, &error);
+
+	if (error != NULL) {
+		GtkWidget *d;
+		d = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+					    GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "%s", error->message);
+		gtk_dialog_run (GTK_DIALOG(d));
+		gtk_widget_destroy (d);
+		g_error_free (error);
+	}
+	g_free (uri);
+}
+
+/***************************************************************************
+ ***                          MAKE CHECK TESTS                           ***
+ ***************************************************************************/
+#ifdef EGG_TEST
+#include "egg-test.h"<--- Include file: "egg-test.h" not found.
+
+void
+gpm_common_test (gpointer data)
+{
+	EggTest *test = (EggTest *) data;
+	if (egg_test_start (test, "GpmCommon") == FALSE)
+		return;
+
+	egg_test_end (test);
+}
+
+#endif
+
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/30.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/30.html new file mode 100644 index 0000000..e535678 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/30.html @@ -0,0 +1,343 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright 2008 Red Hat, Inc.
+ * Copyright 2007 William Jon McCann <mccann@jhu.edu>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Written by: Ray Strode
+ *             William Jon McCann
+ */
+
+#ifndef __MATE_LANGUAGES_H
+#define __MATE_LANGUAGES_H
+
+#ifndef MATE_DESKTOP_USE_UNSTABLE_API
+#error    This is unstable API. You must define MATE_DESKTOP_USE_UNSTABLE_API before including mate-languages.h
+#endif
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+G_BEGIN_DECLS
+
+char *        mate_get_language_from_locale    (const char *locale,
+                                                 const char *translation);
+char *        mate_get_country_from_locale     (const char *locale,
+                                                 const char *translation);
+char **       mate_get_all_locales             (void);
+gboolean      mate_parse_locale                (const char *locale,
+                                                 char      **language_codep,
+                                                 char      **country_codep,
+                                                 char      **codesetp,
+                                                 char      **modifierp);
+char *        mate_normalize_locale            (const char *locale);
+gboolean      mate_language_has_translations   (const char *code);
+char *        mate_get_language_from_code      (const char *code,
+                                                 const char *translation);
+char *        mate_get_country_from_code       (const char *code,
+                                                 const char *translation);
+
+G_END_DECLS
+
+#endif /* __MATE_LANGUAGES_H */
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/31.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/31.html new file mode 100644 index 0000000..d54be09 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/31.html @@ -0,0 +1,4187 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
   1
+   2
+   3
+   4
+   5
+   6
+   7
+   8
+   9
+  10
+  11
+  12
+  13
+  14
+  15
+  16
+  17
+  18
+  19
+  20
+  21
+  22
+  23
+  24
+  25
+  26
+  27
+  28
+  29
+  30
+  31
+  32
+  33
+  34
+  35
+  36
+  37
+  38
+  39
+  40
+  41
+  42
+  43
+  44
+  45
+  46
+  47
+  48
+  49
+  50
+  51
+  52
+  53
+  54
+  55
+  56
+  57
+  58
+  59
+  60
+  61
+  62
+  63
+  64
+  65
+  66
+  67
+  68
+  69
+  70
+  71
+  72
+  73
+  74
+  75
+  76
+  77
+  78
+  79
+  80
+  81
+  82
+  83
+  84
+  85
+  86
+  87
+  88
+  89
+  90
+  91
+  92
+  93
+  94
+  95
+  96
+  97
+  98
+  99
+ 100
+ 101
+ 102
+ 103
+ 104
+ 105
+ 106
+ 107
+ 108
+ 109
+ 110
+ 111
+ 112
+ 113
+ 114
+ 115
+ 116
+ 117
+ 118
+ 119
+ 120
+ 121
+ 122
+ 123
+ 124
+ 125
+ 126
+ 127
+ 128
+ 129
+ 130
+ 131
+ 132
+ 133
+ 134
+ 135
+ 136
+ 137
+ 138
+ 139
+ 140
+ 141
+ 142
+ 143
+ 144
+ 145
+ 146
+ 147
+ 148
+ 149
+ 150
+ 151
+ 152
+ 153
+ 154
+ 155
+ 156
+ 157
+ 158
+ 159
+ 160
+ 161
+ 162
+ 163
+ 164
+ 165
+ 166
+ 167
+ 168
+ 169
+ 170
+ 171
+ 172
+ 173
+ 174
+ 175
+ 176
+ 177
+ 178
+ 179
+ 180
+ 181
+ 182
+ 183
+ 184
+ 185
+ 186
+ 187
+ 188
+ 189
+ 190
+ 191
+ 192
+ 193
+ 194
+ 195
+ 196
+ 197
+ 198
+ 199
+ 200
+ 201
+ 202
+ 203
+ 204
+ 205
+ 206
+ 207
+ 208
+ 209
+ 210
+ 211
+ 212
+ 213
+ 214
+ 215
+ 216
+ 217
+ 218
+ 219
+ 220
+ 221
+ 222
+ 223
+ 224
+ 225
+ 226
+ 227
+ 228
+ 229
+ 230
+ 231
+ 232
+ 233
+ 234
+ 235
+ 236
+ 237
+ 238
+ 239
+ 240
+ 241
+ 242
+ 243
+ 244
+ 245
+ 246
+ 247
+ 248
+ 249
+ 250
+ 251
+ 252
+ 253
+ 254
+ 255
+ 256
+ 257
+ 258
+ 259
+ 260
+ 261
+ 262
+ 263
+ 264
+ 265
+ 266
+ 267
+ 268
+ 269
+ 270
+ 271
+ 272
+ 273
+ 274
+ 275
+ 276
+ 277
+ 278
+ 279
+ 280
+ 281
+ 282
+ 283
+ 284
+ 285
+ 286
+ 287
+ 288
+ 289
+ 290
+ 291
+ 292
+ 293
+ 294
+ 295
+ 296
+ 297
+ 298
+ 299
+ 300
+ 301
+ 302
+ 303
+ 304
+ 305
+ 306
+ 307
+ 308
+ 309
+ 310
+ 311
+ 312
+ 313
+ 314
+ 315
+ 316
+ 317
+ 318
+ 319
+ 320
+ 321
+ 322
+ 323
+ 324
+ 325
+ 326
+ 327
+ 328
+ 329
+ 330
+ 331
+ 332
+ 333
+ 334
+ 335
+ 336
+ 337
+ 338
+ 339
+ 340
+ 341
+ 342
+ 343
+ 344
+ 345
+ 346
+ 347
+ 348
+ 349
+ 350
+ 351
+ 352
+ 353
+ 354
+ 355
+ 356
+ 357
+ 358
+ 359
+ 360
+ 361
+ 362
+ 363
+ 364
+ 365
+ 366
+ 367
+ 368
+ 369
+ 370
+ 371
+ 372
+ 373
+ 374
+ 375
+ 376
+ 377
+ 378
+ 379
+ 380
+ 381
+ 382
+ 383
+ 384
+ 385
+ 386
+ 387
+ 388
+ 389
+ 390
+ 391
+ 392
+ 393
+ 394
+ 395
+ 396
+ 397
+ 398
+ 399
+ 400
+ 401
+ 402
+ 403
+ 404
+ 405
+ 406
+ 407
+ 408
+ 409
+ 410
+ 411
+ 412
+ 413
+ 414
+ 415
+ 416
+ 417
+ 418
+ 419
+ 420
+ 421
+ 422
+ 423
+ 424
+ 425
+ 426
+ 427
+ 428
+ 429
+ 430
+ 431
+ 432
+ 433
+ 434
+ 435
+ 436
+ 437
+ 438
+ 439
+ 440
+ 441
+ 442
+ 443
+ 444
+ 445
+ 446
+ 447
+ 448
+ 449
+ 450
+ 451
+ 452
+ 453
+ 454
+ 455
+ 456
+ 457
+ 458
+ 459
+ 460
+ 461
+ 462
+ 463
+ 464
+ 465
+ 466
+ 467
+ 468
+ 469
+ 470
+ 471
+ 472
+ 473
+ 474
+ 475
+ 476
+ 477
+ 478
+ 479
+ 480
+ 481
+ 482
+ 483
+ 484
+ 485
+ 486
+ 487
+ 488
+ 489
+ 490
+ 491
+ 492
+ 493
+ 494
+ 495
+ 496
+ 497
+ 498
+ 499
+ 500
+ 501
+ 502
+ 503
+ 504
+ 505
+ 506
+ 507
+ 508
+ 509
+ 510
+ 511
+ 512
+ 513
+ 514
+ 515
+ 516
+ 517
+ 518
+ 519
+ 520
+ 521
+ 522
+ 523
+ 524
+ 525
+ 526
+ 527
+ 528
+ 529
+ 530
+ 531
+ 532
+ 533
+ 534
+ 535
+ 536
+ 537
+ 538
+ 539
+ 540
+ 541
+ 542
+ 543
+ 544
+ 545
+ 546
+ 547
+ 548
+ 549
+ 550
+ 551
+ 552
+ 553
+ 554
+ 555
+ 556
+ 557
+ 558
+ 559
+ 560
+ 561
+ 562
+ 563
+ 564
+ 565
+ 566
+ 567
+ 568
+ 569
+ 570
+ 571
+ 572
+ 573
+ 574
+ 575
+ 576
+ 577
+ 578
+ 579
+ 580
+ 581
+ 582
+ 583
+ 584
+ 585
+ 586
+ 587
+ 588
+ 589
+ 590
+ 591
+ 592
+ 593
+ 594
+ 595
+ 596
+ 597
+ 598
+ 599
+ 600
+ 601
+ 602
+ 603
+ 604
+ 605
+ 606
+ 607
+ 608
+ 609
+ 610
+ 611
+ 612
+ 613
+ 614
+ 615
+ 616
+ 617
+ 618
+ 619
+ 620
+ 621
+ 622
+ 623
+ 624
+ 625
+ 626
+ 627
+ 628
+ 629
+ 630
+ 631
+ 632
+ 633
+ 634
+ 635
+ 636
+ 637
+ 638
+ 639
+ 640
+ 641
+ 642
+ 643
+ 644
+ 645
+ 646
+ 647
+ 648
+ 649
+ 650
+ 651
+ 652
+ 653
+ 654
+ 655
+ 656
+ 657
+ 658
+ 659
+ 660
+ 661
+ 662
+ 663
+ 664
+ 665
+ 666
+ 667
+ 668
+ 669
+ 670
+ 671
+ 672
+ 673
+ 674
+ 675
+ 676
+ 677
+ 678
+ 679
+ 680
+ 681
+ 682
+ 683
+ 684
+ 685
+ 686
+ 687
+ 688
+ 689
+ 690
+ 691
+ 692
+ 693
+ 694
+ 695
+ 696
+ 697
+ 698
+ 699
+ 700
+ 701
+ 702
+ 703
+ 704
+ 705
+ 706
+ 707
+ 708
+ 709
+ 710
+ 711
+ 712
+ 713
+ 714
+ 715
+ 716
+ 717
+ 718
+ 719
+ 720
+ 721
+ 722
+ 723
+ 724
+ 725
+ 726
+ 727
+ 728
+ 729
+ 730
+ 731
+ 732
+ 733
+ 734
+ 735
+ 736
+ 737
+ 738
+ 739
+ 740
+ 741
+ 742
+ 743
+ 744
+ 745
+ 746
+ 747
+ 748
+ 749
+ 750
+ 751
+ 752
+ 753
+ 754
+ 755
+ 756
+ 757
+ 758
+ 759
+ 760
+ 761
+ 762
+ 763
+ 764
+ 765
+ 766
+ 767
+ 768
+ 769
+ 770
+ 771
+ 772
+ 773
+ 774
+ 775
+ 776
+ 777
+ 778
+ 779
+ 780
+ 781
+ 782
+ 783
+ 784
+ 785
+ 786
+ 787
+ 788
+ 789
+ 790
+ 791
+ 792
+ 793
+ 794
+ 795
+ 796
+ 797
+ 798
+ 799
+ 800
+ 801
+ 802
+ 803
+ 804
+ 805
+ 806
+ 807
+ 808
+ 809
+ 810
+ 811
+ 812
+ 813
+ 814
+ 815
+ 816
+ 817
+ 818
+ 819
+ 820
+ 821
+ 822
+ 823
+ 824
+ 825
+ 826
+ 827
+ 828
+ 829
+ 830
+ 831
+ 832
+ 833
+ 834
+ 835
+ 836
+ 837
+ 838
+ 839
+ 840
+ 841
+ 842
+ 843
+ 844
+ 845
+ 846
+ 847
+ 848
+ 849
+ 850
+ 851
+ 852
+ 853
+ 854
+ 855
+ 856
+ 857
+ 858
+ 859
+ 860
+ 861
+ 862
+ 863
+ 864
+ 865
+ 866
+ 867
+ 868
+ 869
+ 870
+ 871
+ 872
+ 873
+ 874
+ 875
+ 876
+ 877
+ 878
+ 879
+ 880
+ 881
+ 882
+ 883
+ 884
+ 885
+ 886
+ 887
+ 888
+ 889
+ 890
+ 891
+ 892
+ 893
+ 894
+ 895
+ 896
+ 897
+ 898
+ 899
+ 900
+ 901
+ 902
+ 903
+ 904
+ 905
+ 906
+ 907
+ 908
+ 909
+ 910
+ 911
+ 912
+ 913
+ 914
+ 915
+ 916
+ 917
+ 918
+ 919
+ 920
+ 921
+ 922
+ 923
+ 924
+ 925
+ 926
+ 927
+ 928
+ 929
+ 930
+ 931
+ 932
+ 933
+ 934
+ 935
+ 936
+ 937
+ 938
+ 939
+ 940
+ 941
+ 942
+ 943
+ 944
+ 945
+ 946
+ 947
+ 948
+ 949
+ 950
+ 951
+ 952
+ 953
+ 954
+ 955
+ 956
+ 957
+ 958
+ 959
+ 960
+ 961
+ 962
+ 963
+ 964
+ 965
+ 966
+ 967
+ 968
+ 969
+ 970
+ 971
+ 972
+ 973
+ 974
+ 975
+ 976
+ 977
+ 978
+ 979
+ 980
+ 981
+ 982
+ 983
+ 984
+ 985
+ 986
+ 987
+ 988
+ 989
+ 990
+ 991
+ 992
+ 993
+ 994
+ 995
+ 996
+ 997
+ 998
+ 999
+1000
+1001
+1002
+1003
+1004
+1005
+1006
+1007
+1008
+1009
+1010
+1011
+1012
+1013
+1014
+1015
+1016
+1017
+1018
+1019
+1020
+1021
+1022
+1023
+1024
+1025
+1026
+1027
+1028
+1029
+1030
+1031
+1032
+1033
+1034
+1035
+1036
+1037
+1038
+1039
+1040
+1041
+1042
+1043
+1044
+1045
+1046
+1047
+1048
+1049
+1050
+1051
+1052
+1053
+1054
+1055
+1056
+1057
+1058
+1059
+1060
+1061
+1062
+1063
+1064
+1065
+1066
+1067
+1068
+1069
+1070
+1071
+1072
+1073
+1074
+1075
+1076
+1077
+1078
+1079
+1080
+1081
+1082
+1083
+1084
+1085
+1086
+1087
+1088
+1089
+1090
+1091
+1092
+1093
+1094
+1095
+1096
+1097
+1098
+1099
+1100
+1101
+1102
+1103
+1104
+1105
+1106
+1107
+1108
+1109
+1110
+1111
+1112
+1113
+1114
+1115
+1116
+1117
+1118
+1119
+1120
+1121
+1122
+1123
+1124
+1125
+1126
+1127
+1128
+1129
+1130
+1131
+1132
+1133
+1134
+1135
+1136
+1137
+1138
+1139
+1140
+1141
+1142
+1143
+1144
+1145
+1146
+1147
+1148
+1149
+1150
+1151
+1152
+1153
+1154
+1155
+1156
+1157
+1158
+1159
+1160
+1161
+1162
+1163
+1164
+1165
+1166
+1167
+1168
+1169
+1170
+1171
+1172
+1173
+1174
+1175
+1176
+1177
+1178
+1179
+1180
+1181
+1182
+1183
+1184
+1185
+1186
+1187
+1188
+1189
+1190
+1191
+1192
+1193
+1194
+1195
+1196
+1197
+1198
+1199
+1200
+1201
+1202
+1203
+1204
+1205
+1206
+1207
+1208
+1209
+1210
+1211
+1212
+1213
+1214
+1215
+1216
+1217
+1218
+1219
+1220
+1221
+1222
+1223
+1224
+1225
+1226
+1227
+1228
+1229
+1230
+1231
+1232
+1233
+1234
+1235
+1236
+1237
+1238
+1239
+1240
+1241
+1242
+1243
+1244
+1245
+1246
+1247
+1248
+1249
+1250
+1251
+1252
+1253
+1254
+1255
+1256
+1257
+1258
+1259
+1260
+1261
+1262
+1263
+1264
+1265
+1266
+1267
+1268
+1269
+1270
+1271
+1272
+1273
+1274
+1275
+1276
+1277
+1278
+1279
+1280
+1281
+1282
+1283
+1284
+1285
+1286
+1287
+1288
+1289
+1290
+1291
+1292
+1293
+1294
+1295
+1296
+1297
+1298
+1299
+1300
+1301
+1302
+1303
+1304
+1305
+1306
+1307
+1308
+1309
+1310
+1311
+1312
+1313
+1314
+1315
+1316
+1317
+1318
+1319
+1320
+1321
+1322
+1323
+1324
+1325
+1326
+1327
+1328
+1329
+1330
+1331
+1332
+1333
+1334
+1335
+1336
+1337
+1338
+1339
+1340
+1341
+1342
+1343
+1344
+1345
+1346
+1347
+1348
+1349
+1350
+1351
+1352
+1353
+1354
+1355
+1356
+1357
+1358
+1359
+1360
+1361
+1362
+1363
+1364
+1365
+1366
+1367
+1368
+1369
+1370
+1371
+1372
+1373
+1374
+1375
+1376
+1377
+1378
+1379
+1380
+1381
+1382
+1383
+1384
+1385
+1386
+1387
+1388
+1389
+1390
+1391
+1392
+1393
+1394
+1395
+1396
+1397
+1398
+1399
+1400
+1401
+1402
+1403
+1404
+1405
+1406
+1407
+1408
+1409
+1410
+1411
+1412
+1413
+1414
+1415
+1416
+1417
+1418
+1419
+1420
+1421
+1422
+1423
+1424
+1425
+1426
+1427
+1428
+1429
+1430
+1431
+1432
+1433
+1434
+1435
+1436
+1437
+1438
+1439
+1440
+1441
+1442
+1443
+1444
+1445
+1446
+1447
+1448
+1449
+1450
+1451
+1452
+1453
+1454
+1455
+1456
+1457
+1458
+1459
+1460
+1461
+1462
+1463
+1464
+1465
+1466
+1467
+1468
+1469
+1470
+1471
+1472
+1473
+1474
+1475
+1476
+1477
+1478
+1479
+1480
+1481
+1482
+1483
+1484
+1485
+1486
+1487
+1488
+1489
+1490
+1491
+1492
+1493
+1494
+1495
+1496
+1497
+1498
+1499
+1500
+1501
+1502
+1503
+1504
+1505
+1506
+1507
+1508
+1509
+1510
+1511
+1512
+1513
+1514
+1515
+1516
+1517
+1518
+1519
+1520
+1521
+1522
+1523
+1524
+1525
+1526
+1527
+1528
+1529
+1530
+1531
+1532
+1533
+1534
+1535
+1536
+1537
+1538
+1539
+1540
+1541
+1542
+1543
+1544
+1545
+1546
+1547
+1548
+1549
+1550
+1551
+1552
+1553
+1554
+1555
+1556
+1557
+1558
+1559
+1560
+1561
+1562
+1563
+1564
+1565
+1566
+1567
+1568
+1569
+1570
+1571
+1572
+1573
+1574
+1575
+1576
+1577
+1578
+1579
+1580
+1581
+1582
+1583
+1584
+1585
+1586
+1587
+1588
+1589
+1590
+1591
+1592
+1593
+1594
+1595
+1596
+1597
+1598
+1599
+1600
+1601
+1602
+1603
+1604
+1605
+1606
+1607
+1608
+1609
+1610
+1611
+1612
+1613
+1614
+1615
+1616
+1617
+1618
+1619
+1620
+1621
+1622
+1623
+1624
+1625
+1626
+1627
+1628
+1629
+1630
+1631
+1632
+1633
+1634
+1635
+1636
+1637
+1638
+1639
+1640
+1641
+1642
+1643
+1644
+1645
+1646
+1647
+1648
+1649
+1650
+1651
+1652
+1653
+1654
+1655
+1656
+1657
+1658
+1659
+1660
+1661
+1662
+1663
+1664
+1665
+1666
+1667
+1668
+1669
+1670
+1671
+1672
+1673
+1674
+1675
+1676
+1677
+1678
+1679
+1680
+1681
+1682
+1683
+1684
+1685
+1686
+1687
+1688
+1689
+1690
+1691
+1692
+1693
+1694
+1695
+1696
+1697
+1698
+1699
+1700
+1701
+1702
+1703
+1704
+1705
+1706
+1707
+1708
+1709
+1710
+1711
+1712
+1713
+1714
+1715
+1716
+1717
+1718
+1719
+1720
+1721
+1722
+1723
+1724
+1725
+1726
+1727
+1728
+1729
+1730
+1731
+1732
+1733
+1734
+1735
+1736
+1737
+1738
+1739
+1740
+1741
+1742
+1743
+1744
+1745
+1746
+1747
+1748
+1749
+1750
+1751
+1752
+1753
+1754
+1755
+1756
+1757
+1758
+1759
+1760
+1761
+1762
+1763
+1764
+1765
+1766
+1767
+1768
+1769
+1770
+1771
+1772
+1773
+1774
+1775
+1776
+1777
+1778
+1779
+1780
+1781
+1782
+1783
+1784
+1785
+1786
+1787
+1788
+1789
+1790
+1791
+1792
+1793
+1794
+1795
+1796
+1797
+1798
+1799
+1800
+1801
+1802
+1803
+1804
+1805
+1806
+1807
+1808
+1809
+1810
+1811
+1812
+1813
+1814
+1815
+1816
+1817
+1818
+1819
+1820
+1821
+1822
+1823
+1824
+1825
+1826
+1827
+1828
+1829
+1830
+1831
+1832
+1833
+1834
+1835
+1836
+1837
+1838
+1839
+1840
+1841
+1842
+1843
+1844
+1845
+1846
+1847
+1848
+1849
+1850
+1851
+1852
+1853
+1854
+1855
+1856
+1857
+1858
+1859
+1860
+1861
+1862
+1863
+1864
+1865
+1866
+1867
+1868
+1869
+1870
+1871
+1872
+1873
+1874
+1875
+1876
+1877
+1878
+1879
+1880
+1881
+1882
+1883
+1884
+1885
+1886
+1887
+1888
+1889
+1890
+1891
+1892
+1893
+1894
+1895
+1896
+1897
+1898
+1899
+1900
+1901
+1902
+1903
+1904
+1905
+1906
+1907
+1908
+1909
+1910
+1911
+1912
+1913
+1914
+1915
+1916
+1917
+1918
+1919
+1920
+1921
+1922
+1923
+1924
+1925
+1926
+1927
+1928
+1929
+1930
+1931
+1932
+1933
+1934
+1935
+1936
+1937
+1938
+1939
+1940
+1941
+1942
+1943
+1944
+1945
+1946
+1947
+1948
+1949
+1950
+1951
+1952
+1953
+1954
+1955
+1956
+1957
+1958
+1959
+1960
+1961
+1962
+1963
+1964
+1965
+1966
+1967
+1968
+1969
+1970
+1971
+1972
+1973
+1974
+1975
/* mate-rr-config.c
+ * -*- c-basic-offset: 4 -*-
+ *
+ * Copyright 2007, 2008, Red Hat, Inc.
+ * Copyright 2010 Giovanni Campagna
+ *
+ * This file is part of the Mate Library.
+ *
+ * The Mate Library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * The Mate Library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with the Mate Library; see the file COPYING.LIB.  If not,
+ * write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Author: Soren Sandmann <sandmann@redhat.com>
+ */
+
+#define MATE_DESKTOP_USE_UNSTABLE_API
+
+#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n-lib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gstdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <X11/Xlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdk/gdkx.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "mate-rr-config.h"
+
+#include "edid.h"
+#include "mate-rr-private.h"
+
+#define CONFIG_INTENDED_BASENAME "monitors.xml"
+#define CONFIG_BACKUP_BASENAME "monitors.xml.backup"
+
+/* In version 0 of the config file format, we had several <configuration>
+ * toplevel elements and no explicit version number.  So, the filed looked
+ * like
+ *
+ *   <configuration>
+ *     ...
+ *   </configuration>
+ *   <configuration>
+ *     ...
+ *   </configuration>
+ *
+ * Since version 1 of the config file, the file has a toplevel <monitors>
+ * element to group all the configurations.  That element has a "version"
+ * attribute which is an integer. So, the file looks like this:
+ *
+ *   <monitors version="1">
+ *     <configuration>
+ *       ...
+ *     </configuration>
+ *     <configuration>
+ *       ...
+ *     </configuration>
+ *   </monitors>
+ */
+
+/* A helper wrapper around the GMarkup parser stuff */
+static gboolean parse_file_gmarkup (const gchar *file,
+				    const GMarkupParser *parser,
+				    gpointer data,
+				    GError **err);
+
+typedef struct CrtcAssignment CrtcAssignment;
+
+static gboolean         crtc_assignment_apply (CrtcAssignment   *assign,
+					       guint32           timestamp,
+					       GError          **error);
+static CrtcAssignment  *crtc_assignment_new   (MateRRScreen      *screen,
+					       MateRROutputInfo **outputs,
+					       GError            **error);
+static void             crtc_assignment_free  (CrtcAssignment   *assign);
+
+enum {
+  PROP_0,
+  PROP_SCREEN,
+  PROP_LAST
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (MateRRConfig, mate_rr_config, G_TYPE_OBJECT)<--- There is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
+
+typedef struct Parser Parser;
+
+/* Parser for monitor configurations */
+struct Parser
+{
+    int			config_file_version;
+    MateRROutputInfo *	output;
+    MateRRConfig *	configuration;
+    GPtrArray *		outputs;
+    GPtrArray *		configurations;
+    GQueue *		stack;
+};
+
+static int
+parse_int (const char *text)
+{
+    return strtol (text, NULL, 0);
+}
+
+static guint
+parse_uint (const char *text)
+{
+    return strtoul (text, NULL, 0);
+}
+
+static gboolean
+stack_is (Parser *parser,
+	  const char *s1,
+	  ...)
+{
+    GList *stack = NULL;
+    const char *s;
+    GList *l1, *l2;
+    va_list args;
+
+    stack = g_list_prepend (stack, (gpointer)s1);
+
+    va_start (args, s1);
+
+    s = va_arg (args, const char *);
+    while (s)
+    {
+	stack = g_list_prepend (stack, (gpointer)s);
+	s = va_arg (args, const char *);
+    }
+
+    va_end (args);
+
+    l1 = stack;
+    l2 = parser->stack->head;
+
+    while (l1 && l2)
+    {
+	if (strcmp (l1->data, l2->data) != 0)
+	{
+	    g_list_free (stack);
+	    return FALSE;
+	}
+
+	l1 = l1->next;
+	l2 = l2->next;
+    }
+
+    g_list_free (stack);
+
+    return (!l1 && !l2);
+}
+
+static void
+handle_start_element (GMarkupParseContext *context,
+		      const gchar         *name,
+		      const gchar        **attr_names,
+		      const gchar        **attr_values,
+		      gpointer             user_data,
+		      GError             **err)
+{
+    Parser *parser = user_data;
+
+    if (strcmp (name, "output") == 0)
+    {
+	int i;
+	g_assert (parser->output == NULL);
+
+	parser->output = g_object_new (MATE_TYPE_RR_OUTPUT_INFO, NULL);
+	parser->output->priv->rotation = 0;
+
+	for (i = 0; attr_names[i] != NULL; ++i)
+	{
+	    if (strcmp (attr_names[i], "name") == 0)
+	    {
+		parser->output->priv->name = g_strdup (attr_values[i]);
+		break;
+	    }
+	}
+
+	if (!parser->output->priv->name)
+	{
+	    /* This really shouldn't happen, but it's better to make
+	     * something up than to crash later.
+	     */
+	    g_warning ("Malformed monitor configuration file");
+
+	    parser->output->priv->name = g_strdup ("default");
+	}
+	parser->output->priv->connected = FALSE;
+	parser->output->priv->on = FALSE;
+	parser->output->priv->primary = FALSE;
+    }
+    else if (strcmp (name, "configuration") == 0)
+    {
+	g_assert (parser->configuration == NULL);
+
+	parser->configuration = g_object_new (MATE_TYPE_RR_CONFIG, NULL);
+	parser->configuration->priv->clone = FALSE;
+	parser->configuration->priv->outputs = NULL;
+    }
+    else if (strcmp (name, "monitors") == 0)
+    {
+	int i;
+
+	for (i = 0; attr_names[i] != NULL; i++)
+	{
+	    if (strcmp (attr_names[i], "version") == 0)
+	    {
+		parser->config_file_version = parse_int (attr_values[i]);
+		break;
+	    }
+	}
+    }
+
+    g_queue_push_tail (parser->stack, g_strdup (name));
+}
+
+static void
+handle_end_element (GMarkupParseContext *context,
+		    const gchar         *name,
+		    gpointer             user_data,
+		    GError             **err)
+{
+    Parser *parser = user_data;
+
+    if (strcmp (name, "output") == 0)
+    {
+	/* If no rotation properties were set, just use MATE_RR_ROTATION_0 */
+	if (parser->output->priv->rotation == 0)
+	    parser->output->priv->rotation = MATE_RR_ROTATION_0;
+
+	g_ptr_array_add (parser->outputs, parser->output);
+
+	parser->output = NULL;
+    }
+    else if (strcmp (name, "configuration") == 0)
+    {
+	g_ptr_array_add (parser->outputs, NULL);
+	parser->configuration->priv->outputs =
+	    (MateRROutputInfo **)g_ptr_array_free (parser->outputs, FALSE);
+	parser->outputs = g_ptr_array_new ();
+	g_ptr_array_add (parser->configurations, parser->configuration);
+	parser->configuration = NULL;
+    }
+
+    g_free (g_queue_pop_tail (parser->stack));
+}
+
+#define TOPLEVEL_ELEMENT (parser->config_file_version > 0 ? "monitors" : NULL)
+
+static void
+handle_text (GMarkupParseContext *context,
+	     const gchar         *text,
+	     gsize                text_len,
+	     gpointer             user_data,
+	     GError             **err)
+{
+    Parser *parser = user_data;
+
+    if (stack_is (parser, "vendor", "output", "configuration", TOPLEVEL_ELEMENT, NULL))
+    {
+	parser->output->priv->connected = TRUE;
+
+	strncpy ((gchar*) parser->output->priv->vendor, text, 3);
+	parser->output->priv->vendor[3] = 0;
+    }
+    else if (stack_is (parser, "clone", "configuration", TOPLEVEL_ELEMENT, NULL))
+    {
+	if (strcmp (text, "yes") == 0)
+	    parser->configuration->priv->clone = TRUE;
+    }
+    else if (stack_is (parser, "product", "output", "configuration", TOPLEVEL_ELEMENT, NULL))
+    {
+	parser->output->priv->connected = TRUE;
+
+	parser->output->priv->product = parse_int (text);
+    }
+    else if (stack_is (parser, "serial", "output", "configuration", TOPLEVEL_ELEMENT, NULL))
+    {
+	parser->output->priv->connected = TRUE;
+
+	parser->output->priv->serial = parse_uint (text);
+    }
+    else if (stack_is (parser, "width", "output", "configuration", TOPLEVEL_ELEMENT, NULL))
+    {
+	parser->output->priv->on = TRUE;
+
+	parser->output->priv->width = parse_int (text);
+    }
+    else if (stack_is (parser, "x", "output", "configuration", TOPLEVEL_ELEMENT, NULL))
+    {
+	parser->output->priv->on = TRUE;
+
+	parser->output->priv->x = parse_int (text);
+    }
+    else if (stack_is (parser, "y", "output", "configuration", TOPLEVEL_ELEMENT, NULL))
+    {
+	parser->output->priv->on = TRUE;
+
+	parser->output->priv->y = parse_int (text);
+    }
+    else if (stack_is (parser, "height", "output", "configuration", TOPLEVEL_ELEMENT, NULL))
+    {
+	parser->output->priv->on = TRUE;
+
+	parser->output->priv->height = parse_int (text);
+    }
+    else if (stack_is (parser, "rate", "output", "configuration", TOPLEVEL_ELEMENT, NULL))
+    {
+	parser->output->priv->on = TRUE;
+
+	parser->output->priv->rate = parse_int (text);
+    }
+    else if (stack_is (parser, "rotation", "output", "configuration", TOPLEVEL_ELEMENT, NULL))
+    {
+	if (strcmp (text, "normal") == 0)
+	{
+	    parser->output->priv->rotation |= MATE_RR_ROTATION_0;
+	}
+	else if (strcmp (text, "left") == 0)
+	{
+	    parser->output->priv->rotation |= MATE_RR_ROTATION_90;
+	}
+	else if (strcmp (text, "upside_down") == 0)
+	{
+	    parser->output->priv->rotation |= MATE_RR_ROTATION_180;
+	}
+	else if (strcmp (text, "right") == 0)
+	{
+	    parser->output->priv->rotation |= MATE_RR_ROTATION_270;
+	}
+    }
+    else if (stack_is (parser, "reflect_x", "output", "configuration", TOPLEVEL_ELEMENT, NULL))
+    {
+	if (strcmp (text, "yes") == 0)
+	{
+	    parser->output->priv->rotation |= MATE_RR_REFLECT_X;
+	}
+    }
+    else if (stack_is (parser, "reflect_y", "output", "configuration", TOPLEVEL_ELEMENT, NULL))
+    {
+	if (strcmp (text, "yes") == 0)
+	{
+	    parser->output->priv->rotation |= MATE_RR_REFLECT_Y;
+	}
+    }
+    else if (stack_is (parser, "primary", "output", "configuration", TOPLEVEL_ELEMENT, NULL))
+    {
+	if (strcmp (text, "yes") == 0)
+	{
+	    parser->output->priv->primary = TRUE;
+	}
+    }
+    else
+    {
+	/* Ignore other properties so we can expand the format in the future */
+    }
+}
+
+static void
+parser_free (Parser *parser)
+{
+    guint i;
+    GList *list;
+
+    g_assert (parser != NULL);
+
+    if (parser->output)
+	g_object_unref (parser->output);
+
+    if (parser->configuration)
+	g_object_unref (parser->configuration);
+
+    for (i = 0; i < parser->outputs->len; ++i)
+    {
+	MateRROutputInfo *output = parser->outputs->pdata[i];
+
+	g_object_unref (output);
+    }
+
+    g_ptr_array_free (parser->outputs, TRUE);
+
+    for (i = 0; i < parser->configurations->len; ++i)
+    {
+	MateRRConfig *config = parser->configurations->pdata[i];
+
+	g_object_unref (config);
+    }
+
+    g_ptr_array_free (parser->configurations, TRUE);
+
+    for (list = parser->stack->head; list; list = list->next)
+	g_free (list->data);
+    g_queue_free (parser->stack);
+
+    g_free (parser);
+}
+
+static MateRRConfig **
+configurations_read_from_file (const gchar *filename, GError **error)
+{
+    Parser *parser = g_new0 (Parser, 1);
+    MateRRConfig **result;
+    GMarkupParser callbacks = {
+	handle_start_element,
+	handle_end_element,
+	handle_text,
+	NULL, /* passthrough */
+	NULL, /* error */
+    };
+
+    parser->config_file_version = 0;
+    parser->configurations = g_ptr_array_new ();
+    parser->outputs = g_ptr_array_new ();
+    parser->stack = g_queue_new ();
+
+    if (!parse_file_gmarkup (filename, &callbacks, parser, error))
+    {
+	result = NULL;
+
+	g_assert (parser->outputs);
+	goto out;
+    }
+
+    g_assert (parser->outputs);
+
+    g_ptr_array_add (parser->configurations, NULL);
+    result = (MateRRConfig **)g_ptr_array_free (parser->configurations, FALSE);
+    parser->configurations = g_ptr_array_new ();
+
+    g_assert (parser->outputs);
+out:
+    parser_free (parser);
+
+    return result;
+}
+
+static void
+mate_rr_config_init (MateRRConfig *self)
+{
+    self->priv = mate_rr_config_get_instance_private (self);
+
+    self->priv->clone = FALSE;
+    self->priv->screen = NULL;
+    self->priv->outputs = NULL;
+}
+
+static void
+mate_rr_config_set_property (GObject *gobject, guint property_id, const GValue *value, GParamSpec *property)
+{
+    MateRRConfig *self = MATE_RR_CONFIG (gobject);
+
+    switch (property_id) {
+	case PROP_SCREEN:
+	    self->priv->screen = g_value_dup_object (value);
+	    return;
+	default:
+	    G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, property_id, property);
+    }
+}
+
+static void
+mate_rr_config_finalize (GObject *gobject)
+{
+    MateRRConfig *self = MATE_RR_CONFIG (gobject);
+
+    if (self->priv->screen)
+	g_object_unref (self->priv->screen);
+
+    if (self->priv->outputs) {
+	int i;
+
+        for (i = 0; self->priv->outputs[i] != NULL; i++) {
+	    MateRROutputInfo *output = self->priv->outputs[i];
+	    g_object_unref (output);
+	}
+	g_free (self->priv->outputs);
+    }
+
+    G_OBJECT_CLASS (mate_rr_config_parent_class)->finalize (gobject);
+}
+
+gboolean
+mate_rr_config_load_current (MateRRConfig *config, GError **error)
+{
+    GPtrArray *a;
+    MateRROutput **rr_outputs;
+    int i;
+    int clone_width = -1;
+    int clone_height = -1;
+    int last_x;
+
+    g_return_val_if_fail (MATE_IS_RR_CONFIG (config), FALSE);
+
+    a = g_ptr_array_new ();
+    rr_outputs = mate_rr_screen_list_outputs (config->priv->screen);
+
+    config->priv->clone = FALSE;
+
+    for (i = 0; rr_outputs[i] != NULL; ++i)
+    {
+	MateRROutput *rr_output = rr_outputs[i];
+	MateRROutputInfo *output = g_object_new (MATE_TYPE_RR_OUTPUT_INFO, NULL);
+	MateRRMode *mode = NULL;
+	const guint8 *edid_data = mate_rr_output_get_edid_data (rr_output);
+	MateRRCrtc *crtc;
+
+	output->priv->name = g_strdup (mate_rr_output_get_name (rr_output));
+	output->priv->connected = mate_rr_output_is_connected (rr_output);
+
+	if (!output->priv->connected)
+	{
+	    output->priv->x = -1;
+	    output->priv->y = -1;
+	    output->priv->width = -1;
+	    output->priv->height = -1;
+	    output->priv->rate = -1;
+	    output->priv->rotation = MATE_RR_ROTATION_0;
+	}
+	else
+	{
+	    MonitorInfo *info = NULL;
+
+	    if (edid_data)
+		info = decode_edid (edid_data);
+
+	    if (info)
+	    {
+		memcpy (output->priv->vendor, info->manufacturer_code,
+			sizeof (output->priv->vendor));
+
+		output->priv->product = info->product_code;
+		output->priv->serial = info->serial_number;
+		output->priv->aspect = info->aspect_ratio;
+	    }
+	    else
+	    {
+		g_strlcpy (output->priv->vendor, "???", sizeof (output->priv->vendor));
+		output->priv->product = 0;
+		output->priv->serial = 0;
+	    }
+
+	    if (mate_rr_output_is_laptop (rr_output))
+		output->priv->display_name = g_strdup (_("Laptop"));
+	    else
+		output->priv->display_name = make_display_name (info);
+
+	    g_free (info);
+
+	    crtc = mate_rr_output_get_crtc (rr_output);
+	    mode = crtc? mate_rr_crtc_get_current_mode (crtc) : NULL;
+
+	    if (crtc && mode)
+	    {
+		output->priv->on = TRUE;
+
+		mate_rr_crtc_get_position (crtc, &output->priv->x, &output->priv->y);
+		output->priv->width = mate_rr_mode_get_width (mode);
+		output->priv->height = mate_rr_mode_get_height (mode);
+		output->priv->rate = mate_rr_mode_get_freq (mode);
+		output->priv->rotation = mate_rr_crtc_get_current_rotation (crtc);
+
+		if (output->priv->x == 0 && output->priv->y == 0) {
+			if (clone_width == -1) {
+				clone_width = output->priv->width;
+				clone_height = output->priv->height;
+			} else if (clone_width == output->priv->width &&
+				   clone_height == output->priv->height) {
+				config->priv->clone = TRUE;
+			}
+		}
+	    }
+	    else
+	    {
+		output->priv->on = FALSE;
+		config->priv->clone = FALSE;
+	    }
+
+	    /* Get preferred size for the monitor */
+	    mode = mate_rr_output_get_preferred_mode (rr_output);
+
+	    if (!mode)
+	    {
+		MateRRMode **modes = mate_rr_output_list_modes (rr_output);
+
+		/* FIXME: we should pick the "best" mode here, where best is
+		 * sorted wrt
+		 *
+		 * - closest aspect ratio
+		 * - mode area
+		 * - refresh rate
+		 * - We may want to extend randrwrap so that get_preferred
+		 *   returns that - although that could also depend on
+		 *   the crtc.
+		 */
+		if (modes[0])
+		    mode = modes[0];
+	    }
+
+	    if (mode)
+	    {
+		output->priv->pref_width = mate_rr_mode_get_width (mode);
+		output->priv->pref_height = mate_rr_mode_get_height (mode);
+	    }
+	    else
+	    {
+		/* Pick some random numbers. This should basically never happen */
+		output->priv->pref_width = 1024;
+		output->priv->pref_height = 768;
+	    }
+	}
+
+        output->priv->primary = mate_rr_output_get_is_primary (rr_output);
+
+	g_ptr_array_add (a, output);
+    }
+
+    g_ptr_array_add (a, NULL);
+
+    config->priv->outputs = (MateRROutputInfo **)g_ptr_array_free (a, FALSE);
+
+    /* Walk the outputs computing the right-most edge of all
+     * lit-up displays
+     */
+    last_x = 0;
+    for (i = 0; config->priv->outputs[i] != NULL; ++i)
+    {
+	MateRROutputInfo *output = config->priv->outputs[i];
+
+	if (output->priv->on)
+	{
+	    last_x = MAX (last_x, output->priv->x + output->priv->width);
+	}
+    }
+
+    /* Now position all off displays to the right of the
+     * on displays
+     */
+    for (i = 0; config->priv->outputs[i] != NULL; ++i)
+    {
+	MateRROutputInfo *output = config->priv->outputs[i];
+
+	if (output->priv->connected && !output->priv->on)
+	{
+	    output->priv->x = last_x;
+	    last_x = output->priv->x + output->priv->width;
+	}
+    }
+
+    g_assert (mate_rr_config_match (config, config));
+
+    return TRUE;
+}
+
+gboolean
+mate_rr_config_load_filename (MateRRConfig *result, const char *filename, GError **error)
+{
+    MateRRConfig *current;
+    MateRRConfig **configs;
+    gboolean found = FALSE;
+
+    g_return_val_if_fail (MATE_IS_RR_CONFIG (result), FALSE);
+    g_return_val_if_fail (filename != NULL, FALSE);
+    g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+
+    if (filename == NULL)
+      filename = mate_rr_config_get_intended_filename ();
+
+    current = mate_rr_config_new_current (result->priv->screen, error);
+
+    configs = configurations_read_from_file (filename, error);
+
+    if (configs)
+    {
+	int i;
+
+	for (i = 0; configs[i] != NULL; ++i)
+	{
+	    if (mate_rr_config_match (configs[i], current))
+	    {
+		int j;
+		GPtrArray *array;
+		result->priv->clone = configs[i]->priv->clone;
+
+		array = g_ptr_array_new ();
+		for (j = 0; configs[i]->priv->outputs[j] != NULL; j++) {
+		    g_object_ref (configs[i]->priv->outputs[j]);
+		    g_ptr_array_add (array, configs[i]->priv->outputs[j]);
+		}
+		g_ptr_array_add (array, NULL);
+		result->priv->outputs = (MateRROutputInfo **) g_ptr_array_free (array, FALSE);
+
+		found = TRUE;
+		break;
+	    }
+	    g_object_unref (configs[i]);
+	}
+	g_free (configs);
+
+	if (!found)
+	    g_set_error (error, MATE_RR_ERROR, MATE_RR_ERROR_NO_MATCHING_CONFIG,
+			 _("none of the saved display configurations matched the active configuration"));
+    }
+
+    g_object_unref (current);
+    return found;
+}
+
+static void
+mate_rr_config_class_init (MateRRConfigClass *klass)
+{
+    GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+
+    gobject_class->set_property = mate_rr_config_set_property;
+    gobject_class->finalize = mate_rr_config_finalize;
+
+    g_object_class_install_property (gobject_class, PROP_SCREEN,
+				     g_param_spec_object ("screen", "Screen", "The MateRRScreen this config applies to", MATE_TYPE_RR_SCREEN,
+							  G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
+}
+
+MateRRConfig *
+mate_rr_config_new_current (MateRRScreen *screen, GError **error)
+{
+    MateRRConfig *self = g_object_new (MATE_TYPE_RR_CONFIG, "screen", screen, NULL);
+
+    if (mate_rr_config_load_current (self, error))
+      return self;
+    else
+      {
+	g_object_unref (self);
+	return NULL;
+      }
+}
+
+MateRRConfig *
+mate_rr_config_new_stored (MateRRScreen *screen, GError **error)
+{
+    MateRRConfig *self = g_object_new (MATE_TYPE_RR_CONFIG, "screen", screen, NULL);
+    char *filename;
+    gboolean success;
+
+    filename = mate_rr_config_get_intended_filename ();
+
+    success = mate_rr_config_load_filename (self, filename, error);
+
+    g_free (filename);
+
+    if (success)
+      return self;
+    else
+      {
+	g_object_unref (self);
+	return NULL;
+      }
+}
+
+static gboolean
+parse_file_gmarkup (const gchar          *filename,
+		    const GMarkupParser  *parser,
+		    gpointer             data,
+		    GError              **err)
+{
+    GMarkupParseContext *context = NULL;
+    gchar *contents = NULL;
+    gboolean result = TRUE;
+    gsize len;
+
+    if (!g_file_get_contents (filename, &contents, &len, err))
+    {
+	result = FALSE;
+	goto out;
+    }
+
+    context = g_markup_parse_context_new (parser, 0, data, NULL);
+
+    if (!g_markup_parse_context_parse (context, contents, len, err))
+    {
+	result = FALSE;
+	goto out;
+    }
+
+    if (!g_markup_parse_context_end_parse (context, err))
+    {
+	result = FALSE;
+	goto out;
+    }
+
+out:
+    if (contents)
+	g_free (contents);
+
+    if (context)
+	g_markup_parse_context_free (context);
+
+    return result;
+}
+
+static gboolean
+output_match (MateRROutputInfo *output1, MateRROutputInfo *output2)
+{
+    g_assert (MATE_IS_RR_OUTPUT_INFO (output1));
+    g_assert (MATE_IS_RR_OUTPUT_INFO (output2));
+
+    if (strcmp (output1->priv->name, output2->priv->name) != 0)
+	return FALSE;
+
+    if (strcmp (output1->priv->vendor, output2->priv->vendor) != 0)
+	return FALSE;
+
+    if (output1->priv->product != output2->priv->product)
+	return FALSE;
+
+    if (output1->priv->serial != output2->priv->serial)
+	return FALSE;
+
+    if (output1->priv->connected != output2->priv->connected)
+	return FALSE;
+
+    return TRUE;
+}
+
+static gboolean
+output_equal (MateRROutputInfo *output1, MateRROutputInfo *output2)
+{
+    g_assert (MATE_IS_RR_OUTPUT_INFO (output1));
+    g_assert (MATE_IS_RR_OUTPUT_INFO (output2));
+
+    if (!output_match (output1, output2))
+	return FALSE;
+
+    if (output1->priv->on != output2->priv->on)
+	return FALSE;
+
+    if (output1->priv->on)
+    {
+	if (output1->priv->width != output2->priv->width)
+	    return FALSE;
+
+	if (output1->priv->height != output2->priv->height)
+	    return FALSE;
+
+	if (output1->priv->rate != output2->priv->rate)
+	    return FALSE;
+
+	if (output1->priv->x != output2->priv->x)
+	    return FALSE;
+
+	if (output1->priv->y != output2->priv->y)
+	    return FALSE;
+
+	if (output1->priv->rotation != output2->priv->rotation)
+	    return FALSE;
+    }
+
+    return TRUE;
+}
+
+static MateRROutputInfo *
+find_output (MateRRConfig *config, const char *name)
+{
+    int i;
+
+    for (i = 0; config->priv->outputs[i] != NULL; ++i)
+    {
+	MateRROutputInfo *output = config->priv->outputs[i];
+
+	if (strcmp (name, output->priv->name) == 0)
+	    return output;
+    }
+
+    return NULL;
+}
+
+/* Match means "these configurations apply to the same hardware
+ * setups"
+ */
+gboolean
+mate_rr_config_match (MateRRConfig *c1, MateRRConfig *c2)
+{
+    int i;
+    g_return_val_if_fail (MATE_IS_RR_CONFIG (c1), FALSE);
+    g_return_val_if_fail (MATE_IS_RR_CONFIG (c2), FALSE);
+
+    for (i = 0; c1->priv->outputs[i] != NULL; ++i)
+    {
+	MateRROutputInfo *output1 = c1->priv->outputs[i];
+	MateRROutputInfo *output2;
+
+	output2 = find_output (c2, output1->priv->name);
+	if (!output2 || !output_match (output1, output2))
+	    return FALSE;
+    }
+
+    return TRUE;
+}
+
+/* Equal means "the configurations will result in the same
+ * modes being set on the outputs"
+ */
+gboolean
+mate_rr_config_equal (MateRRConfig  *c1,
+		       MateRRConfig  *c2)
+{
+    int i;
+    g_return_val_if_fail (MATE_IS_RR_CONFIG (c1), FALSE);
+    g_return_val_if_fail (MATE_IS_RR_CONFIG (c2), FALSE);
+
+    for (i = 0; c1->priv->outputs[i] != NULL; ++i)
+    {
+	MateRROutputInfo *output1 = c1->priv->outputs[i];
+	MateRROutputInfo *output2;
+
+	output2 = find_output (c2, output1->priv->name);
+	if (!output2 || !output_equal (output1, output2))
+	    return FALSE;
+    }
+
+    return TRUE;
+}
+
+static MateRROutputInfo **
+make_outputs (MateRRConfig *config)
+{
+    GPtrArray *outputs;
+    MateRROutputInfo *first_on;
+    int i;
+
+    outputs = g_ptr_array_new ();
+
+    first_on = NULL;
+
+    for (i = 0; config->priv->outputs[i] != NULL; ++i)
+    {
+	MateRROutputInfo *old = config->priv->outputs[i];
+	MateRROutputInfo *new = g_object_new (MATE_TYPE_RR_OUTPUT_INFO, NULL);
+	*(new->priv) = *(old->priv);
+	if (old->priv->name)
+	    new->priv->name = g_strdup (old->priv->name);
+	if (old->priv->display_name)
+	    new->priv->display_name = g_strdup (old->priv->display_name);
+
+	if (old->priv->on && !first_on)
+	    first_on = old;
+
+	if (config->priv->clone && new->priv->on)
+	{
+	    g_assert (first_on);
+
+	    new->priv->width = first_on->priv->width;
+	    new->priv->height = first_on->priv->height;
+	    new->priv->rotation = first_on->priv->rotation;
+	    new->priv->x = 0;
+	    new->priv->y = 0;
+	}
+
+	g_ptr_array_add (outputs, new);
+    }
+
+    g_ptr_array_add (outputs, NULL);
+
+    return (MateRROutputInfo **)g_ptr_array_free (outputs, FALSE);
+}
+
+gboolean
+mate_rr_config_applicable (MateRRConfig  *configuration,
+			    MateRRScreen  *screen,
+			    GError        **error)
+{
+    MateRROutputInfo **outputs;
+    CrtcAssignment *assign;
+    gboolean result;
+    int i;
+
+    g_return_val_if_fail (MATE_IS_RR_CONFIG (configuration), FALSE);
+    g_return_val_if_fail (MATE_IS_RR_SCREEN (screen), FALSE);
+    g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+
+    outputs = make_outputs (configuration);
+    assign = crtc_assignment_new (screen, outputs, error);
+
+    if (assign)
+    {
+	result = TRUE;
+	crtc_assignment_free (assign);
+    }
+    else
+    {
+	result = FALSE;
+    }
+
+    for (i = 0; outputs[i] != NULL; i++) {
+	 g_object_unref (outputs[i]);
+    }
+
+    return result;
+}
+
+/* Database management */
+
+static void
+ensure_config_directory (void)
+{
+    g_mkdir_with_parents (g_get_user_config_dir (), 0700);
+}
+
+char *
+mate_rr_config_get_backup_filename (void)
+{
+    ensure_config_directory ();
+    return g_build_filename (g_get_user_config_dir (), CONFIG_BACKUP_BASENAME, NULL);
+}
+
+char *
+mate_rr_config_get_intended_filename (void)
+{
+    ensure_config_directory ();
+    return g_build_filename (g_get_user_config_dir (), CONFIG_INTENDED_BASENAME, NULL);
+}
+
+static const char *
+get_rotation_name (MateRRRotation r)
+{
+    if (r & MATE_RR_ROTATION_0)
+	return "normal";
+    if (r & MATE_RR_ROTATION_90)
+	return "left";
+    if (r & MATE_RR_ROTATION_180)
+	return "upside_down";
+    if (r & MATE_RR_ROTATION_270)
+	return "right";
+
+    return "normal";
+}
+
+static const char *
+yes_no (int x)
+{
+    return x? "yes" : "no";
+}
+
+static const char *
+get_reflect_x (MateRRRotation r)
+{
+    return yes_no (r & MATE_RR_REFLECT_X);
+}
+
+static const char *
+get_reflect_y (MateRRRotation r)
+{
+    return yes_no (r & MATE_RR_REFLECT_Y);
+}
+
+static void
+emit_configuration (MateRRConfig *config,
+		    GString *string)
+{
+    int j;
+
+    g_string_append_printf (string, "  <configuration>\n");
+
+    g_string_append_printf (string, "      <clone>%s</clone>\n", yes_no (config->priv->clone));
+
+    for (j = 0; config->priv->outputs[j] != NULL; ++j)
+    {
+	MateRROutputInfo *output = config->priv->outputs[j];
+
+	g_string_append_printf (
+	    string, "      <output name=\"%s\">\n", output->priv->name);
+
+	if (output->priv->connected && *output->priv->vendor != '\0')
+	{
+	    g_string_append_printf (
+		string, "          <vendor>%s</vendor>\n", output->priv->vendor);
+	    g_string_append_printf (
+		string, "          <product>0x%04x</product>\n", output->priv->product);
+	    g_string_append_printf (
+		string, "          <serial>0x%08x</serial>\n", output->priv->serial);
+	}
+
+	/* An unconnected output which is on does not make sense */
+	if (output->priv->connected && output->priv->on)
+	{
+	    g_string_append_printf (
+		string, "          <width>%d</width>\n", output->priv->width);
+	    g_string_append_printf (
+		string, "          <height>%d</height>\n", output->priv->height);
+	    g_string_append_printf (
+		string, "          <rate>%d</rate>\n", output->priv->rate);
+	    g_string_append_printf (
+		string, "          <x>%d</x>\n", output->priv->x);
+	    g_string_append_printf (
+		string, "          <y>%d</y>\n", output->priv->y);
+	    g_string_append_printf (
+		string, "          <rotation>%s</rotation>\n", get_rotation_name (output->priv->rotation));
+	    g_string_append_printf (
+		string, "          <reflect_x>%s</reflect_x>\n", get_reflect_x (output->priv->rotation));
+	    g_string_append_printf (
+		string, "          <reflect_y>%s</reflect_y>\n", get_reflect_y (output->priv->rotation));
+            g_string_append_printf (
+                string, "          <primary>%s</primary>\n", yes_no (output->priv->primary));
+	}
+
+	g_string_append_printf (string, "      </output>\n");
+    }
+
+    g_string_append_printf (string, "  </configuration>\n");
+}
+
+void
+mate_rr_config_sanitize (MateRRConfig *config)
+{
+    int i;
+    int x_offset, y_offset;
+    gboolean found;
+
+    /* Offset everything by the top/left-most coordinate to
+     * make sure the configuration starts at (0, 0)
+     */
+    x_offset = y_offset = G_MAXINT;
+    for (i = 0; config->priv->outputs[i]; ++i)
+    {
+	MateRROutputInfo *output = config->priv->outputs[i];
+
+	if (output->priv->on)
+	{
+	    x_offset = MIN (x_offset, output->priv->x);
+	    y_offset = MIN (y_offset, output->priv->y);
+	}
+    }
+
+    for (i = 0; config->priv->outputs[i]; ++i)
+    {
+	MateRROutputInfo *output = config->priv->outputs[i];
+
+	if (output->priv->on)
+	{
+	    output->priv->x -= x_offset;
+	    output->priv->y -= y_offset;
+	}
+    }
+
+    /* Only one primary, please */
+    found = FALSE;
+    for (i = 0; config->priv->outputs[i]; ++i)
+    {
+        if (config->priv->outputs[i]->priv->primary)
+        {
+            if (found)
+            {
+                config->priv->outputs[i]->priv->primary = FALSE;
+            }
+            else
+            {
+                found = TRUE;
+            }
+        }
+    }
+}
+
+gboolean
+mate_rr_config_ensure_primary (MateRRConfig *configuration)
+{
+        int              i;
+        MateRROutputInfo  *laptop;
+        MateRROutputInfo  *top_left;
+        gboolean        found;
+        MateRRConfigPrivate *priv;
+
+        g_return_val_if_fail (MATE_IS_RR_CONFIG (configuration), FALSE);
+
+        laptop = NULL;
+        top_left = NULL;
+        found = FALSE;
+        priv = configuration->priv;
+
+        for (i = 0; priv->outputs[i] != NULL; ++i) {
+                MateRROutputInfo *info = priv->outputs[i];
+
+                if (! info->priv->on) {
+                        info->priv->primary = FALSE;
+                        continue;
+		}
+
+                /* ensure only one */
+                if (info->priv->primary) {
+                        if (found) {
+                                info->priv->primary = FALSE;
+                        } else {
+                                found = TRUE;
+                        }
+                }
+
+                if (top_left == NULL
+                    || (info->priv->x < top_left->priv->x
+                        && info->priv->y < top_left->priv->y)) {
+                        top_left = info;
+                }
+                if (laptop == NULL
+                    && _mate_rr_output_name_is_laptop (info->priv->name)) {
+                        laptop = info;
+                }
+        }
+
+        if (!found) {
+                if (laptop != NULL) {
+                        laptop->priv->primary = TRUE;
+                } else if (top_left != NULL) {
+		        /* Note: top_left can be NULL if all outputs are off */
+                        top_left->priv->primary = TRUE;
+                }
+        }
+
+        return !found;
+}
+
+gboolean
+mate_rr_config_save (MateRRConfig *configuration, GError **error)
+{
+    MateRRConfig **configurations;
+    GString *output;
+    int i;
+    gchar *intended_filename;
+    gchar *backup_filename;
+    gboolean result;
+
+    g_return_val_if_fail (MATE_IS_RR_CONFIG (configuration), FALSE);
+    g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+
+    output = g_string_new ("");
+
+    backup_filename = mate_rr_config_get_backup_filename ();
+    intended_filename = mate_rr_config_get_intended_filename ();
+
+    configurations = configurations_read_from_file (intended_filename, NULL); /* NULL-GError */
+
+    g_string_append_printf (output, "<monitors version=\"1\">\n");
+
+    if (configurations)
+    {
+	for (i = 0; configurations[i] != NULL; ++i)
+	{
+	    if (!mate_rr_config_match (configurations[i], configuration))
+		emit_configuration (configurations[i], output);
+	    g_object_unref (configurations[i]);
+	}
+
+	g_free (configurations);
+    }
+
+    emit_configuration (configuration, output);
+
+    g_string_append_printf (output, "</monitors>\n");
+
+    /* backup the file first */
+    rename (intended_filename, backup_filename); /* no error checking because the intended file may not even exist */
+
+    result = g_file_set_contents (intended_filename, output->str, -1, error);
+
+    if (!result)
+	rename (backup_filename, intended_filename); /* no error checking because the backup may not even exist */
+
+    g_free (backup_filename);
+    g_free (intended_filename);
+    g_string_free (output, TRUE);
+
+    return result;
+}
+
+gboolean
+mate_rr_config_apply_with_time (MateRRConfig *config,
+				 MateRRScreen *screen,
+				 guint32        timestamp,
+				 GError       **error)
+{
+    CrtcAssignment *assignment;
+    MateRROutputInfo **outputs;
+    gboolean result = FALSE;
+    int i;
+    GdkDisplay *display;
+
+    g_return_val_if_fail (MATE_IS_RR_CONFIG (config), FALSE);
+    g_return_val_if_fail (MATE_IS_RR_SCREEN (screen), FALSE);
+
+    outputs = make_outputs (config);
+
+    assignment = crtc_assignment_new (screen, outputs, error);
+
+    for (i = 0; outputs[i] != NULL; i++)
+	g_object_unref (outputs[i]);
+    g_free (outputs);
+
+    if (assignment)
+    {
+	if (crtc_assignment_apply (assignment, timestamp, error))
+	    result = TRUE;
+
+	crtc_assignment_free (assignment);
+
+	display = gdk_display_get_default ();
+	gdk_display_flush (display);
+    }
+
+    return result;
+}
+
+/* mate_rr_config_apply_from_filename_with_time:
+ * @screen: A #MateRRScreen
+ * @filename: Path of the file to look in for stored RANDR configurations.
+ * @timestamp: X server timestamp from the event that causes the screen configuration to change (a user's button press, for example)
+ * @error: Location to store error, or %NULL
+ *
+ * First, this function refreshes the @screen to match the current RANDR
+ * configuration from the X server.  Then, it tries to load the file in
+ * @filename and looks for suitable matching RANDR configurations in the file;
+ * if one is found, that configuration will be applied to the current set of
+ * RANDR outputs.
+ *
+ * Typically, @filename is the result of mate_rr_config_get_intended_filename() or
+ * mate_rr_config_get_backup_filename().
+ *
+ * Returns: TRUE if the RANDR configuration was loaded and applied from
+ * $(XDG_CONFIG_HOME)/monitors.xml, or FALSE otherwise:
+ *
+ * If the current RANDR configuration could not be refreshed, the @error will
+ * have a domain of #MATE_RR_ERROR and a corresponding error code.
+ *
+ * If the file in question is loaded successfully but the configuration cannot
+ * be applied, the @error will have a domain of #MATE_RR_ERROR.  Note that an
+ * error code of #MATE_RR_ERROR_NO_MATCHING_CONFIG is not a real error; it
+ * simply means that there were no stored configurations that match the current
+ * set of RANDR outputs.
+ *
+ * If the file in question cannot be loaded, the @error will have a domain of
+ * #G_FILE_ERROR.  Note that an error code of G_FILE_ERROR_NOENT is not really
+ * an error, either; it means that there was no stored configuration file and so
+ * nothing is changed.
+ */
+gboolean
+mate_rr_config_apply_from_filename_with_time (MateRRScreen *screen, const char *filename, guint32 timestamp, GError **error)
+{
+    MateRRConfig *stored;
+    GError *my_error;
+
+    g_return_val_if_fail (MATE_IS_RR_SCREEN (screen), FALSE);
+    g_return_val_if_fail (filename != NULL, FALSE);
+    g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+
+    my_error = NULL;
+    if (!mate_rr_screen_refresh (screen, &my_error)) {
+	    if (my_error) {
+		    g_propagate_error (error, my_error);
+		    return FALSE; /* This is a genuine error */
+	    }
+
+	    /* This means the screen didn't change, so just proceed */
+    }
+
+    stored = g_object_new (MATE_TYPE_RR_CONFIG, "screen", screen, NULL);
+
+    if (mate_rr_config_load_filename (stored, filename, error))
+    {
+	gboolean result;
+
+	mate_rr_config_ensure_primary (stored);
+	result = mate_rr_config_apply_with_time (stored, screen, timestamp, error);
+
+	g_object_unref (stored);
+
+	return result;
+    }
+    else
+    {
+        g_object_unref (stored);
+	return FALSE;
+    }
+}
+
+/**
+ * mate_rr_config_get_outputs:
+ *
+ * Returns: (array zero-terminated=1) (element-type MateDesktop.RROutputInfo) (transfer none): the output configuration for this #MateRRConfig
+ */
+MateRROutputInfo **
+mate_rr_config_get_outputs (MateRRConfig *self)
+{
+    g_return_val_if_fail (MATE_IS_RR_CONFIG (self), NULL);
+
+    return self->priv->outputs;
+}
+
+/**
+ * mate_rr_config_get_clone:
+ *
+ * Returns: whether at least two outputs are at (0, 0) offset and they
+ * have the same width/height.  Those outputs are of course connected and on
+ * (i.e. they have a CRTC assigned).
+ */
+gboolean
+mate_rr_config_get_clone (MateRRConfig *self)
+{
+    g_return_val_if_fail (MATE_IS_RR_CONFIG (self), FALSE);
+
+    return self->priv->clone;
+}
+
+void
+mate_rr_config_set_clone (MateRRConfig *self, gboolean clone)
+{
+    g_return_if_fail (MATE_IS_RR_CONFIG (self));
+
+    self->priv->clone = clone;
+}
+
+/*
+ * CRTC assignment
+ */
+typedef struct CrtcInfo CrtcInfo;
+
+struct CrtcInfo
+{
+    MateRRMode    *mode;
+    int        x;
+    int        y;
+    MateRRRotation rotation;
+    GPtrArray *outputs;
+};
+
+struct CrtcAssignment
+{
+    MateRRScreen *screen;
+    GHashTable *info;
+    MateRROutput *primary;
+};
+
+static gboolean
+can_clone (CrtcInfo *info,
+	   MateRROutput *output)
+{
+    guint i;
+
+    for (i = 0; i < info->outputs->len; ++i)
+    {
+	MateRROutput *clone = info->outputs->pdata[i];
+
+	if (!mate_rr_output_can_clone (clone, output))
+	    return FALSE;
+    }
+
+    return TRUE;
+}
+
+static gboolean
+crtc_assignment_assign (CrtcAssignment   *assign,
+			MateRRCrtc      *crtc,
+			MateRRMode      *mode,
+			int               x,
+			int               y,
+			MateRRRotation   rotation,
+                        gboolean          primary,
+			MateRROutput    *output,
+			GError          **error)
+{
+    CrtcInfo *info = g_hash_table_lookup (assign->info, crtc);
+    guint32 crtc_id;
+    const char *output_name;
+
+    crtc_id = mate_rr_crtc_get_id (crtc);
+    output_name = mate_rr_output_get_name (output);
+
+    if (!mate_rr_crtc_can_drive_output (crtc, output))
+    {
+	g_set_error (error, MATE_RR_ERROR, MATE_RR_ERROR_CRTC_ASSIGNMENT,
+		     _("CRTC %d cannot drive output %s"), crtc_id, output_name);
+	return FALSE;
+    }
+
+    if (!mate_rr_output_supports_mode (output, mode))
+    {
+	g_set_error (error, MATE_RR_ERROR, MATE_RR_ERROR_CRTC_ASSIGNMENT,
+		     _("output %s does not support mode %dx%d@%dHz"),
+		     output_name,
+		     mate_rr_mode_get_width (mode),
+		     mate_rr_mode_get_height (mode),
+		     mate_rr_mode_get_freq (mode));
+	return FALSE;
+    }
+
+    if (!mate_rr_crtc_supports_rotation (crtc, rotation))
+    {
+	g_set_error (error, MATE_RR_ERROR, MATE_RR_ERROR_CRTC_ASSIGNMENT,
+		     _("CRTC %d does not support rotation=%s"),
+		     crtc_id,
+		     get_rotation_name (rotation));
+	return FALSE;
+    }
+
+    if (info)
+    {
+	if (!(info->mode == mode	&&
+	      info->x == x		&&
+	      info->y == y		&&
+	      info->rotation == rotation))
+	{
+	    g_set_error (error, MATE_RR_ERROR, MATE_RR_ERROR_CRTC_ASSIGNMENT,
+			 _("output %s does not have the same parameters as another cloned output:\n"
+			   "existing mode = %d, new mode = %d\n"
+			   "existing coordinates = (%d, %d), new coordinates = (%d, %d)\n"
+			   "existing rotation = %s, new rotation = %s"),
+			 output_name,
+			 mate_rr_mode_get_id (info->mode), mate_rr_mode_get_id (mode),
+			 info->x, info->y,
+			 x, y,
+			 get_rotation_name (info->rotation), get_rotation_name (rotation));
+	    return FALSE;
+	}
+
+	if (!can_clone (info, output))
+	{
+	    g_set_error (error, MATE_RR_ERROR, MATE_RR_ERROR_CRTC_ASSIGNMENT,
+			 _("cannot clone to output %s"),
+			 output_name);
+	    return FALSE;
+	}
+
+	g_ptr_array_add (info->outputs, output);
+
+	if (primary && !assign->primary)
+	{
+	    assign->primary = output;
+	}
+
+	return TRUE;
+    }
+    else
+    {
+	info = g_new0 (CrtcInfo, 1);
+
+	info->mode = mode;
+	info->x = x;
+	info->y = y;
+	info->rotation = rotation;
+	info->outputs = g_ptr_array_new ();
+
+	g_ptr_array_add (info->outputs, output);
+
+	g_hash_table_insert (assign->info, crtc, info);
+
+        if (primary && !assign->primary)
+        {
+            assign->primary = output;
+        }
+
+	return TRUE;
+    }
+}
+
+static void
+crtc_assignment_unassign (CrtcAssignment *assign,
+			  MateRRCrtc         *crtc,
+			  MateRROutput       *output)
+{
+    CrtcInfo *info = g_hash_table_lookup (assign->info, crtc);
+
+    if (info)
+    {
+	g_ptr_array_remove (info->outputs, output);
+
+        if (assign->primary == output)
+        {
+            assign->primary = NULL;
+        }
+
+	if (info->outputs->len == 0)
+	    g_hash_table_remove (assign->info, crtc);
+    }
+}
+
+static void
+crtc_assignment_free (CrtcAssignment *assign)
+{
+    g_hash_table_destroy (assign->info);
+
+    g_free (assign);
+}
+
+typedef struct {
+    guint32 timestamp;
+    gboolean has_error;
+    GError **error;
+} ConfigureCrtcState;
+
+static void
+configure_crtc (gpointer key,
+		gpointer value,
+		gpointer data)
+{
+    MateRRCrtc *crtc = key;
+    CrtcInfo *info = value;
+    ConfigureCrtcState *state = data;
+
+    if (state->has_error)
+	return;
+
+    if (!mate_rr_crtc_set_config_with_time (crtc,
+					     state->timestamp,
+					     info->x, info->y,
+					     info->mode,
+					     info->rotation,
+					     (MateRROutput **)info->outputs->pdata,
+					     info->outputs->len,
+					     state->error))
+	state->has_error = TRUE;
+}
+
+static gboolean
+mode_is_rotated (CrtcInfo *info)
+{
+    if ((info->rotation & MATE_RR_ROTATION_270)		||
+	(info->rotation & MATE_RR_ROTATION_90))
+    {
+	return TRUE;
+    }
+    return FALSE;
+}
+
+static gboolean
+crtc_is_rotated (MateRRCrtc *crtc)
+{
+    MateRRRotation r = mate_rr_crtc_get_current_rotation (crtc);
+
+    if ((r & MATE_RR_ROTATION_270)		||
+	(r & MATE_RR_ROTATION_90))
+    {
+	return TRUE;
+    }
+
+    return FALSE;
+}
+
+static void
+accumulate_error (GString *accumulated_error, GError *error)
+{
+    g_string_append_printf (accumulated_error, "    %s\n", error->message);
+    g_error_free (error);
+}
+
+/* Check whether the given set of settings can be used
+ * at the same time -- ie. whether there is an assignment
+ * of CRTC's to outputs.
+ *
+ * Brute force - the number of objects involved is small
+ * enough that it doesn't matter.
+ */
+static gboolean
+real_assign_crtcs (MateRRScreen *screen,
+		   MateRROutputInfo **outputs,
+		   CrtcAssignment *assignment,
+		   GError **error)
+{
+    MateRRCrtc **crtcs = mate_rr_screen_list_crtcs (screen);
+    MateRROutputInfo *output;
+    int i;
+    gboolean tried_mode;
+    GError *my_error;
+    GString *accumulated_error;
+    gboolean success;
+
+    output = *outputs;
+    if (!output)
+	return TRUE;
+
+    /* It is always allowed for an output to be turned off */
+    if (!output->priv->on)
+    {
+	return real_assign_crtcs (screen, outputs + 1, assignment, error);
+    }
+
+    success = FALSE;
+    tried_mode = FALSE;
+    accumulated_error = g_string_new (NULL);
+
+    for (i = 0; crtcs[i] != NULL; ++i)
+    {
+	MateRRCrtc *crtc = crtcs[i];
+	int crtc_id = mate_rr_crtc_get_id (crtc);
+	int pass;
+
+	g_string_append_printf (accumulated_error,
+				_("Trying modes for CRTC %d\n"),
+				crtc_id);
+
+	/* Make two passes, one where frequencies must match, then
+	 * one where they don't have to
+	 */
+	for (pass = 0; pass < 2; ++pass)
+	{
+	    MateRROutput *mate_rr_output = mate_rr_screen_get_output_by_name (screen, output->priv->name);
+	    MateRRMode **modes = mate_rr_output_list_modes (mate_rr_output);
+	    int j;
+
+	    for (j = 0; modes[j] != NULL; ++j)
+	    {
+		MateRRMode *mode = modes[j];
+		int mode_width;
+		int mode_height;
+		int mode_freq;
+
+		mode_width = mate_rr_mode_get_width (mode);
+		mode_height = mate_rr_mode_get_height (mode);
+		mode_freq = mate_rr_mode_get_freq (mode);
+
+		g_string_append_printf (accumulated_error,
+					_("CRTC %d: trying mode %dx%d@%dHz with output at %dx%d@%dHz (pass %d)\n"),
+					crtc_id,
+					mode_width, mode_height, mode_freq,
+					output->priv->width, output->priv->height, output->priv->rate,
+					pass);
+
+		if (mode_width == output->priv->width	&&
+		    mode_height == output->priv->height &&
+		    (pass == 1 || mode_freq == output->priv->rate))
+		{
+		    tried_mode = TRUE;
+
+		    my_error = NULL;
+		    if (crtc_assignment_assign (
+			    assignment, crtc, modes[j],
+			    output->priv->x, output->priv->y,
+			    output->priv->rotation,
+                            output->priv->primary,
+			    mate_rr_output,
+			    &my_error))
+		    {
+			my_error = NULL;
+			if (real_assign_crtcs (screen, outputs + 1, assignment, &my_error)) {
+			    success = TRUE;
+			    goto out;
+			} else
+			    accumulate_error (accumulated_error, my_error);
+
+			crtc_assignment_unassign (assignment, crtc, mate_rr_output);
+		    } else
+			accumulate_error (accumulated_error, my_error);
+		}
+	    }
+	}
+    }
+
+out:
+
+    if (success)
+	g_string_free (accumulated_error, TRUE);
+    else {
+	char *str;
+
+	str = g_string_free (accumulated_error, FALSE);
+
+	if (tried_mode)
+	    g_set_error (error, MATE_RR_ERROR, MATE_RR_ERROR_CRTC_ASSIGNMENT,
+			 _("could not assign CRTCs to outputs:\n%s"),
+			 str);
+	else
+	    g_set_error (error, MATE_RR_ERROR, MATE_RR_ERROR_CRTC_ASSIGNMENT,
+			 _("none of the selected modes were compatible with the possible modes:\n%s"),
+			 str);
+
+	g_free (str);
+    }
+
+    return success;
+}
+
+static void
+crtc_info_free (CrtcInfo *info)
+{
+    g_ptr_array_free (info->outputs, TRUE);
+    g_free (info);
+}
+
+static void
+get_required_virtual_size (CrtcAssignment *assign, int *width, int *height)
+{
+    GList *active_crtcs = g_hash_table_get_keys (assign->info);
+    GList *list;
+    int d;
+
+    if (!width)
+	width = &d;
+    if (!height)
+	height = &d;
+
+    /* Compute size of the screen */
+    *width = *height = 1;
+    for (list = active_crtcs; list != NULL; list = list->next)
+    {
+	MateRRCrtc *crtc = list->data;
+	CrtcInfo *info = g_hash_table_lookup (assign->info, crtc);
+	int w, h;
+
+	w = mate_rr_mode_get_width (info->mode);
+	h = mate_rr_mode_get_height (info->mode);
+
+	if (mode_is_rotated (info))
+	{
+	    int tmp = h;
+	    h = w;
+	    w = tmp;
+	}
+
+	*width = MAX (*width, info->x + w);
+	*height = MAX (*height, info->y + h);
+    }
+
+    g_list_free (active_crtcs);
+}
+
+static CrtcAssignment *
+crtc_assignment_new (MateRRScreen *screen, MateRROutputInfo **outputs, GError **error)
+{
+    CrtcAssignment *assignment = g_new0 (CrtcAssignment, 1);
+
+    assignment->info = g_hash_table_new_full (
+	g_direct_hash, g_direct_equal, NULL, (GFreeFunc)crtc_info_free);
+
+    if (real_assign_crtcs (screen, outputs, assignment, error))
+    {
+	int width, height;
+	int min_width, max_width, min_height, max_height;
+	int required_pixels, min_pixels, max_pixels;
+
+	get_required_virtual_size (assignment, &width, &height);
+
+	mate_rr_screen_get_ranges (
+	    screen, &min_width, &max_width, &min_height, &max_height);
+
+	required_pixels = width * height;
+	min_pixels = min_width * min_height;
+	max_pixels = max_width * max_height;
+
+	if (required_pixels < min_pixels || required_pixels > max_pixels)
+	{
+	    g_set_error (error, MATE_RR_ERROR, MATE_RR_ERROR_BOUNDS_ERROR,
+			 /* Translators: the "requested", "minimum", and
+			  * "maximum" words here are not keywords; please
+			  * translate them as usual. */
+			 _("required virtual size does not fit available size: "
+			   "requested=(%d, %d), minimum=(%d, %d), maximum=(%d, %d)"),
+			 width, height,
+			 min_width, min_height,
+			 max_width, max_height);
+	    goto fail;
+	}
+
+	assignment->screen = screen;
+
+	return assignment;
+    }
+
+fail:
+    crtc_assignment_free (assignment);
+
+    return NULL;
+}
+
+static gboolean
+crtc_assignment_apply (CrtcAssignment *assign, guint32 timestamp, GError **error)
+{
+    MateRRCrtc **all_crtcs = mate_rr_screen_list_crtcs (assign->screen);
+    int width, height;
+    int i;
+    int min_width, max_width, min_height, max_height;
+    int width_mm, height_mm;
+    gboolean success = TRUE;
+
+    /* Compute size of the screen */
+    get_required_virtual_size (assign, &width, &height);
+
+    mate_rr_screen_get_ranges (
+	assign->screen, &min_width, &max_width, &min_height, &max_height);
+
+    /* We should never get here if the dimensions don't fit in the virtual size,
+     * but just in case we do, fix it up.
+     */
+    width = MAX (min_width, width);
+    width = MIN (max_width, width);
+    height = MAX (min_height, height);
+    height = MIN (max_height, height);
+
+    /* FMQ: do we need to check the sizes instead of clamping them? */
+
+    /* Grab the server while we fiddle with the CRTCs and the screen, so that
+     * apps that listen for RANDR notifications will only receive the final
+     * status.
+     */
+
+    gdk_x11_display_grab (gdk_screen_get_display (assign->screen->priv->gdk_screen));
+
+    /* Turn off all crtcs that are currently displaying outside the new screen,
+     * or are not used in the new setup
+     */
+    for (i = 0; all_crtcs[i] != NULL; ++i)
+    {
+	MateRRCrtc *crtc = all_crtcs[i];
+	MateRRMode *mode = mate_rr_crtc_get_current_mode (crtc);
+	int x, y;
+
+	if (mode)
+	{
+	    int w, h;
+	    mate_rr_crtc_get_position (crtc, &x, &y);
+
+	    w = mate_rr_mode_get_width (mode);
+	    h = mate_rr_mode_get_height (mode);
+
+	    if (crtc_is_rotated (crtc))
+	    {
+		int tmp = h;
+		h = w;
+		w = tmp;
+	    }
+
+	    if (x + w > width || y + h > height || !g_hash_table_lookup (assign->info, crtc))
+	    {
+		if (!mate_rr_crtc_set_config_with_time (crtc, timestamp, 0, 0, NULL, MATE_RR_ROTATION_0, NULL, 0, error))
+		{
+		    success = FALSE;
+		    break;
+		}
+
+	    }
+	}
+    }
+
+    /* The 'physical size' of an X screen is meaningless if that screen
+     * can consist of many monitors. So just pick a size that make the
+     * dpi 96.
+     *
+     * Firefox and Evince apparently believe what X tells them.
+     */
+    width_mm = (width / 96.0) * 25.4 + 0.5;
+    height_mm = (height / 96.0) * 25.4 + 0.5;
+
+    if (success)
+    {
+	ConfigureCrtcState state;
+
+	mate_rr_screen_set_size (assign->screen, width, height, width_mm, height_mm);
+
+	state.timestamp = timestamp;
+	state.has_error = FALSE;
+	state.error = error;
+
+	g_hash_table_foreach (assign->info, configure_crtc, &state);
+
+	success = !state.has_error;
+    }
+
+    mate_rr_screen_set_primary_output (assign->screen, assign->primary);
+
+    gdk_x11_display_ungrab (gdk_screen_get_display (assign->screen->priv->gdk_screen));
+
+    return success;
+}
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/32.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/32.html new file mode 100644 index 0000000..c34a780 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/32.html @@ -0,0 +1,637 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
/* mate-rr.h
+ *
+ * Copyright 2007, 2008, Red Hat, Inc.
+ *
+ * This file is part of the Mate Library.
+ *
+ * The Mate Library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * The Mate Library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with the Mate Library; see the file COPYING.LIB.  If not,
+ * write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA  02110-1301, USA.
+ *
+ * Author: Soren Sandmann <sandmann@redhat.com>
+ */
+#ifndef MATE_RR_H
+#define MATE_RR_H
+
+#ifndef MATE_DESKTOP_USE_UNSTABLE_API
+#error    MateRR is unstable API. You must define MATE_DESKTOP_USE_UNSTABLE_API before including materr.h
+#endif
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdk/gdk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+typedef struct MateRRScreenPrivate MateRRScreenPrivate;
+typedef struct MateRROutput MateRROutput;
+typedef struct MateRRCrtc MateRRCrtc;
+typedef struct MateRRMode MateRRMode;
+
+typedef struct {
+    GObject parent;
+
+    MateRRScreenPrivate* priv;
+} MateRRScreen;
+
+typedef struct {
+    GObjectClass parent_class;
+
+        void (* changed) (void);
+} MateRRScreenClass;
+
+typedef enum
+{
+    MATE_RR_ROTATION_0 =	(1 << 0),
+    MATE_RR_ROTATION_90 =	(1 << 1),
+    MATE_RR_ROTATION_180 =	(1 << 2),
+    MATE_RR_ROTATION_270 =	(1 << 3),
+    MATE_RR_REFLECT_X =	(1 << 4),
+    MATE_RR_REFLECT_Y =	(1 << 5)
+} MateRRRotation;
+
+/* Error codes */
+
+#define MATE_RR_ERROR (mate_rr_error_quark ())
+
+GQuark mate_rr_error_quark (void);
+
+typedef enum {
+    MATE_RR_ERROR_UNKNOWN,		/* generic "fail" */
+    MATE_RR_ERROR_NO_RANDR_EXTENSION,	/* RANDR extension is not present */
+    MATE_RR_ERROR_RANDR_ERROR,		/* generic/undescribed error from the underlying XRR API */
+    MATE_RR_ERROR_BOUNDS_ERROR,	/* requested bounds of a CRTC are outside the maximum size */
+    MATE_RR_ERROR_CRTC_ASSIGNMENT,	/* could not assign CRTCs to outputs */
+    MATE_RR_ERROR_NO_MATCHING_CONFIG,	/* none of the saved configurations matched the current configuration */
+} MateRRError;
+
+#define MATE_RR_CONNECTOR_TYPE_PANEL "Panel"  /* This is a laptop's built-in LCD */
+
+#define MATE_TYPE_RR_SCREEN                  (mate_rr_screen_get_type())
+#define MATE_RR_SCREEN(obj)                  (G_TYPE_CHECK_INSTANCE_CAST ((obj), MATE_TYPE_RR_SCREEN, MateRRScreen))
+#define MATE_IS_RR_SCREEN(obj)               (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MATE_TYPE_RR_SCREEN))
+#define MATE_RR_SCREEN_CLASS(klass)          (G_TYPE_CHECK_CLASS_CAST ((klass), MATE_TYPE_RR_SCREEN, MateRRScreenClass))
+#define MATE_IS_RR_SCREEN_CLASS(klass)       (G_TYPE_CHECK_CLASS_TYPE ((klass), MATE_TYPE_RR_SCREEN))
+#define MATE_RR_SCREEN_GET_CLASS(obj)        (G_TYPE_INSTANCE_GET_CLASS ((obj), MATE_TYPE_RR_SCREEN, MateRRScreenClass))
+
+#define MATE_TYPE_RR_OUTPUT (mate_rr_output_get_type())
+#define MATE_TYPE_RR_CRTC   (mate_rr_crtc_get_type())
+#define MATE_TYPE_RR_MODE   (mate_rr_mode_get_type())
+
+GType mate_rr_screen_get_type (void);
+GType mate_rr_output_get_type (void);
+GType mate_rr_crtc_get_type (void);
+GType mate_rr_mode_get_type (void);
+
+/* MateRRScreen */
+MateRRScreen * mate_rr_screen_new                (GdkScreen             *screen,
+						    GError               **error);
+MateRROutput **mate_rr_screen_list_outputs       (MateRRScreen         *screen);
+MateRRCrtc **  mate_rr_screen_list_crtcs         (MateRRScreen         *screen);
+MateRRMode **  mate_rr_screen_list_modes         (MateRRScreen         *screen);
+MateRRMode **  mate_rr_screen_list_clone_modes   (MateRRScreen	  *screen);
+void            mate_rr_screen_set_size           (MateRRScreen         *screen,
+						    int                    width,
+						    int                    height,
+						    int                    mm_width,
+						    int                    mm_height);
+MateRRCrtc *   mate_rr_screen_get_crtc_by_id     (MateRRScreen         *screen,
+						    guint32                id);
+gboolean        mate_rr_screen_refresh            (MateRRScreen         *screen,
+						    GError               **error);
+MateRROutput * mate_rr_screen_get_output_by_id   (MateRRScreen         *screen,
+						    guint32                id);
+MateRROutput * mate_rr_screen_get_output_by_name (MateRRScreen         *screen,
+						    const char            *name);
+void            mate_rr_screen_get_ranges         (MateRRScreen         *screen,
+						    int                   *min_width,
+						    int                   *max_width,
+						    int                   *min_height,
+						    int                   *max_height);
+void            mate_rr_screen_get_timestamps     (MateRRScreen         *screen,
+						    guint32               *change_timestamp_ret,
+						    guint32               *config_timestamp_ret);
+
+void            mate_rr_screen_set_primary_output (MateRRScreen         *screen,
+                                                    MateRROutput         *output);
+
+/* MateRROutput */
+guint32         mate_rr_output_get_id             (MateRROutput         *output);
+const char *    mate_rr_output_get_name           (MateRROutput         *output);
+gboolean        mate_rr_output_is_connected       (MateRROutput         *output);
+int             mate_rr_output_get_size_inches    (MateRROutput         *output);
+int             mate_rr_output_get_width_mm       (MateRROutput         *outout);
+int             mate_rr_output_get_height_mm      (MateRROutput         *output);
+const guint8 *  mate_rr_output_get_edid_data      (MateRROutput         *output);
+MateRRCrtc **  mate_rr_output_get_possible_crtcs (MateRROutput         *output);
+MateRRMode *   mate_rr_output_get_current_mode   (MateRROutput         *output);
+MateRRCrtc *   mate_rr_output_get_crtc           (MateRROutput         *output);
+const char *    mate_rr_output_get_connector_type (MateRROutput         *output);
+gboolean        mate_rr_output_is_laptop          (MateRROutput         *output);
+void            mate_rr_output_get_position       (MateRROutput         *output,
+						    int                   *x,
+						    int                   *y);
+gboolean        mate_rr_output_can_clone          (MateRROutput         *output,
+						    MateRROutput         *clone);
+MateRRMode **  mate_rr_output_list_modes         (MateRROutput         *output);
+MateRRMode *   mate_rr_output_get_preferred_mode (MateRROutput         *output);
+gboolean        mate_rr_output_supports_mode      (MateRROutput         *output,
+						    MateRRMode           *mode);
+gboolean        mate_rr_output_get_is_primary     (MateRROutput         *output);
+
+/* MateRRMode */
+guint32         mate_rr_mode_get_id               (MateRRMode           *mode);
+guint           mate_rr_mode_get_width            (MateRRMode           *mode);
+guint           mate_rr_mode_get_height           (MateRRMode           *mode);
+int             mate_rr_mode_get_freq             (MateRRMode           *mode);
+
+/* MateRRCrtc */
+guint32         mate_rr_crtc_get_id               (MateRRCrtc           *crtc);
+
+#ifndef MATE_DISABLE_DEPRECATED
+gboolean        mate_rr_crtc_set_config           (MateRRCrtc           *crtc,
+						    int                    x,
+						    int                    y,
+						    MateRRMode           *mode,
+						    MateRRRotation        rotation,
+						    MateRROutput        **outputs,
+						    int                    n_outputs,
+						    GError               **error);
+#endif
+
+gboolean        mate_rr_crtc_set_config_with_time (MateRRCrtc           *crtc,
+						    guint32                timestamp,
+						    int                    x,
+						    int                    y,
+						    MateRRMode           *mode,
+						    MateRRRotation        rotation,
+						    MateRROutput        **outputs,
+						    int                    n_outputs,
+						    GError               **error);
+gboolean        mate_rr_crtc_can_drive_output     (MateRRCrtc           *crtc,
+						    MateRROutput         *output);
+MateRRMode *   mate_rr_crtc_get_current_mode     (MateRRCrtc           *crtc);
+void            mate_rr_crtc_get_position         (MateRRCrtc           *crtc,
+						    int                   *x,
+						    int                   *y);
+MateRRRotation mate_rr_crtc_get_current_rotation (MateRRCrtc           *crtc);
+MateRRRotation mate_rr_crtc_get_rotations        (MateRRCrtc           *crtc);
+gboolean        mate_rr_crtc_supports_rotation    (MateRRCrtc           *crtc,
+						    MateRRRotation        rotation);
+
+gboolean        mate_rr_crtc_get_gamma            (MateRRCrtc           *crtc,
+						    int                   *size,
+						    unsigned short       **red,
+						    unsigned short       **green,
+						    unsigned short       **blue);
+void            mate_rr_crtc_set_gamma            (MateRRCrtc           *crtc,
+						    int                    size,
+						    unsigned short        *red,
+						    unsigned short        *green,
+						    unsigned short        *blue);
+#endif /* MATE_RR_H */
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/33.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/33.html new file mode 100644 index 0000000..9c3c0f9 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/33.html @@ -0,0 +1,537 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
/* mate-rr-config.h
+ * -*- c-basic-offset: 4 -*-
+ *
+ * Copyright 2007, 2008, Red Hat, Inc.
+ * Copyright 2010 Giovanni Campagna
+ *
+ * This file is part of the Mate Library.
+ *
+ * The Mate Library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * The Mate Library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with the Mate Library; see the file COPYING.LIB.  If not,
+ * write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA  02110-1301, USA.
+ *
+ * Author: Soren Sandmann <sandmann@redhat.com>
+ */
+#ifndef MATE_RR_CONFIG_H
+#define MATE_RR_CONFIG_H
+
+#ifndef MATE_DESKTOP_USE_UNSTABLE_API
+#error   mate-rr-config.h is unstable API. You must define MATE_DESKTOP_USE_UNSTABLE_API before including mate-rr-config.h
+#endif
+
+#include "mate-rr.h"
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+typedef struct MateRROutputInfoPrivate MateRROutputInfoPrivate;
+typedef struct MateRRConfigPrivate MateRRConfigPrivate;
+
+typedef struct
+{
+    GObject parent;
+
+    /*< private >*/
+    MateRROutputInfoPrivate *priv;
+} MateRROutputInfo;
+
+typedef struct
+{
+    GObjectClass parent_class;
+} MateRROutputInfoClass;
+
+#define MATE_TYPE_RR_OUTPUT_INFO                  (mate_rr_output_info_get_type())
+#define MATE_RR_OUTPUT_INFO(obj)                  (G_TYPE_CHECK_INSTANCE_CAST ((obj), MATE_TYPE_RR_OUTPUT_INFO, MateRROutputInfo))
+#define MATE_IS_RR_OUTPUT_INFO(obj)               (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MATE_TYPE_RR_OUTPUT_INFO))
+#define MATE_RR_OUTPUT_INFO_CLASS(klass)          (G_TYPE_CHECK_CLASS_CAST ((klass), MATE_TYPE_RR_OUTPUT_INFO, MateRROutputInfoClass))
+#define MATE_IS_RR_OUTPUT_INFO_CLASS(klass)       (G_TYPE_CHECK_CLASS_TYPE ((klass), MATE_TYPE_RR_OUTPUT_INFO))
+#define MATE_RR_OUTPUT_INFO_GET_CLASS(obj)        (G_TYPE_INSTANCE_GET_CLASS ((obj), MATE_TYPE_RR_OUTPUT_INFO, MateRROutputInfoClass))
+
+GType mate_rr_output_info_get_type (void);
+
+char *mate_rr_output_info_get_name (MateRROutputInfo *self);
+
+gboolean mate_rr_output_info_is_active  (MateRROutputInfo *self);
+void     mate_rr_output_info_set_active (MateRROutputInfo *self, gboolean active);
+
+void mate_rr_output_info_get_geometry (MateRROutputInfo *self, int *x, int *y, int *width, int *height);
+void mate_rr_output_info_set_geometry (MateRROutputInfo *self, int  x, int  y, int  width, int  height);
+
+int  mate_rr_output_info_get_refresh_rate (MateRROutputInfo *self);
+void mate_rr_output_info_set_refresh_rate (MateRROutputInfo *self, int rate);
+
+MateRRRotation mate_rr_output_info_get_rotation (MateRROutputInfo *self);
+void            mate_rr_output_info_set_rotation (MateRROutputInfo *self, MateRRRotation rotation);
+
+gboolean mate_rr_output_info_is_connected     (MateRROutputInfo *self);
+void     mate_rr_output_info_get_vendor       (MateRROutputInfo *self, gchar* vendor);
+guint    mate_rr_output_info_get_product      (MateRROutputInfo *self);
+guint    mate_rr_output_info_get_serial       (MateRROutputInfo *self);
+double   mate_rr_output_info_get_aspect_ratio (MateRROutputInfo *self);
+char    *mate_rr_output_info_get_display_name (MateRROutputInfo *self);
+
+gboolean mate_rr_output_info_get_primary (MateRROutputInfo *self);
+void     mate_rr_output_info_set_primary (MateRROutputInfo *self, gboolean primary);
+
+int mate_rr_output_info_get_preferred_width  (MateRROutputInfo *self);
+int mate_rr_output_info_get_preferred_height (MateRROutputInfo *self);
+
+typedef struct
+{
+    GObject parent;
+
+    /*< private >*/
+    MateRRConfigPrivate *priv;
+} MateRRConfig;
+
+typedef struct
+{
+    GObjectClass parent_class;
+} MateRRConfigClass;
+
+#define MATE_TYPE_RR_CONFIG                  (mate_rr_config_get_type())
+#define MATE_RR_CONFIG(obj)                  (G_TYPE_CHECK_INSTANCE_CAST ((obj), MATE_TYPE_RR_CONFIG, MateRRConfig))
+#define MATE_IS_RR_CONFIG(obj)               (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MATE_TYPE_RR_CONFIG))
+#define MATE_RR_CONFIG_CLASS(klass)          (G_TYPE_CHECK_CLASS_CAST ((klass), MATE_TYPE_RR_CONFIG, MateRRConfigClass))
+#define MATE_IS_RR_CONFIG_CLASS(klass)       (G_TYPE_CHECK_CLASS_TYPE ((klass), MATE_TYPE_RR_CONFIG))
+#define MATE_RR_CONFIG_GET_CLASS(obj)        (G_TYPE_INSTANCE_GET_CLASS ((obj), MATE_TYPE_RR_CONFIG, MateRRConfigClass))
+
+GType               mate_rr_config_get_type     (void);
+
+MateRRConfig      *mate_rr_config_new_current  (MateRRScreen  *screen,
+						  GError        **error);
+MateRRConfig      *mate_rr_config_new_stored   (MateRRScreen  *screen,
+						  GError        **error);
+gboolean                mate_rr_config_load_current (MateRRConfig  *self,
+						      GError        **error);
+gboolean                mate_rr_config_load_filename (MateRRConfig  *self,
+						       const gchar    *filename,
+						       GError        **error);
+gboolean            mate_rr_config_match        (MateRRConfig  *config1,
+						  MateRRConfig  *config2);
+gboolean            mate_rr_config_equal	 (MateRRConfig  *config1,
+						  MateRRConfig  *config2);
+gboolean            mate_rr_config_save         (MateRRConfig  *configuration,
+						  GError        **error);
+void                mate_rr_config_sanitize     (MateRRConfig  *configuration);
+gboolean            mate_rr_config_ensure_primary (MateRRConfig  *configuration);
+
+gboolean	    mate_rr_config_apply_with_time (MateRRConfig  *configuration,
+						     MateRRScreen  *screen,
+						     guint32         timestamp,
+						     GError        **error);
+
+gboolean            mate_rr_config_apply_from_filename_with_time (MateRRScreen  *screen,
+								   const char     *filename,
+								   guint32         timestamp,
+								   GError        **error);
+
+gboolean            mate_rr_config_applicable   (MateRRConfig  *configuration,
+						  MateRRScreen  *screen,
+						  GError        **error);
+
+gboolean            mate_rr_config_get_clone    (MateRRConfig  *configuration);
+void                mate_rr_config_set_clone    (MateRRConfig  *configuration, gboolean clone);
+MateRROutputInfo **mate_rr_config_get_outputs  (MateRRConfig  *configuration);
+
+char *mate_rr_config_get_backup_filename (void);
+char *mate_rr_config_get_intended_filename (void);
+
+#endif
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/34.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/34.html new file mode 100644 index 0000000..7f5da4f --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/34.html @@ -0,0 +1,405 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+82
+83
+84
#ifndef MATE_RR_PRIVATE_H
+#define MATE_RR_PRIVATE_H
+
+#include <X11/Xlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#ifdef HAVE_RANDR
+#include <X11/extensions/Xrandr.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+
+typedef struct ScreenInfo ScreenInfo;
+
+struct ScreenInfo
+{
+    int			min_width;
+    int			max_width;
+    int			min_height;
+    int			max_height;
+
+#ifdef HAVE_RANDR
+    XRRScreenResources *resources;
+#endif
+
+    MateRROutput **	outputs;
+    MateRRCrtc **	crtcs;
+    MateRRMode **	modes;
+
+    MateRRScreen *	screen;
+
+    MateRRMode **	clone_modes;
+
+#ifdef HAVE_RANDR
+    RROutput            primary;
+#endif
+};
+
+struct MateRRScreenPrivate
+{
+    GdkScreen *			gdk_screen;
+    GdkWindow *			gdk_root;
+    Display *			xdisplay;
+    Screen *			xscreen;
+    Window			xroot;
+    ScreenInfo *		info;
+
+    int				randr_event_base;
+    int				rr_major_version;
+    int				rr_minor_version;
+
+    Atom                        connector_type_atom;
+};
+
+struct MateRROutputInfoPrivate
+{
+    char *		name;
+
+    gboolean		on;
+    int			width;
+    int			height;
+    int			rate;
+    int			x;
+    int			y;
+    MateRRRotation	rotation;
+
+    gboolean		connected;
+    gchar		vendor[4];
+    guint		product;
+    guint		serial;
+    double		aspect;
+    int			pref_width;
+    int			pref_height;
+    char *		display_name;
+    gboolean            primary;
+};
+
+struct MateRRConfigPrivate
+{
+  gboolean clone;
+  MateRRScreen *screen;
+  MateRROutputInfo **outputs;
+};
+
+gboolean _mate_rr_output_name_is_laptop (const char *name);
+
+#endif
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/35.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/35.html new file mode 100644 index 0000000..15b9709 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/35.html @@ -0,0 +1,1333 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * mate-rr-labeler.c - Utility to label monitors to identify them
+ * while they are being configured.
+ *
+ * Copyright 2008, Novell, Inc.
+ *
+ * This file is part of the Mate Library.
+ *
+ * The Mate Library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * The Mate Library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with the Mate Library; see the file COPYING.LIB.  If not,
+ * write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Author: Federico Mena-Quintero <federico@novell.com>
+ */
+
+#define MATE_DESKTOP_USE_UNSTABLE_API
+
+#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n-lib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <X11/Xproto.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <X11/Xlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <X11/Xutil.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <X11/Xatom.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdk/gdkx.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "mate-rr-labeler.h"
+
+struct _MateRRLabelerPrivate {
+	MateRRConfig *config;
+
+	int num_outputs;
+
+	GdkRGBA *palette;
+	GtkWidget **windows;
+
+	GdkScreen  *screen;
+	Atom        workarea_atom;
+};
+
+enum {
+	PROP_0,
+	PROP_CONFIG,
+	PROP_LAST
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (MateRRLabeler, mate_rr_labeler, G_TYPE_OBJECT);
+
+static void mate_rr_labeler_finalize (GObject *object);
+static void create_label_windows (MateRRLabeler *labeler);
+static void setup_from_config (MateRRLabeler *labeler);
+
+static int
+get_current_desktop (GdkScreen *screen)
+{
+        Display *display;
+        Window win;
+        Atom current_desktop, type;
+        int format;
+        unsigned long n_items, bytes_after;
+        unsigned char *data_return = NULL;
+        int workspace = 0;
+
+        display = GDK_DISPLAY_XDISPLAY (gdk_screen_get_display (screen));
+        win = XRootWindow (display, GDK_SCREEN_XNUMBER (screen));
+
+        current_desktop = XInternAtom (display, "_NET_CURRENT_DESKTOP", True);
+
+        XGetWindowProperty (display,
+                            win,
+                            current_desktop,
+                            0, G_MAXLONG,
+                            False, XA_CARDINAL,
+                            &type, &format, &n_items, &bytes_after,
+                            &data_return);
+
+        if (type == XA_CARDINAL && format == 32 && n_items > 0)
+                workspace = (int) data_return[0];
+        if (data_return)
+                XFree (data_return);
+
+        return workspace;
+}
+
+static gboolean
+get_work_area (MateRRLabeler *labeler,
+	       GdkRectangle   *rect)
+{
+	Atom            workarea;
+	Atom            type;
+	Window          win;
+	int             format;
+	gulong          num;
+	gulong          leftovers;
+	gulong          max_len = 4 * 32;
+	guchar         *ret_workarea;
+	long           *workareas;<--- Variable 'workareas' can be declared as pointer to const
+	int             result;
+	int             disp_screen;
+	int             desktop;
+	Display        *display;
+
+	display = GDK_DISPLAY_XDISPLAY (gdk_screen_get_display (labeler->priv->screen));
+	workarea = XInternAtom (display, "_NET_WORKAREA", True);
+
+	disp_screen = GDK_SCREEN_XNUMBER (labeler->priv->screen);
+
+	/* Defaults in case of error */
+	rect->x = 0;
+	rect->y = 0;
+	rect->width = WidthOfScreen (gdk_x11_screen_get_xscreen (labeler->priv->screen));
+	rect->height = HeightOfScreen (gdk_x11_screen_get_xscreen (labeler->priv->screen));
+
+	if (workarea == None)
+		return FALSE;
+
+	win = XRootWindow (display, disp_screen);
+	result = XGetWindowProperty (display,
+				     win,
+				     workarea,
+				     0,
+				     max_len,
+				     False,
+				     AnyPropertyType,
+				     &type,
+				     &format,
+				     &num,
+				     &leftovers,
+				     &ret_workarea);
+
+	if (result != Success
+	    || type == None
+	    || format == 0
+	    || leftovers
+	    || num % 4) {
+		return FALSE;
+	}
+
+	desktop = get_current_desktop (labeler->priv->screen);
+
+	workareas = (long *) ret_workarea;
+	rect->x = workareas[desktop * 4];
+	rect->y = workareas[desktop * 4 + 1];
+	rect->width = workareas[desktop * 4 + 2];
+	rect->height = workareas[desktop * 4 + 3];
+
+	XFree (ret_workarea);
+
+	return TRUE;
+}
+
+static GdkFilterReturn
+screen_xevent_filter (GdkXEvent      *xevent,
+		      GdkEvent       *event,
+		      MateRRLabeler *labeler)
+{
+	XEvent *xev;<--- Variable 'xev' can be declared as pointer to const
+
+	xev = (XEvent *) xevent;
+
+	if (xev->type == PropertyNotify &&
+	    xev->xproperty.atom == labeler->priv->workarea_atom) {
+		/* update label positions */
+		mate_rr_labeler_hide (labeler);
+		create_label_windows (labeler);
+	}
+
+	return GDK_FILTER_CONTINUE;
+}
+
+static void
+mate_rr_labeler_init (MateRRLabeler *labeler)
+{
+	GdkWindow *gdkwindow;
+
+	labeler->priv = mate_rr_labeler_get_instance_private (labeler);
+
+	labeler->priv->workarea_atom = XInternAtom (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
+						    "_NET_WORKAREA",
+						    True);
+
+	labeler->priv->screen = gdk_screen_get_default ();
+	/* code is not really designed to handle multiple screens so *shrug* */
+	gdkwindow = gdk_screen_get_root_window (labeler->priv->screen);
+	gdk_window_add_filter (gdkwindow, (GdkFilterFunc) screen_xevent_filter, labeler);
+	gdk_window_set_events (gdkwindow, gdk_window_get_events (gdkwindow) | GDK_PROPERTY_CHANGE_MASK);
+}
+
+static void
+mate_rr_labeler_set_property (GObject *gobject, guint property_id, const GValue *value, GParamSpec *param_spec)
+{
+	MateRRLabeler *self = MATE_RR_LABELER (gobject);
+
+	switch (property_id) {
+	case PROP_CONFIG:
+		self->priv->config = MATE_RR_CONFIG (g_value_dup_object (value));
+		return;
+	default:
+		G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, property_id, param_spec);
+	}
+}
+
+static GObject *
+mate_rr_labeler_constructor (GType type, guint n_construct_properties, GObjectConstructParam *construct_properties)
+{
+	MateRRLabeler *self = (MateRRLabeler*) G_OBJECT_CLASS (mate_rr_labeler_parent_class)->constructor (type, n_construct_properties, construct_properties);
+
+	setup_from_config (self);
+
+	return (GObject*) self;
+}
+
+static void
+mate_rr_labeler_class_init (MateRRLabelerClass *klass)
+{
+	GObjectClass *object_class;
+
+	object_class = (GObjectClass *) klass;
+
+	object_class->set_property = mate_rr_labeler_set_property;
+	object_class->finalize = mate_rr_labeler_finalize;
+	object_class->constructor = mate_rr_labeler_constructor;
+
+	g_object_class_install_property (object_class, PROP_CONFIG, g_param_spec_object ("config",
+											 "Configuration",
+											 "RandR configuration to label",
+											 MATE_TYPE_RR_CONFIG,
+											 G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY |
+											 G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
+}
+
+static void
+mate_rr_labeler_finalize (GObject *object)
+{
+	MateRRLabeler *labeler;
+	GdkWindow      *gdkwindow;
+
+	labeler = MATE_RR_LABELER (object);
+
+	gdkwindow = gdk_screen_get_root_window (labeler->priv->screen);
+	gdk_window_remove_filter (gdkwindow, (GdkFilterFunc) screen_xevent_filter, labeler);
+
+	if (labeler->priv->config != NULL) {
+		g_object_unref (labeler->priv->config);
+	}
+
+	if (labeler->priv->windows != NULL) {
+		mate_rr_labeler_hide (labeler);
+		g_free (labeler->priv->windows);
+	}
+
+	g_free (labeler->priv->palette);
+
+	G_OBJECT_CLASS (mate_rr_labeler_parent_class)->finalize (object);
+}
+
+static int
+count_outputs (MateRRConfig *config)
+{
+	int i;
+	MateRROutputInfo **outputs = mate_rr_config_get_outputs (config);
+
+	for (i = 0; outputs[i] != NULL; i++)
+		;
+
+	return i;
+}
+
+static void
+make_palette (MateRRLabeler *labeler)
+{
+	/* The idea is that we go around an hue color wheel.  We want to start
+	 * at red, go around to green/etc. and stop at blue --- because magenta
+	 * is evil.  Eeeeek, no magenta, please!
+	 *
+	 * Purple would be nice, though.  Remember that we are watered down
+	 * (i.e. low saturation), so that would be like Like berries with cream.
+	 * Mmmmm, berries.
+	 */
+	double start_hue;
+	double end_hue;
+	int i;
+
+	g_assert (labeler->priv->num_outputs > 0);
+
+	labeler->priv->palette = g_new (GdkRGBA, labeler->priv->num_outputs);
+
+	start_hue = 0.0; /* red */
+	end_hue   = 2.0/3; /* blue */
+
+	for (i = 0; i < labeler->priv->num_outputs; i++) {
+		double h, s, v;
+		double r, g, b;
+
+		h = start_hue + (end_hue - start_hue) / labeler->priv->num_outputs * i;
+		s = 1.0 / 3;
+		v = 1.0;
+
+		gtk_hsv_to_rgb (h, s, v, &r, &g, &b);
+
+		labeler->priv->palette[i].red   = r;
+		labeler->priv->palette[i].green = g;
+		labeler->priv->palette[i].blue  = b;
+		labeler->priv->palette[i].alpha  = 1.0;
+	}
+}
+
+#define LABEL_WINDOW_EDGE_THICKNESS 2
+#define LABEL_WINDOW_PADDING 12
+
+static gboolean
+label_window_draw_event_cb (GtkWidget *widget, cairo_t *cr, gpointer data)
+{
+	GdkRGBA *color;
+	GtkAllocation allocation;
+
+	color = g_object_get_data (G_OBJECT (widget), "color");
+	gtk_widget_get_allocation (widget, &allocation);
+
+	/* edge outline */
+
+	cairo_set_source_rgb (cr, 0, 0, 0);
+	cairo_rectangle (cr,
+			 LABEL_WINDOW_EDGE_THICKNESS / 2.0,
+			 LABEL_WINDOW_EDGE_THICKNESS / 2.0,
+			 allocation.width - LABEL_WINDOW_EDGE_THICKNESS,
+			 allocation.height - LABEL_WINDOW_EDGE_THICKNESS);
+	cairo_set_line_width (cr, LABEL_WINDOW_EDGE_THICKNESS);
+	cairo_stroke (cr);
+
+	/* fill */
+	gdk_cairo_set_source_rgba (cr, color);
+	cairo_rectangle (cr,
+			 LABEL_WINDOW_EDGE_THICKNESS,
+			 LABEL_WINDOW_EDGE_THICKNESS,
+			 allocation.width - LABEL_WINDOW_EDGE_THICKNESS * 2,
+			 allocation.height - LABEL_WINDOW_EDGE_THICKNESS * 2);
+	cairo_fill (cr);
+
+	return FALSE;
+}
+
+static void
+position_window (MateRRLabeler  *labeler,
+		 GtkWidget       *window,
+		 int              x,
+		 int              y)
+{
+	GdkRectangle    workarea;
+	GdkRectangle    monitor;
+	GdkMonitor     *monitor_num;
+
+	get_work_area (labeler, &workarea);
+	monitor_num = gdk_display_get_monitor_at_point (gdk_screen_get_display (labeler->priv->screen), x, y);
+	gdk_monitor_get_geometry (monitor_num, &monitor);
+	gdk_rectangle_intersect (&monitor, &workarea, &workarea);
+
+	gtk_window_move (GTK_WINDOW (window), workarea.x, workarea.y);
+}
+
+static GtkWidget *
+create_label_window (MateRRLabeler *labeler, MateRROutputInfo *output, GdkRGBA *color)
+{
+	GtkWidget *window;
+	GtkWidget *widget;
+	char *str;
+	char *display_name;
+	GdkRGBA black = { 0, 0, 0, 1.0 };
+	int x,y;
+
+	window = gtk_window_new (GTK_WINDOW_POPUP);
+	gtk_widget_set_app_paintable (window, TRUE);
+
+	gtk_container_set_border_width (GTK_CONTAINER (window), LABEL_WINDOW_PADDING + LABEL_WINDOW_EDGE_THICKNESS);
+
+	/* This is semi-dangerous.  The color is part of the labeler->palette
+	 * array.  Note that in mate_rr_labeler_finalize(), we are careful to
+	 * free the palette only after we free the windows.
+	 */
+	g_object_set_data (G_OBJECT (window), "color", color);
+
+	g_signal_connect (window, "draw",
+			  G_CALLBACK (label_window_draw_event_cb), labeler);
+
+	if (mate_rr_config_get_clone (labeler->priv->config)) {
+		/* Keep this string in sync with mate-control-center/capplets/display/xrandr-capplet.c:get_display_name() */
+
+		/* Translators:  this is the feature where what you see on your laptop's
+		 * screen is the same as your external monitor.  Here, "Mirror" is being
+		 * used as an adjective, not as a verb.  For example, the Spanish
+		 * translation could be "Pantallas en Espejo", *not* "Espejar Pantallas".
+		 */
+		display_name = g_strdup_printf (_("Mirror Screens"));
+		str = g_strdup_printf ("<b>%s</b>", display_name);
+	} else {
+		display_name = g_strdup_printf ("<b>%s</b>\n<small>%s</small>", mate_rr_output_info_get_display_name (output), mate_rr_output_info_get_name (output));
+		str = g_strdup_printf ("%s", display_name);
+	}
+	g_free (display_name);
+
+	widget = gtk_label_new (NULL);
+	gtk_label_set_markup (GTK_LABEL (widget), str);
+	g_free (str);
+
+	/* Make the label explicitly black.  We don't want it to follow the
+	 * theme's colors, since the label is always shown against a light
+	 * pastel background.  See bgo#556050
+	 */
+	gtk_widget_override_color (widget, gtk_widget_get_state_flags (widget), &black);
+
+	gtk_container_add (GTK_CONTAINER (window), widget);
+
+	/* Should we center this at the top edge of the monitor, instead of using the upper-left corner? */
+	mate_rr_output_info_get_geometry (output, &x, &y, NULL, NULL);
+	position_window (labeler, window, x, y);
+
+	gtk_widget_show_all (window);
+
+	return window;
+}
+
+static void
+create_label_windows (MateRRLabeler *labeler)
+{
+	int i;
+	gboolean created_window_for_clone;
+	MateRROutputInfo **outputs;
+
+	labeler->priv->windows = g_new (GtkWidget *, labeler->priv->num_outputs);
+
+	created_window_for_clone = FALSE;
+
+	outputs = mate_rr_config_get_outputs (labeler->priv->config);
+
+	for (i = 0; i < labeler->priv->num_outputs; i++) {
+		if (!created_window_for_clone && mate_rr_output_info_is_active (outputs[i])) {
+			labeler->priv->windows[i] = create_label_window (labeler, outputs[i], labeler->priv->palette + i);
+
+			if (mate_rr_config_get_clone (labeler->priv->config))
+				created_window_for_clone = TRUE;
+		} else
+			labeler->priv->windows[i] = NULL;
+	}
+}
+
+static void
+setup_from_config (MateRRLabeler *labeler)
+{
+	labeler->priv->num_outputs = count_outputs (labeler->priv->config);
+
+	make_palette (labeler);
+
+	create_label_windows (labeler);
+}
+
+/**
+ * mate_rr_labeler_new:
+ * @config: Configuration of the screens to label
+ *
+ * Create a GUI element that will display colored labels on each connected monitor.
+ * This is useful when users are required to identify which monitor is which, e.g. for
+ * for configuring multiple monitors.
+ * The labels will be shown by default, use mate_rr_labeler_hide to hide them.
+ *
+ * Returns: A new #MateRRLabeler
+ */
+MateRRLabeler *
+mate_rr_labeler_new (MateRRConfig *config)
+{
+	g_return_val_if_fail (MATE_IS_RR_CONFIG (config), NULL);
+
+	return g_object_new (MATE_TYPE_RR_LABELER, "config", config, NULL);
+}
+
+/**
+ * mate_rr_labeler_hide:
+ * @labeler: A #MateRRLabeler
+ *
+ * Hide ouput labels.
+ */
+void
+mate_rr_labeler_hide (MateRRLabeler *labeler)
+{
+	int i;
+	MateRRLabelerPrivate *priv;
+
+	g_return_if_fail (MATE_IS_RR_LABELER (labeler));
+
+	priv = labeler->priv;
+
+	if (priv->windows == NULL)
+		return;
+
+	for (i = 0; i < priv->num_outputs; i++)
+		if (priv->windows[i] != NULL) {
+			gtk_widget_destroy (priv->windows[i]);
+			priv->windows[i] = NULL;
+	}
+	g_free (priv->windows);
+	priv->windows = NULL;
+}
+
+/**
+ * mate_rr_labeler_get_rgba_for_output:
+ * @labeler: A #MateRRLabeler
+ * @output: Output device (i.e. monitor) to query
+ * @color_out: (out): Color of selected monitor.
+ *
+ * Get the color used for the label on a given output (monitor).
+ */
+void
+mate_rr_labeler_get_rgba_for_output (MateRRLabeler *labeler, MateRROutputInfo *output, GdkRGBA *color_out)
+{
+	int i;
+	MateRROutputInfo **outputs;
+
+	g_return_if_fail (MATE_IS_RR_LABELER (labeler));
+	g_return_if_fail (MATE_IS_RR_OUTPUT_INFO (output));
+	g_return_if_fail (color_out != NULL);
+
+	outputs = mate_rr_config_get_outputs (labeler->priv->config);
+
+	for (i = 0; i < labeler->priv->num_outputs; i++)
+		if (outputs[i] == output) {
+			*color_out = labeler->priv->palette[i];
+			return;
+		}
+
+	g_warning ("trying to get the color for unknown MateOutputInfo %p; returning magenta!", output);
+
+	color_out->red   = 1.0;
+	color_out->green = 0.0;
+	color_out->blue  = 1.0;
+	color_out->alpha = 1.0;
+}
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/36.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/36.html new file mode 100644 index 0000000..57e6ed4 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/36.html @@ -0,0 +1,741 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
/* mate-rr-output-info.c
+ * -*- c-basic-offset: 4 -*-
+ *
+ * Copyright 2010 Giovanni Campagna
+ *
+ * This file is part of the Mate Desktop Library.
+ *
+ * The Mate Desktop Library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * The Mate Library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with the Mate Desktop Library; see the file COPYING.LIB.  If not,
+ * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#define MATE_DESKTOP_USE_UNSTABLE_API
+
+#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "mate-rr-config.h"
+
+#include "edid.h"
+#include "mate-rr-private.h"
+
+G_DEFINE_TYPE_WITH_PRIVATE (MateRROutputInfo, mate_rr_output_info, G_TYPE_OBJECT)<--- There is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
+
+static void
+mate_rr_output_info_init (MateRROutputInfo *self)
+{
+    self->priv = mate_rr_output_info_get_instance_private (self);
+
+    self->priv->name = NULL;
+    self->priv->on = FALSE;
+    self->priv->display_name = NULL;
+}
+
+static void
+mate_rr_output_info_finalize (GObject *gobject)
+{
+    MateRROutputInfo *self = MATE_RR_OUTPUT_INFO (gobject);
+
+    g_free (self->priv->name);
+    g_free (self->priv->display_name);
+
+    G_OBJECT_CLASS (mate_rr_output_info_parent_class)->finalize (gobject);
+}
+
+static void
+mate_rr_output_info_class_init (MateRROutputInfoClass *klass)
+{
+    GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+
+    gobject_class->finalize = mate_rr_output_info_finalize;
+}
+
+/**
+ * mate_rr_output_info_get_name:
+ *
+ * Returns: (transfer none): the output name
+ */
+char *mate_rr_output_info_get_name (MateRROutputInfo *self)
+{
+    g_return_val_if_fail (MATE_IS_RR_OUTPUT_INFO (self), NULL);
+
+    return self->priv->name;
+}
+
+/**
+ * mate_rr_output_info_is_active:
+ *
+ * Returns: whether there is a CRTC assigned to this output (i.e. a signal is being sent to it)
+ */
+gboolean mate_rr_output_info_is_active (MateRROutputInfo *self)
+{
+    g_return_val_if_fail (MATE_IS_RR_OUTPUT_INFO (self), FALSE);
+
+    return self->priv->on;
+}
+
+void mate_rr_output_info_set_active (MateRROutputInfo *self, gboolean active)
+{
+    g_return_if_fail (MATE_IS_RR_OUTPUT_INFO (self));
+
+    self->priv->on = active;
+}
+
+/**
+ * mate_rr_output_info_get_geometry:
+ * @self: a #MateRROutputInfo
+ * @x: (out) (allow-none):
+ * @y: (out) (allow-none):
+ * @width: (out) (allow-none):
+ * @height: (out) (allow-none):
+ */
+void mate_rr_output_info_get_geometry (MateRROutputInfo *self, int *x, int *y, int *width, int *height)
+{
+    g_return_if_fail (MATE_IS_RR_OUTPUT_INFO (self));
+
+    if (x)
+	*x = self->priv->x;
+    if (y)
+	*y = self->priv->y;
+    if (width)
+	*width = self->priv->width;
+    if (height)
+	*height = self->priv->height;
+}
+
+/**
+ * mate_rr_output_info_set_geometry:
+ * @self: a #MateRROutputInfo
+ * @x: x offset for monitor
+ * @y: y offset for monitor
+ * @width: monitor width
+ * @height: monitor height
+ *
+ * Set the geometry for the monitor connected to the specified output.
+ */
+void mate_rr_output_info_set_geometry (MateRROutputInfo *self, int  x, int  y, int  width, int  height)
+{
+    g_return_if_fail (MATE_IS_RR_OUTPUT_INFO (self));
+
+    self->priv->x = x;
+    self->priv->y = y;
+    self->priv->width = width;
+    self->priv->height = height;
+}
+
+int mate_rr_output_info_get_refresh_rate (MateRROutputInfo *self)
+{
+    g_return_val_if_fail (MATE_IS_RR_OUTPUT_INFO (self), 0);
+
+    return self->priv->rate;
+}
+
+void mate_rr_output_info_set_refresh_rate (MateRROutputInfo *self, int rate)
+{
+    g_return_if_fail (MATE_IS_RR_OUTPUT_INFO (self));
+
+    self->priv->rate = rate;
+}
+
+MateRRRotation mate_rr_output_info_get_rotation (MateRROutputInfo *self)
+{
+    g_return_val_if_fail (MATE_IS_RR_OUTPUT_INFO (self), MATE_RR_ROTATION_0);
+
+    return self->priv->rotation;
+}
+
+void mate_rr_output_info_set_rotation (MateRROutputInfo *self, MateRRRotation rotation)
+{
+    g_return_if_fail (MATE_IS_RR_OUTPUT_INFO (self));
+
+    self->priv->rotation = rotation;
+}
+
+/**
+ * mate_rr_output_info_is_connected:
+ *
+ * Returns: whether the output is physically connected to a monitor
+ */
+gboolean mate_rr_output_info_is_connected (MateRROutputInfo *self)
+{
+    g_return_val_if_fail (MATE_IS_RR_OUTPUT_INFO (self), FALSE);
+
+    return self->priv->connected;
+}
+
+/**
+ * mate_rr_output_info_get_vendor:
+ * @self: a #MateRROutputInfo
+ * @vendor: (out caller-allocates) (array fixed-size=4):
+ */
+void mate_rr_output_info_get_vendor (MateRROutputInfo *self, gchar* vendor)
+{
+    g_return_if_fail (MATE_IS_RR_OUTPUT_INFO (self));
+    g_return_if_fail (vendor != NULL);
+
+    vendor[0] = self->priv->vendor[0];
+    vendor[1] = self->priv->vendor[1];
+    vendor[2] = self->priv->vendor[2];
+    vendor[3] = self->priv->vendor[3];
+}
+
+guint mate_rr_output_info_get_product (MateRROutputInfo *self)
+{
+    g_return_val_if_fail (MATE_IS_RR_OUTPUT_INFO (self), 0);
+
+    return self->priv->product;
+}
+
+guint mate_rr_output_info_get_serial (MateRROutputInfo *self)
+{
+    g_return_val_if_fail (MATE_IS_RR_OUTPUT_INFO (self), 0);
+
+    return self->priv->serial;
+}
+
+double mate_rr_output_info_get_aspect_ratio (MateRROutputInfo *self)
+{
+    g_return_val_if_fail (MATE_IS_RR_OUTPUT_INFO (self), 0);
+
+    return self->priv->aspect;
+}
+
+/**
+ * mate_rr_output_info_get_display_name:
+ *
+ * Returns: (transfer none): the display name of this output
+ */
+char *mate_rr_output_info_get_display_name (MateRROutputInfo *self)
+{
+    g_return_val_if_fail (MATE_IS_RR_OUTPUT_INFO (self), NULL);
+
+    return self->priv->display_name;
+}
+
+gboolean mate_rr_output_info_get_primary (MateRROutputInfo *self)
+{
+    g_return_val_if_fail (MATE_IS_RR_OUTPUT_INFO (self), FALSE);
+
+    return self->priv->primary;
+}
+
+void mate_rr_output_info_set_primary (MateRROutputInfo *self, gboolean primary)
+{
+    g_return_if_fail (MATE_IS_RR_OUTPUT_INFO (self));
+
+    self->priv->primary = primary;
+}
+
+int mate_rr_output_info_get_preferred_width (MateRROutputInfo *self)
+{
+    g_return_val_if_fail (MATE_IS_RR_OUTPUT_INFO (self), 0);
+
+    return self->priv->pref_width;
+}
+
+int mate_rr_output_info_get_preferred_height (MateRROutputInfo *self)
+{
+    g_return_val_if_fail (MATE_IS_RR_OUTPUT_INFO (self), 0);
+
+    return self->priv->pref_height;
+}
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/37.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/37.html new file mode 100644 index 0000000..a54440d --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/37.html @@ -0,0 +1,4569 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
   1
+   2
+   3
+   4
+   5
+   6
+   7
+   8
+   9
+  10
+  11
+  12
+  13
+  14
+  15
+  16
+  17
+  18
+  19
+  20
+  21
+  22
+  23
+  24
+  25
+  26
+  27
+  28
+  29
+  30
+  31
+  32
+  33
+  34
+  35
+  36
+  37
+  38
+  39
+  40
+  41
+  42
+  43
+  44
+  45
+  46
+  47
+  48
+  49
+  50
+  51
+  52
+  53
+  54
+  55
+  56
+  57
+  58
+  59
+  60
+  61
+  62
+  63
+  64
+  65
+  66
+  67
+  68
+  69
+  70
+  71
+  72
+  73
+  74
+  75
+  76
+  77
+  78
+  79
+  80
+  81
+  82
+  83
+  84
+  85
+  86
+  87
+  88
+  89
+  90
+  91
+  92
+  93
+  94
+  95
+  96
+  97
+  98
+  99
+ 100
+ 101
+ 102
+ 103
+ 104
+ 105
+ 106
+ 107
+ 108
+ 109
+ 110
+ 111
+ 112
+ 113
+ 114
+ 115
+ 116
+ 117
+ 118
+ 119
+ 120
+ 121
+ 122
+ 123
+ 124
+ 125
+ 126
+ 127
+ 128
+ 129
+ 130
+ 131
+ 132
+ 133
+ 134
+ 135
+ 136
+ 137
+ 138
+ 139
+ 140
+ 141
+ 142
+ 143
+ 144
+ 145
+ 146
+ 147
+ 148
+ 149
+ 150
+ 151
+ 152
+ 153
+ 154
+ 155
+ 156
+ 157
+ 158
+ 159
+ 160
+ 161
+ 162
+ 163
+ 164
+ 165
+ 166
+ 167
+ 168
+ 169
+ 170
+ 171
+ 172
+ 173
+ 174
+ 175
+ 176
+ 177
+ 178
+ 179
+ 180
+ 181
+ 182
+ 183
+ 184
+ 185
+ 186
+ 187
+ 188
+ 189
+ 190
+ 191
+ 192
+ 193
+ 194
+ 195
+ 196
+ 197
+ 198
+ 199
+ 200
+ 201
+ 202
+ 203
+ 204
+ 205
+ 206
+ 207
+ 208
+ 209
+ 210
+ 211
+ 212
+ 213
+ 214
+ 215
+ 216
+ 217
+ 218
+ 219
+ 220
+ 221
+ 222
+ 223
+ 224
+ 225
+ 226
+ 227
+ 228
+ 229
+ 230
+ 231
+ 232
+ 233
+ 234
+ 235
+ 236
+ 237
+ 238
+ 239
+ 240
+ 241
+ 242
+ 243
+ 244
+ 245
+ 246
+ 247
+ 248
+ 249
+ 250
+ 251
+ 252
+ 253
+ 254
+ 255
+ 256
+ 257
+ 258
+ 259
+ 260
+ 261
+ 262
+ 263
+ 264
+ 265
+ 266
+ 267
+ 268
+ 269
+ 270
+ 271
+ 272
+ 273
+ 274
+ 275
+ 276
+ 277
+ 278
+ 279
+ 280
+ 281
+ 282
+ 283
+ 284
+ 285
+ 286
+ 287
+ 288
+ 289
+ 290
+ 291
+ 292
+ 293
+ 294
+ 295
+ 296
+ 297
+ 298
+ 299
+ 300
+ 301
+ 302
+ 303
+ 304
+ 305
+ 306
+ 307
+ 308
+ 309
+ 310
+ 311
+ 312
+ 313
+ 314
+ 315
+ 316
+ 317
+ 318
+ 319
+ 320
+ 321
+ 322
+ 323
+ 324
+ 325
+ 326
+ 327
+ 328
+ 329
+ 330
+ 331
+ 332
+ 333
+ 334
+ 335
+ 336
+ 337
+ 338
+ 339
+ 340
+ 341
+ 342
+ 343
+ 344
+ 345
+ 346
+ 347
+ 348
+ 349
+ 350
+ 351
+ 352
+ 353
+ 354
+ 355
+ 356
+ 357
+ 358
+ 359
+ 360
+ 361
+ 362
+ 363
+ 364
+ 365
+ 366
+ 367
+ 368
+ 369
+ 370
+ 371
+ 372
+ 373
+ 374
+ 375
+ 376
+ 377
+ 378
+ 379
+ 380
+ 381
+ 382
+ 383
+ 384
+ 385
+ 386
+ 387
+ 388
+ 389
+ 390
+ 391
+ 392
+ 393
+ 394
+ 395
+ 396
+ 397
+ 398
+ 399
+ 400
+ 401
+ 402
+ 403
+ 404
+ 405
+ 406
+ 407
+ 408
+ 409
+ 410
+ 411
+ 412
+ 413
+ 414
+ 415
+ 416
+ 417
+ 418
+ 419
+ 420
+ 421
+ 422
+ 423
+ 424
+ 425
+ 426
+ 427
+ 428
+ 429
+ 430
+ 431
+ 432
+ 433
+ 434
+ 435
+ 436
+ 437
+ 438
+ 439
+ 440
+ 441
+ 442
+ 443
+ 444
+ 445
+ 446
+ 447
+ 448
+ 449
+ 450
+ 451
+ 452
+ 453
+ 454
+ 455
+ 456
+ 457
+ 458
+ 459
+ 460
+ 461
+ 462
+ 463
+ 464
+ 465
+ 466
+ 467
+ 468
+ 469
+ 470
+ 471
+ 472
+ 473
+ 474
+ 475
+ 476
+ 477
+ 478
+ 479
+ 480
+ 481
+ 482
+ 483
+ 484
+ 485
+ 486
+ 487
+ 488
+ 489
+ 490
+ 491
+ 492
+ 493
+ 494
+ 495
+ 496
+ 497
+ 498
+ 499
+ 500
+ 501
+ 502
+ 503
+ 504
+ 505
+ 506
+ 507
+ 508
+ 509
+ 510
+ 511
+ 512
+ 513
+ 514
+ 515
+ 516
+ 517
+ 518
+ 519
+ 520
+ 521
+ 522
+ 523
+ 524
+ 525
+ 526
+ 527
+ 528
+ 529
+ 530
+ 531
+ 532
+ 533
+ 534
+ 535
+ 536
+ 537
+ 538
+ 539
+ 540
+ 541
+ 542
+ 543
+ 544
+ 545
+ 546
+ 547
+ 548
+ 549
+ 550
+ 551
+ 552
+ 553
+ 554
+ 555
+ 556
+ 557
+ 558
+ 559
+ 560
+ 561
+ 562
+ 563
+ 564
+ 565
+ 566
+ 567
+ 568
+ 569
+ 570
+ 571
+ 572
+ 573
+ 574
+ 575
+ 576
+ 577
+ 578
+ 579
+ 580
+ 581
+ 582
+ 583
+ 584
+ 585
+ 586
+ 587
+ 588
+ 589
+ 590
+ 591
+ 592
+ 593
+ 594
+ 595
+ 596
+ 597
+ 598
+ 599
+ 600
+ 601
+ 602
+ 603
+ 604
+ 605
+ 606
+ 607
+ 608
+ 609
+ 610
+ 611
+ 612
+ 613
+ 614
+ 615
+ 616
+ 617
+ 618
+ 619
+ 620
+ 621
+ 622
+ 623
+ 624
+ 625
+ 626
+ 627
+ 628
+ 629
+ 630
+ 631
+ 632
+ 633
+ 634
+ 635
+ 636
+ 637
+ 638
+ 639
+ 640
+ 641
+ 642
+ 643
+ 644
+ 645
+ 646
+ 647
+ 648
+ 649
+ 650
+ 651
+ 652
+ 653
+ 654
+ 655
+ 656
+ 657
+ 658
+ 659
+ 660
+ 661
+ 662
+ 663
+ 664
+ 665
+ 666
+ 667
+ 668
+ 669
+ 670
+ 671
+ 672
+ 673
+ 674
+ 675
+ 676
+ 677
+ 678
+ 679
+ 680
+ 681
+ 682
+ 683
+ 684
+ 685
+ 686
+ 687
+ 688
+ 689
+ 690
+ 691
+ 692
+ 693
+ 694
+ 695
+ 696
+ 697
+ 698
+ 699
+ 700
+ 701
+ 702
+ 703
+ 704
+ 705
+ 706
+ 707
+ 708
+ 709
+ 710
+ 711
+ 712
+ 713
+ 714
+ 715
+ 716
+ 717
+ 718
+ 719
+ 720
+ 721
+ 722
+ 723
+ 724
+ 725
+ 726
+ 727
+ 728
+ 729
+ 730
+ 731
+ 732
+ 733
+ 734
+ 735
+ 736
+ 737
+ 738
+ 739
+ 740
+ 741
+ 742
+ 743
+ 744
+ 745
+ 746
+ 747
+ 748
+ 749
+ 750
+ 751
+ 752
+ 753
+ 754
+ 755
+ 756
+ 757
+ 758
+ 759
+ 760
+ 761
+ 762
+ 763
+ 764
+ 765
+ 766
+ 767
+ 768
+ 769
+ 770
+ 771
+ 772
+ 773
+ 774
+ 775
+ 776
+ 777
+ 778
+ 779
+ 780
+ 781
+ 782
+ 783
+ 784
+ 785
+ 786
+ 787
+ 788
+ 789
+ 790
+ 791
+ 792
+ 793
+ 794
+ 795
+ 796
+ 797
+ 798
+ 799
+ 800
+ 801
+ 802
+ 803
+ 804
+ 805
+ 806
+ 807
+ 808
+ 809
+ 810
+ 811
+ 812
+ 813
+ 814
+ 815
+ 816
+ 817
+ 818
+ 819
+ 820
+ 821
+ 822
+ 823
+ 824
+ 825
+ 826
+ 827
+ 828
+ 829
+ 830
+ 831
+ 832
+ 833
+ 834
+ 835
+ 836
+ 837
+ 838
+ 839
+ 840
+ 841
+ 842
+ 843
+ 844
+ 845
+ 846
+ 847
+ 848
+ 849
+ 850
+ 851
+ 852
+ 853
+ 854
+ 855
+ 856
+ 857
+ 858
+ 859
+ 860
+ 861
+ 862
+ 863
+ 864
+ 865
+ 866
+ 867
+ 868
+ 869
+ 870
+ 871
+ 872
+ 873
+ 874
+ 875
+ 876
+ 877
+ 878
+ 879
+ 880
+ 881
+ 882
+ 883
+ 884
+ 885
+ 886
+ 887
+ 888
+ 889
+ 890
+ 891
+ 892
+ 893
+ 894
+ 895
+ 896
+ 897
+ 898
+ 899
+ 900
+ 901
+ 902
+ 903
+ 904
+ 905
+ 906
+ 907
+ 908
+ 909
+ 910
+ 911
+ 912
+ 913
+ 914
+ 915
+ 916
+ 917
+ 918
+ 919
+ 920
+ 921
+ 922
+ 923
+ 924
+ 925
+ 926
+ 927
+ 928
+ 929
+ 930
+ 931
+ 932
+ 933
+ 934
+ 935
+ 936
+ 937
+ 938
+ 939
+ 940
+ 941
+ 942
+ 943
+ 944
+ 945
+ 946
+ 947
+ 948
+ 949
+ 950
+ 951
+ 952
+ 953
+ 954
+ 955
+ 956
+ 957
+ 958
+ 959
+ 960
+ 961
+ 962
+ 963
+ 964
+ 965
+ 966
+ 967
+ 968
+ 969
+ 970
+ 971
+ 972
+ 973
+ 974
+ 975
+ 976
+ 977
+ 978
+ 979
+ 980
+ 981
+ 982
+ 983
+ 984
+ 985
+ 986
+ 987
+ 988
+ 989
+ 990
+ 991
+ 992
+ 993
+ 994
+ 995
+ 996
+ 997
+ 998
+ 999
+1000
+1001
+1002
+1003
+1004
+1005
+1006
+1007
+1008
+1009
+1010
+1011
+1012
+1013
+1014
+1015
+1016
+1017
+1018
+1019
+1020
+1021
+1022
+1023
+1024
+1025
+1026
+1027
+1028
+1029
+1030
+1031
+1032
+1033
+1034
+1035
+1036
+1037
+1038
+1039
+1040
+1041
+1042
+1043
+1044
+1045
+1046
+1047
+1048
+1049
+1050
+1051
+1052
+1053
+1054
+1055
+1056
+1057
+1058
+1059
+1060
+1061
+1062
+1063
+1064
+1065
+1066
+1067
+1068
+1069
+1070
+1071
+1072
+1073
+1074
+1075
+1076
+1077
+1078
+1079
+1080
+1081
+1082
+1083
+1084
+1085
+1086
+1087
+1088
+1089
+1090
+1091
+1092
+1093
+1094
+1095
+1096
+1097
+1098
+1099
+1100
+1101
+1102
+1103
+1104
+1105
+1106
+1107
+1108
+1109
+1110
+1111
+1112
+1113
+1114
+1115
+1116
+1117
+1118
+1119
+1120
+1121
+1122
+1123
+1124
+1125
+1126
+1127
+1128
+1129
+1130
+1131
+1132
+1133
+1134
+1135
+1136
+1137
+1138
+1139
+1140
+1141
+1142
+1143
+1144
+1145
+1146
+1147
+1148
+1149
+1150
+1151
+1152
+1153
+1154
+1155
+1156
+1157
+1158
+1159
+1160
+1161
+1162
+1163
+1164
+1165
+1166
+1167
+1168
+1169
+1170
+1171
+1172
+1173
+1174
+1175
+1176
+1177
+1178
+1179
+1180
+1181
+1182
+1183
+1184
+1185
+1186
+1187
+1188
+1189
+1190
+1191
+1192
+1193
+1194
+1195
+1196
+1197
+1198
+1199
+1200
+1201
+1202
+1203
+1204
+1205
+1206
+1207
+1208
+1209
+1210
+1211
+1212
+1213
+1214
+1215
+1216
+1217
+1218
+1219
+1220
+1221
+1222
+1223
+1224
+1225
+1226
+1227
+1228
+1229
+1230
+1231
+1232
+1233
+1234
+1235
+1236
+1237
+1238
+1239
+1240
+1241
+1242
+1243
+1244
+1245
+1246
+1247
+1248
+1249
+1250
+1251
+1252
+1253
+1254
+1255
+1256
+1257
+1258
+1259
+1260
+1261
+1262
+1263
+1264
+1265
+1266
+1267
+1268
+1269
+1270
+1271
+1272
+1273
+1274
+1275
+1276
+1277
+1278
+1279
+1280
+1281
+1282
+1283
+1284
+1285
+1286
+1287
+1288
+1289
+1290
+1291
+1292
+1293
+1294
+1295
+1296
+1297
+1298
+1299
+1300
+1301
+1302
+1303
+1304
+1305
+1306
+1307
+1308
+1309
+1310
+1311
+1312
+1313
+1314
+1315
+1316
+1317
+1318
+1319
+1320
+1321
+1322
+1323
+1324
+1325
+1326
+1327
+1328
+1329
+1330
+1331
+1332
+1333
+1334
+1335
+1336
+1337
+1338
+1339
+1340
+1341
+1342
+1343
+1344
+1345
+1346
+1347
+1348
+1349
+1350
+1351
+1352
+1353
+1354
+1355
+1356
+1357
+1358
+1359
+1360
+1361
+1362
+1363
+1364
+1365
+1366
+1367
+1368
+1369
+1370
+1371
+1372
+1373
+1374
+1375
+1376
+1377
+1378
+1379
+1380
+1381
+1382
+1383
+1384
+1385
+1386
+1387
+1388
+1389
+1390
+1391
+1392
+1393
+1394
+1395
+1396
+1397
+1398
+1399
+1400
+1401
+1402
+1403
+1404
+1405
+1406
+1407
+1408
+1409
+1410
+1411
+1412
+1413
+1414
+1415
+1416
+1417
+1418
+1419
+1420
+1421
+1422
+1423
+1424
+1425
+1426
+1427
+1428
+1429
+1430
+1431
+1432
+1433
+1434
+1435
+1436
+1437
+1438
+1439
+1440
+1441
+1442
+1443
+1444
+1445
+1446
+1447
+1448
+1449
+1450
+1451
+1452
+1453
+1454
+1455
+1456
+1457
+1458
+1459
+1460
+1461
+1462
+1463
+1464
+1465
+1466
+1467
+1468
+1469
+1470
+1471
+1472
+1473
+1474
+1475
+1476
+1477
+1478
+1479
+1480
+1481
+1482
+1483
+1484
+1485
+1486
+1487
+1488
+1489
+1490
+1491
+1492
+1493
+1494
+1495
+1496
+1497
+1498
+1499
+1500
+1501
+1502
+1503
+1504
+1505
+1506
+1507
+1508
+1509
+1510
+1511
+1512
+1513
+1514
+1515
+1516
+1517
+1518
+1519
+1520
+1521
+1522
+1523
+1524
+1525
+1526
+1527
+1528
+1529
+1530
+1531
+1532
+1533
+1534
+1535
+1536
+1537
+1538
+1539
+1540
+1541
+1542
+1543
+1544
+1545
+1546
+1547
+1548
+1549
+1550
+1551
+1552
+1553
+1554
+1555
+1556
+1557
+1558
+1559
+1560
+1561
+1562
+1563
+1564
+1565
+1566
+1567
+1568
+1569
+1570
+1571
+1572
+1573
+1574
+1575
+1576
+1577
+1578
+1579
+1580
+1581
+1582
+1583
+1584
+1585
+1586
+1587
+1588
+1589
+1590
+1591
+1592
+1593
+1594
+1595
+1596
+1597
+1598
+1599
+1600
+1601
+1602
+1603
+1604
+1605
+1606
+1607
+1608
+1609
+1610
+1611
+1612
+1613
+1614
+1615
+1616
+1617
+1618
+1619
+1620
+1621
+1622
+1623
+1624
+1625
+1626
+1627
+1628
+1629
+1630
+1631
+1632
+1633
+1634
+1635
+1636
+1637
+1638
+1639
+1640
+1641
+1642
+1643
+1644
+1645
+1646
+1647
+1648
+1649
+1650
+1651
+1652
+1653
+1654
+1655
+1656
+1657
+1658
+1659
+1660
+1661
+1662
+1663
+1664
+1665
+1666
+1667
+1668
+1669
+1670
+1671
+1672
+1673
+1674
+1675
+1676
+1677
+1678
+1679
+1680
+1681
+1682
+1683
+1684
+1685
+1686
+1687
+1688
+1689
+1690
+1691
+1692
+1693
+1694
+1695
+1696
+1697
+1698
+1699
+1700
+1701
+1702
+1703
+1704
+1705
+1706
+1707
+1708
+1709
+1710
+1711
+1712
+1713
+1714
+1715
+1716
+1717
+1718
+1719
+1720
+1721
+1722
+1723
+1724
+1725
+1726
+1727
+1728
+1729
+1730
+1731
+1732
+1733
+1734
+1735
+1736
+1737
+1738
+1739
+1740
+1741
+1742
+1743
+1744
+1745
+1746
+1747
+1748
+1749
+1750
+1751
+1752
+1753
+1754
+1755
+1756
+1757
+1758
+1759
+1760
+1761
+1762
+1763
+1764
+1765
+1766
+1767
+1768
+1769
+1770
+1771
+1772
+1773
+1774
+1775
+1776
+1777
+1778
+1779
+1780
+1781
+1782
+1783
+1784
+1785
+1786
+1787
+1788
+1789
+1790
+1791
+1792
+1793
+1794
+1795
+1796
+1797
+1798
+1799
+1800
+1801
+1802
+1803
+1804
+1805
+1806
+1807
+1808
+1809
+1810
+1811
+1812
+1813
+1814
+1815
+1816
+1817
+1818
+1819
+1820
+1821
+1822
+1823
+1824
+1825
+1826
+1827
+1828
+1829
+1830
+1831
+1832
+1833
+1834
+1835
+1836
+1837
+1838
+1839
+1840
+1841
+1842
+1843
+1844
+1845
+1846
+1847
+1848
+1849
+1850
+1851
+1852
+1853
+1854
+1855
+1856
+1857
+1858
+1859
+1860
+1861
+1862
+1863
+1864
+1865
+1866
+1867
+1868
+1869
+1870
+1871
+1872
+1873
+1874
+1875
+1876
+1877
+1878
+1879
+1880
+1881
+1882
+1883
+1884
+1885
+1886
+1887
+1888
+1889
+1890
+1891
+1892
+1893
+1894
+1895
+1896
+1897
+1898
+1899
+1900
+1901
+1902
+1903
+1904
+1905
+1906
+1907
+1908
+1909
+1910
+1911
+1912
+1913
+1914
+1915
+1916
+1917
+1918
+1919
+1920
+1921
+1922
+1923
+1924
+1925
+1926
+1927
+1928
+1929
+1930
+1931
+1932
+1933
+1934
+1935
+1936
+1937
+1938
+1939
+1940
+1941
+1942
+1943
+1944
+1945
+1946
+1947
+1948
+1949
+1950
+1951
+1952
+1953
+1954
+1955
+1956
+1957
+1958
+1959
+1960
+1961
+1962
+1963
+1964
+1965
+1966
+1967
+1968
+1969
+1970
+1971
+1972
+1973
+1974
+1975
+1976
+1977
+1978
+1979
+1980
+1981
+1982
+1983
+1984
+1985
+1986
+1987
+1988
+1989
+1990
+1991
+1992
+1993
+1994
+1995
+1996
+1997
+1998
+1999
+2000
+2001
+2002
+2003
+2004
+2005
+2006
+2007
+2008
+2009
+2010
+2011
+2012
+2013
+2014
+2015
+2016
+2017
+2018
+2019
+2020
+2021
+2022
+2023
+2024
+2025
+2026
+2027
+2028
+2029
+2030
+2031
+2032
+2033
+2034
+2035
+2036
+2037
+2038
+2039
+2040
+2041
+2042
+2043
+2044
+2045
+2046
+2047
+2048
+2049
+2050
+2051
+2052
+2053
+2054
+2055
+2056
+2057
+2058
+2059
+2060
+2061
+2062
+2063
+2064
+2065
+2066
+2067
+2068
+2069
+2070
+2071
+2072
+2073
+2074
+2075
+2076
+2077
+2078
+2079
+2080
+2081
+2082
+2083
+2084
+2085
+2086
+2087
+2088
+2089
+2090
+2091
+2092
+2093
+2094
+2095
+2096
+2097
+2098
+2099
+2100
+2101
+2102
+2103
+2104
+2105
+2106
+2107
+2108
+2109
+2110
+2111
+2112
+2113
+2114
+2115
+2116
+2117
+2118
+2119
+2120
+2121
+2122
+2123
+2124
+2125
+2126
+2127
+2128
+2129
+2130
+2131
+2132
+2133
+2134
+2135
+2136
+2137
+2138
+2139
+2140
+2141
+2142
+2143
+2144
+2145
+2146
+2147
+2148
+2149
+2150
+2151
+2152
+2153
+2154
+2155
+2156
+2157
+2158
+2159
+2160
+2161
+2162
+2163
+2164
+2165
+2166
/* mate-rr.c
+ *
+ * Copyright 2007, 2008, Red Hat, Inc.
+ *
+ * This file is part of the Mate Library.
+ *
+ * The Mate Library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * The Mate Library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with the Mate Library; see the file COPYING.LIB.  If not,
+ * write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Author: Soren Sandmann <sandmann@redhat.com>
+ */
+
+#define MATE_DESKTOP_USE_UNSTABLE_API
+
+#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n-lib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <X11/Xlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#ifdef HAVE_RANDR
+#include <X11/extensions/Xrandr.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdk/gdkx.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <X11/Xatom.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#undef MATE_DISABLE_DEPRECATED
+#include "mate-rr.h"
+#include "mate-rr-config.h"
+
+#include "private.h"
+#include "mate-rr-private.h"
+
+#define DISPLAY(o) ((o)->info->screen->priv->xdisplay)
+
+#ifndef HAVE_RANDR
+/* This is to avoid a ton of ifdefs wherever we use a type from libXrandr */
+typedef int RROutput;
+typedef int RRCrtc;
+typedef int RRMode;
+typedef int Rotation;
+#define RR_Rotate_0		1
+#define RR_Rotate_90		2
+#define RR_Rotate_180		4
+#define RR_Rotate_270		8
+#define RR_Reflect_X		16
+#define RR_Reflect_Y		32
+#endif
+
+enum {
+    SCREEN_PROP_0,
+    SCREEN_PROP_GDK_SCREEN,
+    SCREEN_PROP_LAST,
+};
+
+enum {
+    SCREEN_CHANGED,
+    SCREEN_SIGNAL_LAST,
+};
+
+gint screen_signals[SCREEN_SIGNAL_LAST];
+
+struct MateRROutput
+{
+    ScreenInfo *	info;
+    RROutput		id;
+
+    char *		name;
+    MateRRCrtc *	current_crtc;
+    gboolean		connected;
+    gulong		width_mm;
+    gulong		height_mm;
+    MateRRCrtc **	possible_crtcs;
+    MateRROutput **	clones;
+    MateRRMode **	modes;
+    int			n_preferred;
+    guint8 *		edid_data;
+    int         edid_size;
+    char *              connector_type;
+};
+
+struct MateRROutputWrap
+{
+    RROutput		id;
+};
+
+struct MateRRCrtc
+{
+    ScreenInfo *	info;
+    RRCrtc		id;
+
+    MateRRMode *	current_mode;
+    MateRROutput **	current_outputs;
+    MateRROutput **	possible_outputs;
+    int			x;
+    int			y;
+
+    MateRRRotation	current_rotation;
+    MateRRRotation	rotations;
+    int			gamma_size;
+};
+
+struct MateRRMode
+{
+    ScreenInfo *	info;
+    RRMode		id;
+    char *		name;
+    int			width;
+    int			height;
+    int			freq;		/* in mHz */
+};
+
+/* MateRRCrtc */
+static MateRRCrtc *  crtc_new          (ScreenInfo         *info,
+					 RRCrtc              id);
+static MateRRCrtc *  crtc_copy         (const MateRRCrtc  *from);
+static void           crtc_free         (MateRRCrtc        *crtc);
+
+#ifdef HAVE_RANDR
+static gboolean       crtc_initialize   (MateRRCrtc        *crtc,
+					 XRRScreenResources *res,
+					 GError            **error);
+#endif
+
+/* MateRROutput */
+static MateRROutput *output_new        (ScreenInfo         *info,
+					 RROutput            id);
+
+#ifdef HAVE_RANDR
+static gboolean       output_initialize (MateRROutput      *output,
+					 XRRScreenResources *res,
+					 GError            **error);
+#endif
+
+static MateRROutput *output_copy       (const MateRROutput *from);
+static void           output_free       (MateRROutput      *output);
+
+/* MateRRMode */
+static MateRRMode *  mode_new          (ScreenInfo         *info,
+					 RRMode              id);
+
+#ifdef HAVE_RANDR
+static void           mode_initialize   (MateRRMode        *mode,
+					 XRRModeInfo        *info);
+#endif
+
+static MateRRMode *  mode_copy         (const MateRRMode  *from);
+static void           mode_free         (MateRRMode        *mode);
+
+static void mate_rr_screen_finalize (GObject*);
+static void mate_rr_screen_set_property (GObject*, guint, const GValue*, GParamSpec*);
+static void mate_rr_screen_get_property (GObject*, guint, GValue*, GParamSpec*);
+static gboolean mate_rr_screen_initable_init (GInitable*, GCancellable*, GError**);
+static void mate_rr_screen_initable_iface_init (GInitableIface *iface);
+G_DEFINE_TYPE_WITH_CODE (MateRRScreen, mate_rr_screen, G_TYPE_OBJECT,<--- There is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_CODE is a macro then please configure it.
+                         G_ADD_PRIVATE(MateRRScreen)
+                         G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE, mate_rr_screen_initable_iface_init))
+
+G_DEFINE_BOXED_TYPE (MateRRCrtc, mate_rr_crtc, crtc_copy, crtc_free)
+G_DEFINE_BOXED_TYPE (MateRROutput, mate_rr_output, output_copy, output_free)
+G_DEFINE_BOXED_TYPE (MateRRMode, mate_rr_mode, mode_copy, mode_free)
+
+/* Errors */
+
+/**
+ * mate_rr_error_quark:
+ *
+ * Returns the #GQuark that will be used for #GError values returned by the
+ * MateRR API.
+ *
+ * Return value: a #GQuark used to identify errors coming from the MateRR API.
+ */
+GQuark
+mate_rr_error_quark (void)
+{
+    return g_quark_from_static_string ("mate-rr-error-quark");
+}
+
+/* Screen */
+static MateRROutput *
+mate_rr_output_by_id (ScreenInfo *info, RROutput id)
+{
+    MateRROutput **output;
+
+    g_assert (info != NULL);
+
+    for (output = info->outputs; *output; ++output)
+    {
+	if ((*output)->id == id)
+	    return *output;
+    }
+
+    return NULL;
+}
+
+static MateRRCrtc *
+crtc_by_id (ScreenInfo *info, RRCrtc id)
+{
+    MateRRCrtc **crtc;
+
+    if (!info)
+        return NULL;
+
+    for (crtc = info->crtcs; *crtc; ++crtc)
+    {
+	if ((*crtc)->id == id)
+	    return *crtc;
+    }
+
+    return NULL;
+}
+
+static MateRRMode *
+mode_by_id (ScreenInfo *info, RRMode id)
+{
+    MateRRMode **mode;
+
+    g_assert (info != NULL);
+
+    for (mode = info->modes; *mode; ++mode)
+    {
+	if ((*mode)->id == id)
+	    return *mode;
+    }
+
+    return NULL;
+}
+
+static void
+screen_info_free (ScreenInfo *info)
+{
+    MateRROutput **output;
+    MateRRCrtc **crtc;
+    MateRRMode **mode;
+
+    g_assert (info != NULL);
+
+#ifdef HAVE_RANDR
+    if (info->resources)
+    {
+	XRRFreeScreenResources (info->resources);
+
+	info->resources = NULL;
+    }
+#endif
+
+    if (info->outputs)
+    {
+	for (output = info->outputs; *output; ++output)
+	    output_free (*output);
+	g_free (info->outputs);
+    }
+
+    if (info->crtcs)
+    {
+	for (crtc = info->crtcs; *crtc; ++crtc)
+	    crtc_free (*crtc);
+	g_free (info->crtcs);
+    }
+
+    if (info->modes)
+    {
+	for (mode = info->modes; *mode; ++mode)
+	    mode_free (*mode);
+	g_free (info->modes);
+    }
+
+    if (info->clone_modes)
+    {
+	/* The modes themselves were freed above */
+	g_free (info->clone_modes);
+    }
+
+    g_free (info);
+}
+
+static gboolean
+has_similar_mode (MateRROutput *output, MateRRMode *mode)
+{
+    int i;
+    MateRRMode **modes = mate_rr_output_list_modes (output);
+    guint width = mate_rr_mode_get_width (mode);
+    guint height = mate_rr_mode_get_height (mode);
+
+    for (i = 0; modes[i] != NULL; ++i)
+    {
+	MateRRMode *m = modes[i];
+
+	if (mate_rr_mode_get_width (m) == width	&&
+	    mate_rr_mode_get_height (m) == height)
+	{
+	    return TRUE;
+	}
+    }
+
+    return FALSE;
+}
+
+static void
+gather_clone_modes (ScreenInfo *info)
+{
+    int i;
+    GPtrArray *result = g_ptr_array_new ();
+
+    for (i = 0; info->outputs[i] != NULL; ++i)
+    {
+	int j;
+	MateRROutput *output1, *output2;
+
+	output1 = info->outputs[i];
+
+	if (!output1->connected)
+	    continue;
+
+	for (j = 0; output1->modes[j] != NULL; ++j)
+	{
+	    MateRRMode *mode = output1->modes[j];
+	    gboolean valid;
+	    int k;
+
+	    valid = TRUE;
+	    for (k = 0; info->outputs[k] != NULL; ++k)
+	    {
+		output2 = info->outputs[k];
+
+		if (!output2->connected)
+		    continue;
+
+		if (!has_similar_mode (output2, mode))
+		{
+		    valid = FALSE;
+		    break;
+		}
+	    }
+
+	    if (valid)
+		g_ptr_array_add (result, mode);
+	}
+    }
+
+    g_ptr_array_add (result, NULL);
+
+    info->clone_modes = (MateRRMode **)g_ptr_array_free (result, FALSE);
+}
+
+#ifdef HAVE_RANDR
+static gboolean
+fill_screen_info_from_resources (ScreenInfo *info,
+				 XRRScreenResources *resources,
+				 GError **error)
+{
+    int i;
+    GPtrArray *a;
+    MateRRCrtc **crtc;
+    MateRROutput **output;
+
+    info->resources = resources;
+
+    /* We create all the structures before initializing them, so
+     * that they can refer to each other.
+     */
+    a = g_ptr_array_new ();
+    for (i = 0; i < resources->ncrtc; ++i)
+    {
+	g_ptr_array_add (a, crtc_new (info, resources->crtcs[i]));
+    }
+    g_ptr_array_add (a, NULL);
+    info->crtcs = (MateRRCrtc **)g_ptr_array_free (a, FALSE);
+
+    a = g_ptr_array_new ();
+    for (i = 0; i < resources->noutput; ++i)
+    {
+	g_ptr_array_add (a, output_new (info, resources->outputs[i]));
+    }
+    g_ptr_array_add (a, NULL);
+    info->outputs = (MateRROutput **)g_ptr_array_free (a, FALSE);
+
+    a = g_ptr_array_new ();
+    for (i = 0;  i < resources->nmode; ++i)
+    {
+	MateRRMode *mode = mode_new (info, resources->modes[i].id);
+
+	g_ptr_array_add (a, mode);
+    }
+    g_ptr_array_add (a, NULL);
+    info->modes = (MateRRMode **)g_ptr_array_free (a, FALSE);
+
+    /* Initialize */
+    for (crtc = info->crtcs; *crtc; ++crtc)
+    {
+	if (!crtc_initialize (*crtc, resources, error))
+	    return FALSE;
+    }
+
+    for (output = info->outputs; *output; ++output)
+    {
+	if (!output_initialize (*output, resources, error))
+	    return FALSE;
+    }
+
+    for (i = 0; i < resources->nmode; ++i)
+    {
+	MateRRMode *mode = mode_by_id (info, resources->modes[i].id);
+
+	mode_initialize (mode, &(resources->modes[i]));
+    }
+
+    gather_clone_modes (info);
+
+    return TRUE;
+}
+#endif /* HAVE_RANDR */
+
+static gboolean
+fill_out_screen_info (Display *xdisplay,
+		      Window xroot,
+		      ScreenInfo *info,
+		      gboolean needs_reprobe,
+		      GError **error)
+{
+#ifdef HAVE_RANDR
+    XRRScreenResources *resources;
+	GdkDisplay *display;
+
+    g_assert (xdisplay != NULL);
+    g_assert (info != NULL);
+
+    /* First update the screen resources */
+
+    if (needs_reprobe)
+        resources = XRRGetScreenResources (xdisplay, xroot);
+    else
+        resources = XRRGetScreenResourcesCurrent (xdisplay, xroot);
+
+    if (resources)
+    {
+	if (!fill_screen_info_from_resources (info, resources, error))
+	    return FALSE;
+    }
+    else
+    {
+	g_set_error (error, MATE_RR_ERROR, MATE_RR_ERROR_RANDR_ERROR,
+		     /* Translators: a CRTC is a CRT Controller (this is X terminology). */
+		     _("could not get the screen resources (CRTCs, outputs, modes)"));
+	return FALSE;
+    }
+
+    /* Then update the screen size range.  We do this after XRRGetScreenResources() so that
+     * the X server will already have an updated view of the outputs.
+     */
+
+    if (needs_reprobe) {
+	gboolean success;
+
+	display = gdk_display_get_default ();
+    gdk_x11_display_error_trap_push (display);
+	success = XRRGetScreenSizeRange (xdisplay, xroot,
+					 &(info->min_width),
+					 &(info->min_height),
+					 &(info->max_width),
+					 &(info->max_height));
+	gdk_display_flush (display);
+	if (gdk_x11_display_error_trap_pop (display)) {
+	    g_set_error (error, MATE_RR_ERROR, MATE_RR_ERROR_UNKNOWN,
+			 _("unhandled X error while getting the range of screen sizes"));
+	    return FALSE;
+	}
+
+	if (!success) {
+	    g_set_error (error, MATE_RR_ERROR, MATE_RR_ERROR_RANDR_ERROR,
+			 _("could not get the range of screen sizes"));
+            return FALSE;
+        }
+    }
+    else
+    {
+        mate_rr_screen_get_ranges (info->screen,
+					 &(info->min_width),
+					 &(info->max_width),
+					 &(info->min_height),
+					 &(info->max_height));
+    }
+
+    info->primary = None;
+	display = gdk_display_get_default ();
+    gdk_x11_display_error_trap_push (display);
+    info->primary = XRRGetOutputPrimary (xdisplay, xroot);
+    gdk_x11_display_error_trap_pop_ignored (display);
+
+    return TRUE;
+#else
+    return FALSE;
+#endif /* HAVE_RANDR */
+}
+
+static ScreenInfo *
+screen_info_new (MateRRScreen *screen, gboolean needs_reprobe, GError **error)
+{
+    ScreenInfo *info = g_new0 (ScreenInfo, 1);
+    MateRRScreenPrivate *priv;
+
+    g_assert (screen != NULL);
+
+    priv = screen->priv;
+
+    info->outputs = NULL;
+    info->crtcs = NULL;
+    info->modes = NULL;
+    info->screen = screen;
+
+    if (fill_out_screen_info (priv->xdisplay, priv->xroot, info, needs_reprobe, error))
+    {
+	return info;
+    }
+    else
+    {
+	screen_info_free (info);
+	return NULL;
+    }
+}
+
+static gboolean
+screen_update (MateRRScreen *screen, gboolean force_callback, gboolean needs_reprobe, GError **error)
+{
+    ScreenInfo *info;
+    gboolean changed = FALSE;
+
+    g_assert (screen != NULL);
+
+    info = screen_info_new (screen, needs_reprobe, error);
+    if (!info)
+	    return FALSE;
+
+#ifdef HAVE_RANDR
+    if (info->resources->configTimestamp != screen->priv->info->resources->configTimestamp)
+	    changed = TRUE;
+#endif
+
+    screen_info_free (screen->priv->info);
+
+    screen->priv->info = info;
+
+    if (changed || force_callback)
+	g_signal_emit (G_OBJECT (screen), screen_signals[SCREEN_CHANGED], 0);
+
+    return changed;
+}
+
+static GdkFilterReturn
+screen_on_event (GdkXEvent *xevent,
+		 GdkEvent *event,
+		 gpointer data)
+{
+#ifdef HAVE_RANDR
+    MateRRScreen *screen = data;
+    MateRRScreenPrivate *priv = screen->priv;
+    XEvent *e = xevent;
+    int event_num;
+
+    if (!e)
+	return GDK_FILTER_CONTINUE;
+
+    event_num = e->type - priv->randr_event_base;
+
+    if (event_num == RRScreenChangeNotify) {
+	/* We don't reprobe the hardware; we just fetch the X server's latest
+	 * state.  The server already knows the new state of the outputs; that's
+	 * why it sent us an event!
+	 */
+        screen_update (screen, TRUE, FALSE, NULL); /* NULL-GError */
+#if 0
+	/* Enable this code to get a dialog showing the RANDR timestamps, for debugging purposes */
+	{
+	    GtkWidget *dialog;
+	    XRRScreenChangeNotifyEvent *rr_event;
+	    static int dialog_num;
+
+	    rr_event = (XRRScreenChangeNotifyEvent *) e;
+
+	    dialog = gtk_message_dialog_new (NULL,
+					     0,
+					     GTK_MESSAGE_INFO,
+					     GTK_BUTTONS_CLOSE,
+					     "RRScreenChangeNotify timestamps (%d):\n"
+					     "event change: %u\n"
+					     "event config: %u\n"
+					     "event serial: %lu\n"
+					     "----------------------"
+					     "screen change: %u\n"
+					     "screen config: %u\n",
+					     dialog_num++,
+					     (guint32) rr_event->timestamp,
+					     (guint32) rr_event->config_timestamp,
+					     rr_event->serial,
+					     (guint32) priv->info->resources->timestamp,
+					     (guint32) priv->info->resources->configTimestamp);
+	    g_signal_connect (dialog, "response",
+			      G_CALLBACK (gtk_widget_destroy), NULL);
+	    gtk_widget_show (dialog);
+	}
+#endif
+    }
+#if 0
+    /* WHY THIS CODE IS DISABLED:
+     *
+     * Note that in mate_rr_screen_new(), we only select for
+     * RRScreenChangeNotifyMask.  We used to select for other values in
+     * RR*NotifyMask, but we weren't really doing anything useful with those
+     * events.  We only care about "the screens changed in some way or another"
+     * for now.
+     *
+     * If we ever run into a situtation that could benefit from processing more
+     * detailed events, we can enable this code again.
+     *
+     * Note that the X server sends RRScreenChangeNotify in conjunction with the
+     * more detailed events from RANDR 1.2 - see xserver/randr/randr.c:TellChanged().
+     */
+    else if (event_num == RRNotify)
+    {
+	/* Other RandR events */
+
+	XRRNotifyEvent *event = (XRRNotifyEvent *)e;
+
+	/* Here we can distinguish between RRNotify events supported
+	 * since RandR 1.2 such as RRNotify_OutputProperty.  For now, we
+	 * don't have anything special to do for particular subevent types, so
+	 * we leave this as an empty switch().
+	 */
+	switch (event->subtype)
+	{
+	default:
+	    break;
+	}
+
+	/* No need to reprobe hardware here */
+	screen_update (screen, TRUE, FALSE, NULL); /* NULL-GError */
+    }
+#endif
+
+#endif /* HAVE_RANDR */
+
+    /* Pass the event on to GTK+ */
+    return GDK_FILTER_CONTINUE;
+}
+
+static gboolean
+mate_rr_screen_initable_init (GInitable *initable, GCancellable *canc, GError **error)
+
+{
+    MateRRScreen *self = MATE_RR_SCREEN (initable);
+    MateRRScreenPrivate *priv = self->priv;
+    Display *dpy = GDK_SCREEN_XDISPLAY (self->priv->gdk_screen);
+    int event_base;
+    int ignore;
+
+    priv->connector_type_atom = XInternAtom (dpy, "ConnectorType", FALSE);
+
+#ifdef HAVE_RANDR
+    if (XRRQueryExtension (dpy, &event_base, &ignore))
+    {
+        priv->randr_event_base = event_base;
+
+        XRRQueryVersion (dpy, &priv->rr_major_version, &priv->rr_minor_version);
+        if (priv->rr_major_version < 1 || (priv->rr_major_version == 1 && priv->rr_minor_version < 3)) {
+            g_set_error (error, MATE_RR_ERROR, MATE_RR_ERROR_NO_RANDR_EXTENSION,
+                "RANDR extension is too old (must be at least 1.3)");
+            return FALSE;
+        }
+
+        priv->info = screen_info_new (self, TRUE, error);
+
+        if (!priv->info) {
+	    return FALSE;
+	}
+
+        XRRSelectInput (priv->xdisplay,
+            priv->xroot,
+            RRScreenChangeNotifyMask);
+        gdk_x11_register_standard_event_type (gdk_screen_get_display (priv->gdk_screen),
+                          event_base,
+                          RRNotify + 1);
+        gdk_window_add_filter (priv->gdk_root, screen_on_event, self);
+
+        return TRUE;
+    }
+    else
+    {
+#endif /* HAVE_RANDR */
+    g_set_error (error, MATE_RR_ERROR, MATE_RR_ERROR_NO_RANDR_EXTENSION,
+        _("RANDR extension is not present"));
+
+    return FALSE;
+
+#ifdef HAVE_RANDR
+   }
+#endif
+}
+
+void
+mate_rr_screen_initable_iface_init (GInitableIface *iface)
+{
+    iface->init = mate_rr_screen_initable_init;
+}
+
+void
+    mate_rr_screen_finalize (GObject *gobject)
+{
+    MateRRScreen *screen = MATE_RR_SCREEN (gobject);
+
+    gdk_window_remove_filter (screen->priv->gdk_root, screen_on_event, screen);
+
+    if (screen->priv->info)
+      screen_info_free (screen->priv->info);
+
+    G_OBJECT_CLASS (mate_rr_screen_parent_class)->finalize (gobject);
+}
+
+void
+mate_rr_screen_set_property (GObject *gobject, guint property_id, const GValue *value, GParamSpec *property)
+{
+    MateRRScreen *self = MATE_RR_SCREEN (gobject);
+    MateRRScreenPrivate *priv = self->priv;
+
+    switch (property_id)
+    {
+    case SCREEN_PROP_GDK_SCREEN:
+        priv->gdk_screen = g_value_get_object (value);
+        priv->gdk_root = gdk_screen_get_root_window (priv->gdk_screen);
+        priv->xroot = GDK_WINDOW_XID (priv->gdk_root);
+        priv->xdisplay = GDK_SCREEN_XDISPLAY (priv->gdk_screen);
+        priv->xscreen = gdk_x11_screen_get_xscreen (priv->gdk_screen);
+        return;
+    default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, property_id, property);
+        return;
+    }
+}
+
+void
+mate_rr_screen_get_property (GObject *gobject, guint property_id, GValue *value, GParamSpec *property)
+{
+    MateRRScreen *self = MATE_RR_SCREEN (gobject);
+    MateRRScreenPrivate *priv = self->priv;
+
+    switch (property_id)
+    {
+    case SCREEN_PROP_GDK_SCREEN:
+        g_value_set_object (value, priv->gdk_screen);
+        return;
+     default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, property_id, property);
+        return;
+    }
+}
+
+void
+mate_rr_screen_class_init (MateRRScreenClass *klass)
+{
+    GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+
+    gobject_class->set_property = mate_rr_screen_set_property;
+    gobject_class->get_property = mate_rr_screen_get_property;
+    gobject_class->finalize = mate_rr_screen_finalize;
+
+    g_object_class_install_property(
+        gobject_class,
+        SCREEN_PROP_GDK_SCREEN,
+        g_param_spec_object (
+            "gdk-screen",
+            "GDK Screen",
+            "The GDK Screen represented by this MateRRScreen",
+            GDK_TYPE_SCREEN,
+	    G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)
+        );
+
+    screen_signals[SCREEN_CHANGED] = g_signal_new("changed",
+        G_TYPE_FROM_CLASS (gobject_class),
+        G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
+        G_STRUCT_OFFSET (MateRRScreenClass, changed),
+        NULL,
+        NULL,
+        g_cclosure_marshal_VOID__VOID,
+        G_TYPE_NONE,
+        0);
+}
+
+void
+mate_rr_screen_init (MateRRScreen *self)
+{
+    MateRRScreenPrivate *priv = mate_rr_screen_get_instance_private (self);
+    self->priv = priv;
+
+    priv->gdk_screen = NULL;
+    priv->gdk_root = NULL;
+    priv->xdisplay = NULL;
+    priv->xroot = None;
+    priv->xscreen = NULL;
+    priv->info = NULL;
+    priv->rr_major_version = 0;
+    priv->rr_minor_version = 0;
+}
+
+/**
+ * mate_rr_screen_new:
+ * @screen: the #GdkScreen on which to operate
+ * @error: will be set if XRandR is not supported
+ *
+ * Creates a new #MateRRScreen instance
+ *
+ * Returns: a new #MateRRScreen instance or NULL if screen could not be created,
+ * for instance if the driver does not support Xrandr 1.2
+ */
+MateRRScreen *
+mate_rr_screen_new (GdkScreen *screen,
+                    GError **error)
+{
+    _mate_desktop_init_i18n ();
+    return g_initable_new (MATE_TYPE_RR_SCREEN, NULL, error, "gdk-screen", screen, NULL);
+}
+
+void
+mate_rr_screen_set_size (MateRRScreen *screen,
+			  int	      width,
+			  int       height,
+			  int       mm_width,
+			  int       mm_height)
+{
+    g_return_if_fail (MATE_IS_RR_SCREEN (screen));
+
+#ifdef HAVE_RANDR
+	GdkDisplay *display;
+
+	display = gdk_display_get_default ();
+    gdk_x11_display_error_trap_push (display);
+    XRRSetScreenSize (screen->priv->xdisplay, screen->priv->xroot,
+		      width, height, mm_width, mm_height);
+    gdk_x11_display_error_trap_pop_ignored (display);
+#endif
+}
+
+/**
+ * mate_rr_screen_get_ranges:
+ * @screen: a #MateRRScreen
+ * @min_width: (out): the minimum width
+ * @max_width: (out): the maximum width
+ * @min_height: (out): the minimum height
+ * @max_height: (out): the maximum height
+ *
+ * Get the ranges of the screen
+ */
+void
+mate_rr_screen_get_ranges (MateRRScreen *screen,
+			    int	          *min_width,
+			    int	          *max_width,
+			    int           *min_height,
+			    int	          *max_height)
+{
+    MateRRScreenPrivate *priv;
+
+    g_return_if_fail (MATE_IS_RR_SCREEN (screen));
+
+    priv = screen->priv;
+
+    if (min_width)
+	*min_width = priv->info->min_width;
+
+    if (max_width)
+	*max_width = priv->info->max_width;
+
+    if (min_height)
+	*min_height = priv->info->min_height;
+
+    if (max_height)
+	*max_height = priv->info->max_height;
+}
+
+/**
+ * mate_rr_screen_get_timestamps:
+ * @screen: a #MateRRScreen
+ * @change_timestamp_ret: (out): Location in which to store the timestamp at which the RANDR configuration was last changed
+ * @config_timestamp_ret: (out): Location in which to store the timestamp at which the RANDR configuration was last obtained
+ *
+ * Queries the two timestamps that the X RANDR extension maintains.  The X
+ * server will prevent change requests for stale configurations, those whose
+ * timestamp is not equal to that of the latest request for configuration.  The
+ * X server will also prevent change requests that have an older timestamp to
+ * the latest change request.
+ */
+void
+mate_rr_screen_get_timestamps (MateRRScreen *screen,
+				guint32       *change_timestamp_ret,
+				guint32       *config_timestamp_ret)
+{
+    MateRRScreenPrivate *priv;
+
+    g_return_if_fail (MATE_IS_RR_SCREEN (screen));
+
+    priv = screen->priv;
+
+#ifdef HAVE_RANDR
+    if (change_timestamp_ret)
+	*change_timestamp_ret = priv->info->resources->timestamp;
+
+    if (config_timestamp_ret)
+	*config_timestamp_ret = priv->info->resources->configTimestamp;
+#endif
+}
+
+static gboolean
+force_timestamp_update (MateRRScreen *screen)
+{
+#ifdef HAVE_RANDR
+    MateRRScreenPrivate *priv = screen->priv;
+    MateRRCrtc *crtc;
+    XRRCrtcInfo *current_info;
+	GdkDisplay *display;
+    Status status;
+    gboolean timestamp_updated;
+
+    timestamp_updated = FALSE;
+
+    crtc = priv->info->crtcs[0];
+
+    if (crtc == NULL)
+	goto out;
+
+    current_info = XRRGetCrtcInfo (priv->xdisplay,
+				   priv->info->resources,
+				   crtc->id);
+
+    if (current_info == NULL)
+	  goto out;
+
+	display = gdk_display_get_default ();
+    gdk_x11_display_error_trap_push (display);
+    status = XRRSetCrtcConfig (priv->xdisplay,
+			       priv->info->resources,
+			       crtc->id,
+			       current_info->timestamp,
+			       current_info->x,
+			       current_info->y,
+			       current_info->mode,
+			       current_info->rotation,
+			       current_info->outputs,
+			       current_info->noutput);
+
+    XRRFreeCrtcInfo (current_info);
+
+    gdk_display_flush (display);
+    if (gdk_x11_display_error_trap_pop (display))
+	goto out;
+
+    if (status == RRSetConfigSuccess)
+	timestamp_updated = TRUE;
+out:
+    return timestamp_updated;
+#else
+    return FALSE;
+#endif
+}
+
+/**
+ * mate_rr_screen_refresh:
+ * @screen: a #MateRRScreen
+ * @error: location to store error, or %NULL
+ *
+ * Refreshes the screen configuration, and calls the screen's callback if it
+ * exists and if the screen's configuration changed.
+ *
+ * Return value: TRUE if the screen's configuration changed; otherwise, the
+ * function returns FALSE and a NULL error if the configuration didn't change,
+ * or FALSE and a non-NULL error if there was an error while refreshing the
+ * configuration.
+ */
+gboolean
+mate_rr_screen_refresh (MateRRScreen *screen,
+			 GError       **error)
+{
+    gboolean refreshed;
+
+    g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+
+    gdk_x11_display_grab (gdk_screen_get_display (screen->priv->gdk_screen));
+
+    refreshed = screen_update (screen, FALSE, TRUE, error);
+    force_timestamp_update (screen); /* this is to keep other clients from thinking that the X server re-detected things by itself - bgo#621046 */
+
+    gdk_x11_display_ungrab (gdk_screen_get_display (screen->priv->gdk_screen));
+
+    return refreshed;
+}
+
+/**
+ * mate_rr_screen_list_modes:
+ *
+ * List available XRandR modes
+ *
+ * Returns: (array zero-terminated=1) (transfer none):
+ */
+MateRRMode **
+mate_rr_screen_list_modes (MateRRScreen *screen)
+{
+    g_return_val_if_fail (MATE_IS_RR_SCREEN (screen), NULL);
+    g_return_val_if_fail (screen->priv->info != NULL, NULL);
+
+    return screen->priv->info->modes;
+}
+
+/**
+ * mate_rr_screen_list_clone_modes:
+ *
+ * List available XRandR clone modes
+ *
+ * Returns: (array zero-terminated=1) (transfer none):
+ */
+MateRRMode **
+mate_rr_screen_list_clone_modes   (MateRRScreen *screen)
+{
+    g_return_val_if_fail (MATE_IS_RR_SCREEN (screen), NULL);
+    g_return_val_if_fail (screen->priv->info != NULL, NULL);
+
+    return screen->priv->info->clone_modes;
+}
+
+/**
+ * mate_rr_screen_list_crtcs:
+ *
+ * List all CRTCs
+ *
+ * Returns: (array zero-terminated=1) (transfer none):
+ */
+MateRRCrtc **
+mate_rr_screen_list_crtcs (MateRRScreen *screen)
+{
+    g_return_val_if_fail (MATE_IS_RR_SCREEN (screen), NULL);
+    g_return_val_if_fail (screen->priv->info != NULL, NULL);
+
+    return screen->priv->info->crtcs;
+}
+
+/**
+ * mate_rr_screen_list_outputs:
+ *
+ * List all outputs
+ *
+ * Returns: (array zero-terminated=1) (transfer none):
+ */
+MateRROutput **
+mate_rr_screen_list_outputs (MateRRScreen *screen)
+{
+    g_return_val_if_fail (MATE_IS_RR_SCREEN (screen), NULL);
+    g_return_val_if_fail (screen->priv->info != NULL, NULL);
+
+    return screen->priv->info->outputs;
+}
+
+/**
+ * mate_rr_screen_get_crtc_by_id:
+ *
+ * Returns: (transfer none): the CRTC identified by @id
+ */
+MateRRCrtc *
+mate_rr_screen_get_crtc_by_id (MateRRScreen *screen,
+				guint32        id)
+{
+    MateRRCrtc **crtcs;
+    int i;
+
+    g_return_val_if_fail (MATE_IS_RR_SCREEN (screen), NULL);
+    g_return_val_if_fail (screen->priv->info != NULL, NULL);
+
+    crtcs = screen->priv->info->crtcs;
+
+    for (i = 0; crtcs[i] != NULL; ++i)
+    {
+	if (crtcs[i]->id == id)
+	    return crtcs[i];
+    }
+
+    return NULL;
+}
+
+/**
+ * mate_rr_screen_get_output_by_id:
+ *
+ * Returns: (transfer none): the output identified by @id
+ */
+MateRROutput *
+mate_rr_screen_get_output_by_id (MateRRScreen *screen,
+				  guint32        id)
+{
+    MateRROutput **outputs;
+    int i;
+
+    g_return_val_if_fail (MATE_IS_RR_SCREEN (screen), NULL);
+    g_return_val_if_fail (screen->priv->info != NULL, NULL);
+
+    outputs = screen->priv->info->outputs;
+
+    for (i = 0; outputs[i] != NULL; ++i)
+    {
+	if (outputs[i]->id == id)
+	    return outputs[i];
+    }
+
+    return NULL;
+}
+
+/* MateRROutput */
+static MateRROutput *
+output_new (ScreenInfo *info, RROutput id)
+{
+    MateRROutput *output = g_slice_new0 (MateRROutput);
+
+    output->id = id;
+    output->info = info;
+
+    return output;
+}
+
+static guint8 *
+get_property (Display *dpy,
+	      RROutput output,
+	      Atom atom,
+	      int *len)
+{
+#ifdef HAVE_RANDR
+    unsigned char *prop;
+    int actual_format;
+    unsigned long nitems, bytes_after;
+    Atom actual_type;
+    guint8 *result;
+
+    XRRGetOutputProperty (dpy, output, atom,
+			  0, 100, False, False,
+			  AnyPropertyType,
+			  &actual_type, &actual_format,
+			  &nitems, &bytes_after, &prop);
+
+    if (actual_type == XA_INTEGER && actual_format == 8)
+    {
+#ifdef GLIB_VERSION_2_68
+	result = g_memdup2 (prop, nitems);
+#else
+	result = g_memdup (prop, nitems);
+#endif
+	if (len)
+	    *len = nitems;
+    }
+    else
+    {
+	result = NULL;
+    }
+
+    XFree (prop);
+
+    return result;
+#else
+    return NULL;
+#endif /* HAVE_RANDR */
+}
+
+static guint8 *
+read_edid_data (MateRROutput *output, int *len)
+{
+    Atom edid_atom;
+    guint8 *result;
+
+    edid_atom = XInternAtom (DISPLAY (output), "EDID", FALSE);
+    result = get_property (DISPLAY (output),
+			   output->id, edid_atom, len);
+
+    if (!result)
+    {
+	edid_atom = XInternAtom (DISPLAY (output), "EDID_DATA", FALSE);
+	result = get_property (DISPLAY (output),
+			       output->id, edid_atom, len);
+    }
+
+    if (result)
+    {
+	if (*len % 128 == 0)
+	    return result;
+	else
+	    g_free (result);
+    }
+
+    return NULL;
+}
+
+static char *
+get_connector_type_string (MateRROutput *output)
+{
+#ifdef HAVE_RANDR
+    char *result;
+    unsigned char *prop;
+    int actual_format;
+    unsigned long nitems, bytes_after;
+    Atom actual_type;
+    Atom connector_type;
+    char *connector_type_str;
+
+    result = NULL;
+
+    if (XRRGetOutputProperty (DISPLAY (output), output->id, output->info->screen->priv->connector_type_atom,
+			      0, 100, False, False,
+			      AnyPropertyType,
+			      &actual_type, &actual_format,
+			      &nitems, &bytes_after, &prop) != Success)
+	return NULL;
+
+    if (!(actual_type == XA_ATOM && actual_format == 32 && nitems == 1))
+	goto out;
+
+    connector_type = *((Atom *) prop);
+
+    connector_type_str = XGetAtomName (DISPLAY (output), connector_type);
+    if (connector_type_str) {
+	result = g_strdup (connector_type_str); /* so the caller can g_free() it */
+	XFree (connector_type_str);
+    }
+
+out:
+
+    XFree (prop);
+
+    return result;
+#else
+    return NULL;
+#endif
+}
+
+#ifdef HAVE_RANDR
+static gboolean
+output_initialize (MateRROutput *output, XRRScreenResources *res, GError **error)
+{
+    XRROutputInfo *info = XRRGetOutputInfo (
+	DISPLAY (output), res, output->id);
+    GPtrArray *a;
+    int i;
+
+#if 0
+    g_print ("Output %lx Timestamp: %u\n", output->id, (guint32)info->timestamp);
+#endif
+
+    if (!info || !output->info)
+    {
+	/* FIXME: see the comment in crtc_initialize() */
+	/* Translators: here, an "output" is a video output */
+	g_set_error (error, MATE_RR_ERROR, MATE_RR_ERROR_RANDR_ERROR,
+		     _("could not get information about output %d"),
+		     (int) output->id);
+	return FALSE;
+    }
+
+    output->name = g_strdup (info->name); /* FIXME: what is nameLen used for? */
+    output->current_crtc = crtc_by_id (output->info, info->crtc);
+    output->width_mm = info->mm_width;
+    output->height_mm = info->mm_height;
+    output->connected = (info->connection == RR_Connected);
+    output->connector_type = get_connector_type_string (output);
+
+    /* Possible crtcs */
+    a = g_ptr_array_new ();
+
+    for (i = 0; i < info->ncrtc; ++i)
+    {
+	MateRRCrtc *crtc = crtc_by_id (output->info, info->crtcs[i]);
+
+	if (crtc)
+	    g_ptr_array_add (a, crtc);
+    }
+    g_ptr_array_add (a, NULL);
+    output->possible_crtcs = (MateRRCrtc **)g_ptr_array_free (a, FALSE);
+
+    /* Clones */
+    a = g_ptr_array_new ();
+    for (i = 0; i < info->nclone; ++i)
+    {
+	MateRROutput *mate_rr_output = mate_rr_output_by_id (output->info, info->clones[i]);
+
+	if (mate_rr_output)
+	    g_ptr_array_add (a, mate_rr_output);
+    }
+    g_ptr_array_add (a, NULL);
+    output->clones = (MateRROutput **)g_ptr_array_free (a, FALSE);
+
+    /* Modes */
+    a = g_ptr_array_new ();
+    for (i = 0; i < info->nmode; ++i)
+    {
+	MateRRMode *mode = mode_by_id (output->info, info->modes[i]);
+
+	if (mode)
+	    g_ptr_array_add (a, mode);
+    }
+    g_ptr_array_add (a, NULL);
+    output->modes = (MateRRMode **)g_ptr_array_free (a, FALSE);
+
+    output->n_preferred = info->npreferred;
+
+    /* Edid data */
+    output->edid_data = read_edid_data (output, &output->edid_size);
+
+    XRRFreeOutputInfo (info);
+
+    return TRUE;
+}
+#endif /* HAVE_RANDR */
+
+static MateRROutput*
+output_copy (const MateRROutput *from)
+{
+    GPtrArray *array;
+    MateRRCrtc **p_crtc;
+    MateRROutput **p_output;
+    MateRRMode **p_mode;
+    MateRROutput *output = g_slice_new0 (MateRROutput);
+
+    output->id = from->id;
+    output->info = from->info;
+    output->name = g_strdup (from->name);
+    output->current_crtc = from->current_crtc;
+    output->width_mm = from->width_mm;
+    output->height_mm = from->height_mm;
+    output->connected = from->connected;
+    output->n_preferred = from->n_preferred;
+    output->connector_type = g_strdup (from->connector_type);
+
+    array = g_ptr_array_new ();
+    for (p_crtc = from->possible_crtcs; *p_crtc != NULL; p_crtc++)
+    {
+        g_ptr_array_add (array, *p_crtc);
+    }
+    output->possible_crtcs = (MateRRCrtc**) g_ptr_array_free (array, FALSE);
+
+    array = g_ptr_array_new ();
+    for (p_output = from->clones; *p_output != NULL; p_output++)
+    {
+        g_ptr_array_add (array, *p_output);
+    }
+    output->clones = (MateRROutput**) g_ptr_array_free (array, FALSE);
+
+    array = g_ptr_array_new ();
+    for (p_mode = from->modes; *p_mode != NULL; p_mode++)
+    {
+        g_ptr_array_add (array, *p_mode);
+    }
+    output->modes = (MateRRMode**) g_ptr_array_free (array, FALSE);
+
+    output->edid_size = from->edid_size;
+#ifdef GLIB_VERSION_2_68
+    output->edid_data = g_memdup2 (from->edid_data, from->edid_size);
+#else
+    output->edid_data = g_memdup (from->edid_data, from->edid_size);
+#endif
+    return output;
+}
+
+static void
+output_free (MateRROutput *output)
+{
+    g_free (output->clones);
+    g_free (output->modes);
+    g_free (output->possible_crtcs);
+    g_free (output->edid_data);
+    g_free (output->name);
+    g_free (output->connector_type);
+    g_slice_free (MateRROutput, output);
+}
+
+guint32
+mate_rr_output_get_id (MateRROutput *output)
+{
+    g_assert(output != NULL);
+
+    return output->id;
+}
+
+const guint8 *
+mate_rr_output_get_edid_data (MateRROutput *output)
+{
+    g_return_val_if_fail (output != NULL, NULL);
+
+    return output->edid_data;
+}
+
+/**
+ * mate_rr_screen_get_output_by_name:
+ *
+ * Returns: (transfer none): the output identified by @name
+ */
+MateRROutput *
+mate_rr_screen_get_output_by_name (MateRRScreen *screen,
+				    const char    *name)
+{
+    int i;
+
+    g_return_val_if_fail (MATE_IS_RR_SCREEN (screen), NULL);
+    g_return_val_if_fail (screen->priv->info != NULL, NULL);
+
+    for (i = 0; screen->priv->info->outputs[i] != NULL; ++i)
+    {
+	MateRROutput *output = screen->priv->info->outputs[i];
+
+	if (strcmp (output->name, name) == 0)
+	    return output;
+    }
+
+    return NULL;
+}
+
+/**
+ * mate_rr_output_get_crtc:
+ * @output: a #MateRROutput
+ * Returns: (transfer none):
+ */
+MateRRCrtc *
+mate_rr_output_get_crtc (MateRROutput *output)
+{
+    g_return_val_if_fail (output != NULL, NULL);
+
+    return output->current_crtc;
+}
+
+/**
+ * mate_rr_output_get_possible_crtcs:
+ * @output: a #MateRROutput
+ * Returns: (array zero-terminated=1) (transfer none):
+ */
+MateRRCrtc **
+mate_rr_output_get_possible_crtcs (MateRROutput *output)
+{
+    g_return_val_if_fail (output != NULL, NULL);
+
+    return output->possible_crtcs;
+}
+
+/* Returns NULL if the ConnectorType property is not available */
+const char *
+mate_rr_output_get_connector_type (MateRROutput *output)
+{
+    g_return_val_if_fail (output != NULL, NULL);
+
+    return output->connector_type;
+}
+
+gboolean
+_mate_rr_output_name_is_laptop (const char *name)
+{
+    if (!name)
+        return FALSE;
+
+    if (strstr (name, "lvds") || /* Most drivers use an "LVDS" prefix... */
+        strstr (name, "LVDS") ||
+        strstr (name, "Lvds") ||
+        strstr (name, "LCD")  || /* ... but fglrx uses "LCD" in some versions.  Shoot me now, kthxbye. */
+        strstr (name, "eDP"))    /* eDP is for internal laptop panel connections */
+        return TRUE;
+
+    return FALSE;
+}
+
+gboolean
+mate_rr_output_is_laptop (MateRROutput *output)
+{
+    g_return_val_if_fail (output != NULL, FALSE);
+
+    if (!output->connected)
+        return FALSE;
+
+    if (g_strcmp0 (output->connector_type, MATE_RR_CONNECTOR_TYPE_PANEL) == 0)
+        return TRUE;
+
+    /* Fallback (see https://bugs.freedesktop.org/show_bug.cgi?id=26736) */
+    return _mate_rr_output_name_is_laptop (output->name);
+}
+
+/**
+ * mate_rr_output_get_current_mode:
+ * @output: a #MateRROutput
+ * Returns: (transfer none): the current mode of this output
+ */
+MateRRMode *
+mate_rr_output_get_current_mode (MateRROutput *output)
+{
+    MateRRCrtc *crtc;
+
+    g_return_val_if_fail (output != NULL, NULL);
+
+    if ((crtc = mate_rr_output_get_crtc (output)))
+	return mate_rr_crtc_get_current_mode (crtc);
+
+    return NULL;
+}
+
+/**
+ * mate_rr_output_get_position:
+ * @output: a #MateRROutput
+ * @x: (out) (allow-none):
+ * @y: (out) (allow-none):
+ */
+void
+mate_rr_output_get_position (MateRROutput   *output,
+			      int             *x,
+			      int             *y)
+{
+    MateRRCrtc *crtc;
+
+    g_return_if_fail (output != NULL);
+
+    if ((crtc = mate_rr_output_get_crtc (output)))
+	mate_rr_crtc_get_position (crtc, x, y);
+}
+
+const char *
+mate_rr_output_get_name (MateRROutput *output)
+{
+    g_assert (output != NULL);
+    return output->name;
+}
+
+int
+mate_rr_output_get_width_mm (MateRROutput *output)
+{
+    g_assert (output != NULL);
+    return output->width_mm;
+}
+
+int
+mate_rr_output_get_height_mm (MateRROutput *output)
+{
+    g_assert (output != NULL);
+    return output->height_mm;
+}
+
+/**
+ * mate_rr_output_get_preferred_mode:
+ * @output: a #MateRROutput
+ * Returns: (transfer none):
+ */
+MateRRMode *
+mate_rr_output_get_preferred_mode (MateRROutput *output)
+{
+    g_return_val_if_fail (output != NULL, NULL);
+    if (output->n_preferred)
+	return output->modes[0];
+
+    return NULL;
+}
+
+/**
+ * mate_rr_output_list_modes:
+ * @output: a #MateRROutput
+ * Returns: (array zero-terminated=1) (transfer none):
+ */
+
+MateRRMode **
+mate_rr_output_list_modes (MateRROutput *output)
+{
+    g_return_val_if_fail (output != NULL, NULL);
+    return output->modes;
+}
+
+gboolean
+mate_rr_output_is_connected (MateRROutput *output)
+{
+    g_return_val_if_fail (output != NULL, FALSE);
+    return output->connected;
+}
+
+gboolean
+mate_rr_output_supports_mode (MateRROutput *output,
+			       MateRRMode   *mode)
+{
+    int i;
+
+    g_return_val_if_fail (output != NULL, FALSE);
+    g_return_val_if_fail (mode != NULL, FALSE);
+
+    for (i = 0; output->modes[i] != NULL; ++i)
+    {
+	if (output->modes[i] == mode)
+	    return TRUE;
+    }
+
+    return FALSE;
+}
+
+gboolean
+mate_rr_output_can_clone (MateRROutput *output,
+			   MateRROutput *clone)
+{
+    int i;
+
+    g_return_val_if_fail (output != NULL, FALSE);
+    g_return_val_if_fail (clone != NULL, FALSE);
+
+    for (i = 0; output->clones[i] != NULL; ++i)
+    {
+	if (output->clones[i] == clone)
+	    return TRUE;
+    }
+
+    return FALSE;
+}
+
+gboolean
+mate_rr_output_get_is_primary (MateRROutput *output)
+{
+#ifdef HAVE_RANDR
+    return output->info->primary == output->id;
+#else
+    return FALSE;
+#endif
+}
+
+void
+mate_rr_screen_set_primary_output (MateRRScreen *screen,
+                                    MateRROutput *output)
+{
+#ifdef HAVE_RANDR
+    MateRRScreenPrivate *priv;
+
+    g_return_if_fail (MATE_IS_RR_SCREEN (screen));
+
+    priv = screen->priv;
+
+    RROutput id;
+
+    if (output)
+        id = output->id;
+    else
+        id = None;
+
+    XRRSetOutputPrimary (priv->xdisplay, priv->xroot, id);
+#endif
+}
+
+/* MateRRCrtc */
+typedef struct
+{
+    Rotation xrot;
+    MateRRRotation rot;
+} RotationMap;
+
+static const RotationMap rotation_map[] =
+{
+    { RR_Rotate_0, MATE_RR_ROTATION_0 },
+    { RR_Rotate_90, MATE_RR_ROTATION_90 },
+    { RR_Rotate_180, MATE_RR_ROTATION_180 },
+    { RR_Rotate_270, MATE_RR_ROTATION_270 },
+    { RR_Reflect_X, MATE_RR_REFLECT_X },
+    { RR_Reflect_Y, MATE_RR_REFLECT_Y },
+};
+
+static MateRRRotation
+mate_rr_rotation_from_xrotation (Rotation r)
+{
+    gsize i;
+    MateRRRotation result = 0;
+
+    for (i = 0; i < G_N_ELEMENTS (rotation_map); ++i)
+    {
+	if (r & rotation_map[i].xrot)
+	    result |= rotation_map[i].rot;
+    }
+
+    return result;
+}
+
+static Rotation
+xrotation_from_rotation (MateRRRotation r)
+{
+    gsize i;
+    Rotation result = 0;
+
+    for (i = 0; i < G_N_ELEMENTS (rotation_map); ++i)
+    {
+	if (r & rotation_map[i].rot)
+	    result |= rotation_map[i].xrot;
+    }
+
+    return result;
+}
+
+#ifndef MATE_DISABLE_DEPRECATED_SOURCE
+gboolean
+mate_rr_crtc_set_config (MateRRCrtc      *crtc,
+			  int               x,
+			  int               y,
+			  MateRRMode      *mode,
+			  MateRRRotation   rotation,
+			  MateRROutput   **outputs,
+			  int               n_outputs,
+			  GError          **error)
+{
+    return mate_rr_crtc_set_config_with_time (crtc, GDK_CURRENT_TIME, x, y, mode, rotation, outputs, n_outputs, error);
+}
+#endif
+
+gboolean
+mate_rr_crtc_set_config_with_time (MateRRCrtc      *crtc,
+				    guint32           timestamp,
+				    int               x,
+				    int               y,
+				    MateRRMode      *mode,
+				    MateRRRotation   rotation,
+				    MateRROutput   **outputs,
+				    int               n_outputs,
+				    GError          **error)
+{
+#ifdef HAVE_RANDR
+    ScreenInfo *info;
+    GArray *output_ids;
+	GdkDisplay *display;
+    Status status;
+    gboolean result;
+    int i;
+
+    g_return_val_if_fail (crtc != NULL, FALSE);
+    g_return_val_if_fail (mode != NULL || outputs == NULL || n_outputs == 0, FALSE);
+    g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+
+    info = crtc->info;
+
+    if (mode)
+    {
+	if (x + mode->width > info->max_width
+	    || y + mode->height > info->max_height)
+	{
+	    g_set_error (error, MATE_RR_ERROR, MATE_RR_ERROR_BOUNDS_ERROR,
+			 /* Translators: the "position", "size", and "maximum"
+			  * words here are not keywords; please translate them
+			  * as usual.  A CRTC is a CRT Controller (this is X terminology) */
+			 _("requested position/size for CRTC %d is outside the allowed limit: "
+			   "position=(%d, %d), size=(%d, %d), maximum=(%d, %d)"),
+			 (int) crtc->id,
+			 x, y,
+			 mode->width, mode->height,
+			 info->max_width, info->max_height);
+	    return FALSE;
+	}
+    }
+
+    output_ids = g_array_new (FALSE, FALSE, sizeof (RROutput));
+
+    if (outputs)
+    {
+	for (i = 0; i < n_outputs; ++i)
+	    g_array_append_val (output_ids, outputs[i]->id);
+    }
+
+	display = gdk_display_get_default ();
+    gdk_x11_display_error_trap_push (display);
+    status = XRRSetCrtcConfig (DISPLAY (crtc), info->resources, crtc->id,
+			       timestamp,
+			       x, y,
+			       mode ? mode->id : None,
+			       xrotation_from_rotation (rotation),
+			       (RROutput *)output_ids->data,
+			       output_ids->len);
+
+    g_array_free (output_ids, TRUE);
+
+    if (gdk_x11_display_error_trap_pop (display) || status != RRSetConfigSuccess) {
+        /* Translators: CRTC is a CRT Controller (this is X terminology).
+         * It is *very* unlikely that you'll ever get this error, so it is
+         * only listed for completeness. */
+        g_set_error (error, MATE_RR_ERROR, MATE_RR_ERROR_RANDR_ERROR,
+                     _("could not set the configuration for CRTC %d"),
+                     (int) crtc->id);
+        return FALSE;
+    } else {
+        result = TRUE;
+    }
+
+    return result;
+#else
+    return FALSE;
+#endif /* HAVE_RANDR */
+}
+
+/**
+ * mate_rr_crtc_get_current_mode:
+ * @crtc: a #MateRRCrtc
+ * Returns: (transfer none): the current mode of this crtc
+ */
+MateRRMode *
+mate_rr_crtc_get_current_mode (MateRRCrtc *crtc)
+{
+    g_return_val_if_fail (crtc != NULL, NULL);
+
+    return crtc->current_mode;
+}
+
+guint32
+mate_rr_crtc_get_id (MateRRCrtc *crtc)
+{
+    g_return_val_if_fail (crtc != NULL, 0);
+
+    return crtc->id;
+}
+
+gboolean
+mate_rr_crtc_can_drive_output (MateRRCrtc   *crtc,
+				MateRROutput *output)
+{
+    int i;
+
+    g_return_val_if_fail (crtc != NULL, FALSE);
+    g_return_val_if_fail (output != NULL, FALSE);
+
+    for (i = 0; crtc->possible_outputs[i] != NULL; ++i)
+    {
+	if (crtc->possible_outputs[i] == output)
+	    return TRUE;
+    }
+
+    return FALSE;
+}
+
+/* FIXME: merge with get_mode()? */
+
+/**
+ * mate_rr_crtc_get_position:
+ * @crtc: a #MateRRCrtc
+ * @x: (out) (allow-none):
+ * @y: (out) (allow-none):
+ */
+void
+mate_rr_crtc_get_position (MateRRCrtc *crtc,
+			    int         *x,
+			    int         *y)
+{
+    g_return_if_fail (crtc != NULL);
+
+    if (x)
+	*x = crtc->x;
+
+    if (y)
+	*y = crtc->y;
+}
+
+/* FIXME: merge with get_mode()? */
+MateRRRotation
+mate_rr_crtc_get_current_rotation (MateRRCrtc *crtc)
+{
+    g_assert(crtc != NULL);
+    return crtc->current_rotation;
+}
+
+MateRRRotation
+mate_rr_crtc_get_rotations (MateRRCrtc *crtc)
+{
+    g_assert(crtc != NULL);
+    return crtc->rotations;
+}
+
+gboolean
+mate_rr_crtc_supports_rotation (MateRRCrtc *   crtc,
+				 MateRRRotation rotation)
+{
+    g_return_val_if_fail (crtc != NULL, FALSE);
+    return (crtc->rotations & rotation);
+}
+
+static MateRRCrtc *
+crtc_new (ScreenInfo *info, RROutput id)
+{
+    MateRRCrtc *crtc = g_slice_new0 (MateRRCrtc);
+
+    crtc->id = id;
+    crtc->info = info;
+
+    return crtc;
+}
+
+static MateRRCrtc *
+crtc_copy (const MateRRCrtc *from)
+{
+    MateRROutput **p_output;
+    GPtrArray *array;
+    MateRRCrtc *to = g_slice_new0 (MateRRCrtc);
+
+    to->info = from->info;
+    to->id = from->id;
+    to->current_mode = from->current_mode;
+    to->x = from->x;
+    to->y = from->y;
+    to->current_rotation = from->current_rotation;
+    to->rotations = from->rotations;
+    to->gamma_size = from->gamma_size;
+
+    array = g_ptr_array_new ();
+    for (p_output = from->current_outputs; *p_output != NULL; p_output++)
+    {
+        g_ptr_array_add (array, *p_output);
+    }
+    to->current_outputs = (MateRROutput**) g_ptr_array_free (array, FALSE);
+
+    array = g_ptr_array_new ();
+    for (p_output = from->possible_outputs; *p_output != NULL; p_output++)
+    {
+        g_ptr_array_add (array, *p_output);
+    }
+    to->possible_outputs = (MateRROutput**) g_ptr_array_free (array, FALSE);
+
+    return to;
+}
+
+#ifdef HAVE_RANDR
+static gboolean
+crtc_initialize (MateRRCrtc        *crtc,
+		 XRRScreenResources *res,
+		 GError            **error)
+{
+    XRRCrtcInfo *info = XRRGetCrtcInfo (DISPLAY (crtc), res, crtc->id);
+    GPtrArray *a;
+    int i;
+
+#if 0
+    g_print ("CRTC %lx Timestamp: %u\n", crtc->id, (guint32)info->timestamp);
+#endif
+
+    if (!info)
+    {
+	/* FIXME: We need to reaquire the screen resources */
+	/* FIXME: can we actually catch BadRRCrtc, and does it make sense to emit that? */
+
+	/* Translators: CRTC is a CRT Controller (this is X terminology).
+	 * It is *very* unlikely that you'll ever get this error, so it is
+	 * only listed for completeness. */
+	g_set_error (error, MATE_RR_ERROR, MATE_RR_ERROR_RANDR_ERROR,
+		     _("could not get information about CRTC %d"),
+		     (int) crtc->id);
+	return FALSE;
+    }
+
+    /* MateRRMode */
+    crtc->current_mode = mode_by_id (crtc->info, info->mode);
+
+    crtc->x = info->x;
+    crtc->y = info->y;
+
+    /* Current outputs */
+    a = g_ptr_array_new ();
+    for (i = 0; i < info->noutput; ++i)
+    {
+	MateRROutput *output = mate_rr_output_by_id (crtc->info, info->outputs[i]);
+
+	if (output)
+	    g_ptr_array_add (a, output);
+    }
+    g_ptr_array_add (a, NULL);
+    crtc->current_outputs = (MateRROutput **)g_ptr_array_free (a, FALSE);
+
+    /* Possible outputs */
+    a = g_ptr_array_new ();
+    for (i = 0; i < info->npossible; ++i)
+    {
+	MateRROutput *output = mate_rr_output_by_id (crtc->info, info->possible[i]);
+
+	if (output)
+	    g_ptr_array_add (a, output);
+    }
+    g_ptr_array_add (a, NULL);
+    crtc->possible_outputs = (MateRROutput **)g_ptr_array_free (a, FALSE);
+
+    /* Rotations */
+    crtc->current_rotation = mate_rr_rotation_from_xrotation (info->rotation);
+    crtc->rotations = mate_rr_rotation_from_xrotation (info->rotations);
+
+    XRRFreeCrtcInfo (info);
+
+    /* get an store gamma size */
+    crtc->gamma_size = XRRGetCrtcGammaSize (DISPLAY (crtc), crtc->id);
+
+    return TRUE;
+}
+#endif
+
+static void
+crtc_free (MateRRCrtc *crtc)
+{
+    g_free (crtc->current_outputs);
+    g_free (crtc->possible_outputs);
+    g_slice_free (MateRRCrtc, crtc);
+}
+
+/* MateRRMode */
+static MateRRMode *
+mode_new (ScreenInfo *info, RRMode id)
+{
+    MateRRMode *mode = g_slice_new0 (MateRRMode);
+
+    mode->id = id;
+    mode->info = info;
+
+    return mode;
+}
+
+guint32
+mate_rr_mode_get_id (MateRRMode *mode)
+{
+    g_return_val_if_fail (mode != NULL, 0);
+    return mode->id;
+}
+
+guint
+mate_rr_mode_get_width (MateRRMode *mode)
+{
+    g_return_val_if_fail (mode != NULL, 0);
+    return mode->width;
+}
+
+int
+mate_rr_mode_get_freq (MateRRMode *mode)
+{
+    g_return_val_if_fail (mode != NULL, 0);
+    return (mode->freq) / 1000;
+}
+
+guint
+mate_rr_mode_get_height (MateRRMode *mode)
+{
+    g_return_val_if_fail (mode != NULL, 0);
+    return mode->height;
+}
+
+#ifdef HAVE_RANDR
+static void
+mode_initialize (MateRRMode *mode, XRRModeInfo *info)
+{
+    g_assert (mode != NULL);
+    g_assert (info != NULL);
+
+    mode->name = g_strdup (info->name);
+    mode->width = info->width;
+    mode->height = info->height;
+    mode->freq = ((info->dotClock / (double)info->hTotal) / info->vTotal + 0.5) * 1000;
+}
+#endif /* HAVE_RANDR */
+
+static MateRRMode *
+mode_copy (const MateRRMode *from)
+{
+    MateRRMode *to = g_slice_new0 (MateRRMode);
+
+    to->id = from->id;
+    to->info = from->info;
+    to->name = g_strdup (from->name);
+    to->width = from->width;
+    to->height = from->height;
+    to->freq = from->freq;
+
+    return to;
+}
+
+static void
+mode_free (MateRRMode *mode)
+{
+    g_free (mode->name);
+    g_slice_free (MateRRMode, mode);
+}
+
+void
+mate_rr_crtc_set_gamma (MateRRCrtc *crtc, int size,
+			 unsigned short *red,
+			 unsigned short *green,
+			 unsigned short *blue)
+{
+#ifdef HAVE_RANDR
+    int copy_size;
+    XRRCrtcGamma *gamma;
+
+    g_return_if_fail (crtc != NULL);
+    g_return_if_fail (red != NULL);
+    g_return_if_fail (green != NULL);
+    g_return_if_fail (blue != NULL);
+
+    if (size != crtc->gamma_size)
+	return;
+
+    gamma = XRRAllocGamma (crtc->gamma_size);
+
+    copy_size = crtc->gamma_size * sizeof (unsigned short);
+    memcpy (gamma->red, red, copy_size);
+    memcpy (gamma->green, green, copy_size);
+    memcpy (gamma->blue, blue, copy_size);
+
+    XRRSetCrtcGamma (DISPLAY (crtc), crtc->id, gamma);
+    XRRFreeGamma (gamma);
+#endif /* HAVE_RANDR */
+}
+
+/**
+ * mate_rr_crtc_get_gamma:
+ * @crtc: a #MateRRCrtc
+ * @size:
+ * @red: (out): the minimum width
+ * @green: (out): the maximum width
+ * @blue: (out): the minimum height
+ *
+ * Returns: %TRUE for success
+ */
+gboolean
+mate_rr_crtc_get_gamma (MateRRCrtc *crtc, int *size,
+			 unsigned short **red, unsigned short **green,
+			 unsigned short **blue)
+{
+#ifdef HAVE_RANDR
+    int copy_size;
+    unsigned short *r, *g, *b;
+    XRRCrtcGamma *gamma;
+
+    g_return_val_if_fail (crtc != NULL, FALSE);
+
+    gamma = XRRGetCrtcGamma (DISPLAY (crtc), crtc->id);
+    if (!gamma)
+	return FALSE;
+
+    copy_size = crtc->gamma_size * sizeof (unsigned short);
+
+    if (red) {
+	r = g_new0 (unsigned short, crtc->gamma_size);
+	memcpy (r, gamma->red, copy_size);
+	*red = r;
+    }
+
+    if (green) {
+	g = g_new0 (unsigned short, crtc->gamma_size);
+	memcpy (g, gamma->green, copy_size);
+	*green = g;
+    }
+
+    if (blue) {
+	b = g_new0 (unsigned short, crtc->gamma_size);
+	memcpy (b, gamma->blue, copy_size);
+	*blue = b;
+    }
+
+    XRRFreeGamma (gamma);
+
+    if (size)
+	*size = crtc->gamma_size;
+
+    return TRUE;
+#else
+    return FALSE;
+#endif /* HAVE_RANDR */
+}
+
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/38.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/38.html new file mode 100644 index 0000000..32c4587 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/38.html @@ -0,0 +1,365 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
/*
+ * Copyright (C) 2012,2017 Red Hat, Inc.
+ * Copyright (C) 2018-2021 MATE Developers
+ *
+ * This file is part of the Mate Library.
+ *
+ * The Gnome Library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * The Gnome Library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with the Gnome Library; see the file COPYING.LIB.  If not,
+ * write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Authors: Bastien Nocera <hadess@hadess.net>
++ */
+
+#define MATE_DESKTOP_USE_UNSTABLE_API
+#include "mate-desktop-thumbnail.h"
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+int main (int argc, char **argv)
+{
+    GdkPixbuf *pixbuf;
+    MateDesktopThumbnailFactory *factory;
+    GtkWidget *window, *image;
+    char *content_type;
+
+    gtk_init (&argc, &argv);
+
+    if (argc < 2) {
+        g_print ("Usage: %s FILE...\n", argv[0]);
+        return 1;
+    }
+
+    content_type = g_content_type_guess (argv[1], NULL, 0, NULL);
+    factory = mate_desktop_thumbnail_factory_new (MATE_DESKTOP_THUMBNAIL_SIZE_LARGE);
+    pixbuf = mate_desktop_thumbnail_factory_generate_thumbnail (factory, argv[1], content_type);
+    g_free (content_type);
+    g_object_unref (factory);
+
+    if (pixbuf == NULL) {
+        g_warning ("mate_desktop_thumbnail_factory_generate_thumbnail() failed to generate a thumbnail for %s", argv[1]);
+        return 1;
+    }
+
+    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+    g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
+    image = gtk_image_new_from_pixbuf (pixbuf);
+    g_object_unref (pixbuf);
+    gtk_container_add (GTK_CONTAINER (window), image);
+    gtk_widget_show_all (window);
+
+    gtk_main ();
+
+    return 0;
+}
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/39.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/39.html new file mode 100644 index 0000000..87cd85c --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/39.html @@ -0,0 +1,553 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
/* -*- Mode: C; c-set-style: gnu indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <mate-desktop-item.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <locale.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+static void
+test_ditem (const char *file)
+{
+	MateDesktopItem *ditem;
+	MateDesktopItemType type;
+	const gchar *text;
+	char *uri;
+	char path[256];
+
+	ditem = mate_desktop_item_new_from_file (file,
+						  MATE_DESKTOP_ITEM_LOAD_ONLY_IF_EXISTS,
+						  NULL);
+	if (ditem == NULL) {
+		g_print ("File %s is not an existing ditem\n", file);
+		return;
+	}
+
+	text = mate_desktop_item_get_location (ditem);
+	g_print ("LOCATION: |%s|\n", text);
+
+	type = mate_desktop_item_get_entry_type (ditem);
+	g_print ("TYPE: |%u|\n", type);
+
+	text = mate_desktop_item_get_string
+		(ditem, MATE_DESKTOP_ITEM_TYPE);
+	g_print ("TYPE(string): |%s|\n", text);
+
+	text = mate_desktop_item_get_string
+		(ditem, MATE_DESKTOP_ITEM_EXEC);
+	g_print ("EXEC: |%s|\n", text);
+
+	text = mate_desktop_item_get_string
+		(ditem, MATE_DESKTOP_ITEM_ICON);
+	g_print ("ICON: |%s|\n", text);
+
+	text = mate_desktop_item_get_localestring
+		(ditem, MATE_DESKTOP_ITEM_NAME);
+	g_print ("NAME: |%s|\n", text);
+
+	text = mate_desktop_item_get_localestring_lang
+		(ditem, MATE_DESKTOP_ITEM_NAME,
+		 "cs_CZ");
+	g_print ("NAME(lang=cs_CZ): |%s|\n", text);
+
+	text = mate_desktop_item_get_localestring_lang
+		(ditem, MATE_DESKTOP_ITEM_NAME,
+		 "de");
+	g_print ("NAME(lang=de): |%s|\n", text);
+
+	text = mate_desktop_item_get_localestring_lang
+		(ditem, MATE_DESKTOP_ITEM_NAME,
+		 NULL);
+	g_print ("NAME(lang=null): |%s|\n", text);
+
+	text = mate_desktop_item_get_localestring
+		(ditem, MATE_DESKTOP_ITEM_COMMENT);
+	g_print ("COMMENT: |%s|\n", text);
+
+	g_print ("Setting Name[de]=Neu gestzt! (I have no idea what that means)\n");
+	mate_desktop_item_set_localestring
+		(ditem,
+		 MATE_DESKTOP_ITEM_NAME,
+		 "Neu gesetzt!");
+
+	getcwd (path, 255 - strlen ("/foo.desktop"));
+	g_strlcat (path, "/foo.desktop", sizeof (path));
+
+	g_print ("Saving to foo.desktop\n");
+	uri = g_filename_to_uri (path, NULL, NULL);
+	g_print ("URI: %s\n", uri);
+	mate_desktop_item_save (ditem, uri, FALSE, NULL);
+	g_free (uri);
+}
+
+static void
+launch_item (const char *file)
+{
+	MateDesktopItem *ditem;
+	GList *file_list = NULL;
+	int ret;
+
+	ditem = mate_desktop_item_new_from_file (file,
+						  MATE_DESKTOP_ITEM_LOAD_ONLY_IF_EXISTS,
+						  NULL);
+	if (ditem == NULL) {
+		g_print ("File %s is not an existing ditem\n", file);
+		return;
+
+	}
+
+#if 0
+	file_list = g_list_append (NULL, "file:///bin/sh");
+	file_list = g_list_append (file_list, "foo");
+	file_list = g_list_append (file_list, "bar");
+	file_list = g_list_append (file_list, "http://slashdot.org");
+#endif
+
+	ret = mate_desktop_item_launch (ditem, file_list, 0, NULL);
+	g_print ("launch returned: %d\n", ret);
+}
+
+int
+main (int argc, char **argv)
+{
+	char *file;<--- Variable 'file' can be declared as pointer to const
+	gboolean launch = FALSE;
+
+	if (argc < 2 || argc > 3) {
+		fprintf (stderr, "Usage: test-ditem path [LAUNCH]\n");
+		exit (1);
+	}
+
+	if (argc == 3 &&
+	    strcmp (argv[2], "LAUNCH") == 0)
+		launch = TRUE;
+
+	file = g_strdup (argv[1]);
+
+	gtk_init (&argc, &argv);
+
+	if (launch)
+		launch_item (file);
+	else
+		test_ditem (file);
+
+	/*
+	test_ditem_edit (file);
+	*/
+
+	return 0;
+}
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/4.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/4.html new file mode 100644 index 0000000..95757fe --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/4.html @@ -0,0 +1,311 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2005-2007 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __GPMCOMMON_H
+#define __GPMCOMMON_H
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+G_BEGIN_DECLS
+
+void 		 gpm_help_display				(const gchar	*link_id);
+#ifdef EGG_TEST
+void		 gpm_common_test				(gpointer	 data);
+#endif
+
+G_END_DECLS
+
+#endif	/* __GPMCOMMON_H */
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/40.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/40.html new file mode 100644 index 0000000..50cf0ce --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/40.html @@ -0,0 +1,413 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+82
+83
+84
+85
+86
+87
+88
/* vi: set sw=4 ts=4 wrap ai: */
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * */
+
+#include <stdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <locale.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#define MATE_DESKTOP_USE_UNSTABLE_API
+#include "mate-languages.h"
+
+void test_one_locale(const gchar *locale);
+void test_locales(void);
+
+void test_one_locale(const gchar *locale)
+{
+    char *lang, *country, *norm_locale;
+    char *language_code, *country_code, *codeset, *modifier;
+
+    lang = mate_get_language_from_locale (locale, locale);
+    country = mate_get_country_from_locale (locale, locale);
+    norm_locale = mate_normalize_locale (locale);
+
+    printf("Current locale: %s\n", locale);
+    printf("[locale]:\t\tlang=%s, country=%s, locale=%s\n", lang, country, norm_locale);
+    g_free(lang);
+    g_free(country);
+    g_free(norm_locale);
+
+    if (mate_parse_locale (locale, &language_code, &country_code, &codeset, &modifier)) {
+        lang = mate_get_language_from_code (language_code, locale);
+        country = mate_get_country_from_code (country_code, locale);
+        if (mate_language_has_translations(language_code)) {
+            printf("[mate_parse_locale]:\tlang_code=%s, country_code=%s, code=%s, modifier=%s\n"
+                    "[code]:\t\t\tlang=%s, country=%s, Has translation\n",
+                    language_code, country_code, codeset, modifier,
+                    lang, country);
+        } else {
+            printf("[mate_parse_locale]:\tlang_code=%s, country_code=%s, code=%s, modifier=%s\n"
+                    "[code]:\t\t\tlang=%s, country=%s\n",
+                    language_code, country_code, codeset, modifier,
+                    lang, country);
+        }
+        g_free(lang);
+        g_free(country);
+    }
+    putchar('\n');
+
+    g_free(language_code);
+    g_free(country_code);
+    g_free(codeset);
+    g_free(modifier);
+}
+
+void test_locales(void)
+{
+    char **all;
+    guint i, len;
+
+    all= mate_get_all_locales ();
+    len = g_strv_length (all);
+
+    for (i =0; i < len; i++) {
+        test_one_locale(all[i]);
+    }
+    g_strfreev(all);
+}
+
+int main(int argc, char **argv)
+{
+    if (argc == 2) {
+        test_one_locale(argv[1]);
+    } else {
+        test_locales();
+    }
+    return 0;
+}
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/41.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/41.html new file mode 100644 index 0000000..84d6d5a --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/41.html @@ -0,0 +1,353 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
/*
+ * test.c: general tests for libmate-desktop
+ *
+ * Copyright (C) 2013-2014 Stefano Karapetsas
+ * Copyright (C) 2013-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Authors:
+ *  Stefano Karapetsas <stefano@karapetsas.com>
+ */
+
+#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include "mate-desktop.h"
+#include "mate-colorbutton.h"
+
+int
+main (int argc, char **argv)
+{
+    GtkWindow *window = NULL;
+    GtkWidget *widget = NULL;
+
+    /* initialize GTK+ */
+    gtk_init (&argc, &argv);
+
+    /* create window */
+    window = GTK_WINDOW (gtk_window_new (GTK_WINDOW_TOPLEVEL));
+
+    gtk_window_set_title (window, "MATE Desktop Test");
+
+    /* create a MateColorButton */
+    widget = mate_color_button_new ();
+
+    /* add MateColorButton to window */
+    gtk_container_add (GTK_CONTAINER (window), widget);
+
+    /* quit signal */
+    g_signal_connect (GTK_WIDGET (window), "destroy", gtk_main_quit, NULL);
+
+    gtk_widget_show_all (GTK_WIDGET (window));
+
+    /* start application */
+    gtk_main ();
+    return 0;
+}
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/42.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/42.html new file mode 100644 index 0000000..aad3ebb --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/42.html @@ -0,0 +1,327 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
/*
+ * mate-desktop.h: general functions for libmate-desktop
+ *
+ * Copyright (C) 2013 Stefano Karapetsas
+ * Copyright (C) 2013-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ *
+ * Authors:
+ *  Stefano Karapetsas <stefano@karapetsas.com>
+ */
+
+#ifndef __MATE_DESKTOP_H__
+#define __MATE_DESKTOP_H__
+
+#ifdef HAVE_CONFIG_H
+#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+G_BEGIN_DECLS
+
+#define MATE_DESKTOP_CHECK_VERSION(major,minor,micro) \
+        (MATE_MAJOR > (major) || \
+        (MATE_MAJOR == (major) && MATE_MINOR > (minor)) || \
+        (MATE_MAJOR == (major) && MATE_MINOR == (minor) && \
+        MATE_MICRO >= (micro)))
+
+G_END_DECLS
+
+#endif /* __MATE_DESKTOP_H__ */
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/43.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/43.html new file mode 100644 index 0000000..94b3540 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/43.html @@ -0,0 +1,1577 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
+603
+604
+605
+606
+607
+608
+609
+610
+611
+612
+613
+614
+615
+616
+617
+618
+619
+620
+621
+622
+623
+624
+625
+626
+627
+628
+629
+630
+631
+632
+633
+634
+635
+636
+637
+638
+639
+640
+641
+642
+643
+644
+645
+646
+647
+648
+649
+650
+651
+652
+653
+654
+655
+656
+657
+658
+659
+660
+661
+662
+663
+664
+665
+666
+667
+668
+669
+670
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * Copyright (C) 2011 Perberos <perberos@gmail.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#ifndef __MATE_ABOUT_H__
+#define __MATE_ABOUT_H__
+
+#include <config.h> // autogenerated by ./configure<--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+const char* program_name = N_("MATE Desktop Environment");
+const char* version = PACKAGE_VERSION;
+const char* icon = "mate-desktop";
+const char* website = "https://mate-desktop.org/";
+
+const char* copyright =  N_("Copyright © 1997-2011 GNOME developers\n"
+                            "Copyright © 2011 Perberos\n"
+                            "Copyright © 2012-2024 MATE developers");
+
+/* Increment comments_count if you add other comments. This will be
+ * used to choose a random comment. */
+const int comments_count = 6;
+const char* comments_array[] = {
+    N_("MATE provides an intuitive and attractive desktop to Linux users "
+    "using traditional metaphors."),
+
+    N_("MATE includes most of what you see on your computer, including the file "
+    "manager, document viewer, image viewer, menus, and many applications."),
+
+    N_("MATE is a Free, usable, stable, accessible desktop environment for the Unix-"
+    "like family of operating systems."),
+
+    N_("MATE is the continuation of GNOME 2. Hundreds of people have contributed code to "
+    "GNOME since it was started in 1997; many more have contributed in other "
+    "important ways, including translations, documentation, and quality assurance."),
+
+    N_("GNOME 2 was the most popular Linux desktop but it’s no longer available... "
+    "MATE is here to provide that same desktop to you!"),
+
+    N_("The name “MATE” comes from yerba maté, a species of holly native "
+    "to subtropical South America. Its leaves contain caffeine and are "
+    "used to make infusions and a beverage called mate.")
+};
+
+const char* authors[] = {
+    "MATE:",
+    /* MATE founders */
+    "Perberos <perberos@gmail.com>",
+    "Stefano Karapetsas <stefano@karapetsas.com>",
+    "Steve Zesch <stevezesch2@gmail.com>",
+    "Clement Lefebvre <root@linuxmint.com>",
+    /* MATE developers and contributors */
+    "Scott Balneaves <sbalneav@alburg.net>",
+    "Marcel Dijkstra <marcel.dykstra@gmail.com>",
+    "Jasmine Hassan <jasmine.aura@gmail.com>",
+    "Brent Hull <bhull2010@live.com>",
+    "Steev Klimaszewski <steev@gentoo.org>",
+    "Joseph Krieger <rowen.stipe@gmail.com>",
+    "Nelson Marques <nmo.marques@gmail.com>",
+    "Dan Mashal <dan.mashal@fedoraproject.org>",
+    "Elan Ruusamäe <glen@delfi.ee>",
+    "Yaakov Selkowitz <yselkowitz@users.sourceforge.net>",
+    "Sam Tygier <samtygier@yahoo.co.uk>",
+    "Wolfgang Ulbrich <chat-to-me@raveit.de>",
+    "Sander Sweers <infirit@gmail.com>",
+    "Benjamin Denisart <p.drouand@gmail.com>",
+    "Efstathios Iosifidis <iefstathios@gmail.com>",
+    "Martin Wimpress <code@flexion.org>",
+    "John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>",
+    "Mike Gabriel <sunweaver@debian.org>",
+    "Willy Sudiarto Raharjo <willysr@slackware-id.org>",
+    "Chess Griffin <chess.griffin@gmail.com>",
+    "Vlad Orlov <monsta@inbox.ru>",
+    "Abel McClendon <hcmmac@hosscomm.com>",
+    /* MATE Google Summer of Code students */
+    "Alexander van der Meij <alexandervdm@gliese.me>",
+    "Avishkar Gupta <avishkar_gupta@outlook.com>",
+    "Laszlo Boros <iamsemmu@gmail.com>",
+    "Michal Ratajsky <michal.ratajsky@gmail.com>",
+    "",
+    /* GNOME developers */
+    "GNOME:",
+    "Jérôme Abela",
+    "Rob Adams",
+    "Djihed Afifi",
+    "Sarfraaz Ahmed",
+    "Christopher Aillon",
+    "Lauri Alanko",
+    "Борислав Александров (Borislav Aleksandrov)",
+    "Seth Alves",
+    "Shawn T. Amundson",
+    "Robert Ancell",
+    "Erik Andersen",
+    "Филип Андонов (Filip Andonov)",
+    "Marius Andreiana",
+    "Jon Anhold",
+    "Арангел Ангов (Arangel Angov)",
+    "Никола Антонов (Nikola Antonov)",
+    "Sandy Armstrong",
+    "Frank Arnold",
+    "Arunprakash",
+    "Paolo Bacchilega",
+    "Peter Bach",
+    "Timur I. Bakeyev",
+    "Sébastien Bacher",
+    "Chris Ball",
+    "Szabolcs 'Shooby' Bán",
+    "Lasse Bang Mikkelsen",
+    "Matthew Barnes",
+    "Seba Barto",
+    "Emmanuele Bassi",
+    "Martin Baulig",
+    "Tom Bech",
+    "Andreas Beck",
+    "Carlos Amador Bedolla",
+    "Martijn van Beers",
+    "Frank Belew",
+    "Calum Benson",
+    "Jacob Berkman",
+    "Eckehard Berns",
+    "Žygimantas Beručka",
+    "Runa Bhattacharjee",
+    "Robert Bihlmeyer",
+    "Jonathan Blandford <jrb@redhat.com>",
+    "Christopher Blizzard",
+    "Bruno Boaventura",
+    "Евгени Боевски (Evgeni Boevski)",
+    "Jérôme Bolliet",
+    "Andreas Bolsch",
+    "Wouter Bolsterlee",
+    "David Bolter",
+    "Dave Bordoley",
+    "Paolo Borelli",
+    "James Bowes",
+    "Karsten Bräckelmann",
+    "Hendrik Brandt",
+    "Dario Bressanini",
+    "Emmanuel Briot",
+    "Stephen Browne",
+    "Marcus Brubaker",
+    "Christian Bucher",
+    "Ronald S. Bultje",
+    "Rich Burridge",
+    "Ross Burton",
+    "Jeff Cai",
+    "Brian Cameron",
+    "Dave Camp",
+    "Didier Carlier",
+    "Anders Carlsson",
+    "Luca Cavalli",
+    "Chema Celorio",
+    "Youssef Chahibi",
+    "Gaël Chamoulaud",
+    "Сава Чанков (Sava Chankov)",
+    "Damon Chaplin",
+    "Kevin Charter",
+    "Erwann Chénedé",
+    "張 國 冠",
+    "Павел Чолаков (Pavel Cholakov)",
+    "Kenneth Rohde Christiansen",
+    "Bryan Clark",
+    "Chad Clark",
+    "Matthias Clasen",
+    "Andrew Clausen",
+    "Jason Clinton",
+    "Jules Colding",
+    "Jeremy Collins",
+    "Rusty Conover",
+    "Pat Costello",
+    "Phil Cowans",
+    "Alan Cox",
+    "Dennis Cranston",
+    "Mark Crichton",
+    "Frédéric Crozat",
+    "Andreas Czechanowski",
+    "Виктор Дачев (Victor Dachev)",
+    "Johan Dahlin",
+    "Nalin Dahyabhai",
+    "Dan Damian",
+    "Sayamindu Dasgupta",
+    "Phil Dawes",
+    "Fatih Demir",
+    "Guillaume Desmottes",
+    "Frédéric Devernay",
+    "Joanmarie Diggs",
+    "Feico W. Dillema",
+    "Филип Димитров (Philip Dimitrov)",
+    "Carlos Eduardo Rodrigues Diógenes",
+    "Станимир Джевелеков (Stanimir Djevelekov)",
+    "Петър Добрев (Peter Dobrev)",
+    "Явор Доганов (Yavor Doganov)",
+    "Radek Doulik",
+    "Sebastian Dröge",
+    "Máirín Duffy",
+    "Alex Duggan",
+    "László Dvornik",
+    "Tom Dyas",
+    "Karl Eichwalder",
+    "John Ellis",
+    "Diego Escalante Urrelo",
+    "Behdad Esfahbod",
+    "Arturo Espinosa",
+    "Gus Estrella",
+    "David Etherton",
+    "Larry Ewing",
+    "Marc Ewing",
+    "Gergő Érdi",
+    "Peter Fales",
+    "Ahmad Farghal",
+    "Joaquim Fellmann",
+    "Christophe Fergeau",
+    "Jens Finke",
+    "Mark Finlay",
+    "Dave Finton",
+    "Milon Firikis",
+    "John Fleck",
+    "Raúl Perusquia Flores",
+    "Crispin Flowerday",
+    "Lawrence Foard",
+    "Leonardo Fontenelle",
+    "Glynn Foster",
+    "Ben FrantzDale",
+    "Jeff Freedman",
+    "David Abilleira Freijeiro",
+    "Nat Friedman",
+    "Jochen Friedrich",
+    "Adam Fritzler",
+    "Michael Fulbright",
+    "Christopher R. Gabriel",
+    "Mark Galassi",
+    "Tony Gale",
+    "Carlos García Campos",
+    "Matthew Garrett",
+    "Carlos Garnacho Parro",
+    "Jeff Garzik",
+    "Vincent Geddes",
+    "Владимир Герджиков (Vladimir Gerdjikov)",
+    "Tim Gerla",
+    "Björn Giesler",
+    "Quim Gil",
+    "Evandro Fernandes Giovanini",
+    "Владимира Гиргинова (Vladimira Girginova)",
+    "Dave Glowacki",
+    "Scott Goehring",
+    "Jody Goldberg",
+    "Randy Gordon",
+    "Ted Gould",
+    "Jens Granseuer",
+    "Kenny Graunke",
+    "Alex Graveley",
+    "Jamin Philip Gray",
+    "Dov Grobgeld",
+    "Bertrand Guiheneuf",
+    "Alan Aspuru Guzik",
+    "Telsa Gwynne",
+    "Fredrik Hallenberg",
+    "Mikael Hallendal",
+    "Lars Hamann",
+    "Bill Haneman",
+    "Michael Hanni",
+    "Raja R Harinath",
+    "Heath Harrelson",
+    "Peter Harvey",
+    "Mathias Hasselmann",
+    "Peter Hawkins",
+    "Chris Heath",
+    "Scott Heavner",
+    "Sebastian Heinlein",
+    "Jon K Hellan",
+    "James Henstridge <james@daa.com.au>",
+    "Fernando Herrera",
+    "Richard Hestilow",
+    "Raphael Higino",
+    "Thomas Hinkle",
+    "Iain Holmes",
+    "Adam Hooper",
+    "Alan Horkan",
+    "Khaled Hosny",
+    "Ihar Hrachyshka",
+    "Николай Христов (Nikolay Hristov)",
+    "Irene Huang",
+    "Richard Hughes",
+    "David Huggins-Daines",
+    "Richard Hult",
+    "Andreas Hyden",
+    "Miguel de Icaza <miguel@ximian.com>",
+    "Hiroyuki Ikezoe",
+    "Khandakar Mujahidul Islam",
+    "Johnny Jacob",
+    "Mayank Jain",
+    "Vivek Jain",
+    "Tim Janik",
+    "Stefan Jeske",
+    "王 剑",
+    "Amed Ç. Jiyan",
+    "Michael K. Johnson",
+    "Keld Jørn Simonsen",
+    "Andy Kahn",
+    "Mikkel Kamstrup Erlandsen",
+    "Sami Kananoja",
+    "Янко Канети (Yanko Kaneti)",
+    "Ивелина Кърчева (Ivelina Karcheva)",
+    "Theppitak Karoonboonyanan",
+    "Matt Keenan",
+    "Gábor Kelemen",
+    "Michael Kellen",
+    "Christian Kellner",
+    "Stephen Kiernan",
+    "Spencer Kimball",
+    "Christian Kintner",
+    "Christian Kirbach",
+    "Peter Kirchgessner",
+    "Alexander Kirillov",
+    "Димитър Киров (Dimitar Kirov)",
+    "Andre Klapper",
+    "Helmut Köberle",
+    "Alfredo Kojima",
+    "Атанас Кошаров (Atanas Kosharov)",
+    "Martin Kretzschmar",
+    "Harish Krishnaswamy",
+    "Andrew Kuchling",
+    "Tomas Kuliavas",
+    "Stephan Kulow",
+    "Kaushal Kumar",
+    "Nirmal Kumar",
+    "Praveen Kumar",
+    "Martynas Kunigelis",
+    "Tuomas Kuosmanen",
+    "Olof Kylander",
+    "Mathieu Lacage",
+    "Francis J. Lacoste",
+    "Chris Lahey",
+    "Dom Lachowicz",
+    "Scott Laird",
+    "Birger Langkjer",
+    "Ask Hjorth Larsen",
+    "Alexander Larsson",
+    "Guillaume Laurent",
+    "Ole Laursen",
+    "Michael Lausch",
+    "Will LaShell",
+    "Jens Lautenbacher",
+    "Evan Lawrence",
+    "Garrett LeSage",
+    "Jason Leach",
+    "George Lebl",
+    "Gregory Leblanc",
+    "Elliot Lee <sopwith@redhat.com>",
+    "Marc Lehmann",
+    "Noah Levitt",
+    "Raph Levien",
+    "廖 昭 雄",
+    "Tor Lillqvist",
+    "Matt Loper",
+    "Nick Lopez",
+    "Xan Lopez",
+    "Elixan Loran",
+    "Ryan Lortie",
+    "Harry Lu",
+    "Dirk Lutjens",
+    "Josh MacDonald",
+    "Og Maciel",
+    "David MacKay",
+    "Davyd Madeley",
+    "Mohamed Magdy",
+    "Paolo Maggi",
+    "Sam Magnuson",
+    "Ian Main",
+    "David Malcolm",
+    "Jordi Mallach",
+    "Mandrake",
+    "Daniel Manrique",
+    "Kjartan Maraas",
+    "Matthew Marjanovic",
+    "Heath Martin",
+    "Oliver Maruhn",
+    "Fabio Marzocca",
+    "Dave Mason",
+    "James Mastros",
+    "Peter Mattis",
+    "Gordon Matzigkeit",
+    "Dietmar Maurer <dietmar@ximian.com>",
+    "Justin Maurer",
+    "Shaun McCance",
+    "William Jon McCann",
+    "Callum McKenzie",
+    "Gregory McLean",
+    "Mark McLoughlin",
+    "Michael Meeks",
+    "Federico Mena-Quintero",
+    "Christophe Merlet",
+    "Christian Meyer",
+    "Tim Miao",
+    "Gintautas Miliauskas",
+    "Cesar Miquel",
+    "Julian Missig",
+    "Eric B. Mitchell",
+    "Jaka Mocnik",
+    "Paolo Molaro",
+    "Lynn Monsanto",
+    "David Mosberger",
+    "Rodrigo Moya <rodrigo@ximian.com>",
+    "Dan Mueth",
+    "Thomas Muldowney",
+    "Alexandre Muñiz",
+    "Tim-Philipp Müller",
+    "Sivaiah Nallagatla",
+    "남 성 현",
+    "Deepa Natarajan",
+    "Ales Navicki",
+    "Јован Наумовски (Jovan Naumovski)",
+    "Dave Neary",
+    "Karl Nelson",
+    "Elijah Newren",
+    "Christian Neumair",
+    "Mike Newman",
+    "Seth Nickell",
+    "Asger Alstrup Nielsen",
+    "Kenneth Nielsen",
+    "Nate Nielsen",
+    "Eric Nielson",
+    "Bastien Nocera",
+    "Martin Norbäck",
+    "Joachim Noreiko",
+    "Alexander Nyakhaychyk",
+    "Daniel Nylander",
+    "Padraig O'Briain",
+    "Eskil Olsen",
+    "Jimmy Olsen",
+    "David Orme",
+    "Karl Anders Oygard",
+    "Tomas Ögren",
+    "Keith Packard",
+    "Jay Painter",
+    "Chenthill Palanisamy",
+    "John Palmieri",
+    "Cameron Parish",
+    "Conrad Parker",
+    "Stuart Parmenter",
+    "Guilherme de S. Pastore",
+    "Sankarasivasubramaniam Pasupathilingam",
+    "Данило Шеган",
+    "Mike Pedersen",
+    "Nils Pedersen",
+    "Илия Пенев (Ilia Penev)",
+    "Havoc Pennington",
+    "Ettore Perazzoli",
+    "Carlos Perelló Marín",
+    "Christian Persch",
+    "Marco Pesenti Gritti",
+    "Ian Peters",
+    "Martin Kasper Petersen",
+    "Christof Petig",
+    "Владимир Петков (Vladimir \"Kaladan\" Petkov)",
+    "Joe Pfeiffer",
+    "Ben Pierce",
+    "Chris Pinkham",
+    "Hasbullah Bin Pit",
+    "Sebastian Pölsterl",
+    "Germán Poo-Caamaño",
+    "Пейо Попов (Peio Popov)",
+    "Dick Porter",
+    "Ясен Праматаров (Yasen Pramatarov)",
+    "Tero Pulkkinen",
+    "Атанас Пюскюлев (Atanas Pyuskyulev)",
+    "Sushma Rai",
+    "Ростислав Райков (Rostislav \"zbrox\" Raikov)",
+    "Madhan Raj M.",
+    "Srinivasa Ragavan",
+    "Rajeev Ramanathan",
+    "Jean-François Rameau",
+    "Sriram Ramkrishna",
+    "The Rasterman",
+    "Oliver Rauch",
+    "Lucas Rocha",
+    "Erdal Ronahi",
+    "Andreas Røsdal",
+    "Christian Rose",
+    "Cody Russell",
+    "Reklaw",
+    "Jens Christian Restemeier",
+    "Patrick Reynolds",
+    "Robert Richardson",
+    "Hendrik Richter",
+    "Kristian Rietveld",
+    "Sebastian Rittau",
+    "Alex Roberts",
+    "Michel Roelofs",
+    "Ueli Rutishauser",
+    "Lars Rydlinge",
+    "Peter Ryland",
+    "Claudio Saavedra",
+    "Joseph Sacco",
+    "Bibek Sahu",
+    "Arvind Samptur",
+    "Søren Sandmann",
+    "Damien Sandras",
+    "Pablo Saratxaga",
+    "笹 山 和 宏",
+    "Carsten Schaar",
+    "Christian Schaller",
+    "Wayne Schuller",
+    "Franck Schneider",
+    "Ingo Schneider",
+    "Bernd Schroeder",
+    "John Schulien",
+    "Chris Scobell",
+    "Don Scorgie",
+    "Jens Seidel",
+    "Dodji Seketeli",
+    "Shakti Sen",
+    "Iñigo Serna",
+    "Shaleh",
+    "Devashish Sharma",
+    "Joe Shaw",
+    "Александър Шопов (Alexander Shopov)",
+    "Clytie Siddall",
+    "Alejandro Aguilar Sierra",
+    "Miroslav Silovic",
+    "Manish Singh",
+    "Timo Sirainen",
+    "David F. Skoll",
+    "Jochen Skulj",
+    "Nuke Skyjumper",
+    "Петър Славов (Peter \"Peshka\" Slavov)",
+    "Josh Sled",
+    "John Slee",
+    "Raphaël Slinckx",
+    "Brent Smith",
+    "Garrett Smith",
+    "Suzanna Smith",
+    "Andrew Sobala",
+    "Shreyas Srinivasan",
+    "Maciej Stachowiak",
+    "Stalyn",
+    "Jeffrey Stedfast",
+    "Jakub Steiner",
+    "Ben Stern",
+    "Micah Stetson",
+    "Ray Strode",
+    "Luke Stroven",
+    "Mariano Suárez-Alvarez",
+    "Parthasarathi Susarla",
+    "Nathan Carl Summers",
+    "Istvan Szekeres",
+    "Петър Тахчиев (Peter Tahchiev)",
+    "HideToshi Tajima",
+    "Nigel Tao",
+    "Tristan Tarrant",
+    "Anthony Taylor",
+    "Owen Taylor",
+    "Peter Teichman",
+    "Arturo Tena",
+    "Thomas Thurman",
+    "Kimball Thurston",
+    "András Tímár",
+    "Boyd Timothy",
+    "Rêzan Tovjîn",
+    "Alp Toker",
+    "Chris Toshok",
+    "Christoph Toshok",
+    "Malcolm Tredinnick",
+    "Tom Tromey <tromey@redhat.com>",
+    "David Trowbridge",
+    "Jon Trowbridge",
+    "段 活 文",
+    "Сергей В. Удальцов",
+    "Juan Pablo Ugarte",
+    "Vincent Untz",
+    "Manish Vachharajani",
+    "Neil Vachharajani",
+    "Tristan Van Berkom",
+    "Philip Van Hoof",
+    "Thomas Vander Stichele",
+    "Veerapuram Varadhan",
+    "Васил Василев (Vasil Vasilev)",
+    "Daniel Veillard",
+    "Vendu",
+    "Andrew Veliath",
+    "Юлия Велкова (Julia Velkova)",
+    "Luis Villa",
+    "Olav Vitters",
+    "Marius Vollmer",
+    "Patrick Wade",
+    "Shawn Wagner",
+    "Will Walker",
+    "Hanna Wallach",
+    "Colin Walters",
+    "Matthias Warkus",
+    "Jeff Waugh",
+    "Morten Welinder",
+    "Jonh Wendell",
+    "Bruno Widmann",
+    "Robert Wilhelm",
+    "Sebastian Wilhelmi",
+    "Dan Williams",
+    "James Willcox",
+    "David Winkler",
+    "Dan Winship",
+    "Jeremy Wise",
+    "Roger Wolff",
+    "Ivan Wong",
+    "Frank Worsley",
+    "Rizoyê Xerzî",
+    "Wang Xin",
+    "James Youngman",
+    "Mengjie Yu",
+    "Li Yuan",
+    "Orest Zborowski",
+    "Simon Zheng",
+    "Sascha Ziemann",
+    "Michael Zucchi",
+    "Jason van Zyl",
+    NULL
+};
+
+// documentation
+const char* documenters[] = {
+    "...", // TODO: fillme
+    NULL
+};
+// artists
+const char* artists[] = {
+    "Marcel Dijkstra <marcel.dykstra@gmail.com>",
+    "Rowen Stipe <rowen.stipe@gmail.com>",
+    "Wolfgang Ulbrich <chat-to-me@raveit.de>",
+    NULL
+};
+
+// widget for mate-about window
+GtkAboutDialog* mate_about_dialog = FALSE;
+
+GtkApplication* mate_about_application;
+
+/**
+ * If this value is set to TRUE, then mate_about_dialog will not be called
+ * on the main function.
+ */
+gboolean mate_about_nogui = FALSE;
+// functions
+void mate_about_run(void);
+void mate_about_release_version(void);
+
+static void mate_about_on_activate(GtkApplication* app);
+
+// arguments definitions
+static GOptionEntry command_entries[] = {
+    {"version", 'v', 0, G_OPTION_ARG_NONE, &mate_about_nogui, "Show MATE version", NULL},
+    {NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL}
+};
+
+#endif /* __MATE_ABOUT_H__ */
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/44.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/44.html new file mode 100644 index 0000000..1d3c296 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/44.html @@ -0,0 +1,417 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+82
+83
+84
+85
+86
+87
+88
+89
+90
/*
+ * mate-color.c: MATE color selection tool
+ *
+ * Copyright (C) 2014 Stefano Karapetsas
+ * Copyright (C) 2014-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Authors:
+ *  Stefano Karapetsas <stefano@karapetsas.com>
+ */
+
+#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <libmate-desktop/mate-colorseldialog.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <libmate-desktop/mate-colorsel.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+static gboolean
+copy_color (GtkWidget *widget, GdkEvent  *event, MateColorSelectionDialog *color_dialog)
+{
+    GdkColor color;
+    gchar *color_string;
+
+    mate_color_selection_get_current_color (MATE_COLOR_SELECTION (color_dialog->colorsel), &color);
+    g_object_get (color_dialog->colorsel, "hex-string", &color_string, NULL);
+
+    gtk_clipboard_set_text (gtk_clipboard_get (GDK_SELECTION_CLIPBOARD), color_string, -1);
+
+    g_free (color_string);
+    return 0;
+}
+
+int
+main (int argc, char **argv)
+{
+    GtkWidget *color_dialog = NULL;
+    GtkWidget *color_selection;
+    GtkWidget *widget;
+    GtkWidget *image;
+
+    bindtextdomain (GETTEXT_PACKAGE, LOCALE_DIR);
+    bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+    textdomain (GETTEXT_PACKAGE);
+
+    /* initialize GTK+ */
+    gtk_init (&argc, &argv);
+    gtk_window_set_default_icon_name ("gtk-select-color");
+
+    color_dialog = mate_color_selection_dialog_new (_("MATE Color Selection"));
+    color_selection = MATE_COLOR_SELECTION_DIALOG (color_dialog)->colorsel;
+    mate_color_selection_set_has_palette (MATE_COLOR_SELECTION (color_selection), TRUE);
+
+    /* quit signal */
+    g_signal_connect (color_dialog, "destroy", gtk_main_quit, NULL);
+
+    widget = gtk_button_new_with_mnemonic (_("_Copy"));
+    image = gtk_image_new_from_icon_name ("edit-copy", GTK_ICON_SIZE_BUTTON);
+    gtk_button_set_image (GTK_BUTTON (widget), image);
+    gtk_dialog_add_action_widget (GTK_DIALOG (color_dialog), widget, GTK_RESPONSE_ACCEPT);
+    g_signal_connect (widget, "button-release-event", G_CALLBACK (copy_color), color_dialog);
+
+    widget = gtk_button_new_with_mnemonic (_("_Close"));
+    image = gtk_image_new_from_icon_name ("window-close", GTK_ICON_SIZE_BUTTON);
+    gtk_button_set_image (GTK_BUTTON (widget), image);
+    gtk_dialog_add_action_widget (GTK_DIALOG (color_dialog), widget, GTK_RESPONSE_CLOSE);
+    g_signal_connect (widget, "button-release-event", gtk_main_quit, NULL);
+
+    gtk_widget_show_all (color_dialog);
+    gtk_widget_hide (MATE_COLOR_SELECTION_DIALOG (color_dialog)->ok_button);
+    gtk_widget_hide (MATE_COLOR_SELECTION_DIALOG (color_dialog)->cancel_button);
+    gtk_widget_hide (MATE_COLOR_SELECTION_DIALOG (color_dialog)->help_button);
+
+    /* start application */
+    gtk_main ();
+    return 0;
+}
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/45.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/45.html new file mode 100644 index 0000000..355a1f8 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/45.html @@ -0,0 +1,1777 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
+603
+604
+605
+606
+607
+608
+609
+610
+611
+612
+613
+614
+615
+616
+617
+618
+619
+620
+621
+622
+623
+624
+625
+626
+627
+628
+629
+630
+631
+632
+633
+634
+635
+636
+637
+638
+639
+640
+641
+642
+643
+644
+645
+646
+647
+648
+649
+650
+651
+652
+653
+654
+655
+656
+657
+658
+659
+660
+661
+662
+663
+664
+665
+666
+667
+668
+669
+670
+671
+672
+673
+674
+675
+676
+677
+678
+679
+680
+681
+682
+683
+684
+685
+686
+687
+688
+689
+690
+691
+692
+693
+694
+695
+696
+697
+698
+699
+700
+701
+702
+703
+704
+705
+706
+707
+708
+709
+710
+711
+712
+713
+714
+715
+716
+717
+718
+719
+720
+721
+722
+723
+724
+725
+726
+727
+728
+729
+730
+731
+732
+733
+734
+735
+736
+737
+738
+739
+740
+741
+742
+743
+744
+745
+746
+747
+748
+749
+750
+751
+752
+753
+754
+755
+756
+757
+758
+759
+760
+761
+762
+763
+764
+765
+766
+767
+768
+769
+770
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007-2008 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "config.h"<--- Include file: "config.h" not found.
+
+#include <math.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "egg-array-float.h"
+
+/**
+ * egg_array_float_guassian_value:
+ *
+ * @x: input value
+ * @sigma: sigma value
+ * Return value: the gaussian, in floating point precision
+ **/
+static gfloat
+egg_array_float_guassian_value (gfloat x, gfloat sigma)
+{
+	return (1.0 / (sqrtf(2.0*3.1415927) * sigma)) * (expf((-(powf(x,2.0)))/(2.0 * powf(sigma, 2.0))));
+}
+
+/**
+ * egg_array_float_new:
+ *
+ * @length: length of array
+ * Return value: Allocate array
+ *
+ * Creates a new size array which is zeroed. Free with g_array_free();
+ **/
+EggArrayFloat *
+egg_array_float_new (guint length)
+{
+	guint i;
+	EggArrayFloat *array;
+	array = g_array_sized_new (TRUE, FALSE, sizeof(gfloat), length);
+	array->len = length;
+
+	/* clear to 0.0 */
+	for (i=0; i<length; i++)
+		g_array_index (array, gfloat, i) = 0.0;
+	return array;
+}
+
+/**
+ * egg_array_float_get:
+ *
+ * @array: input array
+ **/
+gfloat
+egg_array_float_get (EggArrayFloat *array, guint i)
+{
+	if (i >= array->len)
+		g_error ("above index! (%u)", i);
+	return g_array_index (array, gfloat, i);
+}
+
+/**
+ * egg_array_float_set:
+ *
+ * @array: input array
+ **/
+void
+egg_array_float_set (EggArrayFloat *array, guint i, gfloat value)
+{
+	g_array_index (array, gfloat, i) = value;
+}
+
+/**
+ * egg_array_float_free:
+ *
+ * @array: input array
+ *
+ * Frees the array, deallocating data
+ **/
+void
+egg_array_float_free (EggArrayFloat *array)
+{
+	if (array != NULL)
+		g_array_free (array, TRUE);
+}
+
+/**
+ * egg_array_float_get_average:
+ * @array: This class instance
+ *
+ * Gets the average value.
+ **/
+gfloat
+egg_array_float_get_average (EggArrayFloat *array)
+{
+	guint i;
+	guint length;
+	gfloat average = 0;
+
+	length = array->len;
+	for (i=0; i<length; i++)
+		average += g_array_index (array, gfloat, i);
+	return average / (gfloat) length;
+}
+
+/**
+ * egg_array_float_compute_gaussian:
+ *
+ * @length: length of output array
+ * @sigma: sigma value
+ * Return value: Gaussian array
+ *
+ * Create a set of Gaussian array of a specified size
+ **/
+EggArrayFloat *
+egg_array_float_compute_gaussian (guint length, gfloat sigma)
+{
+	EggArrayFloat *array;
+	guint half_length;
+	guint i;
+	gfloat division;
+	gfloat value;
+
+	g_return_val_if_fail (length % 2 == 1, NULL);
+
+	array = egg_array_float_new (length);
+
+	/* array positions 0..length, has to be an odd number */
+	half_length = (length / 2) + 1;
+	for (i=0; i<half_length; i++) {
+		division = half_length - (i + 1);
+	g_debug ("half_length=%u, div=%f, sigma=%f", half_length, division, sigma);
+		g_array_index (array, gfloat, i) = egg_array_float_guassian_value (division, sigma);
+	}
+
+	/* no point working these out, we can just reflect the gaussian */
+	for (i=half_length; i<length; i++) {
+		division = g_array_index (array, gfloat, length-(i+1));
+		g_array_index (array, gfloat, i) = division;
+	}
+
+	/* make sure we get an accurate gaussian */
+	value = egg_array_float_sum (array);
+	if (fabs (value - 1.0f) > 0.01f) {
+		g_warning ("got wrong sum (%f), perhaps sigma too high for size?", value);
+		egg_array_float_free (array);
+		array = NULL;
+	}
+
+	return array;
+}
+
+/**
+ * egg_array_float_sum:
+ *
+ * @array: input array
+ *
+ * Sum the elements of the array
+ **/
+gfloat
+egg_array_float_sum (EggArrayFloat *array)
+{
+	guint length;
+	guint i;
+	gfloat total = 0;
+
+	length = array->len;
+	for (i=0; i<length; i++)
+		total += g_array_index (array, gfloat, i);
+	return total;
+}
+
+/**
+ * egg_array_float_print:
+ *
+ * @array: input array
+ *
+ * Print the array
+ **/
+gboolean
+egg_array_float_print (EggArrayFloat *array)
+{
+	guint length;
+	guint i;
+
+	length = array->len;
+	/* debug out */
+	for (i=0; i<length; i++)
+		g_debug ("[%u]\tval=%f", i, g_array_index (array, gfloat, i));
+	return TRUE;
+}
+
+/**
+ * egg_array_float_convolve:
+ *
+ * @data: input array
+ * @kernel: kernel array
+ * Return value: Colvolved array, same length as data
+ *
+ * Convolves an array with a kernel, and returns an array the same size.
+ * THIS FUNCTION IS REALLY SLOW...
+ **/
+EggArrayFloat *
+egg_array_float_convolve (EggArrayFloat *data, EggArrayFloat *kernel)
+{
+	gint length_data;
+	gint length_kernel;
+	EggArrayFloat *result;
+	gfloat value;
+	gint i;
+	gint j;
+	gint idx;
+
+	length_data = data->len;
+	length_kernel = kernel->len;
+
+	result = egg_array_float_new (length_data);
+
+	/* convolve */
+	for (i=0;i<length_data;i++) {
+		value = 0;
+		for (j=0;j<length_kernel;j++) {
+			idx = i+j-(length_kernel/2);
+			if (idx < 0)
+				idx = 0;
+			else if (idx >= length_data)
+				idx = length_data - 1;
+			value += g_array_index (data, gfloat, idx) * g_array_index (kernel, gfloat, j);
+		}
+		g_array_index (result, gfloat, i) = value;
+	}
+	return result;
+}
+
+/**
+ * egg_array_float_compute_integral:
+ * @array: This class instance
+ *
+ * Computes complete discrete integral of dataset.
+ * Will only work with a step size of one.
+ **/
+gfloat
+egg_array_float_compute_integral (EggArrayFloat *array, guint x1, guint x2)
+{
+	gfloat value;
+	guint i;
+
+	g_return_val_if_fail (x2 >= x1, 0.0);
+
+	/* if the same point, then we have no area */
+	if (x1 == x2)
+		return 0.0;
+
+	value = 0.0;
+	for (i=x1; i <= x2; i++)
+		value += g_array_index (array, gfloat, i);
+	return value;
+}
+
+/**
+ * powfi:
+ **/
+static gfloat
+powfi (gfloat base, guint n)
+{
+	guint i;
+	gfloat retval = 1;
+	for (i=1; i <= n; i++)
+		retval *= base;
+	return retval;
+}
+
+/**
+ * egg_array_float_remove_outliers:
+ *
+ * @data: input array
+ * @size: size to analyse
+ * @sigma: sigma for standard deviation
+ * Return value: Data with outliers removed
+ *
+ * Compares local sections of the data, removing outliers if they fall
+ * outside of sigma, and using the average of the other points in its place.
+ **/
+EggArrayFloat *
+egg_array_float_remove_outliers (EggArrayFloat *data, guint length, gfloat sigma)
+{
+	guint i;
+	guint j;
+	guint half_length;
+	gfloat value;
+	gfloat average;
+	gfloat average_not_inc;
+	gfloat average_square;
+	gfloat biggest_difference;
+	gfloat outlier_value;
+	EggArrayFloat *result;
+
+	g_return_val_if_fail (length % 2 == 1, NULL);
+	result = egg_array_float_new (data->len);
+
+	/* check for no data */
+	if (data->len == 0)
+		goto out;
+
+	half_length = (length - 1) / 2;
+
+	/* copy start and end of array */
+	for (i=0; i < half_length; i++)
+		g_array_index (result, gfloat, i) = g_array_index (data, gfloat, i);
+	for (i=data->len-half_length; i < data->len; i++)
+		g_array_index (result, gfloat, i) = g_array_index (data, gfloat, i);
+
+	/* find the standard deviation of a block off data */
+	for (i=half_length; i < data->len-half_length; i++) {
+		average = 0;
+		average_square = 0;
+
+		/* find the average and the squared average */
+		for (j=i-half_length; j<i+half_length+1; j++) {
+			value = g_array_index (data, gfloat, j);
+			average += value;
+			average_square += powfi (value, 2);
+		}
+
+		/* divide by length to get average */
+		average /= length;
+		average_square /= length;
+
+		/* find the standard deviation */
+		value = sqrtf (average_square - powfi (average, 2));
+
+		/* stddev is okay */
+		if (value < sigma) {
+			g_array_index (result, gfloat, i) = g_array_index (data, gfloat, i);
+		} else {
+			/* ignore the biggest difference from the average */
+			biggest_difference = 0;
+			outlier_value = 0;
+			for (j=i-half_length; j<i+half_length+1; j++) {
+				value = fabs (g_array_index (data, gfloat, j) - average);
+				if (value > biggest_difference) {
+					biggest_difference = value;
+					outlier_value = g_array_index (data, gfloat, j);
+				}
+			}
+			average_not_inc = (average * length) - outlier_value;
+			average_not_inc /= length - 1;
+			g_array_index (result, gfloat, i) = average_not_inc;
+		}
+	}
+out:
+	return result;
+}
+
+/***************************************************************************
+ ***                          MAKE CHECK TESTS                           ***
+ ***************************************************************************/
+#ifdef EGG_TEST
+#include "egg-test.h"
+
+void
+egg_array_float_test (gpointer data)
+{
+	EggArrayFloat *array;
+	EggArrayFloat *kernel;
+	EggArrayFloat *result;
+	gfloat value;
+	gfloat sigma;
+	guint size;
+	EggTest *test = (EggTest *) data;
+
+	if (egg_test_start (test, "EggArrayFloat") == FALSE)
+		return;
+
+	/************************************************************/
+	egg_test_title (test, "make sure we get a non null array");
+	array = egg_array_float_new (10);
+	if (array != NULL)
+		egg_test_success (test, "got EggArrayFloat");
+	else
+		egg_test_failed (test, "could not get EggArrayFloat");
+	egg_array_float_print (array);
+	egg_array_float_free (array);
+
+	/************************************************************/
+	egg_test_title (test, "make sure we get the correct length array");
+	array = egg_array_float_new (10);
+	if (array->len == 10)
+		egg_test_success (test, "got correct size");
+	else
+		egg_test_failed (test, "got wrong size");
+
+	/************************************************************/
+	egg_test_title (test, "make sure we get the correct array sum");
+	value = egg_array_float_sum (array);
+	if (value == 0.0)
+		egg_test_success (test, "got correct sum");
+	else
+		egg_test_failed (test, "got wrong sum (%f)", value);
+
+	/************************************************************/
+	egg_test_title (test, "remove outliers");
+	egg_array_float_set (array, 0, 30.0);
+	egg_array_float_set (array, 1, 29.0);
+	egg_array_float_set (array, 2, 31.0);
+	egg_array_float_set (array, 3, 33.0);
+	egg_array_float_set (array, 4, 100.0);
+	egg_array_float_set (array, 5, 27.0);
+	egg_array_float_set (array, 6, 30.0);
+	egg_array_float_set (array, 7, 29.0);
+	egg_array_float_set (array, 8, 31.0);
+	egg_array_float_set (array, 9, 30.0);
+	kernel = egg_array_float_remove_outliers (array, 3, 10.0);
+	if (kernel != NULL && kernel->len == 10)
+		egg_test_success (test, "got correct length outlier array");
+	else
+		egg_test_failed (test, "got gaussian array length (%i)", array->len);
+	egg_array_float_print (array);
+	egg_array_float_print (kernel);
+
+	/************************************************************/
+	egg_test_title (test, "make sure we removed the outliers");
+	value = egg_array_float_sum (kernel);
+	if (fabs(value - 30*10) < 1)
+		egg_test_success (test, "got sum (%f)", value);
+	else
+		egg_test_failed (test, "got wrong sum (%f)", value);
+	egg_array_float_free (kernel);
+
+	/************************************************************/
+	egg_test_title (test, "remove outliers step");
+	egg_array_float_set (array, 0, 0.0);
+	egg_array_float_set (array, 1, 0.0);
+	egg_array_float_set (array, 2, 0.0);
+	egg_array_float_set (array, 3, 0.0);
+	egg_array_float_set (array, 4, 0.0);
+	egg_array_float_set (array, 5, 0.0);
+	egg_array_float_set (array, 6, 0.0);
+	egg_array_float_set (array, 7, 10.0);
+	egg_array_float_set (array, 8, 20.0);
+	egg_array_float_set (array, 9, 50.0);
+	kernel = egg_array_float_remove_outliers (array, 3, 20.0);
+	if (kernel != NULL && kernel->len == 10)
+		egg_test_success (test, "got correct length outlier array");
+	else
+		egg_test_failed (test, "got gaussian array length (%i)", array->len);
+	egg_array_float_print (array);
+	egg_array_float_print (kernel);
+
+	/************************************************************/
+	egg_test_title (test, "make sure we removed the outliers");
+	value = egg_array_float_sum (kernel);
+	if (fabs(value - 80) < 1)
+		egg_test_success (test, "got sum (%f)", value);
+	else
+		egg_test_failed (test, "got wrong sum (%f)", value);
+	egg_array_float_free (kernel);
+
+	/************************************************************/
+	egg_test_title (test, "get gaussian 0.0, sigma 1.1");
+	value = egg_array_float_guassian_value (0.0, 1.1);
+	if (fabs (value - 0.36267) < 0.0001)
+		egg_test_success (test, "got correct gaussian");
+	else
+		egg_test_failed (test, "got wrong gaussian (%f)", value);
+
+	/************************************************************/
+	egg_test_title (test, "get gaussian 0.5, sigma 1.1");
+	value = egg_array_float_guassian_value (0.5, 1.1);
+	if (fabs (value - 0.32708) < 0.0001)
+		egg_test_success (test, "got correct gaussian");
+	else
+		egg_test_failed (test, "got wrong gaussian (%f)", value);
+
+	/************************************************************/
+	egg_test_title (test, "get gaussian 1.0, sigma 1.1");
+	value = egg_array_float_guassian_value (1.0, 1.1);
+	if (fabs (value - 0.23991) < 0.0001)
+		egg_test_success (test, "got correct gaussian");
+	else
+		egg_test_failed (test, "got wrong gaussian (%f)", value);
+
+	/************************************************************/
+	egg_test_title (test, "get gaussian 0.5, sigma 4.5");
+	value = egg_array_float_guassian_value (0.5, 4.5);
+	if (fabs (value - 0.088108) < 0.0001)
+		egg_test_success (test, "got correct gaussian");
+	else
+		egg_test_failed (test, "got wrong gaussian (%f)", value);
+
+	/************************************************************/
+	size = 5;
+	sigma = 1.1;
+	egg_test_title (test, "get inprecise gaussian array (%i), sigma %f", size, sigma);
+	kernel = egg_array_float_compute_gaussian (size, sigma);
+	if (kernel == NULL)
+		egg_test_success (test, NULL);
+	else {
+		egg_test_failed (test, "got gaussian array length (%i)", array->len);
+		egg_array_float_print (kernel);
+	}
+
+	/************************************************************/
+	size = 9;
+	sigma = 1.1;
+	egg_test_title (test, "get gaussian-9 array (%i), sigma %f", size, sigma);
+	kernel = egg_array_float_compute_gaussian (size, sigma);
+	if (kernel != NULL && kernel->len == size)
+		egg_test_success (test, "got correct length gaussian array");
+	else
+		egg_test_failed (test, "got gaussian array length (%i)", array->len);
+	egg_array_float_print (kernel);
+
+	/************************************************************/
+	egg_test_title (test, "make sure we get an accurate gaussian");
+	value = egg_array_float_sum (kernel);
+	if (fabs(value - 1.0) < 0.01)
+		egg_test_success (test, "got sum (%f)", value);
+	else
+		egg_test_failed (test, "got wrong sum (%f)", value);
+
+	/************************************************************/
+	egg_test_title (test, "make sure we get get and set");
+	egg_array_float_set (array, 4, 100.0);
+	value = egg_array_float_get (array, 4);
+	if (value == 100.0)
+		egg_test_success (test, "got value okay", value);
+	else
+		egg_test_failed (test, "got wrong value (%f)", value);
+	egg_array_float_print (array);
+
+	/************************************************************/
+	egg_test_title (test, "make sure we get the correct array sum (2)");
+	egg_array_float_set (array, 0, 20.0);
+	egg_array_float_set (array, 1, 44.0);
+	egg_array_float_set (array, 2, 45.0);
+	egg_array_float_set (array, 3, 89.0);
+	egg_array_float_set (array, 4, 100.0);
+	egg_array_float_set (array, 5, 12.0);
+	egg_array_float_set (array, 6, 76.0);
+	egg_array_float_set (array, 7, 78.0);
+	egg_array_float_set (array, 8, 1.20);
+	egg_array_float_set (array, 9, 3.0);
+	value = egg_array_float_sum (array);
+	if (fabs (value - 468.2) < 0.0001f)
+		egg_test_success (test, "got correct sum");
+	else
+		egg_test_failed (test, "got wrong sum (%f)", value);
+
+	/************************************************************/
+	egg_test_title (test, "test convolving with kernel #1");
+	egg_array_float_set (array, 0, 0.0);
+	egg_array_float_set (array, 1, 0.0);
+	egg_array_float_set (array, 2, 0.0);
+	egg_array_float_set (array, 3, 0.0);
+	egg_array_float_set (array, 4, 100.0);
+	egg_array_float_set (array, 5, 0.0);
+	egg_array_float_set (array, 6, 0.0);
+	egg_array_float_set (array, 7, 0.0);
+	egg_array_float_set (array, 8, 0.0);
+	egg_array_float_set (array, 9, 0.0);
+	result = egg_array_float_convolve (array, kernel);
+	if (result->len == 10)
+		egg_test_success (test, "got correct size convolve product");
+	else
+		egg_test_failed (test, "got correct size convolve product (%f)", result->len);
+	egg_array_float_print (result);
+
+	/************************************************************/
+	egg_test_title (test, "make sure we get the correct array sum of convolve #1");
+	value = egg_array_float_sum (result);
+	if (fabs(value - 100.0) < 5.0)
+		egg_test_success (test, "got correct (enough) sum (%f)", value);
+	else
+		egg_test_failed (test, "got wrong sum (%f)", value);
+	egg_array_float_free (result);
+
+	/************************************************************/
+	egg_test_title (test, "test convolving with kernel #2");
+	egg_array_float_set (array, 0, 100.0);
+	egg_array_float_set (array, 1, 0.0);
+	egg_array_float_set (array, 2, 0.0);
+	egg_array_float_set (array, 3, 0.0);
+	egg_array_float_set (array, 4, 0.0);
+	egg_array_float_set (array, 5, 0.0);
+	egg_array_float_set (array, 6, 0.0);
+	egg_array_float_set (array, 7, 0.0);
+	egg_array_float_set (array, 8, 0.0);
+	egg_array_float_set (array, 9, 0.0);
+	result = egg_array_float_convolve (array, kernel);
+	if (result->len == 10)
+		egg_test_success (test, "got correct size convolve product");
+	else
+		egg_test_failed (test, "got correct size convolve product (%f)", result->len);
+	egg_array_float_print (array);
+	egg_array_float_print (result);
+
+	/************************************************************/
+	egg_test_title (test, "make sure we get the correct array sum of convolve #2");
+	value = egg_array_float_sum (result);
+	if (fabs(value - 100.0) < 10.0)
+		egg_test_success (test, "got correct (enough) sum (%f)", value);
+	else
+		egg_test_failed (test, "got wrong sum (%f)", value);
+
+	egg_array_float_free (result);
+
+	/************************************************************/
+	egg_test_title (test, "test convolving with kernel #3");
+	egg_array_float_set (array, 0, 0.0);
+	egg_array_float_set (array, 1, 0.0);
+	egg_array_float_set (array, 2, 0.0);
+	egg_array_float_set (array, 3, 0.0);
+	egg_array_float_set (array, 4, 0.0);
+	egg_array_float_set (array, 5, 0.0);
+	egg_array_float_set (array, 6, 0.0);
+	egg_array_float_set (array, 7, 0.0);
+	egg_array_float_set (array, 8, 0.0);
+	egg_array_float_set (array, 9, 100.0);
+	result = egg_array_float_convolve (array, kernel);
+	if (result->len == 10)
+		egg_test_success (test, "got correct size convolve product");
+	else
+		egg_test_failed (test, "got correct size convolve product (%f)", result->len);
+	egg_array_float_print (array);
+	egg_array_float_print (result);
+
+	/************************************************************/
+	egg_test_title (test, "make sure we get the correct array sum of convolve #3");
+	value = egg_array_float_sum (result);
+	if (fabs(value - 100.0) < 10.0)
+		egg_test_success (test, "got correct (enough) sum (%f)", value);
+	else
+		egg_test_failed (test, "got wrong sum (%f)", value);
+	egg_array_float_free (result);
+
+	/************************************************************/
+	egg_test_title (test, "test convolving with kernel #4");
+	egg_array_float_set (array, 0, 10.0);
+	egg_array_float_set (array, 1, 10.0);
+	egg_array_float_set (array, 2, 10.0);
+	egg_array_float_set (array, 3, 10.0);
+	egg_array_float_set (array, 4, 10.0);
+	egg_array_float_set (array, 5, 10.0);
+	egg_array_float_set (array, 6, 10.0);
+	egg_array_float_set (array, 7, 10.0);
+	egg_array_float_set (array, 8, 10.0);
+	egg_array_float_set (array, 9, 10.0);
+	result = egg_array_float_convolve (array, kernel);
+	if (result->len == 10)
+		egg_test_success (test, "got correct size convolve product");
+	else
+		egg_test_failed (test, "got incorrect size convolve product (%f)", result->len);
+	egg_array_float_print (array);
+	egg_array_float_print (result);
+
+	/************************************************************/
+	egg_test_title (test, "make sure we get the correct array sum of convolve #4");
+	value = egg_array_float_sum (result);
+	if (fabs(value - 100.0) < 1.0)
+		egg_test_success (test, "got correct (enough) sum (%f)", value);
+	else
+		egg_test_failed (test, "got wrong sum (%f)", value);
+
+	/************************************************************/
+	egg_test_title (test, "test convolving with kernel #5");
+	egg_array_float_set (array, 0, 10.0);
+	egg_array_float_set (array, 1, 10.0);
+	egg_array_float_set (array, 2, 10.0);
+	egg_array_float_set (array, 3, 10.0);
+	egg_array_float_set (array, 4, 0.0);
+	egg_array_float_set (array, 5, 10.0);
+	egg_array_float_set (array, 6, 10.0);
+	egg_array_float_set (array, 7, 10.0);
+	egg_array_float_set (array, 8, 10.0);
+	egg_array_float_set (array, 9, 10.0);
+	result = egg_array_float_convolve (array, kernel);
+	if (result->len == 10)
+		egg_test_success (test, "got correct size convolve product");
+	else
+		egg_test_failed (test, "got incorrect size convolve product (%f)", result->len);
+	egg_array_float_print (array);
+	egg_array_float_print (result);
+
+	/************************************************************/
+	egg_test_title (test, "make sure we get the correct array sum of convolve #5");
+	value = egg_array_float_sum (result);
+	if (fabs(value - 90.0) < 1.0)
+		egg_test_success (test, "got correct (enough) sum (%f)", value);
+	else
+		egg_test_failed (test, "got wrong sum (%f)", value);
+
+	/*************** INTEGRATION TEST ************************/
+	egg_test_title (test, "integration down");
+	egg_array_float_set (array, 0, 0.0);
+	egg_array_float_set (array, 1, 1.0);
+	egg_array_float_set (array, 2, 2.0);
+	egg_array_float_set (array, 3, 3.0);
+	egg_array_float_set (array, 4, 4.0);
+	egg_array_float_set (array, 5, 5.0);
+	egg_array_float_set (array, 6, 6.0);
+	egg_array_float_set (array, 7, 7.0);
+	egg_array_float_set (array, 8, 8.0);
+	egg_array_float_set (array, 9, 9.0);
+	size = egg_array_float_compute_integral (array, 0, 4);
+	if (size == 0+1+2+3+4)
+		egg_test_success (test, "intergrated okay");
+	else
+		egg_test_failed (test, "did not intergrated okay (%i)", size);
+	egg_test_title (test, "integration up");
+	size = egg_array_float_compute_integral (array, 5, 9);
+	if (size == 5+6+7+8+9)
+		egg_test_success (test, "intergrated okay");
+	else
+		egg_test_failed (test, "did not intergrated okay (%i)", size);
+	egg_test_title (test, "integration all");
+	size = egg_array_float_compute_integral (array, 0, 9);
+	if (size == 0+1+2+3+4+5+6+7+8+9)
+		egg_test_success (test, "intergrated okay");
+	else
+		egg_test_failed (test, "did not intergrated okay (%i)", size);
+
+	/*************** AVERAGE TEST ************************/
+	egg_test_title (test, "average");
+	egg_array_float_set (array, 0, 0.0);
+	egg_array_float_set (array, 1, 1.0);
+	egg_array_float_set (array, 2, 2.0);
+	egg_array_float_set (array, 3, 3.0);
+	egg_array_float_set (array, 4, 4.0);
+	egg_array_float_set (array, 5, 5.0);
+	egg_array_float_set (array, 6, 6.0);
+	egg_array_float_set (array, 7, 7.0);
+	egg_array_float_set (array, 8, 8.0);
+	egg_array_float_set (array, 9, 9.0);
+	value = egg_array_float_get_average (array);
+	if (value == 4.5)
+		egg_test_success (test, "averaged okay");
+	else
+		egg_test_failed (test, "did not average okay (%i)", value);
+
+	egg_array_float_free (result);
+	egg_array_float_free (array);
+	egg_array_float_free (kernel);
+
+	egg_test_end (test);
+}
+
+#endif
+
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/46.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/46.html new file mode 100644 index 0000000..679f710 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/46.html @@ -0,0 +1,351 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007-2008 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __EGG_ARRAY_FLOAT_H
+#define __EGG_ARRAY_FLOAT_H
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+G_BEGIN_DECLS
+
+/* at the moment just use a GArray as it's quick */
+typedef GArray EggArrayFloat;
+
+EggArrayFloat	*egg_array_float_new			(guint		 length);
+void		 egg_array_float_free			(EggArrayFloat	*array);
+gfloat		 egg_array_float_sum			(EggArrayFloat	*array);
+EggArrayFloat	*egg_array_float_compute_gaussian	(guint		 length,
+							 gfloat		 sigma);
+gfloat		 egg_array_float_compute_integral	(EggArrayFloat	*array,
+							 guint		 x1,
+							 guint		 x2);
+gfloat		 egg_array_float_get_average		(EggArrayFloat	*array);
+gboolean	 egg_array_float_print			(EggArrayFloat	*array);
+EggArrayFloat	*egg_array_float_convolve		(EggArrayFloat	*data,
+							 EggArrayFloat	*kernel);
+gfloat		 egg_array_float_get			(EggArrayFloat	*array,
+							 guint		 i);
+void		 egg_array_float_set			(EggArrayFloat	*array,
+							 guint		 i,
+							 gfloat		 value);
+EggArrayFloat	*egg_array_float_remove_outliers	(EggArrayFloat *data, guint length, gfloat sigma);
+#ifdef EGG_TEST
+void		 egg_array_float_test			(gpointer	 data);
+#endif
+
+G_END_DECLS
+
+#endif /* __EGG_ARRAY_FLOAT_H */
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/47.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/47.html new file mode 100644 index 0000000..a21b4ae --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/47.html @@ -0,0 +1,335 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007-2008 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __EGG_TEST_H
+#define __EGG_TEST_H
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+typedef struct EggTest EggTest;
+
+gboolean	 egg_test_start			(EggTest *test, const gchar *name);
+void		 egg_test_end			(EggTest *test);
+void		 egg_test_title			(EggTest *test, const gchar *format, ...);
+void		 egg_test_title_assert		(EggTest *test, const gchar *text, gboolean value);
+void		 egg_test_assert		(EggTest *test, gboolean value);
+void		 egg_test_success		(EggTest *test, const gchar *format, ...);
+void		 egg_test_failed		(EggTest *test, const gchar *format, ...) G_GNUC_NORETURN;
+EggTest		*egg_test_init			(void);
+gint		 egg_test_finish		(EggTest *test);
+guint		 egg_test_elapsed		(EggTest *test);
+void		 egg_test_loop_quit		(EggTest *test);
+void		 egg_test_loop_wait		(EggTest *test, guint timeout);
+void		 egg_test_loop_check		(EggTest *test);
+void		 egg_test_set_user_data		(EggTest *test, gpointer user_data);
+gpointer	 egg_test_get_user_data		(EggTest *test);
+gchar		*egg_test_get_data_file		(const gchar *filename);
+
+#endif	/* __EGG_TEST_H */
+
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/48.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/48.html new file mode 100644 index 0000000..d5603e8 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/48.html @@ -0,0 +1,553 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007-2008 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include "egg-color.h"
+
+/**
+ * egg_color_from_rgb:
+ * @red: The red value
+ * @green: The green value
+ * @blue: The blue value
+ **/
+guint32
+egg_color_from_rgb (guint8 red, guint8 green, guint8 blue)
+{
+	guint32 color = 0;
+	color += (guint32) red * 0x10000;
+	color += (guint32) green * 0x100;
+	color += (guint32) blue;
+	return color;
+}
+
+/**
+ * egg_color_to_rgb:
+ * @red: The red value
+ * @green: The green value
+ * @blue: The blue value
+ **/
+void
+egg_color_to_rgb (guint32 color, guint8 *red, guint8 *green, guint8 *blue)
+{
+	*red = (color & 0xff0000) / 0x10000;
+	*green = (color & 0x00ff00) / 0x100;
+	*blue = color & 0x0000ff;
+}
+
+/***************************************************************************
+ ***                          MAKE CHECK TESTS                           ***
+ ***************************************************************************/
+#ifdef EGG_TEST
+#include "egg-test.h"
+
+void
+egg_color_test (gpointer data)
+{
+	guint8 r, g, b;
+	guint32 color;
+	EggTest *test = (EggTest *) data;
+
+	if (egg_test_start (test, "EggColor") == FALSE) {
+		return;
+	}
+
+	/************************************************************/
+	egg_test_title (test, "get red");
+	egg_color_to_rgb (0xff0000, &r, &g, &b);
+	if (r == 255 && g == 0 && b == 0) {
+		egg_test_success (test, "got red");
+	} else {
+		egg_test_failed (test, "could not get red (%i, %i, %i)", r, g, b);
+	}
+
+	/************************************************************/
+	egg_test_title (test, "get green");
+	egg_color_to_rgb (0x00ff00, &r, &g, &b);
+	if (r == 0 && g == 255 && b == 0) {
+		egg_test_success (test, "got green");
+	} else {
+		egg_test_failed (test, "could not get green (%i, %i, %i)", r, g, b);
+	}
+
+	/************************************************************/
+	egg_test_title (test, "get blue");
+	egg_color_to_rgb (0x0000ff, &r, &g, &b);
+	if (r == 0 && g == 0 && b == 255) {
+		egg_test_success (test, "got blue");
+	} else {
+		egg_test_failed (test, "could not get blue (%i, %i, %i)", r, g, b);
+	}
+
+	/************************************************************/
+	egg_test_title (test, "get black");
+	egg_color_to_rgb (0x000000, &r, &g, &b);
+	if (r == 0 && g == 0 && b == 0) {
+		egg_test_success (test, "got black");
+	} else {
+		egg_test_failed (test, "could not get black (%i, %i, %i)", r, g, b);
+	}
+
+	/************************************************************/
+	egg_test_title (test, "get white");
+	egg_color_to_rgb (0xffffff, &r, &g, &b);
+	if (r == 255 && g == 255 && b == 255) {
+		egg_test_success (test, "got white");
+	} else {
+		egg_test_failed (test, "could not get white (%i, %i, %i)", r, g, b);
+	}
+
+	/************************************************************/
+	egg_test_title (test, "set red");
+	color = egg_color_from_rgb (0xff, 0x00, 0x00);
+	if (color == 0xff0000) {
+		egg_test_success (test, "set red");
+	} else {
+		egg_test_failed (test, "could not set red (%i)", color);
+	}
+
+	/************************************************************/
+	egg_test_title (test, "set green");
+	color = egg_color_from_rgb (0x00, 0xff, 0x00);
+	if (color == 0x00ff00) {
+		egg_test_success (test, "set green");
+	} else {
+		egg_test_failed (test, "could not set green (%i)", color);
+	}
+
+	/************************************************************/
+	egg_test_title (test, "set blue");
+	color = egg_color_from_rgb (0x00, 0x00, 0xff);
+	if (color == 0x0000ff) {
+		egg_test_success (test, "set blue");
+	} else {
+		egg_test_failed (test, "could not set blue (%i)", color);
+	}
+
+	/************************************************************/
+	egg_test_title (test, "set white");
+	color = egg_color_from_rgb (0xff, 0xff, 0xff);
+	if (color == 0xffffff) {
+		egg_test_success (test, "set white");
+	} else {
+		egg_test_failed (test, "could not set white (%i)", color);
+	}
+
+	egg_test_end (test);
+}
+
+#endif
+
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/49.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/49.html new file mode 100644 index 0000000..a7f0fcf --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/49.html @@ -0,0 +1,357 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007-2008 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __EGG_COLOR_H
+#define __EGG_COLOR_H
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+G_BEGIN_DECLS
+
+#define	EGG_COLOR_WHITE			0xffffff
+#define	EGG_COLOR_BLACK			0x000000
+#define	EGG_COLOR_RED			0xff0000
+#define	EGG_COLOR_GREEN			0x00ff00
+#define	EGG_COLOR_BLUE			0x0000ff
+#define	EGG_COLOR_CYAN			0x00ffff
+#define	EGG_COLOR_MAGENTA		0xff00ff
+#define	EGG_COLOR_YELLOW		0xffff00
+#define	EGG_COLOR_GREY			0xcccccc
+#define	EGG_COLOR_DARK_RED		0x600000
+#define	EGG_COLOR_DARK_GREEN		0x006000
+#define	EGG_COLOR_DARK_BLUE		0x000060
+#define	EGG_COLOR_DARK_CYAN		0x006060
+#define	EGG_COLOR_DARK_MAGENTA		0x600060
+#define	EGG_COLOR_DARK_YELLOW		0x606000
+#define	EGG_COLOR_DARK_GREY		0x606060
+
+guint32		 egg_color_from_rgb			(guint8		 red,
+							 guint8		 green,
+							 guint8		 blue);
+void		 egg_color_to_rgb			(guint32	 color,
+							 guint8		*red,
+							 guint8		*green,
+							 guint8		*blue);
+#ifdef EGG_TEST
+void		 egg_color_test				(gpointer	 data);
+#endif
+
+G_END_DECLS
+
+#endif /* __EGG_COLOR_H */
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/5.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/5.html new file mode 100644 index 0000000..0ad22c1 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/5.html @@ -0,0 +1,1315 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * MATE Power Manager Inhibit Applet
+ * Copyright (C) 2006 Benjamin Canou <bookeldor@gmail.com>
+ * Copyright (C) 2006-2009 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+
+#include <stdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <mate-panel-applet.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <dbus/dbus-glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "gpm-common.h"
+
+#define GPM_TYPE_INHIBIT_APPLET		(gpm_inhibit_applet_get_type ())
+#define GPM_INHIBIT_APPLET(o)		(G_TYPE_CHECK_INSTANCE_CAST ((o), GPM_TYPE_INHIBIT_APPLET, GpmInhibitApplet))
+#define GPM_INHIBIT_APPLET_CLASS(k)	(G_TYPE_CHECK_CLASS_CAST((k), GPM_TYPE_INHIBIT_APPLET, GpmInhibitAppletClass))
+#define GPM_IS_INHIBIT_APPLET(o)	(G_TYPE_CHECK_INSTANCE_TYPE ((o), GPM_TYPE_INHIBIT_APPLET))
+#define GPM_IS_INHIBIT_APPLET_CLASS(k)	(G_TYPE_CHECK_CLASS_TYPE ((k), GPM_TYPE_INHIBIT_APPLET))
+#define GPM_INHIBIT_APPLET_GET_CLASS(o)	(G_TYPE_INSTANCE_GET_CLASS ((o), GPM_TYPE_INHIBIT_APPLET, GpmInhibitAppletClass))
+
+typedef struct{
+	MatePanelApplet parent;
+	/* applet state */
+	guint cookie;
+	/* the icon */
+	GtkWidget *image;
+	/* connection to g-p-m */
+	DBusGProxy *proxy;
+	DBusGConnection *connection;
+	guint bus_watch_id;
+	guint level;
+	/* a cache for panel size */
+	gint size;
+} GpmInhibitApplet;
+
+typedef struct{
+	MatePanelAppletClass	parent_class;
+} GpmInhibitAppletClass;
+
+GType                gpm_inhibit_applet_get_type  (void);
+
+#define GS_DBUS_SERVICE		"org.gnome.SessionManager"
+#define GS_DBUS_PATH		"/org/gnome/SessionManager"
+#define GS_DBUS_INTERFACE	"org.gnome.SessionManager"
+
+G_DEFINE_TYPE (GpmInhibitApplet, gpm_inhibit_applet, PANEL_TYPE_APPLET)<--- There is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE is a macro then please configure it.
+
+static void	gpm_applet_update_icon		(GpmInhibitApplet *applet);
+static void	gpm_applet_size_allocate_cb     (GtkWidget *widget, GdkRectangle *allocation);;
+static void	gpm_applet_update_tooltip	(GpmInhibitApplet *applet);
+static gboolean	gpm_applet_click_cb		(GpmInhibitApplet *applet, GdkEventButton *event);
+static void	gpm_applet_dialog_about_cb	(GtkAction *action, gpointer data);
+static gboolean	gpm_applet_cb		        (MatePanelApplet *_applet, const gchar *iid, gpointer data);
+static void	gpm_applet_destroy_cb		(GtkWidget *widget);
+
+#define GPM_INHIBIT_APPLET_ID		        "InhibitApplet"
+#define GPM_INHIBIT_APPLET_FACTORY_ID	        "InhibitAppletFactory"
+#define GPM_INHIBIT_APPLET_ICON_INHIBIT		"gpm-inhibit"
+#define GPM_INHIBIT_APPLET_ICON_INVALID		"gpm-inhibit-invalid"
+#define GPM_INHIBIT_APPLET_ICON_UNINHIBIT	"gpm-hibernate"
+#define GPM_INHIBIT_APPLET_NAME			_("Power Manager Inhibit Applet")
+#define GPM_INHIBIT_APPLET_DESC			_("Allows user to inhibit automatic power saving.")
+#define MATE_PANEL_APPLET_VERTICAL(p)					\
+	 (((p) == MATE_PANEL_APPLET_ORIENT_LEFT) || ((p) == MATE_PANEL_APPLET_ORIENT_RIGHT))
+
+/** cookie is returned as an unsigned integer */
+static gboolean
+gpm_applet_inhibit (GpmInhibitApplet *applet,
+		    const gchar     *appname,
+		    const gchar     *reason,
+		    guint           *cookie)
+{
+	GError  *error = NULL;
+	gboolean ret;
+
+	g_return_val_if_fail (cookie != NULL, FALSE);
+
+	if (applet->proxy == NULL) {
+		g_warning ("not connected\n");
+		return FALSE;
+	}
+
+	ret = dbus_g_proxy_call (applet->proxy, "Inhibit", &error,
+				 G_TYPE_STRING, appname,
+				 G_TYPE_UINT, 0, /* xid */
+				 G_TYPE_STRING, reason,
+				 G_TYPE_UINT, 1+2+4+8, /* logoff, switch, suspend, and idle */
+				 G_TYPE_INVALID,
+				 G_TYPE_UINT, cookie,
+				 G_TYPE_INVALID);
+	if (error) {
+		g_debug ("ERROR: %s", error->message);
+		g_error_free (error);
+		*cookie = 0;
+	}
+	if (!ret) {
+		/* abort as the DBUS method failed */
+		g_warning ("Inhibit failed!");
+	}
+
+	return ret;
+}
+
+static gboolean
+gpm_applet_uninhibit (GpmInhibitApplet *applet,
+		      guint            cookie)
+{
+	GError *error = NULL;
+	gboolean ret;
+
+	if (applet->proxy == NULL) {
+		g_warning ("not connected");
+		return FALSE;
+	}
+
+	ret = dbus_g_proxy_call (applet->proxy, "Uninhibit", &error,
+				 G_TYPE_UINT, cookie,
+				 G_TYPE_INVALID,
+				 G_TYPE_INVALID);
+	if (error) {
+		g_debug ("ERROR: %s", error->message);
+		g_error_free (error);
+	}
+	if (!ret) {
+		/* abort as the DBUS method failed */
+		g_warning ("Uninhibit failed!");
+	}
+
+	return ret;
+}
+
+/**
+ * gpm_applet_update_icon:
+ * @applet: Inhibit applet instance
+ *
+ * sets an icon from stock
+ **/
+static void
+gpm_applet_update_icon (GpmInhibitApplet *applet)
+{
+	const gchar *icon;
+
+	/* get icon */
+	if (applet->proxy == NULL) {
+		icon = GPM_INHIBIT_APPLET_ICON_INVALID;
+	} else if (applet->cookie > 0) {
+		icon = GPM_INHIBIT_APPLET_ICON_INHIBIT;
+	} else {
+		icon = GPM_INHIBIT_APPLET_ICON_UNINHIBIT;
+	}
+	gtk_image_set_from_icon_name (GTK_IMAGE(applet->image),
+				      icon,
+				      GTK_ICON_SIZE_BUTTON);
+}
+
+/**
+ * gpm_applet_size_allocate_cb:
+ * @applet: Inhibit applet instance
+ *
+ * resize icon when panel size changed
+ **/
+static void
+gpm_applet_size_allocate_cb (GtkWidget    *widget,
+                             GdkRectangle *allocation)
+{
+	GpmInhibitApplet *applet = GPM_INHIBIT_APPLET (widget);
+	int               size = 0;
+
+	switch (mate_panel_applet_get_orient (MATE_PANEL_APPLET (applet))) {
+		case MATE_PANEL_APPLET_ORIENT_LEFT:
+		case MATE_PANEL_APPLET_ORIENT_RIGHT:
+			size = allocation->width;
+			break;
+
+		case MATE_PANEL_APPLET_ORIENT_UP:
+		case MATE_PANEL_APPLET_ORIENT_DOWN:
+			size = allocation->height;
+			break;
+		default:
+			break;
+	}
+
+	/* Scale to the actual size of the applet, don't quantize to original icon size */
+	/* GtkImage already contains a check to do nothing if it's the same */
+	gtk_image_set_pixel_size (GTK_IMAGE(applet->image), size);
+}
+
+/**
+ * gpm_applet_update_tooltip:
+ * @applet: Inhibit applet instance
+ *
+ * sets tooltip's content (percentage or disabled)
+ **/
+static void
+gpm_applet_update_tooltip (GpmInhibitApplet *applet)
+{
+	const gchar *buf;
+	if (applet->proxy == NULL) {
+		buf = _("Cannot connect to mate-power-manager");
+	} else {
+		if (applet->cookie > 0) {
+			buf = _("Automatic sleep inhibited");
+		} else {
+			buf = _("Automatic sleep enabled");
+		}
+	}
+	gtk_widget_set_tooltip_text (GTK_WIDGET(applet), buf);
+}
+
+/**
+ * gpm_applet_click_cb:
+ * @applet: Inhibit applet instance
+ *
+ * pops and unpops
+ **/
+static gboolean
+gpm_applet_click_cb (GpmInhibitApplet *applet, GdkEventButton *event)
+{
+	/* react only to left mouse button */
+	if (event->button != 1) {
+		return FALSE;
+	}
+
+	if (applet->cookie > 0) {
+		g_debug ("uninhibiting %u", applet->cookie);
+		gpm_applet_uninhibit (applet, applet->cookie);
+		applet->cookie = 0;
+	} else {
+		g_debug ("inhibiting");
+		gpm_applet_inhibit (applet,
+					  GPM_INHIBIT_APPLET_NAME,
+					  _("Manual inhibit"),
+					  &(applet->cookie));
+	}
+	/* update icon */
+	gpm_applet_update_icon (applet);
+	gpm_applet_update_tooltip (applet);
+
+	return TRUE;
+}
+
+/**
+ * gpm_applet_dialog_about_cb:
+ *
+ * displays about dialog
+ **/
+static void
+gpm_applet_dialog_about_cb (GtkAction *action, gpointer data)
+{
+	static const gchar *authors[] = {
+		"Benjamin Canou <bookeldor@gmail.com>",
+		"Richard Hughes <richard@hughsie.com>",
+		NULL
+	};
+
+	const char *documenters [] = {
+		NULL
+	};
+
+	const char *license[] = {
+		 N_("Power Manager is free software; you can redistribute it and/or "
+		   "modify it under the terms of the GNU General Public License "
+		   "as published by the Free Software Foundation; either version 2 "
+		   "of the License, or (at your option) any later version."),
+
+		 N_("Power Manager is distributed in the hope that it will be useful, "
+		   "but WITHOUT ANY WARRANTY; without even the implied warranty of "
+		   "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the "
+		   "GNU General Public License for more details.") ,
+
+		 N_("You should have received a copy of the GNU General Public License "
+		   "along with this program; if not, write to the Free Software "
+		   "Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA "
+		   "02110-1301, USA.")
+	};
+
+	char *license_trans;
+
+	license_trans = g_strjoin("\n\n", _(license[0]), _(license[1]), _(license[2]), NULL);
+
+	gtk_show_about_dialog (NULL,
+	                       "program-name", GPM_INHIBIT_APPLET_NAME,
+	                       "version", VERSION,
+	                       "title", _("About Power Manager Inhibit Applet"),
+	                       "comments", GPM_INHIBIT_APPLET_DESC,
+	                       "copyright", _("Copyright \xC2\xA9 2006-2007 Richard Hughes\n"
+	                                      "Copyright \xC2\xA9 2011-2021 MATE developers"),
+	                       "icon-name", GPM_INHIBIT_APPLET_ICON_INHIBIT,
+	                       "logo-icon-name", GPM_INHIBIT_APPLET_ICON_INHIBIT,
+	                       "license", license_trans,
+	                       "authors", authors,
+	                       "documenters", documenters,
+	                       "translator-credits", _("translator-credits"),
+	                       "wrap-license", TRUE,
+	                       "website", PACKAGE_URL,
+	                       NULL);
+
+	g_free (license_trans);
+}
+
+/**
+ * gpm_applet_help_cb:
+ *
+ * open gpm help
+ **/
+static void
+gpm_applet_help_cb (GtkAction *action, gpointer data)
+{
+	gpm_help_display ("applets-general#applets-inhibit");
+}
+
+/**
+ * gpm_applet_destroy_cb:
+ * @widget: Class instance to destroy
+ **/
+static void
+gpm_applet_destroy_cb (GtkWidget *widget)
+{
+	GpmInhibitApplet *applet = GPM_INHIBIT_APPLET(widget);
+
+	g_bus_unwatch_name (applet->bus_watch_id);
+}
+
+/**
+ * gpm_inhibit_applet_class_init:
+ * @klass: Class instance
+ **/
+static void
+gpm_inhibit_applet_class_init (GpmInhibitAppletClass *class)
+{
+	/* nothing to do here */
+}
+
+/**
+ * gpm_inhibit_applet_dbus_connect:
+ **/
+static gboolean
+gpm_inhibit_applet_dbus_connect (GpmInhibitApplet *applet)
+{
+	GError *error = NULL;
+
+	if (applet->connection == NULL) {
+		g_debug ("get connection\n");
+		g_clear_error (&error);
+		applet->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+		if (error != NULL) {
+			g_warning ("Could not connect to DBUS daemon: %s", error->message);
+			g_error_free (error);
+			applet->connection = NULL;
+			return FALSE;
+		}
+	}
+	if (applet->proxy == NULL) {
+		g_debug ("get proxy\n");
+		g_clear_error (&error);
+		applet->proxy = dbus_g_proxy_new_for_name_owner (applet->connection,
+							 GS_DBUS_SERVICE,
+							 GS_DBUS_PATH,
+							 GS_DBUS_INTERFACE,
+							 &error);
+		if (error != NULL) {
+			g_warning ("Cannot connect, maybe the daemon is not running: %s\n", error->message);
+			g_error_free (error);
+			applet->proxy = NULL;
+			return FALSE;
+		}
+	}
+	return TRUE;
+}
+
+/**
+ * gpm_inhibit_applet_dbus_disconnect:
+ **/
+static gboolean
+gpm_inhibit_applet_dbus_disconnect (GpmInhibitApplet *applet)
+{
+	if (applet->proxy != NULL) {
+		g_debug ("removing proxy\n");
+		g_object_unref (applet->proxy);
+		applet->proxy = NULL;
+		/* we have no inhibit, these are not persistent across reboots */
+		applet->cookie = 0;
+	}
+	return TRUE;
+}
+
+/**
+ * gpm_inhibit_applet_name_appeared_cb:
+ **/
+static void
+gpm_inhibit_applet_name_appeared_cb (GDBusConnection *connection,
+				     const gchar *name,
+				     const gchar *name_owner,
+				     GpmInhibitApplet *applet)
+{
+	gpm_inhibit_applet_dbus_connect (applet);
+	gpm_applet_update_tooltip (applet);
+	gpm_applet_update_icon (applet);;
+}
+
+/**
+ * gpm_inhibit_applet_name_vanished_cb:
+ **/
+static void
+gpm_inhibit_applet_name_vanished_cb (GDBusConnection *connection,
+				     const gchar *name,
+				     GpmInhibitApplet *applet)
+{
+	gpm_inhibit_applet_dbus_disconnect (applet);
+	gpm_applet_update_tooltip (applet);
+	gpm_applet_update_icon (applet);
+}
+
+/**
+ * gpm_inhibit_applet_init:
+ * @applet: Inhibit applet instance
+ **/
+static void
+gpm_inhibit_applet_init (GpmInhibitApplet *applet)
+{
+	/* initialize fields */
+	applet->image = NULL;
+	applet->cookie = 0;
+	applet->connection = NULL;
+	applet->proxy = NULL;
+
+	/* Add application specific icons to search path */
+	gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (),
+                                           GPM_ICONS_DATA);
+
+	/* monitor the daemon */
+	applet->bus_watch_id =
+		g_bus_watch_name (G_BUS_TYPE_SESSION,
+				  GS_DBUS_SERVICE,
+				  G_BUS_NAME_WATCHER_FLAGS_NONE,
+				  (GBusNameAppearedCallback) gpm_inhibit_applet_name_appeared_cb,
+				  (GBusNameVanishedCallback) gpm_inhibit_applet_name_vanished_cb,
+				  applet, NULL);
+
+	/* prepare */
+	mate_panel_applet_set_flags (MATE_PANEL_APPLET (applet), MATE_PANEL_APPLET_EXPAND_MINOR);
+	applet->image = gtk_image_new();
+	gtk_container_add (GTK_CONTAINER (applet), applet->image);
+
+	/* set appropriate size and load icon accordingly */
+	gtk_widget_queue_draw (GTK_WIDGET (applet));
+
+	/* show */
+	gtk_widget_show_all (GTK_WIDGET(applet));
+
+	/* connect */
+	g_signal_connect (G_OBJECT(applet), "button-press-event",
+			  G_CALLBACK(gpm_applet_click_cb), NULL);
+
+	g_signal_connect (G_OBJECT(applet), "size-allocate",
+			  G_CALLBACK(gpm_applet_size_allocate_cb), NULL);
+
+	g_signal_connect (G_OBJECT(applet), "destroy",
+			  G_CALLBACK(gpm_applet_destroy_cb), NULL);
+}
+
+/**
+ * gpm_applet_cb:
+ * @_applet: GpmInhibitApplet instance created by the applet factory
+ * @iid: Applet id
+ *
+ * the function called by libmate-panel-applet factory after creation
+ **/
+static gboolean
+gpm_applet_cb (MatePanelApplet *_applet, const gchar *iid, gpointer data)
+{
+	GpmInhibitApplet *applet = GPM_INHIBIT_APPLET(_applet);
+	GtkActionGroup *action_group;
+
+	static const GtkActionEntry menu_actions [] = {
+		{ "About", "help-about", N_("_About"),
+		  NULL, NULL,
+		  G_CALLBACK (gpm_applet_dialog_about_cb) },
+		{ "Help", "help-browser", N_("_Help"),
+		  NULL, NULL,
+		  G_CALLBACK (gpm_applet_help_cb) }
+	};
+
+	if (strcmp (iid, GPM_INHIBIT_APPLET_ID) != 0) {
+		return FALSE;
+	}
+
+	action_group = gtk_action_group_new ("Inhibit Applet Actions");
+	gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
+	gtk_action_group_add_actions (action_group,
+				      menu_actions,
+				      G_N_ELEMENTS (menu_actions),
+				      applet);
+	mate_panel_applet_setup_menu_from_file (MATE_PANEL_APPLET (applet),
+	                                        INHIBIT_MENU_UI_DIR "/inhibit-applet-menu.xml",
+	                                        action_group);
+	g_object_unref (action_group);
+
+	return TRUE;
+}
+
+/**
+ * this generates a main with a applet factory
+ **/
+MATE_PANEL_APPLET_OUT_PROCESS_FACTORY
+ (/* the factory iid */
+ GPM_INHIBIT_APPLET_FACTORY_ID,
+ /* generates brighness applets instead of regular mate applets  */
+ GPM_TYPE_INHIBIT_APPLET,
+ /* the applet name */
+ "InhibitApplet",
+ /* our callback (with no user data) */
+ gpm_applet_cb, NULL)
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/50.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/50.html new file mode 100644 index 0000000..c5afdf1 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/50.html @@ -0,0 +1,1175 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2006-2008 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "config.h"<--- Include file: "config.h" not found.
+
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <dbus/dbus-glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <dbus/dbus.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "egg-console-kit.h"
+
+static void     egg_console_kit_finalize	(GObject		*object);
+
+#define CONSOLEKIT_NAME			"org.freedesktop.ConsoleKit"
+#define CONSOLEKIT_PATH			"/org/freedesktop/ConsoleKit"
+#define CONSOLEKIT_INTERFACE		"org.freedesktop.ConsoleKit"
+
+#define CONSOLEKIT_MANAGER_PATH	 	"/org/freedesktop/ConsoleKit/Manager"
+#define CONSOLEKIT_MANAGER_INTERFACE    "org.freedesktop.ConsoleKit.Manager"
+#define CONSOLEKIT_SEAT_INTERFACE       "org.freedesktop.ConsoleKit.Seat"
+#define CONSOLEKIT_SESSION_INTERFACE    "org.freedesktop.ConsoleKit.Session"
+
+struct EggConsoleKitPrivate
+{
+	DBusGConnection		*connection;
+	DBusGProxy		*proxy_manager;
+	DBusGProxy		*proxy_session;
+	gchar			*session_id;
+};
+
+enum {
+	EGG_CONSOLE_KIT_ACTIVE_CHANGED,
+	EGG_CONSOLE_KIT_LAST_SIGNAL
+};
+
+static gpointer egg_console_kit_object = NULL;
+static guint signals [EGG_CONSOLE_KIT_LAST_SIGNAL] = { 0 };
+
+G_DEFINE_TYPE_WITH_PRIVATE (EggConsoleKit, egg_console_kit, G_TYPE_OBJECT)<--- There is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
+
+/**
+ * egg_console_kit_restart:
+ **/
+gboolean
+egg_console_kit_restart (EggConsoleKit *console, GError **error)
+{
+	gboolean ret;
+	GError *error_local = NULL;
+
+	g_return_val_if_fail (EGG_IS_CONSOLE_KIT (console), FALSE);
+	g_return_val_if_fail (console->priv->proxy_manager != NULL, FALSE);
+
+	ret = dbus_g_proxy_call (console->priv->proxy_manager, "Restart", &error_local,
+				 G_TYPE_INVALID, G_TYPE_INVALID);
+	if (!ret) {
+		g_warning ("Couldn't restart: %s", error_local->message);
+		if (error != NULL)
+			*error = g_error_new (1, 0, "%s", error_local->message);
+		g_error_free (error_local);
+	}
+	return ret;
+}
+
+/**
+ * egg_console_kit_stop:
+ **/
+gboolean
+egg_console_kit_stop (EggConsoleKit *console, GError **error)
+{
+	gboolean ret;
+	GError *error_local = NULL;
+
+	g_return_val_if_fail (EGG_IS_CONSOLE_KIT (console), FALSE);
+	g_return_val_if_fail (console->priv->proxy_manager != NULL, FALSE);
+
+	ret = dbus_g_proxy_call (console->priv->proxy_manager, "Stop", &error_local,
+				 G_TYPE_INVALID, G_TYPE_INVALID);
+	if (!ret) {
+		g_warning ("Couldn't stop: %s", error_local->message);
+		if (error != NULL)
+			*error = g_error_new (1, 0, "%s", error_local->message);
+		g_error_free (error_local);
+	}
+	return ret;
+}
+
+/**
+ * egg_console_kit_suspend:
+ **/
+gboolean
+egg_console_kit_suspend (EggConsoleKit *console, GError **error)
+{
+	gboolean ret;
+	GError *error_local = NULL;
+
+	g_return_val_if_fail (EGG_IS_CONSOLE_KIT (console), FALSE);
+	g_return_val_if_fail (console->priv->proxy_manager != NULL, FALSE);
+
+	ret = dbus_g_proxy_call (console->priv->proxy_manager, "Suspend", &error_local,
+				 G_TYPE_BOOLEAN, TRUE,
+				 G_TYPE_INVALID, G_TYPE_INVALID);
+	if (!ret) {
+		g_warning ("Couldn't suspend: %s", error_local->message);
+		if (error != NULL)
+			*error = g_error_new (1, 0, "%s", error_local->message);
+		g_error_free (error_local);
+	}
+	return ret;
+}
+
+/**
+ * egg_console_kit_hibernate:
+ **/
+gboolean
+egg_console_kit_hibernate (EggConsoleKit *console, GError **error)
+{
+	gboolean ret;
+	GError *error_local = NULL;
+
+	g_return_val_if_fail (EGG_IS_CONSOLE_KIT (console), FALSE);
+	g_return_val_if_fail (console->priv->proxy_manager != NULL, FALSE);
+
+	ret = dbus_g_proxy_call (console->priv->proxy_manager, "Hibernate", &error_local,
+				 G_TYPE_BOOLEAN, TRUE,
+				 G_TYPE_INVALID, G_TYPE_INVALID);
+	if (!ret) {
+		g_warning ("Couldn't hibernate: %s", error_local->message);
+		if (error != NULL)
+			*error = g_error_new (1, 0, "%s", error_local->message);
+		g_error_free (error_local);
+	}
+	return ret;
+}
+
+/**
+ * egg_console_kit_can_stop:
+ **/
+gboolean
+egg_console_kit_can_stop (EggConsoleKit *console, gboolean *can_stop, GError **error)
+{
+	gboolean ret;
+	GError *error_local = NULL;
+
+	g_return_val_if_fail (EGG_IS_CONSOLE_KIT (console), FALSE);
+	g_return_val_if_fail (console->priv->proxy_manager != NULL, FALSE);
+
+	ret = dbus_g_proxy_call (console->priv->proxy_manager, "CanStop", &error_local,
+				 G_TYPE_INVALID,
+				 G_TYPE_BOOLEAN, can_stop, G_TYPE_INVALID);
+	if (!ret) {
+		g_warning ("Couldn't do CanStop: %s", error_local->message);
+		if (error != NULL)
+			*error = g_error_new (1, 0, "%s", error_local->message);
+		g_error_free (error_local);
+		/* CanStop was only added in new versions of ConsoleKit,
+		 * so assume true if this failed */
+		*can_stop = TRUE;
+	}
+	return ret;
+}
+
+/**
+ * egg_console_kit_can_restart:
+ **/
+gboolean
+egg_console_kit_can_restart (EggConsoleKit *console, gboolean *can_restart, GError **error)
+{
+	gboolean ret;
+	GError *error_local = NULL;
+
+	g_return_val_if_fail (EGG_IS_CONSOLE_KIT (console), FALSE);
+	g_return_val_if_fail (console->priv->proxy_manager != NULL, FALSE);
+
+	ret = dbus_g_proxy_call (console->priv->proxy_manager, "CanRestart", &error_local,
+				 G_TYPE_INVALID,
+				 G_TYPE_BOOLEAN, can_restart, G_TYPE_INVALID);
+	if (!ret) {
+		g_warning ("Couldn't do CanRestart: %s", error_local->message);
+		if (error != NULL)
+			*error = g_error_new (1, 0, "%s", error_local->message);
+		g_error_free (error_local);
+		/* CanRestart was only added in new versions of ConsoleKit,
+		 * so assume true if this failed */
+		*can_restart = TRUE;
+	}
+	return ret;
+}
+
+/**
+ * egg_console_kit_can_suspend:
+ **/
+gboolean
+egg_console_kit_can_suspend (EggConsoleKit *console, gboolean *can_suspend, GError **error)
+{
+	GError *error_local = NULL;
+	gboolean ret;
+	gchar  *retval;
+
+	g_return_val_if_fail (EGG_IS_CONSOLE_KIT (console), FALSE);
+	g_return_val_if_fail (console->priv->proxy_manager != NULL, FALSE);
+
+	ret = dbus_g_proxy_call (console->priv->proxy_manager, "CanSuspend", &error_local,
+				 G_TYPE_INVALID,
+				 G_TYPE_STRING, &retval, G_TYPE_INVALID);
+	if (!ret) {
+		g_warning ("Couldn't do CanSuspend: %s", error_local->message);
+		if (error != NULL)
+			*error = g_error_new (1, 0, "%s", error_local->message);
+		g_error_free (error_local);
+	}
+
+	*can_suspend = g_strcmp0 (retval, "yes") == 0 ||
+		       g_strcmp0 (retval, "challenge") == 0;
+
+	g_free (retval);
+	return ret;
+}
+
+/**
+ * egg_console_kit_can_hibernate:
+ **/
+
+gboolean
+egg_console_kit_can_hibernate (EggConsoleKit *console, gboolean *can_hibernate, GError **error)
+{
+	GError *error_local = NULL;
+	gboolean ret;
+	gchar  *retval;
+
+	g_return_val_if_fail (EGG_IS_CONSOLE_KIT (console), FALSE);
+	g_return_val_if_fail (console->priv->proxy_manager != NULL, FALSE);
+
+	ret = dbus_g_proxy_call (console->priv->proxy_manager, "CanHibernate", &error_local,
+				 G_TYPE_INVALID,
+				 G_TYPE_STRING, &retval, G_TYPE_INVALID);
+	if (!ret) {
+		g_warning ("Couldn't do CanHibernate: %s", error_local->message);
+		if (error != NULL)
+			*error = g_error_new (1, 0, "%s", error_local->message);
+		g_error_free (error_local);
+	}
+
+	*can_hibernate = g_strcmp0 (retval, "yes") == 0 ||
+	                 g_strcmp0 (retval, "challenge") == 0;
+	return ret;
+}
+
+/**
+ * egg_console_kit_is_local:
+ *
+ * Return value: Returns whether the session is local
+ **/
+gboolean
+egg_console_kit_is_local (EggConsoleKit *console)
+{
+	gboolean ret = FALSE;
+	gboolean value = FALSE;
+	GError *error = NULL;
+
+	g_return_val_if_fail (EGG_IS_CONSOLE_KIT (console), FALSE);
+
+	/* maybe console kit does not know about our session */
+	if (console->priv->proxy_session == NULL) {
+		g_warning ("no ConsoleKit session");
+		goto out;
+	}
+
+	/* is our session local */
+	ret = dbus_g_proxy_call (console->priv->proxy_session, "IsLocal", &error, G_TYPE_INVALID,
+				 G_TYPE_BOOLEAN, &value, G_TYPE_INVALID);
+	if (!ret) {
+		g_warning ("IsLocal failed: %s", error->message);
+		g_error_free (error);
+		goto out;
+	}
+
+	/* return value only if we successed */
+	ret = value;
+out:
+	return ret;
+}
+
+/**
+ * egg_console_kit_is_active:
+ *
+ * Return value: Returns whether the session is active on the Seat that it is attached to.
+ **/
+gboolean
+egg_console_kit_is_active (EggConsoleKit *console)
+{
+	gboolean ret = FALSE;
+	gboolean value = FALSE;
+	GError *error = NULL;
+
+	g_return_val_if_fail (EGG_IS_CONSOLE_KIT (console), FALSE);
+
+	/* maybe console kit does not know about our session */
+	if (console->priv->proxy_session == NULL) {
+		g_warning ("no ConsoleKit session");
+		goto out;
+	}
+
+	/* is our session active */
+	ret = dbus_g_proxy_call (console->priv->proxy_session, "IsActive", &error, G_TYPE_INVALID,
+				 G_TYPE_BOOLEAN, &value, G_TYPE_INVALID);
+	if (!ret) {
+		g_warning ("IsActive failed: %s", error->message);
+		g_error_free (error);
+		goto out;
+	}
+
+	/* return value only if we successed */
+	ret = value;
+out:
+	return ret;
+}
+
+/**
+ * egg_console_kit_active_changed_cb:
+ **/
+static void
+egg_console_kit_active_changed_cb (DBusGProxy *proxy, gboolean active, EggConsoleKit *console)
+{
+	g_debug ("emitting active: %i", active);
+	g_signal_emit (console, signals [EGG_CONSOLE_KIT_ACTIVE_CHANGED], 0, active);
+}
+
+/**
+ * egg_console_kit_class_init:
+ * @klass: The EggConsoleKitClass
+ **/
+static void
+egg_console_kit_class_init (EggConsoleKitClass *klass)
+{
+	GObjectClass *object_class = G_OBJECT_CLASS (klass);
+	object_class->finalize = egg_console_kit_finalize;
+
+	signals [EGG_CONSOLE_KIT_ACTIVE_CHANGED] =
+		g_signal_new ("active-changed",
+			      G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
+			      G_STRUCT_OFFSET (EggConsoleKitClass, active_changed),
+			      NULL, NULL, g_cclosure_marshal_VOID__BOOLEAN,
+			      G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
+}
+
+/**
+ * egg_console_kit_init:
+ **/
+static void
+egg_console_kit_init (EggConsoleKit *console)
+{
+	gboolean ret;
+	GError *error = NULL;
+	guint32 pid;
+
+	console->priv = egg_console_kit_get_instance_private (console);
+	console->priv->proxy_manager = NULL;
+	console->priv->session_id = NULL;
+
+	/* connect to D-Bus */
+	console->priv->connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
+	if (console->priv->connection == NULL) {
+		g_warning ("Failed to connect to the D-Bus daemon: %s", error->message);
+		g_error_free (error);
+		goto out;
+	}
+
+	/* connect to ConsoleKit */
+	console->priv->proxy_manager =
+		dbus_g_proxy_new_for_name (console->priv->connection, CONSOLEKIT_NAME,
+					   CONSOLEKIT_MANAGER_PATH, CONSOLEKIT_MANAGER_INTERFACE);
+	if (console->priv->proxy_manager == NULL) {
+		g_warning ("cannot connect to ConsoleKit");
+		goto out;
+	}
+
+	/* get the session we are running in */
+	pid = getpid ();
+	ret = dbus_g_proxy_call (console->priv->proxy_manager, "GetSessionForUnixProcess", &error,
+				 G_TYPE_UINT, pid,
+				 G_TYPE_INVALID,
+				 DBUS_TYPE_G_OBJECT_PATH, &console->priv->session_id,
+				 G_TYPE_INVALID);
+	if (!ret) {
+		g_warning ("Failed to get session for pid %u: %s", pid, error->message);
+		g_error_free (error);
+		goto out;
+	}
+	g_debug ("ConsoleKit session ID: %s", console->priv->session_id);
+
+	/* connect to session */
+	console->priv->proxy_session =
+		dbus_g_proxy_new_for_name (console->priv->connection, CONSOLEKIT_NAME,
+					   console->priv->session_id, CONSOLEKIT_SESSION_INTERFACE);
+	if (console->priv->proxy_session == NULL) {
+		g_warning ("cannot connect to: %s", console->priv->session_id);
+		goto out;
+	}
+	dbus_g_proxy_add_signal (console->priv->proxy_session, "ActiveChanged", G_TYPE_BOOLEAN, G_TYPE_INVALID);
+	dbus_g_proxy_connect_signal (console->priv->proxy_session, "ActiveChanged",
+				     G_CALLBACK (egg_console_kit_active_changed_cb), console, NULL);
+
+out:
+	return;
+}
+
+/**
+ * egg_console_kit_finalize:
+ * @object: The object to finalize
+ **/
+static void
+egg_console_kit_finalize (GObject *object)
+{
+	EggConsoleKit *console;
+
+	g_return_if_fail (EGG_IS_CONSOLE_KIT (object));
+
+	console = EGG_CONSOLE_KIT (object);
+
+	g_return_if_fail (console->priv != NULL);
+	if (console->priv->proxy_manager != NULL)
+		g_object_unref (console->priv->proxy_manager);
+	if (console->priv->proxy_session != NULL)
+		g_object_unref (console->priv->proxy_session);
+	g_free (console->priv->session_id);
+
+	G_OBJECT_CLASS (egg_console_kit_parent_class)->finalize (object);
+}
+
+/**
+ * egg_console_kit_new:
+ *
+ * Return value: a new EggConsoleKit object.
+ **/
+EggConsoleKit *
+egg_console_kit_new (void)
+{
+	if (egg_console_kit_object != NULL) {
+		g_object_ref (egg_console_kit_object);
+	} else {
+		egg_console_kit_object = g_object_new (EGG_TYPE_CONSOLE_KIT, NULL);
+		g_object_add_weak_pointer (egg_console_kit_object, &egg_console_kit_object);
+	}
+
+	return EGG_CONSOLE_KIT (egg_console_kit_object);
+}
+
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/51.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/51.html new file mode 100644 index 0000000..ab7563c --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/51.html @@ -0,0 +1,401 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+82
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __EGG_CONSOLE_KIT_H
+#define __EGG_CONSOLE_KIT_H
+
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+G_BEGIN_DECLS
+
+#define EGG_TYPE_CONSOLE_KIT		(egg_console_kit_get_type ())
+#define EGG_CONSOLE_KIT(o)		(G_TYPE_CHECK_INSTANCE_CAST ((o), EGG_TYPE_CONSOLE_KIT, EggConsoleKit))
+#define EGG_CONSOLE_KIT_CLASS(k)	(G_TYPE_CHECK_CLASS_CAST((k), EGG_TYPE_CONSOLE_KIT, EggConsoleKitClass))
+#define EGG_IS_CONSOLE_KIT(o)		(G_TYPE_CHECK_INSTANCE_TYPE ((o), EGG_TYPE_CONSOLE_KIT))
+#define EGG_IS_CONSOLE_KIT_CLASS(k)	(G_TYPE_CHECK_CLASS_TYPE ((k), EGG_TYPE_CONSOLE_KIT))
+#define EGG_CONSOLE_KIT_GET_CLASS(o)	(G_TYPE_INSTANCE_GET_CLASS ((o), EGG_TYPE_CONSOLE_KIT, EggConsoleKitClass))
+#define EGG_CONSOLE_KIT_ERROR		(egg_console_kit_error_quark ())
+#define EGG_CONSOLE_KIT_TYPE_ERROR	(egg_console_kit_error_get_type ())
+
+typedef struct EggConsoleKitPrivate EggConsoleKitPrivate;
+
+typedef struct
+{
+	 GObject		 parent;
+	 EggConsoleKitPrivate	*priv;
+} EggConsoleKit;
+
+typedef struct
+{
+	GObjectClass	parent_class;
+	void		(* active_changed)		(EggConsoleKit	*console,
+							 gboolean	 active);
+} EggConsoleKitClass;
+
+GType		 egg_console_kit_get_type	  	(void);
+EggConsoleKit	*egg_console_kit_new			(void);
+gboolean	 egg_console_kit_is_local		(EggConsoleKit	*console);
+gboolean	 egg_console_kit_is_active		(EggConsoleKit	*console);
+gboolean	 egg_console_kit_stop			(EggConsoleKit	*console,
+							 GError		**error);
+gboolean	 egg_console_kit_restart		(EggConsoleKit	*console,
+							 GError		**error);
+gboolean	 egg_console_kit_suspend		(EggConsoleKit	*console,
+							 GError		**error);
+gboolean	 egg_console_kit_hibernate		(EggConsoleKit	*console,
+							 GError		**error);
+gboolean	 egg_console_kit_can_stop		(EggConsoleKit	*console,
+							 gboolean	*can_stop,
+							 GError		**error);
+gboolean	 egg_console_kit_can_restart		(EggConsoleKit	*console,
+							 gboolean	*can_restart,
+							 GError		**error);
+gboolean	 egg_console_kit_can_suspend		(EggConsoleKit	*console,
+							 gboolean	*can_restart,
+							 GError		**error);
+gboolean	 egg_console_kit_can_hibernate		(EggConsoleKit	*console,
+							 gboolean	*can_restart,
+							 GError		**error);
+
+G_END_DECLS
+
+#endif /* __EGG_CONSOLE_KIT_H */
+
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/52.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/52.html new file mode 100644 index 0000000..23873bc --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/52.html @@ -0,0 +1,561 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007-2008 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <math.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "egg-discrete.h"
+
+/**
+ * egg_discrete_from_percent:
+ * @percentage: The percentage to convert
+ * @levels: The number of discrete levels
+ *
+ * We have to be carefull when converting from %->discrete as precision is very
+ * important if we want the highest value.
+ *
+ * Return value: The discrete value for this percentage.
+ **/
+guint
+egg_discrete_from_percent (guint percentage, guint levels)
+{
+	/* check we are in range */
+	if (percentage > 100)
+		return levels;
+	if (levels == 0) {
+		g_warning ("levels is 0!");
+		return 0;
+	}
+	return (guint) ((((gfloat) percentage * (gfloat) (levels - 1)) / 100.0f) + 0.5f);
+}
+
+/**
+ * egg_discrete_to_percent:
+ * @hw: The discrete level
+ * @levels: The number of discrete levels
+ *
+ * We have to be carefull when converting from discrete->%.
+ *
+ * Return value: The percentage for this discrete value.
+ **/
+guint
+egg_discrete_to_percent (guint discrete, guint levels)
+{
+	/* check we are in range */
+	if (discrete > levels)
+		return 100;
+	if (levels == 0) {
+		g_warning ("levels is 0!");
+		return 0;
+	}
+	return (guint) (((gfloat) discrete * (100.0f / (gfloat) (levels - 1))) + 0.5f);
+}
+
+/**
+ * egg_discrete_to_fraction:
+ * @hw: The discrete level
+ * @levels: The number of discrete levels
+ *
+ * We have to be careful when converting from discrete->fractions.
+ *
+ * Return value: The floating point fraction (0..1) for this discrete value.
+ **/
+gfloat
+egg_discrete_to_fraction (guint discrete, guint levels)
+{
+	/* check we are in range */
+	if (discrete > levels)
+		return 1.0;
+	if (levels == 0) {
+		g_warning ("levels is 0!");
+		return 0.0;
+	}
+	return (guint) ((gfloat) discrete / ((gfloat) (levels - 1)));
+}
+
+/***************************************************************************
+ ***                          MAKE CHECK TESTS                           ***
+ ***************************************************************************/
+#ifdef EGG_TEST
+#include "egg-test.h"
+
+void
+egg_discrete_test (gpointer data)
+{
+	guint value;
+	gfloat fvalue;
+	EggTest *test = (EggTest *) data;
+
+	if (!egg_test_start (test, "EggDiscrete"))
+		return;
+
+	/************************************************************/
+	egg_test_title (test, "convert discrete 0/10 levels");
+	value = egg_discrete_to_percent (0, 10);
+	if (value == 0) {
+		egg_test_success (test, "got %i", value);
+	} else {
+		egg_test_failed (test, "conversion incorrect (%i)", value);
+	}
+
+	/************************************************************/
+	egg_test_title (test, "convert discrete 9/10 levels");
+	value = egg_discrete_to_percent (9, 10);
+	if (value == 100) {
+		egg_test_success (test, "got %i", value);
+	} else {
+		egg_test_failed (test, "conversion incorrect (%i)", value);
+	}
+
+	/************************************************************/
+	egg_test_title (test, "convert discrete 20/10 levels");
+	value = egg_discrete_to_percent (20, 10);<--- Assignment 'value=egg_discrete_to_percent(20,10)', assigned value is 100<--- Calling function 'egg_discrete_to_percent' returns 100
+	if (value == 100) {<--- Condition 'value==100' is always true
+		egg_test_success (test, "got %i", value);
+	} else {
+		egg_test_failed (test, "conversion incorrect (%i)", value);
+	}
+
+	/************************************************************/
+	egg_test_title (test, "convert discrete 0/10 levels");
+	fvalue = egg_discrete_to_fraction (0, 10);<--- Assignment 'fvalue=egg_discrete_to_fraction(0,10)', assigned value is 0<--- Calling function 'egg_discrete_to_fraction' returns 0
+	if (fvalue > -0.01 && fvalue < 0.01) {<--- Condition 'fvalue>-0.01' is always false
+		egg_test_success (test, "got %f", fvalue);
+	} else {
+		egg_test_failed (test, "conversion incorrect (%f)", fvalue);
+	}
+
+	/************************************************************/
+	egg_test_title (test, "convert discrete 9/10 levels");
+	fvalue = egg_discrete_to_fraction (9, 10);<--- Assignment 'fvalue=egg_discrete_to_fraction(9,10)', assigned value is 1<--- Calling function 'egg_discrete_to_fraction' returns 1<--- Assignment 'fvalue=egg_discrete_to_fraction(9,10)', assigned value is 1<--- Calling function 'egg_discrete_to_fraction' returns 1
+	if (fvalue > -1.01 && fvalue < 1.01) {<--- Condition 'fvalue>-1.01' is always true<--- Condition 'fvalue<1.01' is always false
+		egg_test_success (test, "got %f", fvalue);
+	} else {
+		egg_test_failed (test, "conversion incorrect (%f)", fvalue);
+	}
+
+	egg_test_end (test);
+}
+
+#endif
+
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/53.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/53.html new file mode 100644 index 0000000..7d83d2a --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/53.html @@ -0,0 +1,321 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007-2008 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __EGG_DISCRETE_H
+#define __EGG_DISCRETE_H
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+G_BEGIN_DECLS
+
+guint		 egg_discrete_from_percent		(guint		 percentage,
+							 guint		 levels);
+guint		 egg_discrete_to_percent		(guint		 discrete,
+							 guint		 levels);
+gfloat		 egg_discrete_to_fraction		(guint		 discrete,
+							 guint		 levels);
+#ifdef EGG_TEST
+void		 egg_discrete_test			(gpointer	 data);
+#endif
+
+G_END_DECLS
+
+#endif /* __EGG_DISCRETE_H */
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/54.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/54.html new file mode 100644 index 0000000..a41233d --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/54.html @@ -0,0 +1,1613 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
+603
+604
+605
+606
+607
+608
+609
+610
+611
+612
+613
+614
+615
+616
+617
+618
+619
+620
+621
+622
+623
+624
+625
+626
+627
+628
+629
+630
+631
+632
+633
+634
+635
+636
+637
+638
+639
+640
+641
+642
+643
+644
+645
+646
+647
+648
+649
+650
+651
+652
+653
+654
+655
+656
+657
+658
+659
+660
+661
+662
+663
+664
+665
+666
+667
+668
+669
+670
+671
+672
+673
+674
+675
+676
+677
+678
+679
+680
+681
+682
+683
+684
+685
+686
+687
+688
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007-2009 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#  include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <X11/Xlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <X11/extensions/sync.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdk/gdkx.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdk/gdk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <stdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "egg-idletime.h"
+
+static void     egg_idletime_finalize   (GObject       *object);
+
+struct EggIdletimePrivate
+{
+	gint			 sync_event;
+	gboolean		 reset_set;
+	XSyncCounter		 idle_counter;
+	GPtrArray		*array;
+	Display			*dpy;
+};
+
+typedef struct
+{
+	guint			 id;
+	XSyncValue		 timeout;
+	XSyncAlarm		 xalarm;
+	EggIdletime		*idletime;
+} EggIdletimeAlarm;
+
+enum {
+	SIGNAL_ALARM_EXPIRED,
+	SIGNAL_RESET,
+	LAST_SIGNAL
+};
+
+typedef enum {
+	EGG_IDLETIME_ALARM_TYPE_POSITIVE,
+	EGG_IDLETIME_ALARM_TYPE_NEGATIVE,
+	EGG_IDLETIME_ALARM_TYPE_DISABLED
+} EggIdletimeAlarmType;
+
+static guint signals [LAST_SIGNAL] = { 0 };
+static gpointer egg_idletime_object = NULL;
+
+G_DEFINE_TYPE_WITH_PRIVATE (EggIdletime, egg_idletime, G_TYPE_OBJECT)<--- There is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
+
+/**
+ * egg_idletime_xsyncvalue_to_int64:
+ */
+static gint64
+egg_idletime_xsyncvalue_to_int64 (XSyncValue value)
+{
+	return ((guint64) XSyncValueHigh32 (value)) << 32 | (guint64) XSyncValueLow32 (value);
+}
+
+/**
+ * egg_idletime_get_time:
+ */
+gint64
+egg_idletime_get_time (EggIdletime *idletime)
+{
+	XSyncValue value;
+	XSyncQueryCounter (idletime->priv->dpy, idletime->priv->idle_counter, &value);
+	return egg_idletime_xsyncvalue_to_int64 (value);
+}
+
+/**
+ * egg_idletime_xsync_alarm_set:
+ */
+static void
+egg_idletime_xsync_alarm_set (EggIdletime *idletime, EggIdletimeAlarm *alarm, EggIdletimeAlarmType alarm_type)
+{
+	XSyncAlarmAttributes attr;
+	XSyncValue delta;
+	unsigned int flags;
+	XSyncTestType test;
+
+	/* just remove it */
+	if (alarm_type == EGG_IDLETIME_ALARM_TYPE_DISABLED) {
+		if (alarm->xalarm) {
+			XSyncDestroyAlarm (idletime->priv->dpy, alarm->xalarm);
+			alarm->xalarm = None;
+		}
+		return;
+	}
+
+	/* which way do we do the test? */
+	if (alarm_type == EGG_IDLETIME_ALARM_TYPE_POSITIVE)
+		test = XSyncPositiveTransition;
+	else
+		test = XSyncNegativeTransition;
+
+	XSyncIntToValue (&delta, 0);
+
+	attr.trigger.counter = idletime->priv->idle_counter;
+	attr.trigger.value_type = XSyncAbsolute;
+	attr.trigger.test_type = test;
+	attr.trigger.wait_value = alarm->timeout;
+	attr.delta = delta;
+
+	flags = XSyncCACounter | XSyncCAValueType | XSyncCATestType | XSyncCAValue | XSyncCADelta;
+
+	if (alarm->xalarm)
+		XSyncChangeAlarm (idletime->priv->dpy, alarm->xalarm, flags, &attr);
+	else
+		alarm->xalarm = XSyncCreateAlarm (idletime->priv->dpy, flags, &attr);
+}
+
+/**
+ * egg_idletime_alarm_reset_all:
+ */
+void
+egg_idletime_alarm_reset_all (EggIdletime *idletime)
+{
+	guint i;
+	EggIdletimeAlarm *alarm;
+
+	g_return_if_fail (EGG_IS_IDLETIME (idletime));
+
+	if (!idletime->priv->reset_set)
+		return;
+
+	/* reset all the alarms (except the reset alarm) to their timeouts */
+	for (i=1; i<idletime->priv->array->len; i++) {
+		alarm = g_ptr_array_index (idletime->priv->array, i);
+		egg_idletime_xsync_alarm_set (idletime, alarm, EGG_IDLETIME_ALARM_TYPE_POSITIVE);
+	}
+
+	/* set the reset alarm to be disabled */
+	alarm = g_ptr_array_index (idletime->priv->array, 0);
+	egg_idletime_xsync_alarm_set (idletime, alarm, EGG_IDLETIME_ALARM_TYPE_DISABLED);
+
+	/* emit signal so say we've reset all timers */
+	g_signal_emit (idletime, signals [SIGNAL_RESET], 0);
+
+	/* we need to be reset again on the next event */
+	idletime->priv->reset_set = FALSE;
+}
+
+/**
+ * egg_idletime_alarm_find_id:
+ */
+static EggIdletimeAlarm *
+egg_idletime_alarm_find_id (EggIdletime *idletime, guint id)
+{
+	guint i;
+	EggIdletimeAlarm *alarm;
+	for (i=0; i<idletime->priv->array->len; i++) {
+		alarm = g_ptr_array_index (idletime->priv->array, i);
+		if (alarm->id == id)
+			return alarm;
+	}
+	return NULL;
+}
+
+/**
+ * egg_idletime_set_reset_alarm:
+ */
+static void
+egg_idletime_set_reset_alarm (EggIdletime *idletime, XSyncAlarmNotifyEvent *alarm_event)
+{
+	EggIdletimeAlarm *alarm;
+	int overflow;
+	XSyncValue add;
+	gint64 current, reset_threshold;
+
+	alarm = egg_idletime_alarm_find_id (idletime, 0);
+
+	if (!idletime->priv->reset_set) {
+		/* don't match on the current value because
+		 * XSyncNegativeComparison means less or equal. */
+		XSyncIntToValue (&add, -1);
+		XSyncValueAdd (&alarm->timeout, alarm_event->counter_value, add, &overflow);
+
+		/* set the reset alarm to fire the next time
+		 * idletime->priv->idle_counter < the current counter value */
+		egg_idletime_xsync_alarm_set (idletime, alarm, EGG_IDLETIME_ALARM_TYPE_NEGATIVE);
+
+		/* don't try to set this again if multiple timers are going off in sequence */
+		idletime->priv->reset_set = TRUE;
+
+		current = egg_idletime_get_time (idletime);
+		reset_threshold = egg_idletime_xsyncvalue_to_int64 (alarm->timeout);
+		if (current < reset_threshold) {
+			/* We've missed the alarm already */
+			egg_idletime_alarm_reset_all (idletime);
+		}
+	}
+}
+
+/**
+ * egg_idletime_alarm_find_event:
+ */
+static EggIdletimeAlarm *
+egg_idletime_alarm_find_event (EggIdletime *idletime, XSyncAlarmNotifyEvent *alarm_event)
+{
+	guint i;
+	EggIdletimeAlarm *alarm;
+	for (i=0; i<idletime->priv->array->len; i++) {
+		alarm = g_ptr_array_index (idletime->priv->array, i);
+		if (alarm_event->alarm == alarm->xalarm)
+			return alarm;
+	}
+	return NULL;
+}
+
+/**
+ * egg_idletime_event_filter_cb:
+ */
+static GdkFilterReturn
+egg_idletime_event_filter_cb (GdkXEvent *gdkxevent, GdkEvent *event, gpointer data)
+{
+	EggIdletimeAlarm *alarm;
+	XEvent *xevent = (XEvent *) gdkxevent;
+	EggIdletime *idletime = (EggIdletime *) data;
+	XSyncAlarmNotifyEvent *alarm_event;
+
+	/* no point continuing */
+	if (xevent->type != idletime->priv->sync_event + XSyncAlarmNotify)
+		return GDK_FILTER_CONTINUE;
+
+	alarm_event = (XSyncAlarmNotifyEvent *) xevent;
+
+	/* did we match one of our alarms? */
+	alarm = egg_idletime_alarm_find_event (idletime, alarm_event);
+	if (alarm == NULL)
+		return GDK_FILTER_CONTINUE;
+
+	/* are we the reset alarm? */
+	if (alarm->id == 0) {
+		egg_idletime_alarm_reset_all (idletime);
+		goto out;
+	}
+
+	/* emit */
+	g_signal_emit (alarm->idletime, signals [SIGNAL_ALARM_EXPIRED], 0, alarm->id);
+
+	/* we need the first alarm to go off to set the reset alarm */
+	egg_idletime_set_reset_alarm (idletime, alarm_event);
+out:
+	/* don't propagate */
+	return GDK_FILTER_REMOVE;
+}
+
+/**
+ * egg_idletime_alarm_new:
+ */
+static EggIdletimeAlarm *
+egg_idletime_alarm_new (EggIdletime *idletime, guint id)
+{
+	EggIdletimeAlarm *alarm;
+
+	/* create a new alarm */
+	alarm = g_new0 (EggIdletimeAlarm, 1);
+
+	/* set the default values */
+	alarm->id = id;
+	alarm->xalarm = None;
+	alarm->idletime = g_object_ref (idletime);
+
+	return alarm;
+}
+
+/**
+ * egg_idletime_alarm_set:
+ */
+gboolean
+egg_idletime_alarm_set (EggIdletime *idletime, guint id, guint timeout)
+{
+	EggIdletimeAlarm *alarm;
+
+	g_return_val_if_fail (EGG_IS_IDLETIME (idletime), FALSE);
+	g_return_val_if_fail (id != 0, FALSE);
+	g_return_val_if_fail (timeout != 0, FALSE);
+
+	/* see if we already created an alarm with this ID */
+	alarm = egg_idletime_alarm_find_id (idletime, id);
+	if (alarm == NULL) {
+		/* create a new alarm */
+		alarm = egg_idletime_alarm_new (idletime, id);
+
+		/* add to array */
+		g_ptr_array_add (idletime->priv->array, alarm);
+	}
+
+	/* set the timeout */
+	XSyncIntToValue (&alarm->timeout, (gint)timeout);
+
+	/* set, and start the timer */
+	egg_idletime_xsync_alarm_set (idletime, alarm, EGG_IDLETIME_ALARM_TYPE_POSITIVE);
+	return TRUE;
+}
+
+/**
+ * egg_idletime_alarm_free:
+ */
+static gboolean
+egg_idletime_alarm_free (EggIdletime *idletime, EggIdletimeAlarm *alarm)
+{
+	g_return_val_if_fail (EGG_IS_IDLETIME (idletime), FALSE);
+	g_return_val_if_fail (alarm != NULL, FALSE);
+
+	if (alarm->xalarm)
+		XSyncDestroyAlarm (idletime->priv->dpy, alarm->xalarm);
+	g_object_unref (alarm->idletime);
+	g_ptr_array_remove (idletime->priv->array, alarm);
+	g_free (alarm);
+	return TRUE;
+}
+
+/**
+ * egg_idletime_alarm_free:
+ */
+gboolean
+egg_idletime_alarm_remove (EggIdletime *idletime, guint id)
+{
+	EggIdletimeAlarm *alarm;
+
+	g_return_val_if_fail (EGG_IS_IDLETIME (idletime), FALSE);
+
+	alarm = egg_idletime_alarm_find_id (idletime, id);
+	if (alarm == NULL)
+		return FALSE;
+	egg_idletime_alarm_free (idletime, alarm);
+	return TRUE;
+}
+
+/**
+ * egg_idletime_class_init:
+ **/
+static void
+egg_idletime_class_init (EggIdletimeClass *klass)
+{
+	GObjectClass *object_class = G_OBJECT_CLASS (klass);
+	object_class->finalize = egg_idletime_finalize;
+
+	signals [SIGNAL_ALARM_EXPIRED] =
+		g_signal_new ("alarm-expired",
+			      G_TYPE_FROM_CLASS (object_class),
+			      G_SIGNAL_RUN_LAST,
+			      G_STRUCT_OFFSET (EggIdletimeClass, alarm_expired),
+			      NULL, NULL, g_cclosure_marshal_VOID__UINT,
+			      G_TYPE_NONE, 1, G_TYPE_UINT);
+	signals [SIGNAL_RESET] =
+		g_signal_new ("reset",
+			      G_TYPE_FROM_CLASS (object_class),
+			      G_SIGNAL_RUN_LAST,
+			      G_STRUCT_OFFSET (EggIdletimeClass, reset),
+			      NULL, NULL, g_cclosure_marshal_VOID__VOID,
+			      G_TYPE_NONE, 0);
+}
+
+/**
+ * egg_idletime_init:
+ **/
+static void
+egg_idletime_init (EggIdletime *idletime)
+{
+	int sync_error;
+	int ncounters;
+	XSyncSystemCounter *counters;
+	EggIdletimeAlarm *alarm;
+	gint i;
+
+	idletime->priv = egg_idletime_get_instance_private (idletime);
+
+	idletime->priv->array = g_ptr_array_new ();
+
+	idletime->priv->reset_set = FALSE;
+	idletime->priv->idle_counter = None;
+	idletime->priv->sync_event = 0;
+	idletime->priv->dpy = GDK_DISPLAY_XDISPLAY (gdk_display_get_default());
+
+	/* get the sync event */
+	if (!XSyncQueryExtension (idletime->priv->dpy, &idletime->priv->sync_event, &sync_error)) {
+		g_warning ("No Sync extension.");
+		return;
+	}
+
+	/* gtk_init should do XSyncInitialize for us */
+	counters = XSyncListSystemCounters (idletime->priv->dpy, &ncounters);
+	for (i=0; i < ncounters && !idletime->priv->idle_counter; i++) {
+		if (strcmp(counters[i].name, "IDLETIME") == 0)
+			idletime->priv->idle_counter = counters[i].counter;
+	}
+	XSyncFreeSystemCounterList (counters);
+
+	/* arh. we don't have IDLETIME support */
+	if (!idletime->priv->idle_counter) {
+		g_warning ("No idle counter.");
+		return;
+	}
+
+	/* catch the timer alarm */
+	gdk_window_add_filter (NULL, egg_idletime_event_filter_cb, idletime);
+
+	/* create a reset alarm */
+	alarm = egg_idletime_alarm_new (idletime, 0);
+	g_ptr_array_add (idletime->priv->array, alarm);
+}
+
+/**
+ * egg_idletime_finalize:
+ **/
+static void
+egg_idletime_finalize (GObject *object)
+{
+	guint i;
+	EggIdletime *idletime;
+	EggIdletimeAlarm *alarm;
+
+	g_return_if_fail (object != NULL);
+	g_return_if_fail (EGG_IS_IDLETIME (object));
+
+	idletime = EGG_IDLETIME (object);
+	idletime->priv = egg_idletime_get_instance_private (idletime);
+
+	/* free all counters, including reset counter */
+	for (i=0; i<idletime->priv->array->len; i++) {
+		alarm = g_ptr_array_index (idletime->priv->array, i);
+		egg_idletime_alarm_free (idletime, alarm);
+	}
+	g_ptr_array_free (idletime->priv->array, TRUE);
+
+	G_OBJECT_CLASS (egg_idletime_parent_class)->finalize (object);
+}
+
+/**
+ * egg_idletime_new:
+ **/
+EggIdletime *
+egg_idletime_new (void)
+{
+	if (egg_idletime_object != NULL) {
+		g_object_ref (egg_idletime_object);
+	} else {
+		egg_idletime_object = g_object_new (EGG_IDLETIME_TYPE, NULL);
+		g_object_add_weak_pointer (egg_idletime_object, &egg_idletime_object);
+	}
+	return EGG_IDLETIME (egg_idletime_object);
+}
+
+/***************************************************************************
+ ***                          MAKE CHECK TESTS                           ***
+ ***************************************************************************/
+#ifdef EGG_TEST
+#include "egg-test.h"
+
+static void
+egg_test_egg_idletime_wait (guint time_ms)
+{
+	GTimer *ltimer = g_timer_new ();
+	gfloat goal = time_ms / (gfloat) 1000.0f;
+	do {
+		g_main_context_iteration (NULL, FALSE);
+	} while (g_timer_elapsed (ltimer, NULL) < goal);
+	g_timer_destroy (ltimer);
+}
+
+static guint last_alarm = 0;
+static guint event_time;
+GTimer *timer;
+
+static void
+gpm_alarm_expired_cb (EggIdletime *idletime, guint alarm, gpointer data)
+{
+	last_alarm = alarm;
+	event_time = g_timer_elapsed (timer, NULL) * (gfloat) 1000.0f;
+//	g_print ("[evt %i in %ims]\n", alarm, event_time);
+}
+
+static void
+wait_until_alarm (void)
+{
+	g_print ("*****************************\n");
+	g_print ("*** DO NOT MOVE THE MOUSE ***\n");
+	g_print ("*****************************\n");
+	while (last_alarm == 0)
+		g_main_context_iteration (NULL, FALSE);
+}
+
+static void
+wait_until_reset (void)
+{
+	if (last_alarm == 0)
+		return;
+	g_print ("*****************************\n");
+	g_print ("***     MOVE THE MOUSE    ***\n");
+	g_print ("*****************************\n");
+	while (last_alarm != 0)
+		g_main_context_iteration (NULL, FALSE);
+	egg_test_egg_idletime_wait (1000);
+}
+
+void
+egg_idletime_test (gpointer data)
+{
+	EggIdletime *idletime;
+	gboolean ret;
+	guint i;
+	EggTest *test = (EggTest *) data;
+
+	if (egg_test_start (test, "EggIdletime") == FALSE)
+		return;
+
+	timer = g_timer_new ();
+	gdk_init (NULL, NULL);
+
+	/* warn */
+
+	g_timer_start (timer);
+	/************************************************************/
+	egg_test_title (test, "check to see if delay works as expected");
+	egg_test_egg_idletime_wait (2000);
+	event_time = g_timer_elapsed (timer, NULL) * (gfloat) 1000.0f;
+	if (event_time > 1800 && event_time < 2200) {
+		egg_test_success (test, "time %i~=%i", 2000, event_time);
+	} else {
+		egg_test_failed (test, "time not the same! %i != %i", event_time, 2000);
+	}
+
+	/************************************************************/
+	egg_test_title (test, "make sure we get a non null device");
+	idletime = egg_idletime_new ();
+	if (idletime != NULL) {
+		egg_test_success (test, "got EggIdletime");
+	} else {
+		egg_test_failed (test, "could not get EggIdletime");
+	}
+	g_signal_connect (idletime, "alarm-expired",
+			  G_CALLBACK (gpm_alarm_expired_cb), NULL);
+
+	/************************************************************/
+	egg_test_title (test, "check if we are alarm zero with no alarms");
+	if (last_alarm == 0) {
+		egg_test_success (test, NULL);
+	} else {
+		egg_test_failed (test, "alarm %i set!", last_alarm);
+	}
+
+	/************************************************************/
+	egg_test_title (test, "check if we can set an reset alarm");
+	ret = egg_idletime_alarm_set (idletime, 0, 100);
+	if (!ret) {
+		egg_test_success (test, "ignored reset alarm");
+	} else {
+		egg_test_failed (test, "did not ignore reset alarm");
+	}
+
+	/************************************************************/
+	egg_test_title (test, "check if we can set an alarm timeout of zero");
+	ret = egg_idletime_alarm_set (idletime, 999, 0);
+	if (!ret) {
+		egg_test_success (test, "ignored invalid alarm");
+	} else {
+		egg_test_failed (test, "did not ignore invalid alarm");
+	}
+
+	/************************************************************/
+	g_timer_start (timer);
+	egg_test_title (test, "check if we can set an alarm");
+	ret = egg_idletime_alarm_set (idletime, 101, 5000);
+	if (ret) {
+		egg_test_success (test, "set alarm okay");
+	} else {
+		egg_test_failed (test, "could not set alarm");
+	}
+
+	egg_idletime_alarm_set (idletime, 101, 5000);
+	wait_until_alarm ();
+
+	/* loop this two times */
+	for (i=0; i<2; i++) {
+		/* just let it time out, and wait for human input */
+		wait_until_reset ();
+		g_timer_start (timer);
+
+		/************************************************************/
+		g_timer_start (timer);
+		egg_test_title (test, "check if we can set an alarm");
+		ret = egg_idletime_alarm_set (idletime, 101, 5000);
+		if (ret) {
+			egg_test_success (test, "set alarm 5000ms okay");
+		} else {
+			egg_test_failed (test, "could not set alarm 5000ms");
+		}
+
+		/* wait for alarm to go off */
+		wait_until_alarm ();
+		g_timer_start (timer);
+
+		/************************************************************/
+		egg_test_title (test, "check if correct alarm has gone off");
+		if (last_alarm == 101) {
+			egg_test_success (test, "correct alarm");
+		} else {
+			egg_test_failed (test, "alarm %i set!", last_alarm);
+		}
+
+		/************************************************************/
+		egg_test_title (test, "check if alarm has gone off in correct time");
+		if (event_time > 3000 && event_time < 6000) {
+			egg_test_success (test, "correct, timeout ideally %ims (we did after %ims)", 5000, event_time);
+		} else {
+			egg_test_failed (test, "alarm %i did not timeout correctly !", last_alarm);
+		}
+	}
+
+	/* just let it time out, and wait for human input */
+	wait_until_reset ();
+	g_timer_start (timer);
+
+	/************************************************************/
+	g_timer_start (timer);
+	egg_test_title (test, "check if we can set an existing alarm");
+	ret = egg_idletime_alarm_set (idletime, 101, 10000);
+	if (ret) {
+		egg_test_success (test, "set alarm 10000ms okay");
+	} else {
+		egg_test_failed (test, "could not set alarm 10000ms");
+	}
+
+	/* wait for alarm to go off */
+	wait_until_alarm ();
+	g_timer_start (timer);
+
+	/************************************************************/
+	egg_test_title (test, "check if alarm has gone off in the old time");
+	if (event_time > 5000) {
+		egg_test_success (test, "last timeout value used");
+	} else {
+		egg_test_failed (test, "incorrect timeout used %ims", event_time);
+	}
+
+	/************************************************************/
+	egg_test_title (test, "check if we can remove an invalid alarm");
+	ret = egg_idletime_alarm_remove (idletime, 202);
+	if (!ret) {
+		egg_test_success (test, "ignored invalid alarm");
+	} else {
+		egg_test_failed (test, "removed invalid alarm");
+	}
+
+	/************************************************************/
+	egg_test_title (test, "check if we can remove an valid alarm");
+	ret = egg_idletime_alarm_remove (idletime, 101);
+	if (ret) {
+		egg_test_success (test, "removed valid alarm");
+	} else {
+		egg_test_failed (test, "failed to remove valid alarm");
+	}
+
+	g_timer_destroy (timer);
+	g_object_unref (idletime);
+
+	egg_test_end (test);
+}
+
+#endif
+
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/55.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/55.html new file mode 100644 index 0000000..16a8176 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/55.html @@ -0,0 +1,375 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __EGG_IDLETIME_H
+#define __EGG_IDLETIME_H
+
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+G_BEGIN_DECLS
+
+#define EGG_IDLETIME_TYPE		(egg_idletime_get_type ())
+#define EGG_IDLETIME(o)			(G_TYPE_CHECK_INSTANCE_CAST ((o), EGG_IDLETIME_TYPE, EggIdletime))
+#define EGG_IDLETIME_CLASS(k)		(G_TYPE_CHECK_CLASS_CAST((k), EGG_IDLETIME_TYPE, EggIdletimeClass))
+#define EGG_IS_IDLETIME(o)		(G_TYPE_CHECK_INSTANCE_TYPE ((o), EGG_IDLETIME_TYPE))
+#define EGG_IS_IDLETIME_CLASS(k)	(G_TYPE_CHECK_CLASS_TYPE ((k), EGG_IDLETIME_TYPE))
+#define EGG_IDLETIME_GET_CLASS(o)	(G_TYPE_INSTANCE_GET_CLASS ((o), EGG_IDLETIME_TYPE, EggIdletimeClass))
+
+typedef struct EggIdletimePrivate EggIdletimePrivate;
+
+typedef struct
+{
+	GObject			 parent;
+	EggIdletimePrivate	*priv;
+} EggIdletime;
+
+typedef struct
+{
+	GObjectClass	parent_class;
+	void		(* alarm_expired)		(EggIdletime	*idletime,
+							 guint		 timer_id);
+	void		(* reset)			(EggIdletime	*idletime);
+} EggIdletimeClass;
+
+GType		 egg_idletime_get_type			(void);
+EggIdletime	*egg_idletime_new			(void);
+
+void		 egg_idletime_alarm_reset_all		(EggIdletime	*idletime);
+gboolean	 egg_idletime_alarm_set			(EggIdletime	*idletime,
+							 guint		 alarm_id,
+							 guint		 timeout);
+gboolean	 egg_idletime_alarm_remove		(EggIdletime	*idletime,
+							 guint		 alarm_id);
+gint64		 egg_idletime_get_time			(EggIdletime	*idletime);
+#ifdef EGG_TEST
+void		 egg_idletime_test			(gpointer	 data);
+#endif
+
+G_END_DECLS
+
+#endif	/* __EGG_IDLETIME_H */
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/56.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/56.html new file mode 100644 index 0000000..42ca111 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/56.html @@ -0,0 +1,623 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007-2008 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <math.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "egg-precision.h"
+
+/**
+ * egg_precision_round_up:
+ * @value: The input value
+ * @smallest: The smallest increment allowed
+ *
+ * 101, 10	110
+ * 95,  10	100
+ * 0,   10	0
+ * 112, 10	120
+ * 100, 10	100
+ **/
+gint
+egg_precision_round_up (gfloat value, gint smallest)
+{
+	gfloat division;
+	if (fabs (value) < 0.01)
+		return 0;
+	if (smallest == 0) {
+		g_warning ("divisor zero");
+		return 0;
+	}
+	division = (gfloat) value / (gfloat) smallest;
+	division = ceilf (division);
+	division *= smallest;
+	return (gint) division;
+}
+
+/**
+ * egg_precision_round_down:
+ * @value: The input value
+ * @smallest: The smallest increment allowed
+ *
+ * 101, 10	100
+ * 95,  10	90
+ * 0,   10	0
+ * 112, 10	110
+ * 100, 10	100
+ **/
+gint
+egg_precision_round_down (gfloat value, gint smallest)
+{
+	gfloat division;
+	if (fabs (value) < 0.01)
+		return 0;
+	if (smallest == 0) {
+		g_warning ("divisor zero");
+		return 0;
+	}
+	division = (gfloat) value / (gfloat) smallest;
+	division = floorf (division);
+	division *= smallest;
+	return (gint) division;
+}
+
+/***************************************************************************
+ ***                          MAKE CHECK TESTS                           ***
+ ***************************************************************************/
+#ifdef EGG_TEST
+#include "egg-test.h"
+
+void
+egg_precision_test (gpointer data)
+{
+	guint value;
+	EggTest *test = (EggTest *) data;
+
+	if (!egg_test_start (test, "EggPrecision"))
+		return;
+
+	/************************************************************/
+	egg_test_title (test, "limit precision down 0,10");
+	value = egg_precision_round_down (0, 10);
+	if (value == 0) {
+		egg_test_success (test, "got %i", value);
+	} else {
+		egg_test_failed (test, "precision incorrect (%i)", value);
+	}
+
+	/************************************************************/
+	egg_test_title (test, "limit precision down 4,10");
+	value = egg_precision_round_down (4, 10);
+	if (value == 0) {
+		egg_test_success (test, "got %i", value);
+	} else {
+		egg_test_failed (test, "precision incorrect (%i)", value);
+	}
+
+	/************************************************************/
+	egg_test_title (test, "limit precision down 11,10");
+	value = egg_precision_round_down (11, 10);
+	if (value == 10) {
+		egg_test_success (test, "got %i", value);
+	} else {
+		egg_test_failed (test, "precision incorrect (%i)", value);
+	}
+
+	/************************************************************/
+	egg_test_title (test, "limit precision down 201,2");
+	value = egg_precision_round_down (201, 2);
+	if (value == 200) {
+		egg_test_success (test, "got %i", value);
+	} else {
+		egg_test_failed (test, "precision incorrect (%i)", value);
+	}
+
+	/************************************************************/
+	egg_test_title (test, "limit precision down 100,10");
+	value = egg_precision_round_down (100, 10);
+	if (value == 100) {
+		egg_test_success (test, "got %i", value);
+	} else {
+		egg_test_failed (test, "precision incorrect (%i)", value);
+	}
+
+	/************************************************************/
+	egg_test_title (test, "limit precision up 0,10");
+	value = egg_precision_round_up (0, 10);
+	if (value == 0) {
+		egg_test_success (test, "got %i", value);
+	} else {
+		egg_test_failed (test, "precision incorrect (%i)", value);
+	}
+
+	/************************************************************/
+	egg_test_title (test, "limit precision up 4,10");
+	value = egg_precision_round_up (4, 10);
+	if (value == 10) {
+		egg_test_success (test, "got %i", value);
+	} else {
+		egg_test_failed (test, "precision incorrect (%i)", value);
+	}
+
+	/************************************************************/
+	egg_test_title (test, "limit precision up 11,10");
+	value = egg_precision_round_up (11, 10);
+	if (value == 20) {
+		egg_test_success (test, "got %i", value);
+	} else {
+		egg_test_failed (test, "precision incorrect (%i)", value);
+	}
+
+	/************************************************************/
+	egg_test_title (test, "limit precision up 201,2");
+	value = egg_precision_round_up (201, 2);
+	if (value == 202) {
+		egg_test_success (test, "got %i", value);
+	} else {
+		egg_test_failed (test, "precision incorrect (%i)", value);
+	}
+
+	/************************************************************/
+	egg_test_title (test, "limit precision up 100,10");
+	value = egg_precision_round_up (100, 10);
+	if (value == 100) {
+		egg_test_success (test, "got %i", value);
+	} else {
+		egg_test_failed (test, "precision incorrect (%i)", value);
+	}
+
+	egg_test_end (test);
+}
+
+#endif
+
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/57.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/57.html new file mode 100644 index 0000000..3fafd35 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/57.html @@ -0,0 +1,317 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007-2008 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __EGG_PRECISION_H
+#define __EGG_PRECISION_H
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+G_BEGIN_DECLS
+
+gint		 egg_precision_round_up			(gfloat		 value,
+							 gint		 smallest);
+gint		 egg_precision_round_down		(gfloat		 value,
+							 gint		 smallest);
+#ifdef EGG_TEST
+void		 egg_precision_test			(gpointer	 data);
+#endif
+
+G_END_DECLS
+
+#endif /* __EGG_PRECISION_H */
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/58.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/58.html new file mode 100644 index 0000000..42f5111 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/58.html @@ -0,0 +1,925 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007-2008 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gprintf.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "egg-test.h"
+
+struct EggTest {
+	guint		 total;
+	guint		 succeeded;
+	gboolean	 started;
+	gboolean	 titled;
+	gchar		*type;
+	GTimer		*timer;
+	GMainLoop	*loop;
+	guint		 hang_loop_id;
+	gpointer	 user_data;
+};
+
+/**
+ * egg_test_init:
+ **/
+EggTest *
+egg_test_init (void)
+{
+	EggTest *test;
+	test = g_new (EggTest, 1);
+	test->total = 0;
+	test->succeeded = 0;
+	test->type = NULL;
+	test->started = FALSE;
+	test->titled = FALSE;
+	test->timer = g_timer_new ();
+	test->loop = g_main_loop_new (NULL, FALSE);
+	test->hang_loop_id = 0;
+	return test;
+}
+
+/**
+ * egg_test_loop_quit:
+ **/
+void
+egg_test_loop_quit (EggTest *test)
+{
+	/* disable the loop watch */
+	if (test->hang_loop_id != 0) {
+		g_source_remove (test->hang_loop_id);
+		test->hang_loop_id = 0;
+	}
+	g_main_loop_quit (test->loop);
+}
+
+/**
+ * egg_test_hang_check:
+ **/
+static gboolean
+egg_test_hang_check (gpointer data)
+{
+	EggTest *test = (EggTest *) data;
+	g_main_loop_quit (test->loop);
+	return FALSE;
+}
+
+/**
+ * egg_test_loop_wait:
+ **/
+void
+egg_test_loop_wait (EggTest *test, guint timeout)
+{
+	test->hang_loop_id = g_timeout_add (timeout, egg_test_hang_check, test);
+	g_main_loop_run (test->loop);
+}
+
+/**
+ * egg_test_loop_check:
+ **/
+void
+egg_test_loop_check (EggTest *test)
+{
+	guint elapsed = egg_test_elapsed (test);
+	egg_test_title (test, "did we timeout out of the loop");
+	if (test->hang_loop_id == 0) {
+		egg_test_success (test, "loop blocked for %ims", elapsed);
+	} else {
+		egg_test_failed (test, "hangcheck saved us after %ims", elapsed);
+	}
+}
+
+/**
+ * egg_test_set_user_data:
+ **/
+void
+egg_test_set_user_data (EggTest *test, gpointer user_data)
+{
+	test->user_data = user_data;
+}
+
+/**
+ * egg_test_get_user_data:
+ **/
+gpointer
+egg_test_get_user_data (EggTest *test)<--- Parameter 'test' can be declared as pointer to const
+{
+	return test->user_data;
+}
+
+/**
+ * egg_test_finish:
+ **/
+gint
+egg_test_finish (EggTest *test)
+{
+	gint retval;
+	g_print ("test passes (%u/%u) : ", test->succeeded, test->total);
+	if (test->succeeded == test->total) {
+		g_print ("ALL OKAY\n");
+		retval = 0;
+	} else {
+		g_print ("%u FAILURE(S)\n", test->total - test->succeeded);
+		retval = 1;
+	}
+
+	g_timer_destroy (test->timer);
+	g_main_loop_unref (test->loop);
+	g_free (test);
+
+	return retval;
+}
+
+/**
+ * egg_test_elapsed:
+ *
+ * Returns: time in ms
+ **/
+guint
+egg_test_elapsed (EggTest *test)
+{
+	gdouble time_s;
+	time_s = g_timer_elapsed (test->timer, NULL);
+	return (guint) (time_s * 1000.0f);
+}
+
+/**
+ * egg_test_start:
+ **/
+gboolean
+egg_test_start (EggTest *test, const gchar *name)
+{
+	if (test->started) {
+		g_print ("Not ended test! Cannot start!\n");
+		exit (1);
+	}
+	test->type = g_strdup (name);
+	test->started = TRUE;
+	return TRUE;
+}
+
+/**
+ * egg_test_end:
+ **/
+void
+egg_test_end (EggTest *test)
+{
+	if (test->started == FALSE) {
+		g_print ("Not started test! Cannot finish!\n");
+		exit (1);
+	}
+	g_print ("OK\n");
+
+	/* disable hang check */
+	if (test->hang_loop_id != 0) {
+		g_source_remove (test->hang_loop_id);
+		test->hang_loop_id = 0;
+	}
+
+	test->started = FALSE;
+	g_free (test->type);
+}
+
+/**
+ * egg_test_title:
+ **/
+void
+egg_test_title (EggTest *test, const gchar *format, ...)
+{
+	va_list args;
+	gchar *va_args_buffer = NULL;
+
+	/* already titled? */
+	if (test->titled) {
+		g_print ("Already titled!\n");
+		exit (1);
+	}
+
+	/* reset the value egg_test_elapsed replies with */
+	g_timer_reset (test->timer);
+
+	va_start (args, format);
+	g_vasprintf (&va_args_buffer, format, args);
+	va_end (args);
+	g_print ("> check #%u\t%s: \t%s...", test->total+1, test->type, va_args_buffer);
+	g_free (va_args_buffer);
+
+	test->titled = TRUE;
+	test->total++;
+}
+
+/**
+ * egg_test_success:
+ **/
+void
+egg_test_success (EggTest *test, const gchar *format, ...)
+{
+	va_list args;
+	gchar *va_args_buffer = NULL;
+
+	/* not titled? */
+	if (!test->titled) {
+		g_print ("Not titled!\n");
+		exit (1);
+	}
+	if (format == NULL) {
+		g_print ("...OK\n");
+		goto finish;
+	}
+	va_start (args, format);
+	g_vasprintf (&va_args_buffer, format, args);
+	va_end (args);
+	g_print ("...OK [%s]\n", va_args_buffer);
+	g_free (va_args_buffer);
+finish:
+	test->titled = FALSE;
+	test->succeeded++;
+}
+
+/**
+ * egg_test_failed:
+ **/
+void
+egg_test_failed (EggTest *test, const gchar *format, ...)<--- Parameter 'test' can be declared as pointer to const
+{
+	va_list args;
+	gchar *va_args_buffer = NULL;
+
+	/* not titled? */
+	if (!test->titled) {
+		g_print ("Not titled!\n");
+		exit (1);
+	}
+	if (format == NULL) {
+		g_print ("FAILED\n");
+		goto failed;
+	}
+	va_start (args, format);
+	g_vasprintf (&va_args_buffer, format, args);
+	va_end (args);
+	g_print ("FAILED [%s]\n", va_args_buffer);
+	g_free (va_args_buffer);
+failed:
+	exit (1);
+}
+
+/**
+ * egg_test_assert:
+ **/
+void
+egg_test_assert (EggTest *test, gboolean value)
+{
+	if (value)
+		egg_test_success (test, NULL);
+	else
+		egg_test_failed (test, NULL);
+}
+
+/**
+ * egg_test_title_assert:
+ **/
+void
+egg_test_title_assert (EggTest *test, const gchar *text, gboolean value)
+{
+	egg_test_title (test, "%s", text);
+	if (value)
+		egg_test_success (test, NULL);
+	else
+		egg_test_failed (test, NULL);
+}
+
+/**
+ * egg_test_get_data_file:
+ **/
+gchar *
+egg_test_get_data_file (const gchar *filename)
+{
+	gboolean ret;
+	gchar *full;
+
+	/* check to see if we are being run in the build root */
+	full = g_build_filename ("..", "data", "tests", filename, NULL);
+	ret = g_file_test (full, G_FILE_TEST_EXISTS);
+	if (ret)
+		return full;
+	g_free (full);
+
+	/* check to see if we are being run in the build root */
+	full = g_build_filename ("..", "..", "data", "tests", filename, NULL);
+	ret = g_file_test (full, G_FILE_TEST_EXISTS);
+	if (ret)
+		return full;
+	g_free (full);
+
+	/* check to see if we are being run in make check */
+	full = g_build_filename ("..", "..", "..", "data", "tests", filename, NULL);
+	ret = g_file_test (full, G_FILE_TEST_EXISTS);
+	if (ret)
+		return full;
+	g_print ("[WARN] failed to find '%s'\n", full);
+	g_free (full);
+	return NULL;
+}
+
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/59.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/59.html new file mode 100644 index 0000000..aefec5d --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/59.html @@ -0,0 +1,803 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2010 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "config.h"<--- Include file: "config.h" not found.
+
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <locale.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/types.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/stat.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <fcntl.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#define GCM_BACKLIGHT_HELPER_EXIT_CODE_SUCCESS			0
+#define GCM_BACKLIGHT_HELPER_EXIT_CODE_FAILED			1
+#define GCM_BACKLIGHT_HELPER_EXIT_CODE_ARGUMENTS_INVALID	3
+#define GCM_BACKLIGHT_HELPER_EXIT_CODE_INVALID_USER		4
+
+#define GCM_BACKLIGHT_HELPER_SYSFS_LOCATION			"/sys/class/backlight"
+
+/**
+ * gcm_backlight_helper_get_best_backlight:
+ **/
+static gchar *
+gcm_backlight_helper_get_best_backlight (void)
+{
+	gchar *filename;
+	guint i;
+	gboolean ret;
+	GDir *dir = NULL;
+	GError *error = NULL;
+	const gchar *first_device;
+
+	/* available kernel interfaces in priority order */
+	static const gchar *backlight_interfaces[] = {
+		"gmux_backlight",
+		"nv_backlight",
+		"nvidia_backlight",
+		"intel_backlight",
+		"dell_backlight",
+		"asus_laptop",
+		"toshiba",
+		"eeepc",
+		"eeepc-wmi",
+		"thinkpad_screen",
+		"acpi_video1",
+		"mbp_backlight",
+		"acpi_video0",
+		"fujitsu-laptop",
+		"sony",
+		"samsung",
+		NULL,
+	};
+
+	/* search each one */
+	for (i=0; backlight_interfaces[i] != NULL; i++) {
+		filename = g_build_filename (GCM_BACKLIGHT_HELPER_SYSFS_LOCATION,
+					     backlight_interfaces[i], NULL);
+		ret = g_file_test (filename, G_FILE_TEST_EXISTS);
+		if (ret)
+			goto out;
+		g_free (filename);
+	}
+
+	/* nothing found in the ordered list */
+	filename = NULL;
+
+	/* find any random ones */
+	dir = g_dir_open (GCM_BACKLIGHT_HELPER_SYSFS_LOCATION, 0, &error);
+	if (dir == NULL) {
+		g_warning ("failed to find any devices: %s", error->message);
+		g_error_free (error);
+		goto out;
+	}
+
+	/* get first device if any */
+	first_device = g_dir_read_name (dir);
+	if (first_device != NULL) {
+		filename = g_build_filename (GCM_BACKLIGHT_HELPER_SYSFS_LOCATION,
+					     first_device, NULL);
+	}
+out:
+	if (dir != NULL)
+		g_dir_close (dir);
+	return filename;
+}
+
+/**
+ * gcm_backlight_helper_write:
+ **/
+static gboolean
+gcm_backlight_helper_write (const gchar *filename, gint value, GError **error)
+{
+	gchar *text = NULL;
+	gint retval;
+	gint length;
+	gint fd = -1;
+	gboolean ret = TRUE;
+
+	fd = open (filename, O_WRONLY);
+	if (fd < 0) {
+		ret = FALSE;
+		g_set_error (error, 1, 0, "failed to open filename: %s", filename);
+		goto out;
+	}
+
+	/* convert to text */
+	text = g_strdup_printf ("%i", value);
+	length = strlen (text);
+
+	/* write to device file */
+	retval = write (fd, text, length);
+	if (retval != length) {
+		ret = FALSE;
+		g_set_error (error, 1, 0, "writing '%s' to %s failed", text, filename);
+		goto out;
+	}
+out:
+	if (fd >= 0)
+		close (fd);
+	g_free (text);
+	return ret;
+}
+
+/**
+ * main:
+ **/
+gint
+main (gint argc, gchar *argv[])
+{
+	GOptionContext *context;
+	gint uid;
+	gint euid;
+	guint retval = 0;
+	const gchar *pkexec_uid_str;
+	GError *error = NULL;
+	gboolean ret = FALSE;
+	gint set_brightness = -1;
+	gboolean get_brightness = FALSE;
+	gboolean get_max_brightness = FALSE;
+	gchar *filename = NULL;
+	gchar *filename_file = NULL;
+	gchar *contents = NULL;
+
+	const GOptionEntry options[] = {
+		{ "set-brightness", '\0', 0, G_OPTION_ARG_INT, &set_brightness,
+		   /* command line argument */
+		  _("Set the current brightness"), NULL },
+		{ "get-brightness", '\0', 0, G_OPTION_ARG_NONE, &get_brightness,
+		   /* command line argument */
+		  _("Get the current brightness"), NULL },
+		{ "get-max-brightness", '\0', 0, G_OPTION_ARG_NONE, &get_max_brightness,
+		   /* command line argument */
+		  _("Get the number of brightness levels supported"), NULL },
+		{ NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL }
+	};
+
+	/* setup translations */
+	setlocale (LC_ALL, "");
+	bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR);
+	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+	textdomain (GETTEXT_PACKAGE);
+
+	context = g_option_context_new (NULL);
+	/* TRANSLATORS: tool that is used when copying profiles system-wide */
+	g_option_context_set_summary (context, _("MATE Power Manager Backlight Helper"));
+	g_option_context_add_main_entries (context, options, NULL);
+	g_option_context_parse (context, &argc, &argv, NULL);
+	g_option_context_free (context);
+
+	/* no input */
+	if (set_brightness == -1 && !get_brightness && !get_max_brightness) {
+		/* TRANSLATORS: user did not specify valid options */
+		g_print ("%s\n", _("No valid option was specified"));
+		retval = GCM_BACKLIGHT_HELPER_EXIT_CODE_ARGUMENTS_INVALID;
+		goto out;
+	}
+
+	/* find device */
+	filename = gcm_backlight_helper_get_best_backlight ();
+	if (filename == NULL) {
+		/* TRANSLATORS: no backlights found */
+		g_print ("%s\n", _("No backlights were found on your system"));
+		retval = GCM_BACKLIGHT_HELPER_EXIT_CODE_INVALID_USER;
+		goto out;
+	}
+
+	/* GetBrightness */
+	if (get_brightness) {
+		filename_file = g_build_filename (filename, "brightness", NULL);
+		ret = g_file_get_contents (filename_file, &contents, NULL, &error);
+		if (!ret) {
+			/* TRANSLATORS: failed to access backlight file */
+			g_print ("%s: %s\n", _("Could not get the value of the backlight"), error->message);
+			g_error_free (error);
+			retval = GCM_BACKLIGHT_HELPER_EXIT_CODE_ARGUMENTS_INVALID;
+			goto out;
+		}
+
+		/* just print the contents to stdout */
+		g_print ("%s", contents);
+		retval = GCM_BACKLIGHT_HELPER_EXIT_CODE_SUCCESS;
+		goto out;
+	}
+
+	/* GetSteps */
+	if (get_max_brightness) {
+		filename_file = g_build_filename (filename, "max_brightness", NULL);
+		ret = g_file_get_contents (filename_file, &contents, NULL, &error);
+		if (!ret) {
+			/* TRANSLATORS: failed to access backlight file */
+			g_print ("%s: %s\n", _("Could not get the maximum value of the backlight"), error->message);
+			g_error_free (error);
+			retval = GCM_BACKLIGHT_HELPER_EXIT_CODE_ARGUMENTS_INVALID;
+			goto out;
+		}
+
+		/* just print the contents to stdout */
+		g_print ("%s", contents);
+		retval = GCM_BACKLIGHT_HELPER_EXIT_CODE_SUCCESS;
+		goto out;
+	}
+
+	/* get calling process */
+	uid = getuid ();
+	euid = geteuid ();
+	if (uid != 0 || euid != 0) {
+		/* TRANSLATORS: only able to install profiles as root */
+		g_print ("%s\n", _("This program can only be used by the root user"));
+		retval = GCM_BACKLIGHT_HELPER_EXIT_CODE_ARGUMENTS_INVALID;
+		goto out;
+	}
+
+	/* check we're not being spoofed */
+	pkexec_uid_str = g_getenv ("PKEXEC_UID");
+	if (pkexec_uid_str == NULL) {
+		/* TRANSLATORS: the program must never be directly run */
+		g_print ("%s\n", _("This program must only be run through pkexec"));
+		retval = GCM_BACKLIGHT_HELPER_EXIT_CODE_INVALID_USER;
+		goto out;
+	}
+
+	/* SetBrightness */
+	if (set_brightness != -1) {
+		filename_file = g_build_filename (filename, "brightness", NULL);
+		ret = gcm_backlight_helper_write (filename_file, set_brightness, &error);
+		if (!ret) {
+			/* TRANSLATORS: failed to access backlight file */
+			g_print ("%s: %s\n", _("Could not set the value of the backlight"), error->message);
+			g_error_free (error);
+			retval = GCM_BACKLIGHT_HELPER_EXIT_CODE_ARGUMENTS_INVALID;
+			goto out;
+		}
+	}
+
+	/* success */
+	retval = GCM_BACKLIGHT_HELPER_EXIT_CODE_SUCCESS;
+out:
+	g_free (filename);
+	g_free (filename_file);
+	g_free (contents);
+	return retval;
+}
+
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/6.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/6.html new file mode 100644 index 0000000..b0d4730 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/6.html @@ -0,0 +1,863 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
/*
+ * Copyright 2007 Red Hat, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/* Author: Soren Sandmann <sandmann@redhat.com> */
+
+#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n-lib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <math.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include "edid.h"
+
+typedef struct Vendor Vendor;
+
+struct Vendor {
+	const char vendor_id[4];
+	const char vendor_name[28];
+};
+
+/* This list of vendor codes derived from lshw
+ *
+ * http://ezix.org/project/wiki/HardwareLiSter
+ *
+ * Note: we now prefer to use data coming from hwdata (and shipped with
+ * mate-desktop). See
+ * http://git.fedorahosted.org/git/?p=hwdata.git;a=blob_plain;f=pnp.ids;hb=HEAD
+ * All contributions to the list of vendors should go there.
+ */
+static const struct Vendor vendors[] = {
+	{"AIC", "AG Neovo"},
+	{"ACR", "Acer"},
+	{"DEL", "DELL"},
+	{"SAM", "SAMSUNG"},
+	{"SNY", "SONY"},
+	{"SEC", "Epson"},
+	{"WAC", "Wacom"},
+	{"NEC", "NEC"},
+	{"CMO", "CMO"},	/* Chi Mei */
+	{"BNQ", "BenQ"},
+
+	{"ABP", "Advansys"},
+	{"ACC", "Accton"},
+	{"ACE", "Accton"},
+	{"ADP", "Adaptec"},
+	{"ADV", "AMD"},
+	{"AIR", "AIR"},
+	{"AMI", "AMI"},
+	{"ASU", "ASUS"},
+	{"ATI", "ATI"},
+	{"ATK", "Allied Telesyn"},
+	{"AZT", "Aztech"},
+	{"BAN", "Banya"},
+	{"BRI", "Boca Research"},
+	{"BUS", "Buslogic"},
+	{"CCI", "Cache Computers Inc."},
+	{"CHA", "Chase"},
+	{"CMD", "CMD Technology, Inc."},
+	{"COG", "Cogent"},
+	{"CPQ", "Compaq"},
+	{"CRS", "Crescendo"},
+	{"CSC", "Crystal"},
+	{"CSI", "CSI"},
+	{"CTL", "Creative Labs"},
+	{"DBI", "Digi"},
+	{"DEC", "Digital Equipment"},
+	{"DBK", "Databook"},
+	{"EGL", "Eagle Technology"},
+	{"ELS", "ELSA"},
+	{"ESS", "ESS"},
+	{"FAR", "Farallon"},
+	{"FDC", "Future Domain"},
+	{"HWP", "Hewlett-Packard"},
+	{"IBM", "IBM"},
+	{"INT", "Intel"},
+	{"ISA", "Iomega"},
+	{"LEN", "Lenovo"},
+	{"MDG", "Madge"},
+	{"MDY", "Microdyne"},
+	{"MET", "Metheus"},
+	{"MIC", "Micronics"},
+	{"MLX", "Mylex"},
+	{"NVL", "Novell"},
+	{"OLC", "Olicom"},
+	{"PRO", "Proteon"},
+	{"RII", "Racal"},
+	{"RTL", "Realtek"},
+	{"SCM", "SCM"},
+	{"SKD", "SysKonnect"},
+	{"SGI", "SGI"},
+	{"SMC", "SMC"},
+	{"SNI", "Siemens Nixdorf"},
+	{"STL", "Stallion Technologies"},
+	{"SUN", "Sun"},
+	{"SUP", "SupraExpress"},
+	{"SVE", "SVEC"},
+	{"TCC", "Thomas-Conrad"},
+	{"TCI", "Tulip"},
+	{"TCM", "3Com"},
+	{"TCO", "Thomas-Conrad"},
+	{"TEC", "Tecmar"},
+	{"TRU", "Truevision"},
+	{"TOS", "Toshiba"},
+	{"TYN", "Tyan"},
+	{"UBI", "Ungermann-Bass"},
+	{"USC", "UltraStor"},
+	{"VDM", "Vadem"},
+	{"VMI", "Vermont"},
+	{"WDC", "Western Digital"},
+	{"ZDS", "Zeos"},
+
+	/* From http://faydoc.tripod.com/structures/01/0136.htm */
+	{"ACT", "Targa"},
+	{"ADI", "ADI"},
+	{"AOC", "AOC Intl"},
+	{"API", "Acer America"},
+	{"APP", "Apple Computer"},
+	{"ART", "ArtMedia"},
+	{"AST", "AST Research"},
+	{"CPL", "Compal"},
+	{"CTX", "Chuntex Electronic Co."},
+	{"DPC", "Delta Electronics"},
+	{"DWE", "Daewoo"},
+	{"ECS", "ELITEGROUP"},
+	{"EIZ", "EIZO"},
+	{"FCM", "Funai"},
+	{"GSM", "LG Electronics"},
+	{"GWY", "Gateway 2000"},
+	{"HEI", "Hyundai"},
+	{"HIT", "Hitachi"},
+	{"HSL", "Hansol"},
+	{"HTC", "Hitachi"},
+	{"ICL", "Fujitsu ICL"},
+	{"IVM", "Idek Iiyama"},
+	{"KFC", "KFC Computek"},
+	{"LKM", "ADLAS"},
+	{"LNK", "LINK Tech"},
+	{"LTN", "Lite-On"},
+	{"MAG", "MAG InnoVision"},
+	{"MAX", "Maxdata"},
+	{"MEI", "Panasonic"},
+	{"MEL", "Mitsubishi"},
+	{"MIR", "miro"},
+	{"MTC", "MITAC"},
+	{"NAN", "NANAO"},
+	{"NEC", "NEC Tech"},
+	{"NOK", "Nokia"},
+	{"OQI", "OPTIQUEST"},
+	{"PBN", "Packard Bell"},
+	{"PGS", "Princeton"},
+	{"PHL", "Philips"},
+	{"REL", "Relisys"},
+	{"SDI", "Samtron"},
+	{"SMI", "Smile"},
+	{"SPT", "Sceptre"},
+	{"SRC", "Shamrock Technology"},
+	{"STP", "Sceptre"},
+	{"TAT", "Tatung"},
+	{"TRL", "Royal Information Company"},
+	{"TSB", "Toshiba, Inc."},
+	{"UNM", "Unisys"},
+	{"VSC", "ViewSonic"},
+	{"WTC", "Wen Tech"},
+	{"ZCM", "Zenith Data Systems"},
+
+	{"???", "Unknown"},
+};
+
+static GHashTable* pnp_ids = NULL;
+
+static void read_pnp_ids(void)
+{
+	gchar* contents;
+	gchar** lines;
+	gchar* line;
+	gchar* code, *name;
+	gint i;
+
+	if (pnp_ids)
+		return;
+
+	pnp_ids = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
+
+	if (g_file_get_contents(PNP_IDS, &contents, NULL, NULL))
+	{
+		lines = g_strsplit(contents, "\n", -1);
+
+		for (i = 0; lines[i]; i++)
+		{
+			 line = lines[i];
+
+			 if (line[0] && line[1] && line[2] && line[3] == '\t' && line[4])
+			 {
+				 code = line;
+				 line[3] = '\0';
+				 name = line + 4;
+				 g_hash_table_insert(pnp_ids, code, name);
+			 }
+		}
+
+		g_free(lines);
+		g_free(contents);
+	}
+}
+
+static const char* find_vendor(const char* code)
+{
+	const char* vendor_name;
+	gsize i;
+
+	read_pnp_ids();
+
+	vendor_name = g_hash_table_lookup(pnp_ids, code);
+
+	if (vendor_name)
+		return vendor_name;
+
+	for (i = 0; i < G_N_ELEMENTS (vendors); ++i)
+	{
+		const Vendor* v = &(vendors[i]);
+
+		if (strcmp(v->vendor_id, code) == 0)
+			return v->vendor_name;
+	}
+
+	return code;
+}
+
+char* make_display_name(const MonitorInfo* info)
+{
+	const char* vendor;
+	int width_mm, height_mm, inches;
+
+	if (info)
+	{
+		vendor = find_vendor(info->manufacturer_code);
+	}
+	else
+	{
+		/* Translators: "Unknown" here is used to identify a monitor for which
+		 * we don't know the vendor. When a vendor is known, the name of the
+		 * vendor is used. */
+		vendor = C_("Monitor vendor", "Unknown");
+	}
+
+	if (info && info->width_mm != -1 && info->height_mm)
+	{
+		width_mm = info->width_mm;
+		height_mm = info->height_mm;
+	}
+	else if (info && info->n_detailed_timings)
+	{
+		width_mm = info->detailed_timings[0].width_mm;
+		height_mm = info->detailed_timings[0].height_mm;
+	}
+	else
+	{
+		width_mm = -1;
+		height_mm = -1;
+	}
+
+	if (width_mm != -1 && height_mm != -1)
+	{
+		double d = sqrt (width_mm * width_mm + height_mm * height_mm);
+
+		inches = (int) (d / 25.4 + 0.5);
+	}
+	else
+	{
+		inches = -1;
+	}
+
+	if (inches > 0)
+	{
+		return g_strdup_printf("%s %d\"", vendor, inches);
+	}
+	else
+	{
+		return g_strdup(vendor);
+	}
+}
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/60.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/60.html new file mode 100644 index 0000000..4800680 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/60.html @@ -0,0 +1,1823 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
+603
+604
+605
+606
+607
+608
+609
+610
+611
+612
+613
+614
+615
+616
+617
+618
+619
+620
+621
+622
+623
+624
+625
+626
+627
+628
+629
+630
+631
+632
+633
+634
+635
+636
+637
+638
+639
+640
+641
+642
+643
+644
+645
+646
+647
+648
+649
+650
+651
+652
+653
+654
+655
+656
+657
+658
+659
+660
+661
+662
+663
+664
+665
+666
+667
+668
+669
+670
+671
+672
+673
+674
+675
+676
+677
+678
+679
+680
+681
+682
+683
+684
+685
+686
+687
+688
+689
+690
+691
+692
+693
+694
+695
+696
+697
+698
+699
+700
+701
+702
+703
+704
+705
+706
+707
+708
+709
+710
+711
+712
+713
+714
+715
+716
+717
+718
+719
+720
+721
+722
+723
+724
+725
+726
+727
+728
+729
+730
+731
+732
+733
+734
+735
+736
+737
+738
+739
+740
+741
+742
+743
+744
+745
+746
+747
+748
+749
+750
+751
+752
+753
+754
+755
+756
+757
+758
+759
+760
+761
+762
+763
+764
+765
+766
+767
+768
+769
+770
+771
+772
+773
+774
+775
+776
+777
+778
+779
+780
+781
+782
+783
+784
+785
+786
+787
+788
+789
+790
+791
+792
+793
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2005-2009 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2005 William Jon McCann <mccann@jhu.edu>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+
+#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <time.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <errno.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/time.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/types.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <math.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#ifdef HAVE_UNISTD_H
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif /* HAVE_UNISTD_H */
+
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <libupower-glib/upower.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "gpm-button.h"
+#include "gpm-backlight.h"
+#include "gpm-brightness.h"
+#include "gpm-control.h"
+#include "gpm-common.h"
+#include "gsd-media-keys-window.h"
+#include "gpm-dpms.h"
+#include "gpm-idle.h"
+#include "gpm-marshal.h"
+#include "gpm-icon-names.h"
+#include "egg-console-kit.h"
+
+struct GpmBacklightPrivate
+{
+	UpClient		*client;
+	GpmBrightness		*brightness;
+	GpmButton		*button;
+	GSettings		*settings;
+	GtkWidget		*popup;
+	GpmControl		*control;
+	GpmDpms			*dpms;
+	GpmIdle			*idle;
+	EggConsoleKit		*console;
+	gboolean		 can_dim;
+	gboolean		 system_is_idle;
+	GTimer			*idle_timer;
+	guint			 idle_dim_timeout;
+	guint			 master_percentage;
+};
+
+enum {
+	BRIGHTNESS_CHANGED,
+	LAST_SIGNAL
+};
+
+static guint signals [LAST_SIGNAL] = { 0 };
+
+G_DEFINE_TYPE_WITH_PRIVATE (GpmBacklight, gpm_backlight, G_TYPE_OBJECT)<--- There is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
+
+/**
+ * gpm_backlight_error_quark:
+ * Return value: Our personal error quark.
+ **/
+GQuark
+gpm_backlight_error_quark (void)
+{
+	static GQuark quark = 0;
+	if (!quark)
+		quark = g_quark_from_static_string ("gpm_backlight_error");
+	return quark;
+}
+
+/**
+ * gpm_backlight_get_brightness:
+ **/
+gboolean
+gpm_backlight_get_brightness (GpmBacklight *backlight, guint *brightness, GError **error)
+{
+	guint level;
+	gboolean ret;
+	g_return_val_if_fail (backlight != NULL, FALSE);
+	g_return_val_if_fail (GPM_IS_BACKLIGHT (backlight), FALSE);
+	g_return_val_if_fail (brightness != NULL, FALSE);
+
+	/* check if we have the hw */
+	if (backlight->priv->can_dim == FALSE) {
+		g_set_error_literal (error, gpm_backlight_error_quark (),
+				      GPM_BACKLIGHT_ERROR_HARDWARE_NOT_PRESENT,
+				      "Dim capable hardware not present");
+		return FALSE;
+	}
+
+	/* gets the current brightness */
+	ret = gpm_brightness_get (backlight->priv->brightness, &level);
+	if (ret) {
+		*brightness = level;
+	} else {
+		g_set_error_literal (error, gpm_backlight_error_quark (),
+				      GPM_BACKLIGHT_ERROR_DATA_NOT_AVAILABLE,
+				      "Data not available");
+	}
+	return ret;
+}
+
+/**
+ * gpm_backlight_set_brightness:
+ **/
+gboolean
+gpm_backlight_set_brightness (GpmBacklight *backlight, guint percentage, GError **error)
+{
+	gboolean ret;
+	gboolean hw_changed;
+
+	g_return_val_if_fail (backlight != NULL, FALSE);
+	g_return_val_if_fail (GPM_IS_BACKLIGHT (backlight), FALSE);
+
+	/* check if we have the hw */
+	if (backlight->priv->can_dim == FALSE) {
+		g_set_error_literal (error, gpm_backlight_error_quark (),
+				      GPM_BACKLIGHT_ERROR_HARDWARE_NOT_PRESENT,
+				      "Dim capable hardware not present");
+		return FALSE;
+	}
+
+	/* just set the master percentage for now, don't try to be clever */
+	backlight->priv->master_percentage = percentage;
+
+	/* sets the current policy brightness */
+	ret = gpm_brightness_set (backlight->priv->brightness, percentage, &hw_changed);
+	if (!ret) {
+		g_set_error_literal (error, gpm_backlight_error_quark (),
+				      GPM_BACKLIGHT_ERROR_GENERAL,
+				      "Cannot set policy brightness");
+	}
+	/* we emit a signal for the brightness applet */
+	if (ret && hw_changed) {
+		g_debug ("emitting brightness-changed : %u", percentage);
+		g_signal_emit (backlight, signals [BRIGHTNESS_CHANGED], 0, percentage);
+	}
+	return ret;
+}
+
+/**
+ * gpm_backlight_dialog_init:
+ *
+ * Initialises the popup, and makes sure that it matches the compositing of the screen.
+ **/
+static void
+gpm_backlight_dialog_init (GpmBacklight *backlight)
+{
+	if (backlight->priv->popup != NULL
+	    && !msd_osd_window_is_valid (MSD_OSD_WINDOW (backlight->priv->popup))) {
+		gtk_widget_destroy (backlight->priv->popup);
+		backlight->priv->popup = NULL;
+	}
+
+	if (backlight->priv->popup == NULL) {
+		backlight->priv->popup= msd_media_keys_window_new ();
+		msd_media_keys_window_set_action_custom (MSD_MEDIA_KEYS_WINDOW (backlight->priv->popup),
+							 "gpm-brightness-lcd",
+							 TRUE);
+		gtk_window_set_position (GTK_WINDOW (backlight->priv->popup), GTK_WIN_POS_NONE);
+	}
+}
+
+/**
+ * gpm_backlight_dialog_show:
+ *
+ * Show the brightness popup, and place it nicely on the screen.
+ **/
+static void
+gpm_backlight_dialog_show (GpmBacklight *backlight)
+{
+	int            orig_w;
+	int            orig_h;
+	int            screen_w;
+	int            screen_h;
+	int            x;
+	int            y;
+	int            pointer_x;
+	int            pointer_y;
+	GtkRequisition win_req;
+	GdkScreen     *pointer_screen;
+	GdkRectangle   geometry;
+	GdkMonitor    *monitor;
+	GdkDisplay    *display;
+	GdkSeat       *seat;
+	GdkDevice     *device;
+
+	/*
+	 * get the window size
+	 * if the window hasn't been mapped, it doesn't necessarily
+	 * know its true size, yet, so we need to jump through hoops
+	 */
+	gtk_window_get_default_size (GTK_WINDOW (backlight->priv->popup), &orig_w, &orig_h);
+	gtk_widget_get_preferred_size (backlight->priv->popup, NULL, &win_req);
+
+	if (win_req.width > orig_w) {
+		orig_w = win_req.width;
+	}
+	if (win_req.height > orig_h) {
+		orig_h = win_req.height;
+	}
+
+	pointer_screen = NULL;
+	display = gtk_widget_get_display (backlight->priv->popup);
+	seat = gdk_display_get_default_seat (display);
+	device = gdk_seat_get_pointer (seat);
+	gdk_device_get_position (device,
+	                         &pointer_screen,
+	                         &pointer_x,
+	                         &pointer_y);
+
+	monitor = gdk_display_get_monitor_at_point (gdk_screen_get_display (pointer_screen),
+						    pointer_x,
+						    pointer_y);
+
+	gdk_monitor_get_geometry (monitor, &geometry);
+
+	screen_w = geometry.width;
+	screen_h = geometry.height;
+
+	x = ((screen_w - orig_w) / 2) + geometry.x;
+	y = geometry.y + (screen_h / 2) + (screen_h / 2 - orig_h) / 2;
+
+	gtk_window_move (GTK_WINDOW (backlight->priv->popup), x, y);
+
+	gtk_widget_show (backlight->priv->popup);
+
+	gdk_display_sync (gtk_widget_get_display (backlight->priv->popup));
+}
+
+/**
+ * gpm_backlight_brightness_evaluate_and_set:
+ **/
+static gboolean
+gpm_backlight_brightness_evaluate_and_set (GpmBacklight *backlight, gboolean interactive, gboolean use_initial)
+{
+	gfloat brightness;
+	gfloat scale;
+	gboolean ret;
+	gboolean on_battery;
+	gboolean do_laptop_lcd;
+	gboolean enable_action;
+	gboolean battery_reduce;
+	gboolean hw_changed;
+	guint value;
+	guint old_value;
+
+	if (backlight->priv->can_dim == FALSE) {
+		g_debug ("no dimming hardware");
+		return FALSE;
+	}
+
+	do_laptop_lcd = g_settings_get_boolean (backlight->priv->settings, GPM_SETTINGS_BACKLIGHT_ENABLE);
+	if (do_laptop_lcd == FALSE) {
+		g_warning ("policy is no dimming");
+		return FALSE;
+	}
+
+	/* get the last set brightness */
+	brightness = backlight->priv->master_percentage / 100.0f;
+	g_debug ("1. main brightness %f", brightness);
+
+	/* get battery status */
+	g_object_get (backlight->priv->client,
+		      "on-battery", &on_battery,
+		      NULL);
+
+	/* reduce if on battery power if we should */
+	if (use_initial) {
+		g_debug ("Setting initial brightness level");
+		battery_reduce = g_settings_get_boolean (backlight->priv->settings, GPM_SETTINGS_BACKLIGHT_BATTERY_REDUCE);
+		if (on_battery && battery_reduce) {
+			value = g_settings_get_int (backlight->priv->settings, GPM_SETTINGS_BRIGHTNESS_DIM_BATT);
+			if (value > 100) {
+				g_warning ("cannot use battery brightness value %u, correcting to 50", value);
+				value = 50;
+			}
+			scale = (100 - value) / 100.0f;
+			brightness *= scale;
+		} else {
+			scale = 1.0f;
+		}
+		g_debug ("2. battery scale %f, brightness %f", scale, brightness);
+	}
+
+	/* reduce if system is momentarily idle */
+	if (!on_battery)
+		enable_action = g_settings_get_boolean (backlight->priv->settings, GPM_SETTINGS_IDLE_DIM_AC);
+	else
+		enable_action = g_settings_get_boolean (backlight->priv->settings, GPM_SETTINGS_IDLE_DIM_BATT);
+	if (enable_action && backlight->priv->system_is_idle) {
+		value = g_settings_get_int (backlight->priv->settings, GPM_SETTINGS_IDLE_BRIGHTNESS);
+		if (value > 100) {
+			g_warning ("cannot use idle brightness value %u, correcting to 50", value);
+			value = 50;
+		}
+		scale = value / 100.0f;
+		brightness *= scale;
+	} else {
+		scale = 1.0f;
+	}
+	g_debug ("3. idle scale %f, brightness %f", scale, brightness);
+
+	/* convert to percentage */
+	value = (guint) ((brightness * 100.0f) + 0.5);
+
+	/* only do stuff if the brightness is different */
+	gpm_brightness_get (backlight->priv->brightness, &old_value);
+	if (old_value == value) {
+		g_debug ("values are the same, no action");
+		return FALSE;
+	}
+
+	/* only show dialog if interactive */
+	if (interactive) {
+		gpm_backlight_dialog_init (backlight);
+		msd_media_keys_window_set_volume_level (MSD_MEDIA_KEYS_WINDOW (backlight->priv->popup),
+							round (brightness));
+		gpm_backlight_dialog_show (backlight);
+	}
+
+	ret = gpm_brightness_set (backlight->priv->brightness, value, &hw_changed);
+	/* we emit a signal for the brightness applet */
+	if (ret && hw_changed) {
+		g_debug ("emitting brightness-changed : %u", value);
+		g_signal_emit (backlight, signals [BRIGHTNESS_CHANGED], 0, value);
+	}
+	return TRUE;
+}
+
+/**
+ * gpm_settings_key_changed_cb:
+ *
+ * We might have to do things when the keys change; do them here.
+ **/
+static void
+gpm_settings_key_changed_cb (GSettings *settings, const gchar *key, GpmBacklight *backlight)
+{
+	gboolean on_battery;
+
+	/* get battery status */
+	g_object_get (backlight->priv->client,
+		      "on-battery", &on_battery,
+		      NULL);
+
+	if (g_strcmp0 (key, GPM_SETTINGS_BRIGHTNESS_AC) == 0) {
+		backlight->priv->master_percentage = g_settings_get_double (settings, key);
+		gpm_backlight_brightness_evaluate_and_set (backlight, FALSE, TRUE);
+
+	} else if (on_battery && g_strcmp0 (key, GPM_SETTINGS_BRIGHTNESS_DIM_BATT) == 0) {
+		gpm_backlight_brightness_evaluate_and_set (backlight, FALSE, TRUE);
+
+	} else if (g_strcmp0 (key, GPM_SETTINGS_IDLE_DIM_AC) == 0 ||
+	           g_strcmp0 (key, GPM_SETTINGS_BACKLIGHT_ENABLE) == 0 ||
+	           g_strcmp0 (key, GPM_SETTINGS_SLEEP_DISPLAY_BATT) == 0 ||
+	           g_strcmp0 (key, GPM_SETTINGS_BACKLIGHT_BATTERY_REDUCE) == 0 ||
+	           g_strcmp0 (key, GPM_SETTINGS_IDLE_BRIGHTNESS) == 0) {
+		gpm_backlight_brightness_evaluate_and_set (backlight, FALSE, TRUE);
+
+	} else if (g_strcmp0 (key, GPM_SETTINGS_IDLE_DIM_TIME) == 0) {
+		backlight->priv->idle_dim_timeout = g_settings_get_int (settings, key);
+		gpm_idle_set_timeout_dim (backlight->priv->idle, backlight->priv->idle_dim_timeout);
+	} else {
+		g_debug ("unknown key %s", key);
+	}
+}
+
+/**
+ * gpm_backlight_client_changed_cb:
+ * @client: The up_client class instance
+ * @backlight: This class instance
+ *
+ * Does the actions when the ac power source is inserted/removed.
+ **/
+static void
+gpm_backlight_client_changed_cb (UpClient *client, GParamSpec *pspec, GpmBacklight *backlight)
+{
+	gpm_backlight_brightness_evaluate_and_set (backlight, FALSE, TRUE);
+}
+
+/**
+ * gpm_backlight_button_pressed_cb:
+ * @power: The power class instance
+ * @type: The button type, e.g. "power"
+ * @state: The state, where TRUE is depressed or closed
+ * @brightness: This class instance
+ **/
+static void
+gpm_backlight_button_pressed_cb (GpmButton *button, const gchar *type, GpmBacklight *backlight)
+{
+	gboolean ret;
+	GError *error = NULL;
+	guint percentage;
+	gboolean hw_changed;
+	gboolean on_battery;
+	g_debug ("Button press event type=%s", type);
+
+	if (g_strcmp0 (type, GPM_BUTTON_BRIGHT_UP) == 0) {
+		/* go up one step */
+		ret = gpm_brightness_up (backlight->priv->brightness, &hw_changed);
+
+		/* show the new value */
+		if (ret) {
+			gpm_brightness_get (backlight->priv->brightness, &percentage);
+			gpm_backlight_dialog_init (backlight);
+			msd_media_keys_window_set_volume_level (MSD_MEDIA_KEYS_WINDOW (backlight->priv->popup),
+								percentage);
+			gpm_backlight_dialog_show (backlight);
+			/* save the new percentage */
+			backlight->priv->master_percentage = percentage;
+			/* if using AC power supply, save the new brightness settings */
+			g_object_get (backlight->priv->client, "on-battery", &on_battery, NULL);
+			if (!on_battery) {
+				g_debug ("saving brightness for ac supply: %u", percentage);
+				g_settings_set_double (backlight->priv->settings, GPM_SETTINGS_BRIGHTNESS_AC,
+						       percentage*1.0);
+			}
+		}
+		/* we emit a signal for the brightness applet */
+		if (ret && hw_changed) {
+			g_debug ("emitting brightness-changed : %u", percentage);
+			g_signal_emit (backlight, signals [BRIGHTNESS_CHANGED], 0, percentage);
+		}
+	} else if (g_strcmp0 (type, GPM_BUTTON_BRIGHT_DOWN) == 0) {
+		/* go up down step */
+		ret = gpm_brightness_down (backlight->priv->brightness, &hw_changed);
+
+		/* show the new value */
+		if (ret) {
+			gpm_brightness_get (backlight->priv->brightness, &percentage);
+			gpm_backlight_dialog_init (backlight);
+			msd_media_keys_window_set_volume_level (MSD_MEDIA_KEYS_WINDOW (backlight->priv->popup),
+								percentage);
+			gpm_backlight_dialog_show (backlight);
+			/* save the new percentage */
+			backlight->priv->master_percentage = percentage;
+			/* if using AC power supply, save the new brightness settings */
+			g_object_get (backlight->priv->client, "on-battery", &on_battery, NULL);
+			if (!on_battery) {
+				g_debug ("saving brightness for ac supply: %u", percentage);
+				g_settings_set_double (backlight->priv->settings, GPM_SETTINGS_BRIGHTNESS_AC,
+						       percentage*1.0);
+			}
+		}
+		/* we emit a signal for the brightness applet */
+		if (ret && hw_changed) {
+			g_debug ("emitting brightness-changed : %u", percentage);
+			g_signal_emit (backlight, signals [BRIGHTNESS_CHANGED], 0, percentage);
+		}
+	} else if (g_strcmp0 (type, GPM_BUTTON_LID_OPEN) == 0) {
+		/* make sure we undim when we lift the lid */
+		gpm_backlight_brightness_evaluate_and_set (backlight, FALSE, TRUE);
+
+		/* ensure backlight is on */
+		ret = gpm_dpms_set_mode (backlight->priv->dpms, GPM_DPMS_MODE_ON, &error);
+		if (!ret) {
+			g_warning ("failed to turn on DPMS: %s", error->message);
+			g_error_free (error);
+		}
+	}
+}
+
+/**
+ * gpm_backlight_notify_system_idle_changed:
+ **/
+static gboolean
+gpm_backlight_notify_system_idle_changed (GpmBacklight *backlight, gboolean is_idle)
+{
+	gdouble elapsed;
+
+	/* no point continuing */
+	if (backlight->priv->system_is_idle == is_idle) {
+		g_debug ("state not changed");
+		return FALSE;
+	}
+
+	/* get elapsed time and reset timer */
+	elapsed = g_timer_elapsed (backlight->priv->idle_timer, NULL);
+	g_timer_reset (backlight->priv->idle_timer);
+
+	if (is_idle == FALSE) {
+		g_debug ("we have just been idle for %lfs", elapsed);
+
+		/* The user immediatly undimmed the screen!
+		 * We should double the timeout to avoid this happening again */
+		if (elapsed < 10) {
+			/* double the event time */
+			backlight->priv->idle_dim_timeout *= 2.0;
+			g_debug ("increasing idle dim time to %us", backlight->priv->idle_dim_timeout);
+			gpm_idle_set_timeout_dim (backlight->priv->idle, backlight->priv->idle_dim_timeout);
+		}
+
+		/* We reset the dimming after 2 minutes of idle,
+		 * as the user will have changed tasks */
+		if (elapsed > 2*60) {
+			/* reset back to our default dimming */
+			backlight->priv->idle_dim_timeout =
+				g_settings_get_int (backlight->priv->settings,
+					   GPM_SETTINGS_IDLE_DIM_TIME);
+			g_debug ("resetting idle dim time to %us", backlight->priv->idle_dim_timeout);
+			gpm_idle_set_timeout_dim (backlight->priv->idle, backlight->priv->idle_dim_timeout);
+		}
+	} else {
+		g_debug ("we were active for %lfs", elapsed);
+	}
+
+	g_debug ("changing powersave idle status to %i", is_idle);
+	backlight->priv->system_is_idle = is_idle;
+	return TRUE;
+}
+
+/**
+ * idle_changed_cb:
+ * @idle: The idle class instance
+ * @mode: The idle mode, e.g. GPM_IDLE_MODE_BLANK
+ * @manager: This class instance
+ *
+ * This callback is called when mate-screensaver detects that the idle state
+ * has changed. GPM_IDLE_MODE_BLANK is when the session has become inactive,
+ * and GPM_IDLE_MODE_SLEEP is where the session has become inactive, AND the
+ * session timeout has elapsed for the idle action.
+ **/
+static void
+idle_changed_cb (GpmIdle *idle, GpmIdleMode mode, GpmBacklight *backlight)
+{
+	gboolean ret;
+	GError *error = NULL;
+	gboolean on_battery;
+	GpmDpmsMode dpms_mode;
+
+	/* don't dim or undim the screen when the lid is closed */
+	if (gpm_button_is_lid_closed (backlight->priv->button))
+		return;
+
+	/* don't dim or undim the screen unless ConsoleKit/systemd say we are on the active console */
+	if (!LOGIND_RUNNING() && !egg_console_kit_is_active (backlight->priv->console)) {
+		g_debug ("ignoring as not on active console");
+		return;
+	}
+
+	if (mode == GPM_IDLE_MODE_NORMAL) {
+		/* sync lcd brightness */
+		gpm_backlight_notify_system_idle_changed (backlight, FALSE);
+		gpm_backlight_brightness_evaluate_and_set (backlight, FALSE, TRUE);
+
+		/* ensure backlight is on */
+		ret = gpm_dpms_set_mode (backlight->priv->dpms, GPM_DPMS_MODE_ON, &error);
+		if (!ret) {
+			g_warning ("failed to turn on DPMS: %s", error->message);
+			g_error_free (error);
+		}
+
+	} else if (mode == GPM_IDLE_MODE_DIM) {
+
+		/* sync lcd brightness */
+		gpm_backlight_notify_system_idle_changed (backlight, TRUE);
+		gpm_backlight_brightness_evaluate_and_set (backlight, FALSE, TRUE);
+
+		/* ensure backlight is on */
+		ret = gpm_dpms_set_mode (backlight->priv->dpms, GPM_DPMS_MODE_ON, &error);
+		if (!ret) {
+			g_warning ("failed to turn on DPMS: %s", error->message);
+			g_error_free (error);
+		}
+
+	} else if (mode == GPM_IDLE_MODE_BLANK) {
+
+		/* sync lcd brightness */
+		gpm_backlight_notify_system_idle_changed (backlight, TRUE);
+		gpm_backlight_brightness_evaluate_and_set (backlight, FALSE, TRUE);
+
+		/* get the DPMS state we're supposed to use on the power state */
+		g_object_get (backlight->priv->client,
+			      "on-battery", &on_battery,
+			      NULL);
+		if (!on_battery)
+			dpms_mode = g_settings_get_enum (backlight->priv->settings, GPM_SETTINGS_DPMS_METHOD_AC);
+		else
+			dpms_mode = g_settings_get_enum (backlight->priv->settings, GPM_SETTINGS_DPMS_METHOD_BATT);
+
+		/* check if method is valid */
+		if (dpms_mode == GPM_DPMS_MODE_UNKNOWN || dpms_mode == GPM_DPMS_MODE_ON) {
+			g_warning ("BACKLIGHT method %u unknown. Using OFF.", dpms_mode);
+			dpms_mode = GPM_DPMS_MODE_OFF;
+		}
+
+		/* turn backlight off */
+		ret = gpm_dpms_set_mode (backlight->priv->dpms, dpms_mode, &error);
+		if (!ret) {
+			g_warning ("failed to change DPMS: %s", error->message);
+			g_error_free (error);
+		}
+
+	}
+}
+
+/**
+ * brightness_changed_cb:
+ * @brightness: The GpmBrightness class instance
+ * @percentage: The new percentage brightness
+ * @brightness: This class instance
+ *
+ * This callback is called when the brightness value changes.
+ **/
+static void
+brightness_changed_cb (GpmBrightness *brightness, guint percentage, GpmBacklight *backlight)
+{
+	/* save the new percentage */
+	backlight->priv->master_percentage = percentage;
+
+	/* we emit a signal for the brightness applet */
+	g_debug ("emitting brightness-changed : %u", percentage);
+	g_signal_emit (backlight, signals [BRIGHTNESS_CHANGED], 0, percentage);
+}
+
+/**
+ * control_resume_cb:
+ * @control: The control class instance
+ * @power: This power class instance
+ *
+ * We have to update the caches on resume
+ **/
+static void
+control_resume_cb (GpmControl *control, GpmControlAction action, GpmBacklight *backlight)
+{
+	gboolean ret;
+	GError *error = NULL;
+
+	/* ensure backlight is on */
+	ret = gpm_dpms_set_mode (backlight->priv->dpms, GPM_DPMS_MODE_ON, &error);
+	if (!ret) {
+		g_warning ("failed to turn on DPMS: %s", error->message);
+		g_error_free (error);
+	}
+}
+
+/**
+ * gpm_backlight_finalize:
+ **/
+static void
+gpm_backlight_finalize (GObject *object)
+{
+	GpmBacklight *backlight;
+	g_return_if_fail (object != NULL);
+	g_return_if_fail (GPM_IS_BACKLIGHT (object));
+	backlight = GPM_BACKLIGHT (object);
+
+	g_timer_destroy (backlight->priv->idle_timer);
+	gtk_widget_destroy (backlight->priv->popup);
+
+	g_object_unref (backlight->priv->dpms);
+	g_object_unref (backlight->priv->control);
+	g_object_unref (backlight->priv->settings);
+	g_object_unref (backlight->priv->client);
+	g_object_unref (backlight->priv->button);
+	g_object_unref (backlight->priv->idle);
+	g_object_unref (backlight->priv->brightness);
+	g_object_unref (backlight->priv->console);
+
+	g_return_if_fail (backlight->priv != NULL);
+	G_OBJECT_CLASS (gpm_backlight_parent_class)->finalize (object);
+}
+
+/**
+ * gpm_backlight_class_init:
+ **/
+static void
+gpm_backlight_class_init (GpmBacklightClass *klass)
+{
+	GObjectClass *object_class = G_OBJECT_CLASS (klass);
+	object_class->finalize	   = gpm_backlight_finalize;
+
+	signals [BRIGHTNESS_CHANGED] =
+		g_signal_new ("brightness-changed",
+			      G_TYPE_FROM_CLASS (object_class),
+			      G_SIGNAL_RUN_LAST,
+			      G_STRUCT_OFFSET (GpmBacklightClass, brightness_changed),
+			      NULL, NULL,
+			      g_cclosure_marshal_VOID__UINT,
+			      G_TYPE_NONE, 1, G_TYPE_UINT);
+}
+
+/**
+ * gpm_backlight_init:
+ * @brightness: This brightness class instance
+ *
+ * initialises the brightness class. NOTE: We expect laptop_panel objects
+ * to *NOT* be removed or added during the session.
+ * We only control the first laptop_panel object if there are more than one.
+ **/
+static void
+gpm_backlight_init (GpmBacklight *backlight)
+{
+	backlight->priv = gpm_backlight_get_instance_private (backlight);
+
+	/* record our idle time */
+	backlight->priv->idle_timer = g_timer_new ();
+
+	/* watch for manual brightness changes (for the popup widget) */
+	backlight->priv->brightness = gpm_brightness_new ();
+	g_signal_connect (backlight->priv->brightness, "brightness-changed",
+			  G_CALLBACK (brightness_changed_cb), backlight);
+
+	/* we use up_client for the ac-adapter-changed signal */
+	backlight->priv->client = up_client_new ();
+	g_signal_connect (backlight->priv->client, "notify",
+			  G_CALLBACK (gpm_backlight_client_changed_cb), backlight);
+
+	/* gets caps */
+	backlight->priv->can_dim = gpm_brightness_has_hw (backlight->priv->brightness);
+
+	/* watch for dim value changes */
+	backlight->priv->settings = g_settings_new (GPM_SETTINGS_SCHEMA);
+	g_signal_connect (backlight->priv->settings, "changed", G_CALLBACK (gpm_settings_key_changed_cb), backlight);
+
+	/* set the main brightness, this is designed to be updated if the user changes the
+	 * brightness so we can undim to the 'correct' value */
+	backlight->priv->master_percentage = g_settings_get_double (backlight->priv->settings, GPM_SETTINGS_BRIGHTNESS_AC);
+
+	/* watch for brightness up and down buttons and also check lid state */
+	backlight->priv->button = gpm_button_new ();
+	g_signal_connect (backlight->priv->button, "button-pressed",
+			  G_CALLBACK (gpm_backlight_button_pressed_cb), backlight);
+
+	/* watch for idle mode changes */
+	backlight->priv->idle = gpm_idle_new ();
+	g_signal_connect (backlight->priv->idle, "idle-changed",
+			  G_CALLBACK (idle_changed_cb), backlight);
+
+	/* assumption */
+	backlight->priv->system_is_idle = FALSE;
+	backlight->priv->idle_dim_timeout = g_settings_get_int (backlight->priv->settings, GPM_SETTINGS_IDLE_DIM_TIME);
+	gpm_idle_set_timeout_dim (backlight->priv->idle, backlight->priv->idle_dim_timeout);
+
+	/* use a visual widget */
+	backlight->priv->popup = msd_media_keys_window_new ();
+	msd_media_keys_window_set_action_custom (MSD_MEDIA_KEYS_WINDOW (backlight->priv->popup),
+						 "gpm-brightness-lcd",
+						 TRUE);
+        gtk_window_set_position (GTK_WINDOW (backlight->priv->popup), GTK_WIN_POS_NONE);
+
+	/* DPMS mode poll class */
+	backlight->priv->dpms = gpm_dpms_new ();
+
+	/* we refresh DPMS on resume */
+	backlight->priv->control = gpm_control_new ();
+	g_signal_connect (backlight->priv->control, "resume",
+			  G_CALLBACK (control_resume_cb), backlight);
+
+	/* Don't do dimming on inactive console */
+	backlight->priv->console = egg_console_kit_new ();
+
+	/* sync at startup */
+	gpm_backlight_brightness_evaluate_and_set (backlight, FALSE, TRUE);
+}
+
+/**
+ * gpm_backlight_new:
+ * Return value: A new brightness class instance.
+ **/
+GpmBacklight *
+gpm_backlight_new (void)
+{
+	GpmBacklight *backlight = g_object_new (GPM_TYPE_BACKLIGHT, NULL);
+	return backlight;
+}
+
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/61.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/61.html new file mode 100644 index 0000000..1c225a4 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/61.html @@ -0,0 +1,385 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2006-2007 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __GPMBUTTON_H
+#define __GPMBUTTON_H
+
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+G_BEGIN_DECLS
+
+#define GPM_TYPE_BUTTON		(gpm_button_get_type ())
+#define GPM_BUTTON(o)		(G_TYPE_CHECK_INSTANCE_CAST ((o), GPM_TYPE_BUTTON, GpmButton))
+#define GPM_BUTTON_CLASS(k)	(G_TYPE_CHECK_CLASS_CAST((k), GPM_TYPE_BUTTON, GpmButtonClass))
+#define GPM_IS_BUTTON(o)	(G_TYPE_CHECK_INSTANCE_TYPE ((o), GPM_TYPE_BUTTON))
+#define GPM_IS_BUTTON_CLASS(k)	(G_TYPE_CHECK_CLASS_TYPE ((k), GPM_TYPE_BUTTON))
+#define GPM_BUTTON_GET_CLASS(o)	(G_TYPE_INSTANCE_GET_CLASS ((o), GPM_TYPE_BUTTON, GpmButtonClass))
+
+typedef struct GpmButtonPrivate GpmButtonPrivate;
+
+#define GPM_BUTTON_POWER		"power"
+#define GPM_BUTTON_SLEEP		"sleep"
+#define GPM_BUTTON_SUSPEND		"suspend"
+#define GPM_BUTTON_HIBERNATE		"hibernate"
+#define GPM_BUTTON_LID_DEP		"lid"		/* Remove when HAL drops input support */
+#define GPM_BUTTON_LID_OPEN		"lid-up"
+#define GPM_BUTTON_LID_CLOSED		"lid-down"
+#define GPM_BUTTON_BRIGHT_UP		"brightness-up"
+#define GPM_BUTTON_BRIGHT_DOWN		"brightness-down"
+#define GPM_BUTTON_KBD_BRIGHT_UP	"kbd-illum-up"
+#define GPM_BUTTON_KBD_BRIGHT_DOWN	"kbd-illum-down"
+#define GPM_BUTTON_KBD_BRIGHT_TOGGLE	"kbd-illum-toggle"
+#define GPM_BUTTON_LOCK			"lock"
+#define GPM_BUTTON_BATTERY		"battery"
+
+typedef struct
+{
+	GObject		 parent;
+	GpmButtonPrivate *priv;
+} GpmButton;
+
+typedef struct
+{
+	GObjectClass	parent_class;
+	void		(* button_pressed)	(GpmButton	*button,
+						 const gchar	*type);
+} GpmButtonClass;
+
+GType		 gpm_button_get_type		(void);
+GpmButton	*gpm_button_new			(void);
+gboolean	 gpm_button_is_lid_closed	(GpmButton *button);
+gboolean	 gpm_button_reset_time		(GpmButton *button);
+
+G_END_DECLS
+
+#endif	/* __GPMBUTTON_H */
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/62.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/62.html new file mode 100644 index 0000000..80c2e6a --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/62.html @@ -0,0 +1,385 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2005-2007 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2004-2005 William Jon McCann <mccann@jhu.edu>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __GPM_BACKLIGHT_H
+#define __GPM_BACKLIGHT_H
+
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+G_BEGIN_DECLS
+
+#define GPM_TYPE_BACKLIGHT		(gpm_backlight_get_type ())
+#define GPM_BACKLIGHT(o)		(G_TYPE_CHECK_INSTANCE_CAST ((o), GPM_TYPE_BACKLIGHT, GpmBacklight))
+#define GPM_BACKLIGHT_CLASS(k)		(G_TYPE_CHECK_CLASS_CAST((k), GPM_TYPE_BACKLIGHT, GpmBacklightClass))
+#define GPM_IS_BACKLIGHT(o)		(G_TYPE_CHECK_INSTANCE_TYPE ((o), GPM_TYPE_BACKLIGHT))
+#define GPM_IS_BACKLIGHT_CLASS(k)	(G_TYPE_CHECK_CLASS_TYPE ((k), GPM_TYPE_BACKLIGHT))
+#define GPM_BACKLIGHT_GET_CLASS(o)	(G_TYPE_INSTANCE_GET_CLASS ((o), GPM_TYPE_BACKLIGHT, GpmBacklightClass))
+
+typedef struct GpmBacklightPrivate GpmBacklightPrivate;
+
+typedef struct
+{
+	GObject		         parent;
+	GpmBacklightPrivate *priv;
+} GpmBacklight;
+
+typedef struct
+{
+	GObjectClass	parent_class;
+	void		(* brightness_changed)		(GpmBacklight	*backlight,
+							 gint		 brightness);
+} GpmBacklightClass;
+
+typedef enum
+{
+	 GPM_BACKLIGHT_ERROR_GENERAL,
+	 GPM_BACKLIGHT_ERROR_DATA_NOT_AVAILABLE,
+	 GPM_BACKLIGHT_ERROR_HARDWARE_NOT_PRESENT
+} GpmBacklightError;
+
+GType		 gpm_backlight_get_type			(void);
+GQuark		 gpm_backlight_error_quark		(void);
+GpmBacklight	*gpm_backlight_new			(void);
+
+gboolean	 gpm_backlight_get_brightness		(GpmBacklight	*backlight,
+							 guint		*brightness,
+							 GError		**error);
+gboolean	 gpm_backlight_set_brightness		(GpmBacklight	*backlight,
+							 guint		 brightness,
+							 GError		**error);
+
+G_END_DECLS
+
+#endif /* __GPM_BACKLIGHT_H */
+
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/63.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/63.html new file mode 100644 index 0000000..639ada4 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/63.html @@ -0,0 +1,377 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __GPM_BRIGHTNESS_H
+#define __GPM_BRIGHTNESS_H
+
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+G_BEGIN_DECLS
+
+#define GPM_TYPE_BRIGHTNESS		(gpm_brightness_get_type ())
+#define GPM_BRIGHTNESS(o)		(G_TYPE_CHECK_INSTANCE_CAST ((o), GPM_TYPE_BRIGHTNESS, GpmBrightness))
+#define GPM_BRIGHTNESS_CLASS(k)		(G_TYPE_CHECK_CLASS_CAST((k), GPM_TYPE_BRIGHTNESS, GpmBrightnessClass))
+#define GPM_IS_BRIGHTNESS(o)		(G_TYPE_CHECK_INSTANCE_TYPE ((o), GPM_TYPE_BRIGHTNESS))
+#define GPM_IS_BRIGHTNESS_CLASS(k)	(G_TYPE_CHECK_CLASS_TYPE ((k), GPM_TYPE_BRIGHTNESS))
+#define GPM_BRIGHTNESS_GET_CLASS(o)	(G_TYPE_INSTANCE_GET_CLASS ((o), GPM_TYPE_BRIGHTNESS, GpmBrightnessClass))
+
+#define GPM_BRIGHTNESS_DIM_INTERVAL	5 /* ms */
+
+typedef struct GpmBrightnessPrivate GpmBrightnessPrivate;
+
+typedef struct
+{
+	GObject		         parent;
+	GpmBrightnessPrivate	*priv;
+} GpmBrightness;
+
+typedef struct
+{
+	GObjectClass	parent_class;
+	void		(* brightness_changed)	(GpmBrightness		*brightness,
+						 guint			 percentage);
+} GpmBrightnessClass;
+
+GType		 gpm_brightness_get_type	(void);
+GpmBrightness	*gpm_brightness_new		(void);
+
+gboolean	 gpm_brightness_has_hw		(GpmBrightness		*brightness);
+gboolean	 gpm_brightness_up		(GpmBrightness		*brightness,
+						 gboolean		*hw_changed);
+gboolean	 gpm_brightness_down		(GpmBrightness		*brightness,
+						 gboolean		*hw_changed);
+gboolean	 gpm_brightness_get		(GpmBrightness		*brightness,
+						 guint			*percentage);
+gboolean	 gpm_brightness_set		(GpmBrightness		*brightness,
+						 guint			 percentage,
+						 gboolean		*hw_changed);
+
+G_END_DECLS
+
+#endif /* __GPM_BRIGHTNESS_H */
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/64.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/64.html new file mode 100644 index 0000000..3fc83a2 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/64.html @@ -0,0 +1,413 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+82
+83
+84
+85
+86
+87
+88
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2005 William Jon McCann <mccann@jhu.edu>
+ * Copyright (C) 2005-2007 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __GPM_CONTROL_H
+#define __GPM_CONTROL_H
+
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+G_BEGIN_DECLS
+
+#define GPM_TYPE_CONTROL		(gpm_control_get_type ())
+#define GPM_CONTROL(o)			(G_TYPE_CHECK_INSTANCE_CAST ((o), GPM_TYPE_CONTROL, GpmControl))
+#define GPM_CONTROL_CLASS(k)		(G_TYPE_CHECK_CLASS_CAST((k), GPM_TYPE_CONTROL, GpmControlClass))
+#define GPM_IS_CONTROL(o)		(G_TYPE_CHECK_INSTANCE_TYPE ((o), GPM_TYPE_CONTROL))
+#define GPM_IS_CONTROL_CLASS(k)		(G_TYPE_CHECK_CLASS_TYPE ((k), GPM_TYPE_CONTROL))
+#define GPM_CONTROL_GET_CLASS(o)	(G_TYPE_INSTANCE_GET_CLASS ((o), GPM_TYPE_CONTROL, GpmControlClass))
+
+typedef struct GpmControlPrivate GpmControlPrivate;
+
+typedef struct
+{
+	GObject		      parent;
+	GpmControlPrivate *priv;
+} GpmControl;
+
+typedef enum
+{
+	 GPM_CONTROL_ACTION_SUSPEND,
+	 GPM_CONTROL_ACTION_HIBERNATE,
+	 GPM_CONTROL_ACTION_LAST
+} GpmControlAction;
+
+typedef enum
+{
+	 GPM_CONTROL_ERROR_GENERAL,
+	 GPM_CONTROL_ERROR_LAST
+} GpmControlError;
+
+typedef struct
+{
+	GObjectClass	parent_class;
+	void		(* resume)			(GpmControl	*control,
+							 GpmControlAction action);
+	void		(* sleep)			(GpmControl	*control,
+							 GpmControlAction action);
+	void		(* sleep_failure)		(GpmControl	*control,
+							 GpmControlAction action);
+	void		(* request)			(GpmControl	*control,
+							 const gchar	**type);
+} GpmControlClass;
+
+#define GPM_CONTROL_ERROR gpm_control_error_quark ()
+
+GQuark		 gpm_control_error_quark		(void);
+GType		 gpm_control_get_type			(void);
+GpmControl	*gpm_control_new			(void);
+gboolean	 gpm_control_suspend			(GpmControl	*control,
+							 GError		**error);
+gboolean	 gpm_control_hibernate			(GpmControl	*control,
+							 GError		**error);
+gboolean	 gpm_control_shutdown			(GpmControl	*control,
+						 	 GError		**error);
+gboolean	 gpm_control_get_lock_policy		(GpmControl	*control,
+							 const gchar	*policy);
+
+G_END_DECLS
+
+#endif /* __GPM_CONTROL_H */
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/65.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/65.html new file mode 100644 index 0000000..60ed931 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/65.html @@ -0,0 +1,583 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2005-2007 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __GPMCOMMON_H
+#define __GPMCOMMON_H
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+G_BEGIN_DECLS
+
+#define LOGIND_RUNNING() (access("/run/systemd/seats/", F_OK) >= 0)
+
+#define	GPM_DBUS_SERVICE		"org.mate.PowerManager"
+#define	GPM_DBUS_INTERFACE		"org.mate.PowerManager"
+#define	GPM_DBUS_INTERFACE_BACKLIGHT	"org.mate.PowerManager.Backlight"
+#define	GPM_DBUS_INTERFACE_KBD_BACKLIGHT	"org.mate.PowerManager.KbdBacklight"
+#define	GPM_DBUS_PATH			"/org/mate/PowerManager"
+#define	GPM_DBUS_PATH_BACKLIGHT		"/org/mate/PowerManager/Backlight"
+#define GPM_DBUS_PATH_KBD_BACKLIGHT    "/org/mate/PowerManager/KbdBacklight"
+
+/* common descriptions of this program */
+#define GPM_NAME 			_("Power Manager")
+#define GPM_DESCRIPTION 		_("Power Manager for the MATE desktop")
+
+/* schema location */
+#define GPM_SETTINGS_SCHEMA				"org.mate.power-manager"
+
+/* actions */
+#define GPM_SETTINGS_ACTION_CRITICAL_UPS		"action-critical-ups"
+#define GPM_SETTINGS_ACTION_CRITICAL_BATT		"action-critical-battery"
+#define GPM_SETTINGS_ACTION_LOW_UPS			"action-low-ups"
+#define GPM_SETTINGS_ACTION_SLEEP_TYPE_AC		"action-sleep-type-ac"
+#define GPM_SETTINGS_ACTION_SLEEP_TYPE_BATT		"action-sleep-type-battery"
+#define GPM_SETTINGS_SLEEP_WHEN_CLOSED			"event-when-closed-battery"
+
+/* backlight stuff */
+#define GPM_SETTINGS_BACKLIGHT_ENABLE			"backlight-enable"
+#define GPM_SETTINGS_BACKLIGHT_BATTERY_REDUCE		"backlight-battery-reduce"
+#define GPM_SETTINGS_DPMS_METHOD_AC			"dpms-method-ac"
+#define GPM_SETTINGS_DPMS_METHOD_BATT			"dpms-method-battery"
+#define GPM_SETTINGS_IDLE_BRIGHTNESS			"idle-brightness"
+#define GPM_SETTINGS_IDLE_DIM_AC			"idle-dim-ac"
+#define GPM_SETTINGS_IDLE_DIM_BATT			"idle-dim-battery"
+#define GPM_SETTINGS_IDLE_DIM_TIME			"idle-dim-time"
+#define GPM_SETTINGS_BRIGHTNESS_AC			"brightness-ac"
+#define GPM_SETTINGS_BRIGHTNESS_DIM_BATT		"brightness-dim-battery"
+
+/* keyboard backlight */
+#define GPM_SETTINGS_KBD_BACKLIGHT_BATT_REDUCE     "kbd-backlight-battery-reduce"
+#define GPM_SETTINGS_KBD_BRIGHTNESS_ON_AC      "kbd-brightness-on-ac"
+#define GPM_SETTINGS_KBD_BRIGHTNESS_DIM_BY_ON_BATT      "kbd-brightness-dim-by-on-battery"
+#define GPM_SETTINGS_KBD_BRIGHTNESS_DIM_BY_ON_IDLE "kbd-brightness-dim-by-on-idle"
+
+/* buttons */
+#define GPM_SETTINGS_BUTTON_LID_AC			"button-lid-ac"
+#define GPM_SETTINGS_BUTTON_LID_BATT			"button-lid-battery"
+#define GPM_SETTINGS_BUTTON_SUSPEND			"button-suspend"
+#define GPM_SETTINGS_BUTTON_HIBERNATE			"button-hibernate"
+#define GPM_SETTINGS_BUTTON_POWER			"button-power"
+
+/* general */
+#define GPM_SETTINGS_USE_TIME_POLICY			"use-time-for-policy"
+#define GPM_SETTINGS_NETWORKMANAGER_SLEEP		"network-sleep"
+#define GPM_SETTINGS_IDLE_CHECK_CPU			"check-type-cpu"
+
+/* lock */
+#define GPM_SETTINGS_LOCK_USE_SCREENSAVER		"lock-use-screensaver"
+#define GPM_SETTINGS_LOCK_ON_BLANK_SCREEN		"lock-blank-screen"
+#define GPM_SETTINGS_LOCK_ON_SUSPEND			"lock-suspend"
+#define GPM_SETTINGS_LOCK_ON_HIBERNATE			"lock-hibernate"
+#define GPM_SETTINGS_LOCK_KEYRING_SUSPEND		"lock-keyring-suspend"
+#define GPM_SETTINGS_LOCK_KEYRING_HIBERNATE		"lock-keyring-hibernate"
+
+/* notify */
+#define GPM_SETTINGS_NOTIFY_LOW_CAPACITY		"notify-low-capacity"
+#define GPM_SETTINGS_NOTIFY_DISCHARGING			"notify-discharging"
+#define GPM_SETTINGS_NOTIFY_FULLY_CHARGED		"notify-fully-charged"
+#define GPM_SETTINGS_NOTIFY_SLEEP_FAILED		"notify-sleep-failed"
+#define GPM_SETTINGS_NOTIFY_SLEEP_FAILED_URI		"notify-sleep-failed-uri"
+#define GPM_SETTINGS_NOTIFY_LOW_POWER			"notify-low-power"
+#define GPM_SETTINGS_NOTIFY_LOW_CAPACITY_MOUSE		"notify-low-capacity-mouse"
+
+/* thresholds */
+#define GPM_SETTINGS_PERCENTAGE_LOW			"percentage-low"
+#define GPM_SETTINGS_PERCENTAGE_CRITICAL		"percentage-critical"
+#define GPM_SETTINGS_PERCENTAGE_ACTION			"percentage-action"
+#define GPM_SETTINGS_TIME_LOW				"time-low"
+#define GPM_SETTINGS_TIME_CRITICAL			"time-critical"
+#define GPM_SETTINGS_TIME_ACTION			"time-action"
+
+/* timeout */
+#define GPM_SETTINGS_SLEEP_COMPUTER_AC			"sleep-computer-ac"
+#define GPM_SETTINGS_SLEEP_COMPUTER_BATT		"sleep-computer-battery"
+#define GPM_SETTINGS_SLEEP_COMPUTER_UPS			"sleep-computer-ups"
+#define GPM_SETTINGS_SLEEP_DISPLAY_AC			"sleep-display-ac"
+#define GPM_SETTINGS_SLEEP_DISPLAY_BATT			"sleep-display-battery"
+#define GPM_SETTINGS_SLEEP_DISPLAY_UPS			"sleep-display-ups"
+
+/* ui */
+#define GPM_SETTINGS_ICON_POLICY			"icon-policy"
+#define GPM_SETTINGS_ENABLE_SOUND			"enable-sound"
+#define GPM_SETTINGS_SHOW_ACTIONS			"show-actions"
+
+/* statistics */
+#define GPM_SETTINGS_INFO_HISTORY_TIME			"info-history-time"
+#define GPM_SETTINGS_INFO_HISTORY_TYPE			"info-history-type"
+#define GPM_SETTINGS_INFO_HISTORY_GRAPH_SMOOTH		"info-history-graph-smooth"
+#define GPM_SETTINGS_INFO_HISTORY_GRAPH_POINTS		"info-history-graph-points"
+#define GPM_SETTINGS_INFO_STATS_TYPE			"info-stats-type"
+#define GPM_SETTINGS_INFO_STATS_GRAPH_SMOOTH		"info-stats-graph-smooth"
+#define GPM_SETTINGS_INFO_STATS_GRAPH_POINTS		"info-stats-graph-points"
+#define GPM_SETTINGS_INFO_PAGE_NUMBER			"info-page-number"
+#define GPM_SETTINGS_INFO_LAST_DEVICE			"info-last-device"
+
+/* mate-screensaver */
+#define GS_SETTINGS_SCHEMA				"org.mate.screensaver"
+#define GS_SETTINGS_PREF_LOCK_ENABLED			"lock-enabled"
+
+typedef enum {
+	GPM_ICON_POLICY_ALWAYS,
+	GPM_ICON_POLICY_PRESENT,
+	GPM_ICON_POLICY_CHARGE,
+	GPM_ICON_POLICY_LOW,
+	GPM_ICON_POLICY_CRITICAL,
+	GPM_ICON_POLICY_NEVER
+} GpmIconPolicy;
+
+typedef enum {
+	GPM_ACTION_POLICY_BLANK,
+	GPM_ACTION_POLICY_SUSPEND,
+	GPM_ACTION_POLICY_SHUTDOWN,
+	GPM_ACTION_POLICY_HIBERNATE,
+	GPM_ACTION_POLICY_INTERACTIVE,
+	GPM_ACTION_POLICY_NOTHING
+} GpmActionPolicy;
+
+gchar        *gpm_get_timestring                (guint time);
+guint        gpm_discrete_from_percent          (guint percentage,
+                                                 guint levels);
+guint        gpm_discrete_to_percent            (guint discrete,
+                                                 guint levels);
+void         gpm_help_display                   (const gchar    *link_id);
+gboolean     gpm_notebook_scroll_event_cb       (GtkWidget      *widget,
+                                                 GdkEventScroll *event);
+#ifdef EGG_TEST
+void         gpm_common_test                     (gpointer data);
+#endif
+
+G_END_DECLS
+
+#endif	/* __GPMCOMMON_H */
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/66.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/66.html new file mode 100644 index 0000000..d9218fe --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/66.html @@ -0,0 +1,395 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 8; tab-width: 8 -*-
+ *
+ * Copyright (C) 2006 William Jon McCann <mccann@jhu.edu>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be
+ * useful, but WITHOUT ANY WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE.  See the GNU Lesser General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef MSD_MEDIA_KEYS_WINDOW_H
+#define MSD_MEDIA_KEYS_WINDOW_H
+
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "msd-osd-window.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define MSD_TYPE_MEDIA_KEYS_WINDOW            (msd_media_keys_window_get_type ())
+#define MSD_MEDIA_KEYS_WINDOW(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj),  MSD_TYPE_MEDIA_KEYS_WINDOW, MsdMediaKeysWindow))
+#define MSD_MEDIA_KEYS_WINDOW_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass),   MSD_TYPE_MEDIA_KEYS_WINDOW, MsdMediaKeysWindowClass))
+#define MSD_IS_MEDIA_KEYS_WINDOW(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj),  MSD_TYPE_MEDIA_KEYS_WINDOW))
+#define MSD_IS_MEDIA_KEYS_WINDOW_CLASS(klass) (G_TYPE_INSTANCE_GET_CLASS ((klass), MSD_TYPE_MEDIA_KEYS_WINDOW))
+
+typedef struct MsdMediaKeysWindow                   MsdMediaKeysWindow;
+typedef struct MsdMediaKeysWindowClass              MsdMediaKeysWindowClass;
+typedef struct MsdMediaKeysWindowPrivate            MsdMediaKeysWindowPrivate;
+
+struct MsdMediaKeysWindow {
+        MsdOsdWindow parent;
+
+        MsdMediaKeysWindowPrivate  *priv;
+};
+
+struct MsdMediaKeysWindowClass {
+        MsdOsdWindowClass parent_class;
+};
+
+typedef enum {
+        MSD_MEDIA_KEYS_WINDOW_ACTION_VOLUME,
+        MSD_MEDIA_KEYS_WINDOW_ACTION_CUSTOM
+} MsdMediaKeysWindowAction;
+
+GType                 msd_media_keys_window_get_type          (void);
+
+GtkWidget *           msd_media_keys_window_new               (void);
+void                  msd_media_keys_window_set_action        (MsdMediaKeysWindow      *window,
+                                                               MsdMediaKeysWindowAction action);
+void                  msd_media_keys_window_set_action_custom (MsdMediaKeysWindow      *window,
+                                                               const char              *icon_name,
+                                                               gboolean                 show_level);
+void                  msd_media_keys_window_set_volume_muted  (MsdMediaKeysWindow      *window,
+                                                               gboolean                 muted);
+void                  msd_media_keys_window_set_volume_level  (MsdMediaKeysWindow      *window,
+                                                               int                      level);
+gboolean              msd_media_keys_window_is_valid          (MsdMediaKeysWindow      *window);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/67.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/67.html new file mode 100644 index 0000000..0aff767 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/67.html @@ -0,0 +1,413 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+82
+83
+84
+85
+86
+87
+88
/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 8; tab-width: 8 -*-
+ *
+ * On-screen-display (OSD) window for mate-settings-daemon's plugins
+ *
+ * Copyright (C) 2006 William Jon McCann <mccann@jhu.edu>
+ * Copyright (C) 2009 Novell, Inc
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * Authors:
+ *   William Jon McCann <mccann@jhu.edu>
+ *   Federico Mena-Quintero <federico@novell.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be
+ * useful, but WITHOUT ANY WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE.  See the GNU Lesser General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+/* MsdOsdWindow is an "on-screen-display" window (OSD).  It is the cute,
+ * semi-transparent, curved popup that appears when you press a hotkey global to
+ * the desktop, such as to change the volume, switch your monitor's parameters,
+ * etc.
+ *
+ * You can create a MsdOsdWindow and use it as a normal GtkWindow.  It will
+ * automatically center itself, figure out if it needs to be composited, etc.
+ * Just pack your widgets in it, sit back, and enjoy the ride.
+ */
+
+#ifndef MSD_OSD_WINDOW_H
+#define MSD_OSD_WINDOW_H
+
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Alpha value to be used for foreground objects drawn in an OSD window */
+#define MSD_OSD_WINDOW_FG_ALPHA 1.0
+
+#define MSD_TYPE_OSD_WINDOW            (msd_osd_window_get_type ())
+#define MSD_OSD_WINDOW(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj),  MSD_TYPE_OSD_WINDOW, MsdOsdWindow))
+#define MSD_OSD_WINDOW_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass),   MSD_TYPE_OSD_WINDOW, MsdOsdWindowClass))
+#define MSD_IS_OSD_WINDOW(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj),  MSD_TYPE_OSD_WINDOW))
+#define MSD_IS_OSD_WINDOW_CLASS(klass) (G_TYPE_INSTANCE_GET_CLASS ((klass), MSD_TYPE_OSD_WINDOW))
+#define MSD_OSD_WINDOW_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), MSD_TYPE_OSD_WINDOW, MsdOsdWindowClass))
+
+typedef struct MsdOsdWindow                   MsdOsdWindow;
+typedef struct MsdOsdWindowClass              MsdOsdWindowClass;
+typedef struct MsdOsdWindowPrivate            MsdOsdWindowPrivate;
+
+struct MsdOsdWindow {
+        GtkWindow                   parent;
+
+        MsdOsdWindowPrivate  *priv;
+};
+
+struct MsdOsdWindowClass {
+        GtkWindowClass parent_class;
+
+        void (* draw_when_composited) (MsdOsdWindow *window, cairo_t *cr);
+};
+
+GType                 msd_osd_window_get_type          (void);
+
+GtkWidget *           msd_osd_window_new               (void);
+gboolean              msd_osd_window_is_composited     (MsdOsdWindow      *window);
+gboolean              msd_osd_window_is_valid          (MsdOsdWindow      *window);
+void                  msd_osd_window_update_and_hide   (MsdOsdWindow      *window);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/68.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/68.html new file mode 100644 index 0000000..e084519 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/68.html @@ -0,0 +1,387 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2005 William Jon McCann <mccann@jhu.edu>
+ * Copyright (C) 2005-2008 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __GPM_IDLE_H
+#define __GPM_IDLE_H
+
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+G_BEGIN_DECLS
+
+#define GPM_TYPE_IDLE		(gpm_idle_get_type ())
+#define GPM_IDLE(o)		(G_TYPE_CHECK_INSTANCE_CAST ((o), GPM_TYPE_IDLE, GpmIdle))
+#define GPM_IDLE_CLASS(k)	(G_TYPE_CHECK_CLASS_CAST((k), GPM_TYPE_IDLE, GpmIdleClass))
+#define GPM_IS_IDLE(o)		(G_TYPE_CHECK_INSTANCE_TYPE ((o), GPM_TYPE_IDLE))
+#define GPM_IS_IDLE_CLASS(k)	(G_TYPE_CHECK_CLASS_TYPE ((k), GPM_TYPE_IDLE))
+#define GPM_IDLE_GET_CLASS(o)	(G_TYPE_INSTANCE_GET_CLASS ((o), GPM_TYPE_IDLE, GpmIdleClass))
+
+typedef enum {
+	GPM_IDLE_MODE_NORMAL,
+	GPM_IDLE_MODE_DIM,
+	GPM_IDLE_MODE_BLANK,
+	GPM_IDLE_MODE_SLEEP
+} GpmIdleMode;
+
+typedef struct GpmIdlePrivate GpmIdlePrivate;
+
+typedef struct
+{
+	GObject		parent;
+	GpmIdlePrivate *priv;
+} GpmIdle;
+
+typedef struct
+{
+	GObjectClass	parent_class;
+	void		(* idle_changed)		(GpmIdle	*idle,
+							 GpmIdleMode	 mode);
+} GpmIdleClass;
+
+GType		 gpm_idle_get_type			(void);
+GpmIdle		*gpm_idle_new				(void);
+GpmIdleMode	 gpm_idle_get_mode			(GpmIdle	*idle);
+void		 gpm_idle_set_check_cpu			(GpmIdle	*idle,
+							 gboolean	 check_type_cpu);
+gboolean	 gpm_idle_set_timeout_dim		(GpmIdle	*idle,
+							 guint		 timeout);
+gboolean	 gpm_idle_set_timeout_blank		(GpmIdle	*idle,
+							 guint		 timeout);
+gboolean	 gpm_idle_set_timeout_sleep		(GpmIdle	*idle,
+							 guint		 timeout);
+void		 gpm_idle_test				(gpointer	 data);
+
+G_END_DECLS
+
+#endif /* __GPM_IDLE_H */
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/69.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/69.html new file mode 100644 index 0000000..b2033d5 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/69.html @@ -0,0 +1,483 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
/* This file is generated by glib-genmarshal, do not modify it. This code is licensed under the same license as the containing project. Note that it links to GLib, so must comply with the LGPL linking clauses. */
+#ifndef __GPM_MARSHAL_MARSHAL_H__
+#define __GPM_MARSHAL_MARSHAL_H__
+
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+G_BEGIN_DECLS
+
+/* VOID:INT,BOXED (gpm-marshal.list:1) */
+extern
+void gpm_marshal_VOID__INT_BOXED (GClosure     *closure,
+                                  GValue       *return_value,
+                                  guint         n_param_values,
+                                  const GValue *param_values,
+                                  gpointer      invocation_hint,
+                                  gpointer      marshal_data);
+
+/* VOID:STRING,STRING (gpm-marshal.list:2) */
+extern
+void gpm_marshal_VOID__STRING_STRING (GClosure     *closure,
+                                      GValue       *return_value,
+                                      guint         n_param_values,
+                                      const GValue *param_values,
+                                      gpointer      invocation_hint,
+                                      gpointer      marshal_data);
+
+/* VOID:POINTER,STRING,STRING (gpm-marshal.list:3) */
+extern
+void gpm_marshal_VOID__POINTER_STRING_STRING (GClosure     *closure,
+                                              GValue       *return_value,
+                                              guint         n_param_values,
+                                              const GValue *param_values,
+                                              gpointer      invocation_hint,
+                                              gpointer      marshal_data);
+
+/* VOID:UINT,UINT,BOOLEAN (gpm-marshal.list:4) */
+extern
+void gpm_marshal_VOID__UINT_UINT_BOOLEAN (GClosure     *closure,
+                                          GValue       *return_value,
+                                          guint         n_param_values,
+                                          const GValue *param_values,
+                                          gpointer      invocation_hint,
+                                          gpointer      marshal_data);
+
+/* VOID:STRING,STRING,STRING (gpm-marshal.list:5) */
+extern
+void gpm_marshal_VOID__STRING_STRING_STRING (GClosure     *closure,
+                                             GValue       *return_value,
+                                             guint         n_param_values,
+                                             const GValue *param_values,
+                                             gpointer      invocation_hint,
+                                             gpointer      marshal_data);
+
+/* VOID:STRING,BOOLEAN (gpm-marshal.list:6) */
+extern
+void gpm_marshal_VOID__STRING_BOOLEAN (GClosure     *closure,
+                                       GValue       *return_value,
+                                       guint         n_param_values,
+                                       const GValue *param_values,
+                                       gpointer      invocation_hint,
+                                       gpointer      marshal_data);
+
+/* VOID:STRING,STRING,BOOLEAN (gpm-marshal.list:7) */
+extern
+void gpm_marshal_VOID__STRING_STRING_BOOLEAN (GClosure     *closure,
+                                              GValue       *return_value,
+                                              guint         n_param_values,
+                                              const GValue *param_values,
+                                              gpointer      invocation_hint,
+                                              gpointer      marshal_data);
+
+/* VOID:STRING,STRING,BOOLEAN,BOOLEAN,BOOLEAN (gpm-marshal.list:8) */
+extern
+void gpm_marshal_VOID__STRING_STRING_BOOLEAN_BOOLEAN_BOOLEAN (GClosure     *closure,
+                                                              GValue       *return_value,
+                                                              guint         n_param_values,
+                                                              const GValue *param_values,
+                                                              gpointer      invocation_hint,
+                                                              gpointer      marshal_data);
+
+/* VOID:INT (gpm-marshal.list:9) */
+#define gpm_marshal_VOID__INT	g_cclosure_marshal_VOID__INT
+
+/* VOID:STRING (gpm-marshal.list:10) */
+#define gpm_marshal_VOID__STRING	g_cclosure_marshal_VOID__STRING
+
+/* VOID:INT,LONG,BOOLEAN,BOOLEAN (gpm-marshal.list:11) */
+extern
+void gpm_marshal_VOID__INT_LONG_BOOLEAN_BOOLEAN (GClosure     *closure,
+                                                 GValue       *return_value,
+                                                 guint         n_param_values,
+                                                 const GValue *param_values,
+                                                 gpointer      invocation_hint,
+                                                 gpointer      marshal_data);
+
+/* VOID:BOOLEAN,BOOLEAN (gpm-marshal.list:12) */
+extern
+void gpm_marshal_VOID__BOOLEAN_BOOLEAN (GClosure     *closure,
+                                        GValue       *return_value,
+                                        guint         n_param_values,
+                                        const GValue *param_values,
+                                        gpointer      invocation_hint,
+                                        gpointer      marshal_data);
+
+/* VOID:UINT (gpm-marshal.list:13) */
+#define gpm_marshal_VOID__UINT	g_cclosure_marshal_VOID__UINT
+
+/* VOID:UINT,UINT (gpm-marshal.list:14) */
+extern
+void gpm_marshal_VOID__UINT_UINT (GClosure     *closure,
+                                  GValue       *return_value,
+                                  guint         n_param_values,
+                                  const GValue *param_values,
+                                  gpointer      invocation_hint,
+                                  gpointer      marshal_data);
+
+/* VOID:UINT,POINTER (gpm-marshal.list:15) */
+#define gpm_marshal_VOID__UINT_POINTER	g_cclosure_marshal_VOID__UINT_POINTER
+
+
+G_END_DECLS
+
+#endif /* __GPM_MARSHAL_MARSHAL_H__ */
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/7.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/7.html new file mode 100644 index 0000000..a39b2c6 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/7.html @@ -0,0 +1,1309 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
/*
+ * Copyright 2007 Red Hat, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/* Author: Soren Sandmann <sandmann@redhat.com> */
+
+#include "edid.h"
+#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <math.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+static int get_bit(int in, int bit)
+{
+	return (in & (1 << bit)) >> bit;
+}
+
+static int get_bits(int in, int begin, int end)
+{
+	int mask = (1 << (end - begin + 1)) - 1;
+
+	return (in >> begin) & mask;
+}
+
+static int decode_header(const uchar* edid)
+{
+	if (memcmp(edid, "\x00\xff\xff\xff\xff\xff\xff\x00", 8) == 0)
+	{
+		return TRUE;
+	}
+
+	return FALSE;
+}
+
+static int decode_vendor_and_product_identification(const uchar* edid, MonitorInfo* info)
+{
+	int is_model_year;
+
+	/* Manufacturer Code */
+	info->manufacturer_code[0] = get_bits(edid[0x08], 2, 6);
+	info->manufacturer_code[1] = get_bits(edid[0x08], 0, 1) << 3;
+	info->manufacturer_code[1] |= get_bits(edid[0x09], 5, 7);
+	info->manufacturer_code[2] = get_bits(edid[0x09], 0, 4);
+	info->manufacturer_code[3] = '\0';
+
+	info->manufacturer_code[0] += 'A' - 1;
+	info->manufacturer_code[1] += 'A' - 1;
+	info->manufacturer_code[2] += 'A' - 1;
+
+	/* Product Code */
+	info->product_code = edid[0x0b] << 8 | edid[0x0a];
+
+	/* Serial Number */
+	info->serial_number = edid[0x0c] | edid[0x0d] << 8 | edid[0x0e] << 16 | edid[0x0f] << 24;
+
+	/* Week and Year */
+	is_model_year = FALSE;
+
+	switch (edid[0x10])
+	{
+		case 0x00:
+			info->production_week = -1;
+			break;
+
+		case 0xff:
+			info->production_week = -1;
+			is_model_year = TRUE;
+			break;
+
+		default:
+			info->production_week = edid[0x10];
+			break;
+	}
+
+	if (is_model_year)
+	{
+		info->production_year = -1;
+		info->model_year = 1990 + edid[0x11];
+	}
+	else
+	{
+		info->production_year = 1990 + edid[0x11];
+		info->model_year = -1;
+	}
+
+	return TRUE;
+}
+
+static int decode_edid_version(const uchar* edid, MonitorInfo* info)
+{
+	info->major_version = edid[0x12];
+	info->minor_version = edid[0x13];
+
+	return TRUE;
+}
+
+static int decode_display_parameters(const uchar* edid, MonitorInfo* info)
+{
+	/* Digital vs Analog */
+	info->is_digital = get_bit(edid[0x14], 7);
+
+	if (info->is_digital)
+	{
+		int bits;
+
+		static const int bit_depth[8] = {
+			-1, 6, 8, 10, 12, 14, 16, -1
+		};
+
+		static const Interface interfaces[6] = {
+			UNDEFINED, DVI, HDMI_A, HDMI_B, MDDI, DISPLAY_PORT
+		};
+
+		bits = get_bits(edid[0x14], 4, 6);
+		info->connector.digital.bits_per_primary = bit_depth[bits];
+
+		bits = get_bits(edid[0x14], 0, 3);
+
+		if (bits <= 5)
+		{
+			info->connector.digital.interface = interfaces[bits];
+		}
+		else
+		{
+			info->connector.digital.interface = UNDEFINED;
+		}
+	}
+	else
+	{
+		int bits = get_bits (edid[0x14], 5, 6);
+
+		static const double levels[][3] = {
+			{ 0.7,   0.3,	1.0 },
+			{ 0.714, 0.286,  1.0 },
+			{ 1.0,   0.4,	1.4 },
+			{ 0.7,   0.0,	0.7 },
+		};
+
+		info->connector.analog.video_signal_level = levels[bits][0];
+		info->connector.analog.sync_signal_level = levels[bits][1];
+		info->connector.analog.total_signal_level = levels[bits][2];
+
+		info->connector.analog.blank_to_black = get_bit (edid[0x14], 4);
+
+		info->connector.analog.separate_hv_sync = get_bit (edid[0x14], 3);
+		info->connector.analog.composite_sync_on_h = get_bit (edid[0x14], 2);
+		info->connector.analog.composite_sync_on_green = get_bit (edid[0x14], 1);
+
+		info->connector.analog.serration_on_vsync = get_bit (edid[0x14], 0);
+	}
+
+	/* Screen Size / Aspect Ratio */
+	if (edid[0x15] == 0 && edid[0x16] == 0)
+	{
+		info->width_mm = -1;
+		info->height_mm = -1;
+		info->aspect_ratio = -1.0;
+	}
+	else if (edid[0x16] == 0)
+	{
+		info->width_mm = -1;
+		info->height_mm = -1;
+		info->aspect_ratio = 100.0 / (edid[0x15] + 99);
+	}
+	else if (edid[0x15] == 0)
+	{
+		info->width_mm = -1;
+		info->height_mm = -1;
+		info->aspect_ratio = 100.0 / (edid[0x16] + 99);
+		info->aspect_ratio = 1/info->aspect_ratio; /* portrait */
+	}
+	else
+	{
+		info->width_mm = 10 * edid[0x15];
+		info->height_mm = 10 * edid[0x16];
+	}
+
+	/* Gamma */
+	if (edid[0x17] == 0xFF)
+		info->gamma = -1.0;
+	else
+		info->gamma = (edid[0x17] + 100.0) / 100.0;
+
+	/* Features */
+	info->standby = get_bit(edid[0x18], 7);
+	info->suspend = get_bit(edid[0x18], 6);
+	info->active_off = get_bit(edid[0x18], 5);
+
+	if (info->is_digital)
+	{
+		info->connector.digital.rgb444 = TRUE;
+
+		if (get_bit(edid[0x18], 3))
+			info->connector.digital.ycrcb444 = 1;
+		if (get_bit(edid[0x18], 4))
+			info->connector.digital.ycrcb422 = 1;
+	}
+	else
+	{
+		int bits = get_bits(edid[0x18], 3, 4);
+
+		ColorType color_type[4] = {
+			MONOCHROME, RGB, OTHER_COLOR, UNDEFINED_COLOR
+		};
+
+		info->connector.analog.color_type = color_type[bits];
+	}
+
+	info->srgb_is_standard = get_bit(edid[0x18], 2);
+
+	/* In 1.3 this is called "has preferred timing" */
+	info->preferred_timing_includes_native = get_bit(edid[0x18], 1);
+
+	/* FIXME: In 1.3 this indicates whether the monitor accepts GTF */
+	info->continuous_frequency = get_bit(edid[0x18], 0);
+
+	return TRUE;
+}
+
+static double decode_fraction(int high, int low)
+{
+	double result = 0.0;
+	int i;
+
+	high = (high << 2) | low;
+
+	for (i = 0; i < 10; ++i)
+	{
+		result += get_bit (high, i) * pow (2, i - 10);
+	}
+
+	return result;
+}
+
+static int decode_color_characteristics(const uchar* edid, MonitorInfo* info)
+{
+	info->red_x = decode_fraction(edid[0x1b], get_bits(edid[0x19], 6, 7));
+	info->red_y = decode_fraction(edid[0x1c], get_bits(edid[0x19], 5, 4));
+	info->green_x = decode_fraction(edid[0x1d], get_bits(edid[0x19], 2, 3));
+	info->green_y = decode_fraction(edid[0x1e], get_bits(edid[0x19], 0, 1));
+	info->blue_x = decode_fraction(edid[0x1f], get_bits(edid[0x1a], 6, 7));
+	info->blue_y = decode_fraction(edid[0x20], get_bits(edid[0x1a], 4, 5));
+	info->white_x = decode_fraction(edid[0x21], get_bits(edid[0x1a], 2, 3));
+	info->white_y = decode_fraction(edid[0x22], get_bits(edid[0x1a], 0, 1));
+
+	return TRUE;
+}
+
+static int decode_established_timings(const uchar* edid, MonitorInfo* info)
+{
+	static const Timing established[][8] = {
+		{
+			{800, 600, 60},
+			{800, 600, 56},
+			{640, 480, 75},
+			{640, 480, 72},
+			{640, 480, 67},
+			{640, 480, 60},
+			{720, 400, 88},
+			{720, 400, 70}
+		},
+		{
+			{1280, 1024, 75},
+			{1024, 768, 75},
+			{1024, 768, 70},
+			{1024, 768, 60},
+			{1024, 768, 87},
+			{832, 624, 75},
+			{800, 600, 75},
+			{800, 600, 72}
+		},
+		{
+			{0, 0, 0},
+			{0, 0, 0},
+			{0, 0, 0},
+			{0, 0, 0},
+			{0, 0, 0},
+			{0, 0, 0},
+			{0, 0, 0},
+			{1152, 870, 75}
+		},
+	};
+
+	int i, j, idx;
+
+	idx = 0;
+
+	for (i = 0; i < 3; ++i)
+	{
+		for (j = 0; j < 8; ++j)
+		{
+			int byte = edid[0x23 + i];
+
+			if (get_bit (byte, j) && established[i][j].frequency != 0)
+			{
+				info->established[idx++] = established[i][j];
+			}
+		}
+	}
+
+	return TRUE;
+}
+
+static int decode_standard_timings(const uchar* edid, MonitorInfo* info)
+{
+	int i;
+
+	for (i = 0; i < 8; i++)
+	{
+		int first = edid[0x26 + 2 * i];
+		int second = edid[0x27 + 2 * i];
+
+		if (first != 0x01 && second != 0x01)
+		{
+			int w = 8 * (first + 31);
+			int h = 0;
+
+			switch (get_bits(second, 6, 7))
+			{
+				case 0x00:
+					h = (w / 16) * 10;
+					break;
+				case 0x01:
+					h = (w / 4) * 3;
+					break;
+				case 0x02:
+					h = (w / 5) * 4;
+					break;
+				case 0x03:
+					h = (w / 16) * 9;
+					break;
+			}
+
+			info->standard[i].width = w;
+			info->standard[i].height = h;
+			info->standard[i].frequency = get_bits(second, 0, 5) + 60;
+		}
+	}
+
+	return TRUE;
+}
+
+static void decode_lf_string(const uchar* s, int n_chars, char* result)
+{
+	int i;
+
+	for (i = 0; i < n_chars; ++i)
+	{
+		if (s[i] == 0x0a)
+		{
+			*result++ = '\0';
+			break;
+		}
+		else if (s[i] == 0x00)
+		{
+			/* Convert embedded 0's to spaces */
+			*result++ = ' ';
+		}
+		else
+		{
+			*result++ = s[i];
+		}
+	}
+}
+
+static void decode_display_descriptor(const uchar* desc, MonitorInfo* info)
+{
+	switch (desc[0x03])
+	{
+		case 0xFC:
+			decode_lf_string (desc + 5, 13, info->dsc_product_name);
+			break;
+		case 0xFF:
+			decode_lf_string (desc + 5, 13, info->dsc_serial_number);
+			break;
+		case 0xFE:
+			decode_lf_string (desc + 5, 13, info->dsc_string);
+			break;
+		case 0xFD:
+			/* Range Limits */
+			break;
+		case 0xFB:
+			/* Color Point */
+			break;
+		case 0xFA:
+			/* Timing Identifications */
+			break;
+		case 0xF9:
+			/* Color Management */
+			break;
+		case 0xF8:
+			/* Timing Codes */
+			break;
+		case 0xF7:
+			/* Established Timings */
+			break;
+		case 0x10:
+			break;
+	}
+}
+
+static void decode_detailed_timing(const uchar* timing, DetailedTiming* detailed)
+{
+	int bits;
+
+	StereoType stereo[] = {
+		NO_STEREO, NO_STEREO, FIELD_RIGHT, FIELD_LEFT,
+		TWO_WAY_RIGHT_ON_EVEN, TWO_WAY_LEFT_ON_EVEN,
+		FOUR_WAY_INTERLEAVED, SIDE_BY_SIDE
+	};
+
+	detailed->pixel_clock = (timing[0x00] | timing[0x01] << 8) * 10000;
+	detailed->h_addr = timing[0x02] | ((timing[0x04] & 0xf0) << 4);
+	detailed->h_blank = timing[0x03] | ((timing[0x04] & 0x0f) << 8);
+	detailed->v_addr = timing[0x05] | ((timing[0x07] & 0xf0) << 4);
+	detailed->v_blank = timing[0x06] | ((timing[0x07] & 0x0f) << 8);
+	detailed->h_front_porch = timing[0x08] | get_bits(timing[0x0b], 6, 7) << 8;
+	detailed->h_sync = timing[0x09] | get_bits(timing[0x0b], 4, 5) << 8;
+	detailed->v_front_porch =
+	get_bits (timing[0x0a], 4, 7) | get_bits(timing[0x0b], 2, 3) << 4;
+	detailed->v_sync =
+	get_bits (timing[0x0a], 0, 3) | get_bits(timing[0x0b], 0, 1) << 4;
+	detailed->width_mm =  timing[0x0c] | get_bits(timing[0x0e], 4, 7) << 8;
+	detailed->height_mm = timing[0x0d] | get_bits(timing[0x0e], 0, 3) << 8;
+	detailed->right_border = timing[0x0f];
+	detailed->top_border = timing[0x10];
+
+	detailed->interlaced = get_bit(timing[0x11], 7);
+
+	/* Stereo */
+	bits = get_bits (timing[0x11], 5, 6) << 1 | get_bit(timing[0x11], 0);
+	detailed->stereo = stereo[bits];
+
+	/* Sync */
+	bits = timing[0x11];
+
+	detailed->digital_sync = get_bit(bits, 4);
+
+	if (detailed->digital_sync)
+	{
+		detailed->connector.digital.composite = !get_bit(bits, 3);
+
+		if (detailed->connector.digital.composite)
+		{
+			detailed->connector.digital.serrations = get_bit(bits, 2);
+			detailed->connector.digital.negative_vsync = FALSE;
+		}
+		else
+		{
+			detailed->connector.digital.serrations = FALSE;
+			detailed->connector.digital.negative_vsync = !get_bit(bits, 2);
+		}
+
+		detailed->connector.digital.negative_hsync = !get_bit(bits, 0);
+	}
+	else
+	{
+		detailed->connector.analog.bipolar = get_bit(bits, 3);
+		detailed->connector.analog.serrations = get_bit(bits, 2);
+		detailed->connector.analog.sync_on_green = !get_bit(bits, 1);
+	}
+}
+
+static int decode_descriptors(const uchar* edid, MonitorInfo* info)
+{
+	int i;
+	int timing_idx;
+
+	timing_idx = 0;
+
+	for (i = 0; i < 4; ++i)
+	{
+		int index = 0x36 + i * 18;
+
+		if (edid[index + 0] == 0x00 && edid[index + 1] == 0x00)
+		{
+			decode_display_descriptor(edid + index, info);
+		}
+		else
+		{
+			decode_detailed_timing(edid + index, &(info->detailed_timings[timing_idx++]));
+		}
+	}
+
+	info->n_detailed_timings = timing_idx;
+
+	return TRUE;
+}
+
+static void decode_check_sum(const uchar* edid, MonitorInfo* info)
+{
+	int i;
+	uchar check = 0;
+
+	for (i = 0; i < 128; ++i)
+	{
+		check += edid[i];
+	}
+
+	info->checksum = check;
+}
+
+MonitorInfo* decode_edid(const uchar* edid)
+{
+	MonitorInfo* info = g_new0(MonitorInfo, 1);
+
+	decode_check_sum(edid, info);
+
+	if (decode_header(edid) && decode_vendor_and_product_identification(edid, info) && decode_edid_version(edid, info) && decode_display_parameters(edid, info) && decode_color_characteristics(edid, info) && decode_established_timings(edid, info) && decode_standard_timings(edid, info) && decode_descriptors(edid, info))
+	{
+		return info;
+	}
+	else
+	{
+		g_free(info);
+		return NULL;
+	}
+}
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/70.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/70.html new file mode 100644 index 0000000..5498bd3 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/70.html @@ -0,0 +1,2203 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
+603
+604
+605
+606
+607
+608
+609
+610
+611
+612
+613
+614
+615
+616
+617
+618
+619
+620
+621
+622
+623
+624
+625
+626
+627
+628
+629
+630
+631
+632
+633
+634
+635
+636
+637
+638
+639
+640
+641
+642
+643
+644
+645
+646
+647
+648
+649
+650
+651
+652
+653
+654
+655
+656
+657
+658
+659
+660
+661
+662
+663
+664
+665
+666
+667
+668
+669
+670
+671
+672
+673
+674
+675
+676
+677
+678
+679
+680
+681
+682
+683
+684
+685
+686
+687
+688
+689
+690
+691
+692
+693
+694
+695
+696
+697
+698
+699
+700
+701
+702
+703
+704
+705
+706
+707
+708
+709
+710
+711
+712
+713
+714
+715
+716
+717
+718
+719
+720
+721
+722
+723
+724
+725
+726
+727
+728
+729
+730
+731
+732
+733
+734
+735
+736
+737
+738
+739
+740
+741
+742
+743
+744
+745
+746
+747
+748
+749
+750
+751
+752
+753
+754
+755
+756
+757
+758
+759
+760
+761
+762
+763
+764
+765
+766
+767
+768
+769
+770
+771
+772
+773
+774
+775
+776
+777
+778
+779
+780
+781
+782
+783
+784
+785
+786
+787
+788
+789
+790
+791
+792
+793
+794
+795
+796
+797
+798
+799
+800
+801
+802
+803
+804
+805
+806
+807
+808
+809
+810
+811
+812
+813
+814
+815
+816
+817
+818
+819
+820
+821
+822
+823
+824
+825
+826
+827
+828
+829
+830
+831
+832
+833
+834
+835
+836
+837
+838
+839
+840
+841
+842
+843
+844
+845
+846
+847
+848
+849
+850
+851
+852
+853
+854
+855
+856
+857
+858
+859
+860
+861
+862
+863
+864
+865
+866
+867
+868
+869
+870
+871
+872
+873
+874
+875
+876
+877
+878
+879
+880
+881
+882
+883
+884
+885
+886
+887
+888
+889
+890
+891
+892
+893
+894
+895
+896
+897
+898
+899
+900
+901
+902
+903
+904
+905
+906
+907
+908
+909
+910
+911
+912
+913
+914
+915
+916
+917
+918
+919
+920
+921
+922
+923
+924
+925
+926
+927
+928
+929
+930
+931
+932
+933
+934
+935
+936
+937
+938
+939
+940
+941
+942
+943
+944
+945
+946
+947
+948
+949
+950
+951
+952
+953
+954
+955
+956
+957
+958
+959
+960
+961
+962
+963
+964
+965
+966
+967
+968
+969
+970
+971
+972
+973
+974
+975
+976
+977
+978
+979
+980
+981
+982
+983
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008-2010 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+
+#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <time.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <errno.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <X11/Xatom.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <X11/Xlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <X11/extensions/Xrandr.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdk/gdkx.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/time.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/types.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#ifdef HAVE_UNISTD_H
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif /* HAVE_UNISTD_H */
+
+#include "egg-discrete.h"
+
+#include "gpm-brightness.h"
+#include "gpm-common.h"
+#include "gpm-marshal.h"
+
+#define GPM_SOLE_SETTER_USE_CACHE	TRUE	/* this may be insanity */
+
+struct GpmBrightnessPrivate
+{
+	gboolean		 has_changed_events;
+	gboolean		 cache_trusted;
+	guint			 cache_percentage;
+	guint			 last_set_hw;
+	Atom			 backlight;
+	Display			*dpy;
+	GdkWindow		*root_window;
+	guint			 shared_value;
+	gboolean		 has_extension;
+	gboolean		 hw_changed;
+	/* A cache of XRRScreenResources is used as XRRGetScreenResources is expensive */
+	GPtrArray		*resources;
+	gint			 extension_levels;
+	gint			 extension_current;
+};
+
+enum {
+	BRIGHTNESS_CHANGED,
+	LAST_SIGNAL
+};
+
+typedef enum {
+	ACTION_BACKLIGHT_GET,
+	ACTION_BACKLIGHT_SET,
+	ACTION_BACKLIGHT_INC,
+	ACTION_BACKLIGHT_DEC
+} GpmXRandROp;
+
+G_DEFINE_TYPE_WITH_PRIVATE (GpmBrightness, gpm_brightness, G_TYPE_OBJECT)<--- There is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
+
+static guint signals [LAST_SIGNAL] = { 0 };
+static gpointer gpm_brightness_object = NULL;
+
+/**
+ * gpm_brightness_helper_strtoint:
+ * @text: The text to be converted
+ * @value: The return numeric return value
+ *
+ * Convert a string to a signed integer value in a safe way.
+ *
+ * Return value: %TRUE if the string was converted correctly
+ **/
+static gboolean
+gpm_brightness_helper_strtoint (const gchar *text, gint *value)
+{
+	gchar *endptr = NULL;
+	gint64 value_raw;
+
+	if (text == NULL)
+		return FALSE;
+
+	value_raw = g_ascii_strtoll (text, &endptr, 10);
+
+	if (endptr == text)
+		return FALSE;
+	if (errno == ERANGE || value_raw > G_MAXINT || value_raw < G_MININT)
+		return FALSE;
+
+	*value = (gint) value_raw;
+	return TRUE;
+}
+
+/**
+ * gpm_brightness_helper_get_value:
+ **/
+static gint
+gpm_brightness_helper_get_value (const gchar *argument)
+{
+	gboolean ret;
+	GError *error = NULL;
+	gchar *stdout_data = NULL;
+	gint exit_status = 0;
+	gint value = -1;
+	gchar *command = NULL;
+
+	/* get the data */
+	command = g_strdup_printf (SBINDIR "/mate-power-backlight-helper --%s", argument);
+	ret = g_spawn_command_line_sync (command,
+					 &stdout_data, NULL, &exit_status, &error);
+	if (!ret) {
+		g_error ("failed to get value: %s", error->message);
+		g_error_free (error);
+		goto out;
+	}
+	g_debug ("executing %s retval: %i", command, exit_status);
+
+	/* parse for a number */
+	ret = gpm_brightness_helper_strtoint (stdout_data, &value);
+	if (!ret)
+		goto out;
+out:
+	g_free (command);
+	g_free (stdout_data);
+	return value;
+}
+
+/**
+ * gpm_brightness_helper_set_value:
+ **/
+static gboolean
+gpm_brightness_helper_set_value (const gchar *argument, gint value)
+{
+	gboolean ret;
+	GError *error = NULL;
+	gint exit_status = 0;
+	gchar *command = NULL;
+
+	/* get the data */
+	command = g_strdup_printf ("pkexec " SBINDIR "/mate-power-backlight-helper --%s %i", argument, value);
+	ret = g_spawn_command_line_sync (command, NULL, NULL, &exit_status, &error);
+	if (!ret) {
+		g_error ("failed to get value: %s", error->message);
+		g_error_free (error);
+		goto out;
+	}
+	g_debug ("executing %s retval: %i", command, exit_status);
+out:
+	g_free (command);
+	return ret;
+}
+
+/**
+ * gpm_brightness_get_step:
+ * @levels: The number of levels supported
+ * Return value: the amount of hardware steps to do on each increment or decrement
+ **/
+static guint
+gpm_brightness_get_step (guint levels)
+{
+	/* macbook pro has a bazzillion brightness levels, do in 5% steps */
+	if (levels > 20)
+		return levels / 20;
+	return 1;
+}
+
+/**
+ * gpm_brightness_output_get_internal:
+ **/
+static gboolean
+gpm_brightness_output_get_internal (GpmBrightness *brightness, RROutput output, guint *cur)
+{
+	unsigned long nitems;
+	unsigned long bytes_after;
+	guint *prop;
+	Atom actual_type;
+	int actual_format;
+	gboolean ret = FALSE;
+
+	g_return_val_if_fail (GPM_IS_BRIGHTNESS (brightness), FALSE);
+
+	if (brightness->priv->backlight == None)
+		return FALSE;
+
+	if (XRRGetOutputProperty (brightness->priv->dpy, output, brightness->priv->backlight,
+				  0, 4, False, False, None,
+				  &actual_type, &actual_format,
+				  &nitems, &bytes_after, ((unsigned char **)&prop)) != Success) {
+		g_debug ("failed to get property");
+		return FALSE;
+	}
+	if (actual_type == XA_INTEGER && nitems == 1 && actual_format == 32) {
+		memcpy (cur, prop, sizeof (guint));
+		ret = TRUE;
+	}
+	XFree (prop);
+	return ret;
+}
+
+/**
+ * gpm_brightness_output_set_internal:
+ **/
+static gboolean
+gpm_brightness_output_set_internal (GpmBrightness *brightness, RROutput output, guint value)
+{
+	GdkDisplay *display;
+
+	gboolean ret = TRUE;
+
+	g_return_val_if_fail (GPM_IS_BRIGHTNESS (brightness), FALSE);
+
+	/* don't abort on error */
+	display = gdk_display_get_default ();
+	gdk_x11_display_error_trap_push (display);
+	XRRChangeOutputProperty (brightness->priv->dpy, output, brightness->priv->backlight, XA_INTEGER, 32,
+				 PropModeReplace, (unsigned char *) &value, 1);
+	XFlush (brightness->priv->dpy);
+	gdk_display_flush (display);
+	if (gdk_x11_display_error_trap_pop (display)) {
+		g_warning ("failed to XRRChangeOutputProperty for brightness %u", value);
+		ret = FALSE;
+	}
+	/* we changed the hardware */
+	if (ret)
+		brightness->priv->hw_changed = TRUE;
+	return ret;
+}
+
+/**
+ * gpm_brightness_setup_display:
+ **/
+static gboolean
+gpm_brightness_setup_display (GpmBrightness *brightness)
+{
+	gint major, minor;
+
+	g_return_val_if_fail (GPM_IS_BRIGHTNESS (brightness), FALSE);
+
+	/* get the display */
+	brightness->priv->dpy = GDK_DISPLAY_XDISPLAY (gdk_display_get_default());
+	if (!brightness->priv->dpy) {
+		g_error ("Cannot open display");
+		return FALSE;
+	}
+	/* is XRandR new enough? */
+	if (!XRRQueryVersion (brightness->priv->dpy, &major, &minor)) {
+		g_debug ("RandR extension missing");
+		return FALSE;
+	}
+	if (major < 1 || (major == 1 && minor < 3)) {
+		g_debug ("RandR version %d.%d too old", major, minor);
+		return FALSE;
+	}
+	/* Can we support "Backlight" */
+	brightness->priv->backlight = XInternAtom (brightness->priv->dpy, "Backlight", True);
+	if (brightness->priv->backlight == None) {
+		/* Do we support "BACKLIGHT" (legacy) */
+		brightness->priv->backlight = XInternAtom (brightness->priv->dpy, "BACKLIGHT", True);
+		if (brightness->priv->backlight == None) {
+			g_debug ("No outputs have backlight property");
+			return FALSE;
+		}
+	}
+	return TRUE;
+}
+
+/**
+ * gpm_brightness_output_get_limits:
+ **/
+static gboolean
+gpm_brightness_output_get_limits (GpmBrightness *brightness, RROutput output,
+					 guint *min, guint *max)
+{
+	XRRPropertyInfo *info;
+	gboolean ret = TRUE;
+
+	g_return_val_if_fail (GPM_IS_BRIGHTNESS (brightness), FALSE);
+
+	info = XRRQueryOutputProperty (brightness->priv->dpy, output, brightness->priv->backlight);
+	if (info == NULL) {
+		g_debug ("could not get output property");
+		return FALSE;
+	}
+	if (!info->range || info->num_values != 2) {
+		g_debug ("was not range");
+		ret = FALSE;
+		goto out;
+	}
+	*min = info->values[0];
+	*max = info->values[1];
+out:
+	XFree (info);
+	return ret;
+}
+
+/**
+ * gpm_brightness_output_get_percentage:
+ **/
+static gboolean
+gpm_brightness_output_get_percentage (GpmBrightness *brightness, RROutput output)
+{
+	guint cur;
+	gboolean ret;
+	guint min, max;
+	guint percentage;
+
+	g_return_val_if_fail (GPM_IS_BRIGHTNESS (brightness), FALSE);
+
+	ret = gpm_brightness_output_get_internal (brightness, output, &cur);
+	if (!ret)
+		return FALSE;
+	ret = gpm_brightness_output_get_limits (brightness, output, &min, &max);
+	if (!ret || min == max)
+		return FALSE;
+	g_debug ("hard value=%u, min=%u, max=%u", cur, min, max);
+	percentage = egg_discrete_to_percent (cur, (max-min)+1);
+	g_debug ("percentage %u", percentage);
+	brightness->priv->shared_value = percentage;
+	return TRUE;
+}
+
+/**
+ * gpm_brightness_output_down:
+ **/
+static gboolean
+gpm_brightness_output_down (GpmBrightness *brightness, RROutput output)
+{
+	guint cur;
+	guint step;
+	gboolean ret;
+	guint min, max;
+
+	g_return_val_if_fail (GPM_IS_BRIGHTNESS (brightness), FALSE);
+
+	ret = gpm_brightness_output_get_internal (brightness, output, &cur);
+	if (!ret)
+		return FALSE;
+	ret = gpm_brightness_output_get_limits (brightness, output, &min, &max);
+	if (!ret || min == max)
+		return FALSE;
+	g_debug ("hard value=%u, min=%u, max=%u", cur, min, max);
+	if (cur == min) {
+		g_debug ("already min");
+		return TRUE;
+	}
+	step = gpm_brightness_get_step ((max-min)+1);
+	if (cur < step) {
+		g_debug ("truncating to %u", min);
+		cur = min;
+	} else {
+		cur -= step;
+	}
+	ret = gpm_brightness_output_set_internal (brightness, output, cur);
+	return ret;
+}
+
+/**
+ * gpm_brightness_output_up:
+ **/
+static gboolean
+gpm_brightness_output_up (GpmBrightness *brightness, RROutput output)
+{
+	guint cur;
+	gboolean ret;
+	guint min, max;
+
+	g_return_val_if_fail (GPM_IS_BRIGHTNESS (brightness), FALSE);
+
+	ret = gpm_brightness_output_get_internal (brightness, output, &cur);
+	if (!ret)
+		return FALSE;
+	ret = gpm_brightness_output_get_limits (brightness, output, &min, &max);
+	if (!ret || min == max)
+		return FALSE;
+	g_debug ("hard value=%u, min=%u, max=%u", cur, min, max);
+	if (cur == max) {
+		g_debug ("already max");
+		return TRUE;
+	}
+	cur += gpm_brightness_get_step ((max-min)+1);
+	if (cur > max) {
+		g_debug ("truncating to %u", max);
+		cur = max;
+	}
+	ret = gpm_brightness_output_set_internal (brightness, output, cur);
+	return ret;
+}
+
+/**
+ * gpm_brightness_output_set:
+ **/
+static gboolean
+gpm_brightness_output_set (GpmBrightness *brightness, RROutput output)
+{
+	guint cur;
+	gboolean ret;
+	guint min, max;
+	gint i;
+	gint shared_value_abs;
+	guint step;
+
+	g_return_val_if_fail (GPM_IS_BRIGHTNESS (brightness), FALSE);
+
+	ret = gpm_brightness_output_get_internal (brightness, output, &cur);
+	if (!ret)
+		return FALSE;
+	ret = gpm_brightness_output_get_limits (brightness, output, &min, &max);
+	if (!ret || min == max)
+		return FALSE;
+
+	shared_value_abs = egg_discrete_from_percent (brightness->priv->shared_value, (max-min)+1);
+	g_debug ("percent=%u, absolute=%i", brightness->priv->shared_value, shared_value_abs);
+
+	g_debug ("hard value=%u, min=%u, max=%u", cur, min, max);
+	if (shared_value_abs > (gint) max)
+		shared_value_abs = max;
+	if (shared_value_abs < (gint) min)
+		shared_value_abs = min;
+	if ((gint) cur == shared_value_abs) {
+		g_debug ("already set %u", cur);
+		return TRUE;
+	}
+
+	/* step the correct way */
+	if ((gint) cur < shared_value_abs) {
+
+		/* some adaptors have a large number of steps */
+		step = gpm_brightness_get_step (shared_value_abs - cur);
+		g_debug ("using step of %u", step);
+
+		/* going up */
+		for (i=cur; i<=shared_value_abs; i+=step) {
+			ret = gpm_brightness_output_set_internal (brightness, output, i);
+			if (!ret)
+				break;
+			if ((gint) cur != shared_value_abs)
+				g_usleep (1000 * GPM_BRIGHTNESS_DIM_INTERVAL);
+		}
+	} else {
+
+		/* some adaptors have a large number of steps */
+		step = gpm_brightness_get_step (cur - shared_value_abs);
+		g_debug ("using step of %u", step);
+
+		/* going down */
+		for (i=cur; i>=shared_value_abs; i-=step) {
+			ret = gpm_brightness_output_set_internal (brightness, output, i);
+			if (!ret)
+				break;
+			if ((gint) cur != shared_value_abs)
+				g_usleep (1000 * GPM_BRIGHTNESS_DIM_INTERVAL);
+		}
+	}
+	return TRUE;
+}
+
+/**
+ * gpm_brightness_foreach_resource:
+ **/
+static gboolean
+gpm_brightness_foreach_resource (GpmBrightness *brightness, GpmXRandROp op, XRRScreenResources *resources)
+{
+	gint i;
+	gboolean ret;
+	gboolean success_any = FALSE;
+	RROutput output;
+
+	g_return_val_if_fail (GPM_IS_BRIGHTNESS (brightness), FALSE);
+
+	/* do for each output */
+	for (i=0; i<resources->noutput; i++) {
+		output = resources->outputs[i];
+		g_debug ("resource %i of %i", i+1, resources->noutput);
+		if (op==ACTION_BACKLIGHT_GET) {
+			ret = gpm_brightness_output_get_percentage (brightness, output);
+		} else if (op==ACTION_BACKLIGHT_INC) {
+			ret = gpm_brightness_output_up (brightness, output);
+		} else if (op==ACTION_BACKLIGHT_DEC) {
+			ret = gpm_brightness_output_down (brightness, output);
+		} else if (op==ACTION_BACKLIGHT_SET) {
+			ret = gpm_brightness_output_set (brightness, output);
+		} else {
+			ret = FALSE;
+			g_warning ("op not known");
+		}
+		if (ret) {
+			success_any = TRUE;
+		}
+	}
+	return success_any;
+}
+
+/**
+ * gpm_brightness_foreach_screen:
+ **/
+static gboolean
+gpm_brightness_foreach_screen (GpmBrightness *brightness, GpmXRandROp op)
+{
+	guint i;
+	guint length;
+	XRRScreenResources *resource;
+	gboolean ret;
+	gboolean success_any = FALSE;
+
+	g_return_val_if_fail (GPM_IS_BRIGHTNESS (brightness), FALSE);
+
+	/* Return immediately if we can't use XRandR */
+	if (!brightness->priv->has_extension)
+		return FALSE;
+
+	/* do for each screen */
+	length = brightness->priv->resources->len;
+	for (i=0; i<length; i++) {
+		resource = (XRRScreenResources *) g_ptr_array_index (brightness->priv->resources, i);
+		g_debug ("using resource %p", resource);
+		ret = gpm_brightness_foreach_resource (brightness, op, resource);
+		if (ret)
+			success_any = TRUE;
+	}
+	XSync (brightness->priv->dpy, False);
+	return success_any;
+}
+
+/**
+ * gpm_brightness_trust_cache:
+ * @brightness: This brightness class instance
+ * Return value: if we can trust the cache
+ **/
+static gboolean
+gpm_brightness_trust_cache (GpmBrightness *brightness)
+{
+	g_return_val_if_fail (GPM_IS_BRIGHTNESS (brightness), FALSE);
+	/* only return the cached value if the cache is trusted and we have change events */
+	if (brightness->priv->cache_trusted && brightness->priv->has_changed_events) {
+		g_debug ("using cache for value %u (okay)", brightness->priv->cache_percentage);
+		return TRUE;
+	}
+
+	/* can we trust that if we set a value 5 minutes ago, will it still be valid now?
+	 * if we have multiple things setting policy on the workstation, e.g. fast user switching
+	 * or kpowersave, then this will be invalid -- this logic may be insane */
+	if (GPM_SOLE_SETTER_USE_CACHE && brightness->priv->cache_trusted) {
+		g_debug ("using cache for value %u (probably okay)", brightness->priv->cache_percentage);
+		return TRUE;
+	}
+	return FALSE;
+}
+
+/**
+ * gpm_brightness_set:
+ * @brightness: This brightness class instance
+ * @percentage: The percentage brightness
+ * @hw_changed: If the hardware was changed, i.e. the brightness changed
+ * Return value: %TRUE if success, %FALSE if there was an error
+ **/
+gboolean
+gpm_brightness_set (GpmBrightness *brightness, guint percentage, gboolean *hw_changed)
+{
+	gboolean ret = FALSE;
+	gboolean trust_cache;
+
+	g_return_val_if_fail (GPM_IS_BRIGHTNESS (brightness), FALSE);
+
+	/* can we check the new value with the cache? */
+	trust_cache = gpm_brightness_trust_cache (brightness);
+	if (trust_cache && percentage == brightness->priv->cache_percentage) {
+		g_debug ("not setting the same value %u", percentage);
+		return TRUE;
+	}
+
+	/* set the value we want */
+	brightness->priv->shared_value = percentage;
+
+	/* reset to not-changed */
+	brightness->priv->hw_changed = FALSE;
+	ret = gpm_brightness_foreach_screen (brightness, ACTION_BACKLIGHT_SET);
+
+	/* legacy fallback */
+	if (!ret) {
+		if (brightness->priv->extension_levels < 0)
+			brightness->priv->extension_levels = gpm_brightness_helper_get_value ("get-max-brightness");
+		brightness->priv->extension_current = egg_discrete_from_percent (percentage, brightness->priv->extension_levels+1);
+		ret = gpm_brightness_helper_set_value ("set-brightness", brightness->priv->extension_current);
+	}
+
+	/* did the hardware have to be modified? */
+	if (ret && hw_changed != NULL)
+		*hw_changed = brightness->priv->hw_changed;
+
+	/* we did something to the hardware, so untrusted */
+	if (ret)
+		brightness->priv->cache_trusted = FALSE;
+
+	return ret;
+}
+
+/**
+ * gpm_brightness_get:
+ * @brightness: This brightness class instance
+ * Return value: The percentage brightness, or -1 for no hardware or error
+ *
+ * Gets the current (or at least what this class thinks is current) percentage
+ * brightness. This is quick as no HAL inquiry is done.
+ **/
+gboolean
+gpm_brightness_get (GpmBrightness *brightness, guint *percentage)
+{
+	gboolean ret = FALSE;
+	gboolean trust_cache;
+	guint percentage_local;
+
+	g_return_val_if_fail (GPM_IS_BRIGHTNESS (brightness), FALSE);
+	g_return_val_if_fail (percentage != NULL, FALSE);
+
+	/* can we use the cache? */
+	trust_cache = gpm_brightness_trust_cache (brightness);
+	if (trust_cache) {
+		*percentage = brightness->priv->cache_percentage;
+		return TRUE;
+	}
+
+	/* get the brightness from hardware -- slow */
+	ret = gpm_brightness_foreach_screen (brightness, ACTION_BACKLIGHT_GET);
+	percentage_local = brightness->priv->shared_value;
+
+	/* legacy fallback */
+	if (!ret) {
+		if (brightness->priv->extension_levels < 0)
+			brightness->priv->extension_levels = gpm_brightness_helper_get_value ("get-max-brightness");
+		brightness->priv->extension_current = gpm_brightness_helper_get_value ("get-brightness");
+		percentage_local = egg_discrete_to_percent (brightness->priv->extension_current, brightness->priv->extension_levels+1);
+		ret = TRUE;
+	}
+
+	/* valid? */
+	if (percentage_local > 100) {
+		g_warning ("percentage value of %u will be truncated", percentage_local);
+		percentage_local = 100;
+	}
+
+	/* a new value is always trusted if the method and checks succeed */
+	if (ret) {
+		brightness->priv->cache_percentage = percentage_local;
+		brightness->priv->cache_trusted = TRUE;
+		*percentage = percentage_local;
+	} else {
+		brightness->priv->cache_trusted = FALSE;
+	}
+	return ret;
+}
+
+/**
+ * gpm_brightness_up:
+ * @brightness: This brightness class instance
+ * @hw_changed: If the hardware was changed, i.e. the brightness changed
+ * Return value: %TRUE if success, %FALSE if there was an error
+ *
+ * If possible, put the brightness of the LCD up one unit.
+ **/
+gboolean
+gpm_brightness_up (GpmBrightness *brightness, gboolean *hw_changed)
+{
+	gboolean ret = FALSE;
+	guint step;
+
+	g_return_val_if_fail (GPM_IS_BRIGHTNESS (brightness), FALSE);
+
+	/* reset to not-changed */
+	brightness->priv->hw_changed = FALSE;
+	ret = gpm_brightness_foreach_screen (brightness, ACTION_BACKLIGHT_INC);
+
+	/* did the hardware have to be modified? */
+	if (ret && hw_changed != NULL)
+		*hw_changed = brightness->priv->hw_changed;
+
+	/* we did something to the hardware, so untrusted */
+	if (ret)
+		brightness->priv->cache_trusted = FALSE;
+
+	/* legacy fallback */
+	if (!ret) {
+		if (brightness->priv->extension_levels < 0)
+			brightness->priv->extension_levels = gpm_brightness_helper_get_value ("get-max-brightness");
+		brightness->priv->extension_current = gpm_brightness_helper_get_value ("get-brightness");
+
+		/* increase by the step, limiting to the maximum possible levels */
+		if (brightness->priv->extension_current < brightness->priv->extension_levels) {
+			step = gpm_brightness_get_step (brightness->priv->extension_levels);
+			brightness->priv->extension_current += step;
+			if (brightness->priv->extension_current > brightness->priv->extension_levels)
+				brightness->priv->extension_current = brightness->priv->extension_levels;
+			ret = gpm_brightness_helper_set_value ("set-brightness", brightness->priv->extension_current);
+		}
+		if (hw_changed != NULL)
+			*hw_changed = ret;
+		brightness->priv->cache_trusted = FALSE;
+		goto out;
+	}
+out:
+	return ret;
+}
+
+/**
+ * gpm_brightness_down:
+ * @brightness: This brightness class instance
+ * @hw_changed: If the hardware was changed, i.e. the brightness changed
+ * Return value: %TRUE if success, %FALSE if there was an error
+ *
+ * If possible, put the brightness of the LCD down one unit.
+ **/
+gboolean
+gpm_brightness_down (GpmBrightness *brightness, gboolean *hw_changed)
+{
+	gboolean ret = FALSE;
+	guint step;
+
+	g_return_val_if_fail (GPM_IS_BRIGHTNESS (brightness), FALSE);
+
+	/* reset to not-changed */
+	brightness->priv->hw_changed = FALSE;
+	ret = gpm_brightness_foreach_screen (brightness, ACTION_BACKLIGHT_DEC);
+
+	/* did the hardware have to be modified? */
+	if (ret && hw_changed != NULL)
+		*hw_changed = brightness->priv->hw_changed;
+
+	/* we did something to the hardware, so untrusted */
+	if (ret)
+		brightness->priv->cache_trusted = FALSE;
+
+	/* legacy fallback */
+	if (!ret) {
+		if (brightness->priv->extension_levels < 0)
+			brightness->priv->extension_levels = gpm_brightness_helper_get_value ("get-max-brightness");
+		brightness->priv->extension_current = gpm_brightness_helper_get_value ("get-brightness");
+
+		/* decrease by the step, limiting to zero */
+		if (brightness->priv->extension_current > 0) {
+			step = gpm_brightness_get_step (brightness->priv->extension_levels);
+			brightness->priv->extension_current -= step;
+			if (brightness->priv->extension_current < 0)
+				brightness->priv->extension_current = 0;
+			ret = gpm_brightness_helper_set_value ("set-brightness", brightness->priv->extension_current);
+		}
+		if (hw_changed != NULL)
+			*hw_changed = ret;
+		brightness->priv->cache_trusted = FALSE;
+		goto out;
+	}
+out:
+	return ret;
+}
+
+/**
+ * gpm_brightness_may_have_changed:
+ **/
+static void
+gpm_brightness_may_have_changed (GpmBrightness *brightness)
+{
+	gboolean ret;
+	guint percentage;
+	ret = gpm_brightness_get (brightness, &percentage);
+	if (!ret) {
+		g_warning ("failed to get output");
+		return;
+	}
+	g_debug ("emitting brightness-changed (%u)", percentage);
+	g_signal_emit (brightness, signals [BRIGHTNESS_CHANGED], 0, percentage);
+}
+
+/**
+ * gpm_brightness_filter_xevents:
+ **/
+static GdkFilterReturn
+gpm_brightness_filter_xevents (GdkXEvent *xevent, GdkEvent *event, gpointer data)
+{
+	GpmBrightness *brightness = GPM_BRIGHTNESS (data);
+	if (event->type == GDK_NOTHING)
+		return GDK_FILTER_CONTINUE;
+	gpm_brightness_may_have_changed (brightness);
+	return GDK_FILTER_CONTINUE;
+}
+
+static void gpm_brightness_update_cache (GpmBrightness *brightness);
+
+/**
+ * gpm_brightness_monitors_changed:
+ **/
+static void
+gpm_brightness_monitors_changed (GdkScreen *screen, GpmBrightness *brightness)
+{
+	g_return_if_fail (GPM_IS_BRIGHTNESS (brightness));
+	gpm_brightness_update_cache (brightness);
+}
+
+/**
+ * gpm_brightness_update_cache:
+ **/
+static void
+gpm_brightness_update_cache (GpmBrightness *brightness)
+{
+	guint length;
+	Window root;
+	GdkScreen *gscreen;
+	GdkDisplay *display;
+	XRRScreenResources *resource;
+
+	g_return_if_fail (GPM_IS_BRIGHTNESS (brightness));
+
+	/* invalidate and remove all the previous entries */
+	length = brightness->priv->resources->len;
+	if (length > 0)
+		g_ptr_array_set_size (brightness->priv->resources, 0);
+
+	display = gdk_display_get_default ();
+	gscreen = gdk_display_get_default_screen (display);
+
+	/* if we have not setup the changed on the monitor, set it here */
+	if (g_object_get_data (G_OBJECT (gscreen), "gpk-set-monitors-changed") == NULL) {
+		g_debug ("watching ::monitors_changed on %p", gscreen);
+		g_object_set_data (G_OBJECT (gscreen), "gpk-set-monitors-changed", (gpointer) "true");
+		g_signal_connect (G_OBJECT (gscreen), "monitors_changed",
+				  G_CALLBACK (gpm_brightness_monitors_changed), brightness);
+	}
+
+	root = RootWindow (brightness->priv->dpy, 0);
+
+	gdk_x11_display_error_trap_push (display);
+	resource = XRRGetScreenResourcesCurrent (brightness->priv->dpy, root);
+	if (gdk_x11_display_error_trap_pop (display) || resource == NULL) {
+		g_warning ("failed to XRRGetScreenResourcesCurrent");
+	}
+
+	if (resource != NULL) {
+		g_debug ("adding resource %p", resource);
+		g_ptr_array_add (brightness->priv->resources, resource);
+	}
+}
+
+/**
+ * gpm_brightness_has_hw:
+ **/
+gboolean
+gpm_brightness_has_hw (GpmBrightness *brightness)
+{
+	g_return_val_if_fail (GPM_IS_BRIGHTNESS (brightness), FALSE);
+
+	/* use XRandR first */
+	if (brightness->priv->has_extension)
+		return TRUE;
+
+	/* fallback to legacy access */
+	if (brightness->priv->extension_levels < 0)
+		brightness->priv->extension_levels = gpm_brightness_helper_get_value ("get-max-brightness");
+	if (brightness->priv->extension_levels > 0)
+		return TRUE;
+	return FALSE;
+}
+
+/**
+ * gpm_brightness_finalize:
+ **/
+static void
+gpm_brightness_finalize (GObject *object)
+{
+	GpmBrightness *brightness;
+	g_return_if_fail (object != NULL);
+	g_return_if_fail (GPM_IS_BRIGHTNESS (object));
+	brightness = GPM_BRIGHTNESS (object);
+	g_ptr_array_unref (brightness->priv->resources);
+	gdk_window_remove_filter (brightness->priv->root_window,
+				  gpm_brightness_filter_xevents, brightness);
+	G_OBJECT_CLASS (gpm_brightness_parent_class)->finalize (object);
+}
+
+/**
+ * gpm_brightness_class_init:
+ **/
+static void
+gpm_brightness_class_init (GpmBrightnessClass *klass)
+{
+	GObjectClass *object_class = G_OBJECT_CLASS (klass);
+	object_class->finalize = gpm_brightness_finalize;
+
+	signals [BRIGHTNESS_CHANGED] =
+		g_signal_new ("brightness-changed",
+			      G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
+			      G_STRUCT_OFFSET (GpmBrightnessClass, brightness_changed),
+			      NULL, NULL, g_cclosure_marshal_VOID__UINT,
+			      G_TYPE_NONE, 1, G_TYPE_UINT);
+}
+
+/**
+ * gpm_brightness_init:
+ * @brightness: This brightness class instance
+ **/
+static void
+gpm_brightness_init (GpmBrightness *brightness)
+{
+	GdkScreen *screen;
+	GdkDisplay *display;
+	int event_base;
+	int ignore;
+
+	brightness->priv = gpm_brightness_get_instance_private (brightness);
+
+	brightness->priv->cache_trusted = FALSE;
+	brightness->priv->has_changed_events = FALSE;
+	brightness->priv->cache_percentage = 0;
+	brightness->priv->hw_changed = FALSE;
+	brightness->priv->extension_levels = -1;
+	brightness->priv->resources = g_ptr_array_new_with_free_func ((GDestroyNotify) XRRFreeScreenResources);
+
+	/* can we do this */
+	brightness->priv->has_extension = gpm_brightness_setup_display (brightness);
+	if (brightness->priv->has_extension == FALSE)
+		g_debug ("no XRANDR extension");
+
+	screen = gdk_screen_get_default ();
+	brightness->priv->root_window = gdk_screen_get_root_window (screen);
+	display = gdk_display_get_default ();
+
+	/* as we a filtering by a window, we have to add an event type */
+	if (!XRRQueryExtension (GDK_DISPLAY_XDISPLAY (gdk_display_get_default()), &event_base, &ignore)) {
+		g_warning ("can't get event_base for XRR");
+	}
+	gdk_x11_register_standard_event_type (display, event_base, RRNotify + 1);
+	gdk_window_add_filter (brightness->priv->root_window,
+			       gpm_brightness_filter_xevents, brightness);
+
+	/* don't abort on error */
+	gdk_x11_display_error_trap_push (display);
+	XRRSelectInput (GDK_DISPLAY_XDISPLAY (gdk_display_get_default()),
+			GDK_WINDOW_XID (brightness->priv->root_window),
+			RRScreenChangeNotifyMask |
+			RROutputPropertyNotifyMask); /* <--- the only one we need, but see rh:345551 */
+	gdk_display_flush (display);
+	if (gdk_x11_display_error_trap_pop (display))
+		g_warning ("failed to select XRRSelectInput");
+
+	/* create cache of XRRScreenResources as XRRGetScreenResources() is slow */
+	gpm_brightness_update_cache (brightness);
+}
+
+/**
+ * gpm_brightness_new:
+ * Return value: A new brightness class instance.
+ * Can return NULL if no suitable hardware is found.
+ **/
+GpmBrightness *
+gpm_brightness_new (void)
+{
+	if (gpm_brightness_object != NULL) {
+		g_object_ref (gpm_brightness_object);
+	} else {
+		gpm_brightness_object = g_object_new (GPM_TYPE_BRIGHTNESS, NULL);
+		g_object_add_weak_pointer (gpm_brightness_object, &gpm_brightness_object);
+	}
+	return GPM_BRIGHTNESS (gpm_brightness_object);
+}
+
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/71.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/71.html new file mode 100644 index 0000000..1b9634e --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/71.html @@ -0,0 +1,1087 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2006-2007 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "config.h"<--- Include file: "config.h" not found.
+
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <X11/X.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdk/gdkx.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <X11/XF86keysym.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <libupower-glib/upower.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "gpm-common.h"
+#include "gpm-button.h"
+
+static void     gpm_button_finalize   (GObject	      *object);
+
+struct GpmButtonPrivate
+{
+	GdkScreen		*screen;
+	GdkWindow		*window;
+	GHashTable		*keysym_to_name_hash;
+	gchar			*last_button;
+	GTimer			*timer;
+	gboolean		 lid_is_closed;
+	UpClient		*client;
+};
+
+enum {
+	BUTTON_PRESSED,
+	LAST_SIGNAL
+};
+
+static guint signals [LAST_SIGNAL] = { 0 };
+static gpointer gpm_button_object = NULL;
+
+G_DEFINE_TYPE_WITH_PRIVATE (GpmButton, gpm_button, G_TYPE_OBJECT)<--- There is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
+
+#define GPM_BUTTON_DUPLICATE_TIMEOUT	0.125f
+
+/**
+ * gpm_button_emit_type:
+ **/
+static gboolean
+gpm_button_emit_type (GpmButton *button, const gchar *type)
+{
+	g_return_val_if_fail (GPM_IS_BUTTON (button), FALSE);
+
+	/* did we just have this button before the timeout? */
+	if (g_strcmp0 (type, button->priv->last_button) == 0 &&
+	    g_timer_elapsed (button->priv->timer, NULL) < GPM_BUTTON_DUPLICATE_TIMEOUT) {
+		g_debug ("ignoring duplicate button %s", type);
+		return FALSE;
+	}
+
+	g_debug ("emitting button-pressed : %s", type);
+	g_signal_emit (button, signals [BUTTON_PRESSED], 0, type);
+
+	/* save type and last size */
+	g_free (button->priv->last_button);
+	button->priv->last_button = g_strdup (type);
+	g_timer_reset (button->priv->timer);
+
+	return TRUE;
+}
+
+/**
+ * gpm_button_filter_x_events:
+ **/
+static GdkFilterReturn
+gpm_button_filter_x_events (GdkXEvent *xevent, GdkEvent *event, gpointer data)
+{
+	GpmButton *button = (GpmButton *) data;
+	XEvent *xev = (XEvent *) xevent;
+	guint keycode;
+	const gchar *key;
+	gchar *keycode_str;
+
+	if (xev->type != KeyPress)
+		return GDK_FILTER_CONTINUE;
+
+	keycode = xev->xkey.keycode;
+
+	/* is the key string already in our DB? */
+	keycode_str = g_strdup_printf ("0x%x", keycode);
+	key = g_hash_table_lookup (button->priv->keysym_to_name_hash, (gpointer) keycode_str);
+	g_free (keycode_str);
+
+	/* found anything? */
+	if (key == NULL) {
+		g_debug ("Key %u not found in hash", keycode);
+		/* pass normal keypresses on, which might help with accessibility access */
+		return GDK_FILTER_CONTINUE;
+	}
+
+	g_debug ("Key %u mapped to key %s", keycode, key);
+	gpm_button_emit_type (button, key);
+
+	return GDK_FILTER_REMOVE;
+}
+
+/**
+ * gpm_button_grab_keystring:
+ * @button: This button class instance
+ * @keystr: The key string, e.g. "<Control><Alt>F11"
+ * @hashkey: A unique key made up from the modmask and keycode suitable for
+ *           referencing in a hashtable.
+ *           You must free this string, or specify NULL to ignore.
+ *
+ * Grab the key specified in the key string.
+ *
+ * Return value: TRUE if we parsed and grabbed okay
+ **/
+static gboolean
+gpm_button_grab_keystring (GpmButton *button, guint64 keycode)
+{
+	guint modmask = AnyModifier;
+	Display *display;
+	GdkDisplay *gdkdisplay;
+	gint ret;
+
+	/* get the current X Display */
+	display = GDK_DISPLAY_XDISPLAY (gdk_display_get_default());
+
+	/* don't abort on error */
+	gdkdisplay = gdk_display_get_default ();
+	gdk_x11_display_error_trap_push (gdkdisplay);
+
+	/* grab the key if possible */
+	ret = XGrabKey (display, keycode, modmask,
+			GDK_WINDOW_XID (button->priv->window), True,
+			GrabModeAsync, GrabModeAsync);
+	if (ret == BadAccess) {
+		g_warning ("Failed to grab modmask=%u, keycode=%li",
+			     modmask, (long int) keycode);
+		return FALSE;
+	}
+
+	/* grab the lock key if possible */
+	ret = XGrabKey (display, keycode, LockMask | modmask,
+			GDK_WINDOW_XID (button->priv->window), True,
+			GrabModeAsync, GrabModeAsync);
+	if (ret == BadAccess) {
+		g_warning ("Failed to grab modmask=%u, keycode=%li",
+			     LockMask | modmask, (long int) keycode);
+		return FALSE;
+	}
+
+	/* we are not processing the error */
+	gdk_display_flush (gdkdisplay);
+	gdk_x11_display_error_trap_pop_ignored (gdkdisplay);
+
+	g_debug ("Grabbed modmask=%x, keycode=%li", modmask, (long int) keycode);
+	return TRUE;
+}
+
+/**
+ * gpm_button_grab_keystring:
+ * @button: This button class instance
+ * @keystr: The key string, e.g. "<Control><Alt>F11"
+ * @hashkey: A unique key made up from the modmask and keycode suitable for
+ *           referencing in a hashtable.
+ *           You must free this string, or specify NULL to ignore.
+ *
+ * Grab the key specified in the key string.
+ *
+ * Return value: TRUE if we parsed and grabbed okay
+ **/
+static gboolean
+gpm_button_xevent_key (GpmButton *button, guint keysym, const gchar *key_name)
+{
+	gchar *key = NULL;
+	gboolean ret;
+	gchar *keycode_str;
+	guint keycode;
+
+	/* convert from keysym to keycode */
+	keycode = XKeysymToKeycode (GDK_DISPLAY_XDISPLAY (gdk_display_get_default()), keysym);
+	if (keycode == 0) {
+		g_warning ("could not map keysym %x to keycode", keysym);
+		return FALSE;
+	}
+
+	/* is the key string already in our DB? */
+	keycode_str = g_strdup_printf ("0x%x", keycode);
+	key = g_hash_table_lookup (button->priv->keysym_to_name_hash, (gpointer) keycode_str);
+	if (key != NULL) {
+		g_warning ("found in hash %u", keycode);
+		g_free (keycode_str);
+		return FALSE;
+	}
+
+	/* try to register X event */
+	ret = gpm_button_grab_keystring (button, keycode);
+	if (!ret) {
+		g_warning ("Failed to grab %u", keycode);
+		g_free (keycode_str);
+		return FALSE;
+	}
+
+	/* add to hash table */
+	g_hash_table_insert (button->priv->keysym_to_name_hash, (gpointer) keycode_str, (gpointer) g_strdup (key_name));
+
+	/* the key is freed in the hash function unref */
+	return TRUE;
+}
+
+/**
+ * gpm_button_class_init:
+ * @button: This class instance
+ **/
+static void
+gpm_button_class_init (GpmButtonClass *klass)
+{
+	GObjectClass *object_class = G_OBJECT_CLASS (klass);
+	object_class->finalize = gpm_button_finalize;
+
+	signals [BUTTON_PRESSED] =
+		g_signal_new ("button-pressed",
+			      G_TYPE_FROM_CLASS (object_class),
+			      G_SIGNAL_RUN_LAST,
+			      G_STRUCT_OFFSET (GpmButtonClass, button_pressed),
+			      NULL, NULL,
+			      g_cclosure_marshal_VOID__STRING,
+			      G_TYPE_NONE, 1, G_TYPE_STRING);
+}
+
+/**
+ * gpm_button_is_lid_closed:
+ **/
+gboolean
+gpm_button_is_lid_closed (GpmButton *button)
+{
+	GDBusProxy *proxy;
+	GVariant *res, *inner;
+	gboolean lid;
+	GError *error = NULL;
+
+	g_return_val_if_fail (GPM_IS_BUTTON (button), FALSE);
+
+	if (LOGIND_RUNNING()) {
+		proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
+						       G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
+						       NULL,
+						       "org.freedesktop.UPower",
+						       "/org/freedesktop/UPower",
+						       "org.freedesktop.DBus.Properties",
+						       NULL,
+						       &error );
+		if (proxy == NULL) {
+			g_error("Error connecting to dbus - %s", error->message);
+			g_error_free (error);
+			return -1;
+		}
+
+		res = g_dbus_proxy_call_sync (proxy, "Get",
+					      g_variant_new( "(ss)",
+							     "org.freedesktop.UPower",
+							     "LidIsClosed"),
+					      G_DBUS_CALL_FLAGS_NONE,
+					      -1,
+					      NULL,
+					      &error
+					      );
+		if (error == NULL && res != NULL) {
+			g_variant_get(res, "(v)", &inner );
+			lid = g_variant_get_boolean(inner);
+			g_variant_unref (inner);
+			g_variant_unref (res);
+			return lid;
+		} else if (error != NULL ) {
+			g_error ("Error in dbus - %s", error->message);
+			g_error_free (error);
+		}
+		g_object_unref(proxy);
+
+		return FALSE;
+	}
+	else {
+		return up_client_get_lid_is_closed (button->priv->client);
+	}
+}
+
+/**
+ * gpm_button_reset_time:
+ *
+ * We have to refresh the event time on resume to handle duplicate buttons
+ * properly when the time is significant when we suspend.
+ **/
+gboolean
+gpm_button_reset_time (GpmButton *button)
+{
+	g_return_val_if_fail (GPM_IS_BUTTON (button), FALSE);
+	g_timer_reset (button->priv->timer);
+	return TRUE;
+}
+
+/**
+ * gpm_button_client_changed_cb
+ **/
+static void
+gpm_button_client_changed_cb (UpClient *client, GParamSpec *pspec, GpmButton *button)
+{
+	gboolean lid_is_closed;
+
+	/* get new state */
+	lid_is_closed = gpm_button_is_lid_closed(button);
+
+	/* same state */
+	if (button->priv->lid_is_closed == lid_is_closed)
+		return;
+
+	/* save state */
+	button->priv->lid_is_closed = lid_is_closed;
+
+	/* sent correct event */
+	if (lid_is_closed)
+		gpm_button_emit_type (button, GPM_BUTTON_LID_CLOSED);
+	else
+		gpm_button_emit_type (button, GPM_BUTTON_LID_OPEN);
+}
+
+/**
+ * gpm_button_init:
+ * @button: This class instance
+ **/
+static void
+gpm_button_init (GpmButton *button)
+{
+	button->priv = gpm_button_get_instance_private (button);
+
+	button->priv->screen = gdk_screen_get_default ();
+	button->priv->window = gdk_screen_get_root_window (button->priv->screen);
+
+	button->priv->keysym_to_name_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
+	button->priv->last_button = NULL;
+	button->priv->timer = g_timer_new ();
+
+	button->priv->client = up_client_new ();
+	button->priv->lid_is_closed = up_client_get_lid_is_closed (button->priv->client);
+	g_signal_connect (button->priv->client, "notify",
+			  G_CALLBACK (gpm_button_client_changed_cb), button);
+	/* register the brightness keys */
+	gpm_button_xevent_key (button, XF86XK_PowerOff, GPM_BUTTON_POWER);
+
+	/* The kernel messes up suspend/hibernate in some places. One of
+	 * them is the key names. Unfortunately, they refuse to see the
+	 * errors of their way in the name of 'compatibility'. Meh
+	 */
+	gpm_button_xevent_key (button, XF86XK_Suspend, GPM_BUTTON_HIBERNATE);
+	gpm_button_xevent_key (button, XF86XK_Sleep, GPM_BUTTON_SUSPEND); /* should be configurable */
+	gpm_button_xevent_key (button, XF86XK_Hibernate, GPM_BUTTON_HIBERNATE);
+	gpm_button_xevent_key (button, XF86XK_MonBrightnessUp, GPM_BUTTON_BRIGHT_UP);
+	gpm_button_xevent_key (button, XF86XK_MonBrightnessDown, GPM_BUTTON_BRIGHT_DOWN);
+	gpm_button_xevent_key (button, XF86XK_ScreenSaver, GPM_BUTTON_LOCK);
+	gpm_button_xevent_key (button, XF86XK_Battery, GPM_BUTTON_BATTERY);
+	gpm_button_xevent_key (button, XF86XK_KbdBrightnessUp, GPM_BUTTON_KBD_BRIGHT_UP);
+	gpm_button_xevent_key (button, XF86XK_KbdBrightnessDown, GPM_BUTTON_KBD_BRIGHT_DOWN);
+	gpm_button_xevent_key (button, XF86XK_KbdLightOnOff, GPM_BUTTON_KBD_BRIGHT_TOGGLE);
+
+	/* use global filter */
+	gdk_window_add_filter (button->priv->window,
+			       gpm_button_filter_x_events, (gpointer) button);
+}
+
+/**
+ * gpm_button_finalize:
+ * @object: This class instance
+ **/
+static void
+gpm_button_finalize (GObject *object)
+{
+	GpmButton *button;
+	g_return_if_fail (object != NULL);
+	g_return_if_fail (GPM_IS_BUTTON (object));
+
+	button = GPM_BUTTON (object);
+	button->priv = gpm_button_get_instance_private (button);
+
+	g_object_unref (button->priv->client);
+	g_free (button->priv->last_button);
+	g_timer_destroy (button->priv->timer);
+
+	g_hash_table_unref (button->priv->keysym_to_name_hash);
+
+	G_OBJECT_CLASS (gpm_button_parent_class)->finalize (object);
+}
+
+/**
+ * gpm_button_new:
+ * Return value: new class instance.
+ **/
+GpmButton *
+gpm_button_new (void)
+{
+	if (gpm_button_object != NULL) {
+		g_object_ref (gpm_button_object);
+	} else {
+		gpm_button_object = g_object_new (GPM_TYPE_BUTTON, NULL);
+		g_object_add_weak_pointer (gpm_button_object, &gpm_button_object);
+	}
+	return GPM_BUTTON (gpm_button_object);
+}
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/72.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/72.html new file mode 100644 index 0000000..0235a77 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/72.html @@ -0,0 +1,715 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2005-2007 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "config.h"<--- Include file: "config.h" not found.
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdk/gdk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "gpm-common.h"
+
+/**
+ * gpm_get_timestring:
+ * @time_secs: The time value to convert in seconds
+ * @cookie: The cookie we are looking for
+ *
+ * Returns a localised timestring
+ *
+ * Return value: The time string, e.g. "2 hours 3 minutes"
+ **/
+gchar *
+gpm_get_timestring (guint time_secs)
+{
+	char* timestring = NULL;
+	gint  hours;
+	gint  minutes;
+
+	/* Add 0.5 to do rounding */
+	minutes = (int) ( ( time_secs / 60.0 ) + 0.5 );
+
+	if (minutes == 0) {
+		timestring = g_strdup (_("Unknown time"));
+		return timestring;
+	}
+
+	if (minutes < 60) {
+		timestring = g_strdup_printf (ngettext ("%i minute",
+							"%i minutes",
+							minutes), minutes);
+		return timestring;
+	}
+
+	hours = minutes / 60;
+	minutes = minutes % 60;
+
+	if (minutes == 0)
+		timestring = g_strdup_printf (ngettext (
+				"%i hour",
+				"%i hours",
+				hours), hours);
+	else
+		/* TRANSLATOR: "%i %s %i %s" are "%i hours %i minutes"
+		 * Swap order with "%2$s %2$i %1$s %1$i if needed */
+		timestring = g_strdup_printf (_("%i %s %i %s"),
+				hours, ngettext ("hour", "hours", hours),
+				minutes, ngettext ("minute", "minutes", minutes));
+	return timestring;
+}
+
+/**
+ * gpm_discrete_from_percent:
+ * @percentage: The percentage to convert
+ * @levels: The number of discrete levels
+ *
+ * We have to be carefull when converting from %->discrete as precision is very
+ * important if we want the highest value.
+ *
+ * Return value: The discrete value for this percentage.
+ **/
+guint
+gpm_discrete_from_percent (guint percentage, guint levels)
+{
+    /* for levels < 10 min value is 0 */
+    gint factor;
+    factor = levels < 10 ? 0 : 1;
+    /* check we are in range */
+    if (percentage > 100)
+        return levels;
+    if (levels == 0) {
+        g_warning ("levels is 0!");
+        return 0;
+    }
+    return (guint) ((((gfloat) percentage * (gfloat) (levels - factor)) / 100.0f) + 0.5f);
+}
+
+/**
+ * gpm_discrete_to_percent:
+ * @hw: The discrete level
+ * @levels: The number of discrete levels
+ *
+ * We have to be carefull when converting from discrete->%.
+ *
+ * Return value: The percentage for this discrete value.
+ **/
+guint
+gpm_discrete_to_percent (guint discrete, guint levels)
+{
+    /* for levels < 10 min value is 0 */
+    gint factor;
+    factor = levels < 10 ? 0 : 1;
+    /* check we are in range */
+    if (discrete > levels)
+        return 100;
+    if (levels == 0) {
+        g_warning ("levels is 0!");
+        return 0;
+    }
+    return (guint) (((gfloat) discrete * (100.0f / (gfloat) (levels - factor))) + 0.5f);
+}
+
+/**
+ * gpm_help_display:
+ * @link_id: Subsection of mate-power-manager help section
+ **/
+void
+gpm_help_display (const gchar *link_id)
+{
+	GError *error = NULL;
+	gchar *uri;
+
+	if (link_id != NULL)
+		uri = g_strconcat ("help:mate-power-manager/", link_id, NULL);
+	else
+		uri = g_strdup ("help:mate-power-manager");
+
+	gtk_show_uri_on_window (NULL, uri, GDK_CURRENT_TIME, &error);
+
+	if (error != NULL) {
+		GtkWidget *d;
+		d = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+					    GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "%s", error->message);
+		gtk_dialog_run (GTK_DIALOG(d));
+		gtk_widget_destroy (d);
+		g_error_free (error);
+	}
+	g_free (uri);
+}
+
+gboolean
+gpm_notebook_scroll_event_cb (GtkWidget       *widget,
+                              GdkEventScroll  *event)
+{
+        GtkNotebook *notebook = GTK_NOTEBOOK (widget);
+        GtkWidget *child, *event_widget, *action_widget;
+
+        child = gtk_notebook_get_nth_page (notebook, gtk_notebook_get_current_page (notebook));
+        if (child == NULL)
+                return FALSE;
+
+        event_widget = gtk_get_event_widget ((GdkEvent *) event);
+
+        /* Ignore scroll events from the content of the page */
+        if (event_widget == NULL || event_widget == child || gtk_widget_is_ancestor (event_widget, child))
+                return FALSE;
+
+        /* And also from the action widgets */
+        action_widget = gtk_notebook_get_action_widget (notebook, GTK_PACK_START);
+        if (event_widget == action_widget || (action_widget != NULL && gtk_widget_is_ancestor (event_widget, action_widget)))
+                return FALSE;
+
+        action_widget = gtk_notebook_get_action_widget (notebook, GTK_PACK_END);
+        if (event_widget == action_widget || (action_widget != NULL && gtk_widget_is_ancestor (event_widget, action_widget)))
+                return FALSE;
+
+        switch (event->direction) {
+                case GDK_SCROLL_RIGHT:
+                case GDK_SCROLL_DOWN:
+                        gtk_notebook_next_page (notebook);
+                        break;
+                case GDK_SCROLL_LEFT:
+                case GDK_SCROLL_UP:
+                        gtk_notebook_prev_page (notebook);
+                        break;
+                case GDK_SCROLL_SMOOTH:
+                        switch (gtk_notebook_get_tab_pos (notebook)) {
+                                case GTK_POS_LEFT:
+                                case GTK_POS_RIGHT:
+                                        if (event->delta_y > 0)
+                                                gtk_notebook_next_page (notebook);
+                                        else if (event->delta_y < 0)
+                                                gtk_notebook_prev_page (notebook);
+                                        break;
+                                case GTK_POS_TOP:
+                                case GTK_POS_BOTTOM:
+                                        if (event->delta_x > 0)
+                                                gtk_notebook_next_page (notebook);
+                                        else if (event->delta_x < 0)
+                                                gtk_notebook_prev_page (notebook);
+                                        break;
+				default:
+					break;
+                        }
+                        break;
+		default:
+			break;
+        }
+
+        return TRUE;
+}
+
+/***************************************************************************
+ ***                          MAKE CHECK TESTS                           ***
+ ***************************************************************************/
+#ifdef EGG_TEST
+#include "egg-test.h"
+
+void
+gpm_common_test (gpointer data)
+{
+	EggTest *test = (EggTest *) data;
+	if (egg_test_start (test, "GpmCommon") == FALSE)
+		return;
+
+	egg_test_end (test);
+}
+
+#endif
+
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/73.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/73.html new file mode 100644 index 0000000..6e07df8 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/73.html @@ -0,0 +1,1411 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2006-2007 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+
+#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <time.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <errno.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/time.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/types.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/wait.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#ifdef HAVE_UNISTD_H
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif /* HAVE_UNISTD_H */
+
+#include <gio/gio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#ifdef WITH_LIBSECRET
+#include <libsecret/secret.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif /* WITH_LIBSECRET */
+#ifdef WITH_KEYRING
+#include <gnome-keyring.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif /* WITH_KEYRING */
+
+#include "egg-console-kit.h"
+
+#include "gpm-screensaver.h"
+#include "gpm-common.h"
+#include "gpm-control.h"
+#include "gpm-networkmanager.h"
+
+struct GpmControlPrivate
+{
+	GSettings		*settings;
+};
+
+enum {
+	RESUME,
+	SLEEP,
+	LAST_SIGNAL
+};
+
+static guint signals [LAST_SIGNAL] = { 0 };
+static gpointer gpm_control_object = NULL;
+
+G_DEFINE_TYPE_WITH_PRIVATE (GpmControl, gpm_control, G_TYPE_OBJECT)<--- There is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
+
+/**
+ * gpm_control_error_quark:
+ * Return value: Our personal error quark.
+ **/
+GQuark
+gpm_control_error_quark (void)
+{
+	static GQuark quark = 0;
+	if (!quark)
+		quark = g_quark_from_static_string ("gpm_control_error");
+	return quark;
+}
+
+/**
+ * gpm_manager_systemd_shutdown:
+ *
+ * Shutdown the system using systemd-logind.
+ *
+ * Return value: fd, -1 on error
+ **/
+static gboolean
+gpm_control_systemd_shutdown (void) {
+	GError *error = NULL;
+	GDBusProxy *proxy;
+	GVariant *res = NULL;
+
+	g_debug ("Requesting systemd to shutdown");
+	proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
+					       G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
+					       NULL,
+					       "org.freedesktop.login1",
+					       "/org/freedesktop/login1",
+					       "org.freedesktop.login1.Manager",
+					       NULL,
+					       &error );
+	//append all our arguments
+	if (proxy == NULL) {
+		g_warning ("Error connecting to dbus - %s", error->message);
+		g_error_free (error);
+		return FALSE;
+	}
+
+	res = g_dbus_proxy_call_sync (proxy, "PowerOff",
+				      g_variant_new( "(b)", FALSE),
+				      G_DBUS_CALL_FLAGS_NONE,
+				      -1,
+				      NULL,
+				      &error
+				      );
+	if (error != NULL) {
+		g_warning ("Error in dbus - %s", error->message);
+		g_error_free (error);
+		return FALSE;
+	}
+
+	g_variant_unref(res);
+	return TRUE;
+}
+
+/**
+ * gpm_control_shutdown:
+ * @control: This class instance
+ *
+ * Shuts down the computer
+ **/
+gboolean
+gpm_control_shutdown (GpmControl *control, GError **error)
+{
+	gboolean ret;
+	EggConsoleKit *console;
+
+	if (LOGIND_RUNNING()) {
+		ret = gpm_control_systemd_shutdown ();
+	} else {
+		console = egg_console_kit_new ();
+		ret = egg_console_kit_stop (console, error);
+		g_object_unref (console);
+	}
+	return ret;
+}
+
+/**
+ * gpm_control_get_lock_policy:
+ * @control: This class instance
+ * @policy: The policy string.
+ *
+ * This function finds out if we should lock the screen when we do an
+ * action. It is required as we can either use the mate-screensaver policy
+ * or the custom policy. See the yelp file for more information.
+ *
+ * Return value: TRUE if we should lock.
+ **/
+gboolean
+gpm_control_get_lock_policy (GpmControl *control, const gchar *policy)
+{
+	gboolean do_lock;
+	gboolean use_ss_setting;
+	gchar **schemas = NULL;
+	gboolean schema_exists;
+	gint i;
+
+	/* Check if the mate-screensaver schema exists before trying to read
+	   the lock setting to prevent crashing. See GNOME bug #651225. */
+	g_settings_schema_source_list_schemas (g_settings_schema_source_get_default (), TRUE, &schemas, NULL);
+	schema_exists = FALSE;
+	for (i = 0; schemas[i] != NULL; i++) {
+		if (g_strcmp0 (schemas[i], GS_SETTINGS_SCHEMA) == 0) {
+			schema_exists = TRUE;
+			break;
+		}
+	}
+
+	g_strfreev (schemas);
+
+	/* This allows us to over-ride the custom lock settings set
+	   with a system default set in mate-screensaver.
+	   See bug #331164 for all the juicy details. :-) */
+	use_ss_setting = g_settings_get_boolean (control->priv->settings, GPM_SETTINGS_LOCK_USE_SCREENSAVER);
+	if (use_ss_setting && schema_exists) {
+		GSettings *settings_ss;
+		settings_ss = g_settings_new (GS_SETTINGS_SCHEMA);
+		do_lock = g_settings_get_boolean (settings_ss, GS_SETTINGS_PREF_LOCK_ENABLED);
+		g_debug ("Using ScreenSaver settings (%i)", do_lock);
+		g_object_unref (settings_ss);
+	} else {
+		do_lock = g_settings_get_boolean (control->priv->settings, policy);
+		g_debug ("Using custom locking settings (%i)", do_lock);
+	}
+	return do_lock;
+}
+
+/**
+ * gpm_control_suspend:
+ **/
+gboolean
+gpm_control_suspend (GpmControl *control, GError **error)
+{
+	gboolean allowed = FALSE;
+	gboolean ret = FALSE;
+	gboolean do_lock;
+	gboolean nm_sleep;
+	EggConsoleKit *console;
+	GpmScreensaver *screensaver;
+	guint32 throttle_cookie = 0;
+#ifdef WITH_LIBSECRET
+	gboolean lock_libsecret;
+	GCancellable *libsecret_cancellable = NULL;
+	SecretService *secretservice_proxy = NULL;
+	gint num_secrets_locked;
+	GList *libsecret_collections = NULL;
+#endif /* WITH_LIBSECRET */
+#ifdef WITH_KEYRING
+	gboolean lock_gnome_keyring;
+	GnomeKeyringResult keyres;
+#endif /* WITH_KEYRING */
+
+	GError *dbus_error = NULL;
+	GDBusProxy *proxy;
+	GVariant *res = NULL;
+
+	screensaver = gpm_screensaver_new ();
+
+	if (!LOGIND_RUNNING()) {
+		console = egg_console_kit_new ();
+		egg_console_kit_can_suspend (console, &allowed, NULL);
+		g_object_unref (console);
+
+		if (!allowed) {
+			g_debug ("cannot suspend as not allowed from policy");
+			g_set_error_literal (error, GPM_CONTROL_ERROR, GPM_CONTROL_ERROR_GENERAL, "Cannot suspend");
+			goto out;
+		}
+	}
+
+#ifdef WITH_LIBSECRET
+	/* we should perhaps lock keyrings when sleeping #375681 */
+	lock_libsecret = g_settings_get_boolean (control->priv->settings,
+						 GPM_SETTINGS_LOCK_KEYRING_SUSPEND);
+	if (lock_libsecret) {
+		libsecret_cancellable = g_cancellable_new ();
+		secretservice_proxy = secret_service_get_sync (SECRET_SERVICE_LOAD_COLLECTIONS,
+							       libsecret_cancellable,
+							       error);
+		if (secretservice_proxy == NULL) {
+			g_warning ("failed to connect to secret service");
+		} else {
+			libsecret_collections = secret_service_get_collections (secretservice_proxy);
+			if ( libsecret_collections == NULL) {
+				g_warning ("failed to get secret collections");
+			} else {
+				num_secrets_locked = secret_service_lock_sync (secretservice_proxy,
+									       libsecret_collections,
+									       libsecret_cancellable,
+									       NULL,
+									       error);
+				if (num_secrets_locked <= 0)
+					g_warning ("could not lock keyring");
+				g_list_free (libsecret_collections);
+			}
+			g_object_unref (secretservice_proxy);
+		}
+		g_object_unref (libsecret_cancellable);
+	}
+#endif /* WITH_LIBSECRET */
+#ifdef WITH_KEYRING
+	/* we should perhaps lock keyrings when sleeping #375681 */
+	lock_gnome_keyring = g_settings_get_boolean (control->priv->settings, GPM_SETTINGS_LOCK_KEYRING_SUSPEND);
+	if (lock_gnome_keyring) {
+		keyres = gnome_keyring_lock_all_sync ();
+		if (keyres != GNOME_KEYRING_RESULT_OK)
+			g_warning ("could not lock keyring");
+	}
+#endif /* WITH_KEYRING */
+
+	do_lock = gpm_control_get_lock_policy (control, GPM_SETTINGS_LOCK_ON_SUSPEND);
+	if (do_lock) {
+		throttle_cookie = gpm_screensaver_add_throttle (screensaver, "suspend");
+		gpm_screensaver_lock (screensaver);
+	}
+
+	nm_sleep = g_settings_get_boolean (control->priv->settings, GPM_SETTINGS_NETWORKMANAGER_SLEEP);
+	if (nm_sleep)
+		gpm_networkmanager_sleep ();
+
+	/* Do the suspend */
+	g_debug ("emitting sleep");
+	g_signal_emit (control, signals [SLEEP], 0, GPM_CONTROL_ACTION_SUSPEND);
+
+	if (LOGIND_RUNNING()) {
+		/* sleep via logind */
+		proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
+						       G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
+						       NULL,
+						       "org.freedesktop.login1",
+						       "/org/freedesktop/login1",
+						       "org.freedesktop.login1.Manager",
+						       NULL,
+						       &dbus_error );
+		if (proxy == NULL) {
+			g_warning ("Error connecting to dbus - %s", dbus_error->message);
+			g_error_free (dbus_error);
+			ret = FALSE;
+			goto out;
+		}
+		res = g_dbus_proxy_call_sync (proxy, "Suspend",
+					      g_variant_new( "(b)",FALSE),
+					      G_DBUS_CALL_FLAGS_NONE,
+					      -1,
+					      NULL,
+					      &dbus_error
+					      );
+		if (dbus_error != NULL ) {
+			g_warning ("Error in dbus - %s", dbus_error->message);
+			g_error_free (dbus_error);
+			ret = TRUE;
+		}
+		else {
+			g_variant_unref(res);
+			ret = TRUE;
+		}
+		g_object_unref(proxy);
+	}
+	else {
+		console = egg_console_kit_new ();
+		ret = egg_console_kit_suspend (console, error);
+		g_object_unref (console);
+	}
+
+	g_debug ("emitting resume");
+	g_signal_emit (control, signals [RESUME], 0, GPM_CONTROL_ACTION_SUSPEND);
+
+	if (do_lock) {
+		gpm_screensaver_poke (screensaver);
+		if (throttle_cookie)
+			gpm_screensaver_remove_throttle (screensaver, throttle_cookie);
+	}
+
+	nm_sleep = g_settings_get_boolean (control->priv->settings, GPM_SETTINGS_NETWORKMANAGER_SLEEP);
+	if (nm_sleep)
+		gpm_networkmanager_wake ();
+
+out:
+	g_object_unref (screensaver);
+	return ret;
+}
+
+/**
+ * gpm_control_hibernate:
+ **/
+gboolean
+gpm_control_hibernate (GpmControl *control, GError **error)
+{
+	gboolean allowed = FALSE;
+	gboolean ret = FALSE;
+	gboolean do_lock;
+	gboolean nm_sleep;
+	EggConsoleKit *console;
+	GpmScreensaver *screensaver;
+	guint32 throttle_cookie = 0;
+#ifdef WITH_LIBSECRET
+	gboolean lock_libsecret;
+	GCancellable *libsecret_cancellable = NULL;
+	SecretService *secretservice_proxy = NULL;
+	gint num_secrets_locked;
+	GList *libsecret_collections = NULL;
+#endif /* WITH_LIBSECRET */
+#ifdef WITH_KEYRING
+	gboolean lock_gnome_keyring;
+	GnomeKeyringResult keyres;
+#endif /* WITH_KEYRING */
+
+	GError *dbus_error = NULL;
+	GDBusProxy *proxy;
+	GVariant *res = NULL;
+
+	screensaver = gpm_screensaver_new ();
+
+	if (!LOGIND_RUNNING()) {
+		console = egg_console_kit_new ();
+		egg_console_kit_can_hibernate (console, &allowed, NULL);
+		g_object_unref (console);
+
+		if (!allowed) {
+			g_debug ("cannot hibernate as not allowed from policy");
+			g_set_error_literal (error, GPM_CONTROL_ERROR, GPM_CONTROL_ERROR_GENERAL, "Cannot hibernate");
+			goto out;
+		}
+	}
+
+#ifdef WITH_LIBSECRET
+	/* we should perhaps lock keyrings when sleeping #375681 */
+	lock_libsecret = g_settings_get_boolean (control->priv->settings,
+						 GPM_SETTINGS_LOCK_KEYRING_SUSPEND);
+	if (lock_libsecret) {
+		libsecret_cancellable = g_cancellable_new ();
+		secretservice_proxy = secret_service_get_sync (SECRET_SERVICE_LOAD_COLLECTIONS,
+							       libsecret_cancellable,
+							       error);
+		if (secretservice_proxy == NULL) {
+			g_warning ("failed to connect to secret service");
+		} else {
+			libsecret_collections = secret_service_get_collections (secretservice_proxy);
+			if ( libsecret_collections == NULL) {
+				g_warning ("failed to get secret collections");
+			} else {
+				num_secrets_locked = secret_service_lock_sync (secretservice_proxy,
+									       libsecret_collections,
+									       libsecret_cancellable,
+									       NULL,
+									       error);
+				if (num_secrets_locked <= 0)
+					g_warning ("could not lock keyring");
+				g_list_free (libsecret_collections);
+			}
+			g_object_unref (secretservice_proxy);
+		}
+		g_object_unref (libsecret_cancellable);
+	}
+#endif /* WITH_LIBSECRET */
+#ifdef WITH_KEYRING
+	/* we should perhaps lock keyrings when sleeping #375681 */
+	lock_gnome_keyring = g_settings_get_boolean (control->priv->settings, GPM_SETTINGS_LOCK_KEYRING_HIBERNATE);
+	if (lock_gnome_keyring) {
+		keyres = gnome_keyring_lock_all_sync ();
+		if (keyres != GNOME_KEYRING_RESULT_OK) {
+			g_warning ("could not lock keyring");
+		}
+	}
+#endif /* WITH_KEYRING */
+
+	do_lock = gpm_control_get_lock_policy (control, GPM_SETTINGS_LOCK_ON_HIBERNATE);
+	if (do_lock) {
+		throttle_cookie = gpm_screensaver_add_throttle (screensaver, "hibernate");
+		gpm_screensaver_lock (screensaver);
+	}
+
+	nm_sleep = g_settings_get_boolean (control->priv->settings, GPM_SETTINGS_NETWORKMANAGER_SLEEP);
+	if (nm_sleep)
+		gpm_networkmanager_sleep ();
+
+	g_debug ("emitting sleep");
+	g_signal_emit (control, signals [SLEEP], 0, GPM_CONTROL_ACTION_HIBERNATE);
+
+	if (LOGIND_RUNNING()) {
+		/* sleep via logind */
+		proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
+						       G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
+						       NULL,
+						       "org.freedesktop.login1",
+						       "/org/freedesktop/login1",
+						       "org.freedesktop.login1.Manager",
+						       NULL,
+						       &dbus_error );
+		if (proxy == NULL) {
+			g_warning ("Error connecting to dbus - %s", dbus_error->message);
+			g_error_free (dbus_error);
+			ret = FALSE;
+			goto out;
+		}
+		res = g_dbus_proxy_call_sync (proxy, "Hibernate",
+					      g_variant_new( "(b)",FALSE),
+					      G_DBUS_CALL_FLAGS_NONE,
+					      -1,
+					      NULL,
+					      &dbus_error
+					      );
+		if (dbus_error != NULL ) {
+			g_warning ("Error in dbus - %s", dbus_error->message);
+			g_error_free (dbus_error);
+			ret = TRUE;
+		}
+		else {
+			g_variant_unref(res);
+			ret = TRUE;
+		}
+	}
+	else {
+		console = egg_console_kit_new ();
+		ret = egg_console_kit_hibernate (console, error);
+		g_object_unref (console);
+	}
+
+	g_debug ("emitting resume");
+	g_signal_emit (control, signals [RESUME], 0, GPM_CONTROL_ACTION_HIBERNATE);
+
+	if (do_lock) {
+		gpm_screensaver_poke (screensaver);
+		if (throttle_cookie)
+			gpm_screensaver_remove_throttle (screensaver, throttle_cookie);
+	}
+
+	nm_sleep = g_settings_get_boolean (control->priv->settings, GPM_SETTINGS_NETWORKMANAGER_SLEEP);
+	if (nm_sleep)
+		gpm_networkmanager_wake ();
+
+out:
+	g_object_unref (screensaver);
+	return ret;
+}
+
+/**
+ * gpm_control_finalize:
+ **/
+static void
+gpm_control_finalize (GObject *object)
+{
+	GpmControl *control;
+
+	g_return_if_fail (object != NULL);
+	g_return_if_fail (GPM_IS_CONTROL (object));
+	control = GPM_CONTROL (object);
+
+	g_object_unref (control->priv->settings);
+
+	g_return_if_fail (control->priv != NULL);
+	G_OBJECT_CLASS (gpm_control_parent_class)->finalize (object);
+}
+
+/**
+ * gpm_control_class_init:
+ **/
+static void
+gpm_control_class_init (GpmControlClass *klass)
+{
+	GObjectClass *object_class = G_OBJECT_CLASS (klass);
+	object_class->finalize = gpm_control_finalize;
+
+	signals [RESUME] =
+		g_signal_new ("resume",
+			      G_TYPE_FROM_CLASS (object_class),
+			      G_SIGNAL_RUN_LAST,
+			      G_STRUCT_OFFSET (GpmControlClass, resume),
+			      NULL,
+			      NULL,
+			      g_cclosure_marshal_VOID__INT,
+			      G_TYPE_NONE, 1, G_TYPE_INT);
+	signals [SLEEP] =
+		g_signal_new ("sleep",
+			      G_TYPE_FROM_CLASS (object_class),
+			      G_SIGNAL_RUN_LAST,
+			      G_STRUCT_OFFSET (GpmControlClass, sleep),
+			      NULL,
+			      NULL,
+			      g_cclosure_marshal_VOID__INT,
+			      G_TYPE_NONE, 1, G_TYPE_INT);
+}
+
+/**
+ * gpm_control_init:
+ * @control: This control class instance
+ **/
+static void
+gpm_control_init (GpmControl *control)
+{
+	control->priv = gpm_control_get_instance_private (control);
+
+	control->priv->settings = g_settings_new (GPM_SETTINGS_SCHEMA);
+}
+
+/**
+ * gpm_control_new:
+ * Return value: A new control class instance.
+ **/
+GpmControl *
+gpm_control_new (void)
+{
+	if (gpm_control_object != NULL) {
+		g_object_ref (gpm_control_object);
+	} else {
+		gpm_control_object = g_object_new (GPM_TYPE_CONTROL, NULL);
+		g_object_add_weak_pointer (gpm_control_object, &gpm_control_object);
+	}
+	return GPM_CONTROL (gpm_control_object);
+}
+
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/74.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/74.html new file mode 100644 index 0000000..25a1136 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/74.html @@ -0,0 +1,365 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2005-2008 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __GPMSCREENSAVER_H
+#define __GPMSCREENSAVER_H
+
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+G_BEGIN_DECLS
+
+#define GPM_TYPE_SCREENSAVER		(gpm_screensaver_get_type ())
+#define GPM_SCREENSAVER(o)		(G_TYPE_CHECK_INSTANCE_CAST ((o), GPM_TYPE_SCREENSAVER, GpmScreensaver))
+#define GPM_SCREENSAVER_CLASS(k)	(G_TYPE_CHECK_CLASS_CAST((k), GPM_TYPE_SCREENSAVER, GpmScreensaverClass))
+#define GPM_IS_SCREENSAVER(o)		(G_TYPE_CHECK_INSTANCE_TYPE ((o), GPM_TYPE_SCREENSAVER))
+#define GPM_IS_SCREENSAVER_CLASS(k)	(G_TYPE_CHECK_CLASS_TYPE ((k), GPM_TYPE_SCREENSAVER))
+#define GPM_SCREENSAVER_GET_CLASS(o)	(G_TYPE_INSTANCE_GET_CLASS ((o), GPM_TYPE_SCREENSAVER, GpmScreensaverClass))
+
+typedef struct GpmScreensaverPrivate GpmScreensaverPrivate;
+
+typedef struct
+{
+	GObject		       parent;
+	GpmScreensaverPrivate *priv;
+} GpmScreensaver;
+
+typedef struct
+{
+	GObjectClass	parent_class;
+} GpmScreensaverClass;
+
+GType		 gpm_screensaver_get_type		(void);
+GpmScreensaver	*gpm_screensaver_new			(void);
+void		 gpm_screensaver_test			(gpointer	 data);
+
+gboolean	 gpm_screensaver_lock			(GpmScreensaver	*screensaver);
+guint32 	 gpm_screensaver_add_throttle    	(GpmScreensaver	*screensaver,
+							 const gchar	*reason);
+gboolean 	 gpm_screensaver_remove_throttle    	(GpmScreensaver	*screensaver,
+							 guint32         cookie);
+gboolean	 gpm_screensaver_check_running		(GpmScreensaver	*screensaver);
+gboolean	 gpm_screensaver_poke			(GpmScreensaver	*screensaver);
+
+G_END_DECLS
+
+#endif	/* __GPMSCREENSAVER_H */
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/75.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/75.html new file mode 100644 index 0000000..04bf616 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/75.html @@ -0,0 +1,307 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2005-2007 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __GPM_NETWORKMANAGER_H
+#define __GPM_NETWORKMANAGER_H
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+G_BEGIN_DECLS
+
+gboolean	gpm_networkmanager_sleep		(void);
+gboolean	gpm_networkmanager_wake			(void);
+
+G_END_DECLS
+
+#endif	/* __GPM_NETWORKMANAGER_H */
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/76.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/76.html new file mode 100644 index 0000000..cb13547 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/76.html @@ -0,0 +1,1087 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2005 William Jon McCann <mccann@jhu.edu>
+ * Copyright (C) 2006-2009 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "config.h"<--- Include file: "config.h" not found.
+
+#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <time.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <errno.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/time.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/types.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#ifdef HAVE_UNISTD_H
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif /* HAVE_UNISTD_H */
+
+#include <gdk/gdk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdk/gdkx.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <X11/Xproto.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <X11/extensions/dpms.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "gpm-dpms.h"
+
+static void   gpm_dpms_finalize  (GObject   *object);
+
+/* until we get a nice event-emitting DPMS extension, we have to poll... */
+#define GPM_DPMS_POLL_TIME	10
+
+struct GpmDpmsPrivate
+{
+	gboolean		 dpms_capable;
+	GpmDpmsMode		 mode;
+	guint			 timer_id;
+	Display			*display;
+};
+
+enum {
+	MODE_CHANGED,
+	LAST_SIGNAL
+};
+
+static guint signals [LAST_SIGNAL] = { 0 };
+static gpointer gpm_dpms_object = NULL;
+
+G_DEFINE_TYPE_WITH_PRIVATE (GpmDpms, gpm_dpms, G_TYPE_OBJECT)<--- There is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
+
+/**
+ * gpm_dpms_error_quark:
+ **/
+GQuark
+gpm_dpms_error_quark (void)
+{
+	static GQuark quark = 0;
+	if (!quark)
+		quark = g_quark_from_static_string ("gpm_dpms_error");
+	return quark;
+}
+
+/**
+ * gpm_dpms_x11_get_mode:
+ **/
+static gboolean
+gpm_dpms_x11_get_mode (GpmDpms *dpms, GpmDpmsMode *mode, GError **error)
+{
+	GpmDpmsMode result;
+	BOOL enabled = FALSE;
+	CARD16 state;
+
+	if (dpms->priv->dpms_capable == FALSE) {
+		/* Server or monitor can't DPMS -- assume the monitor is on. */
+		result = GPM_DPMS_MODE_ON;
+		goto out;
+	}
+
+	DPMSInfo (dpms->priv->display, &state, &enabled);
+	if (!enabled) {
+		/* Server says DPMS is disabled -- so the monitor is on. */
+		result = GPM_DPMS_MODE_ON;
+		goto out;
+	}
+
+	switch (state) {
+	case DPMSModeOn:
+		result = GPM_DPMS_MODE_ON;
+		break;
+	case DPMSModeStandby:
+		result = GPM_DPMS_MODE_STANDBY;
+		break;
+	case DPMSModeSuspend:
+		result = GPM_DPMS_MODE_SUSPEND;
+		break;
+	case DPMSModeOff:
+		result = GPM_DPMS_MODE_OFF;
+		break;
+	default:
+		result = GPM_DPMS_MODE_ON;
+		break;
+	}
+out:
+	if (mode)
+		*mode = result;
+	return TRUE;
+}
+
+/**
+ * gpm_dpms_x11_set_mode:
+ **/
+static gboolean
+gpm_dpms_x11_set_mode (GpmDpms *dpms, GpmDpmsMode mode, GError **error)
+{
+	GpmDpmsMode current_mode;
+	CARD16 state;
+	CARD16 current_state;
+	BOOL current_enabled;
+
+	if (!dpms->priv->dpms_capable) {
+		g_debug ("not DPMS capable");
+		g_set_error (error, GPM_DPMS_ERROR, GPM_DPMS_ERROR_GENERAL,
+			     "Display is not DPMS capable");
+		return FALSE;
+	}
+
+	if (!DPMSInfo (dpms->priv->display, &current_state, &current_enabled)) {
+		g_debug ("couldn't get DPMS info");
+		g_set_error (error, GPM_DPMS_ERROR, GPM_DPMS_ERROR_GENERAL,
+			     "Unable to get DPMS state");
+		return FALSE;
+	}
+
+	if (!current_enabled) {
+		g_debug ("DPMS not enabled");
+		g_set_error (error, GPM_DPMS_ERROR, GPM_DPMS_ERROR_GENERAL,
+			     "DPMS is not enabled");
+		return FALSE;
+	}
+
+	switch (mode) {
+	case GPM_DPMS_MODE_ON:
+		state = DPMSModeOn;
+		break;
+	case GPM_DPMS_MODE_STANDBY:
+		state = DPMSModeStandby;
+		break;
+	case GPM_DPMS_MODE_SUSPEND:
+		state = DPMSModeSuspend;
+		break;
+	case GPM_DPMS_MODE_OFF:
+		state = DPMSModeOff;
+		break;
+	default:
+		state = DPMSModeOn;
+		break;
+	}
+
+	gpm_dpms_x11_get_mode (dpms, &current_mode, NULL);
+	if (current_mode != mode) {
+		if (! DPMSForceLevel (dpms->priv->display, state)) {
+			g_set_error (error, GPM_DPMS_ERROR, GPM_DPMS_ERROR_GENERAL,
+				     "Could not change DPMS mode");
+			return FALSE;
+		}
+		XSync (dpms->priv->display, FALSE);
+	}
+
+	return TRUE;
+}
+
+/**
+ * gpm_dpms_set_mode:
+ **/
+gboolean
+gpm_dpms_set_mode (GpmDpms *dpms, GpmDpmsMode mode, GError **error)
+{
+	gboolean ret;
+
+	g_return_val_if_fail (GPM_IS_DPMS (dpms), FALSE);
+
+	if (mode == GPM_DPMS_MODE_UNKNOWN) {
+		g_debug ("mode unknown");
+		g_set_error (error, GPM_DPMS_ERROR, GPM_DPMS_ERROR_GENERAL,
+			     "Unknown DPMS mode");
+		return FALSE;
+	}
+
+	ret = gpm_dpms_x11_set_mode (dpms, mode, error);
+	return ret;
+}
+
+/**
+ * gpm_dpms_get_mode:
+ **/
+gboolean
+gpm_dpms_get_mode (GpmDpms *dpms, GpmDpmsMode *mode, GError **error)
+{
+	gboolean ret;
+	if (mode)
+		*mode = GPM_DPMS_MODE_UNKNOWN;
+	ret = gpm_dpms_x11_get_mode (dpms, mode, error);
+	return ret;
+}
+
+/**
+ * gpm_dpms_poll_mode_cb:
+ **/
+static gboolean
+gpm_dpms_poll_mode_cb (GpmDpms *dpms)
+{
+	gboolean ret;
+	GpmDpmsMode mode;
+	GError *error = NULL;
+
+	/* Try again */
+	ret = gpm_dpms_x11_get_mode (dpms, &mode, &error);
+	if (!ret) {
+		g_clear_error (&error);
+		return TRUE;
+	}
+
+	if (mode != dpms->priv->mode) {
+		dpms->priv->mode = mode;
+		g_signal_emit (dpms, signals [MODE_CHANGED], 0, mode);
+	}
+
+	return TRUE;
+}
+
+/**
+ * gpm_dpms_clear_timeouts:
+ **/
+static gboolean
+gpm_dpms_clear_timeouts (GpmDpms *dpms)
+{
+	gboolean ret = FALSE;
+
+	/* never going to work */
+	if (!dpms->priv->dpms_capable) {
+		g_debug ("not DPMS capable");
+		goto out;
+	}
+
+	g_debug ("set timeouts to zero");
+	ret = DPMSSetTimeouts (dpms->priv->display, 0, 0, 0);
+
+out:
+	return ret;
+}
+
+/**
+ * gpm_dpms_class_init:
+ **/
+static void
+gpm_dpms_class_init (GpmDpmsClass *klass)
+{
+	GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+	object_class->finalize = gpm_dpms_finalize;
+
+	signals [MODE_CHANGED] =
+		g_signal_new ("mode-changed",
+			      G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
+			      G_STRUCT_OFFSET (GpmDpmsClass, mode_changed),
+			      NULL, NULL, g_cclosure_marshal_VOID__UINT,
+			      G_TYPE_NONE, 1, G_TYPE_UINT);
+}
+
+/**
+ * gpm_dpms_init:
+ **/
+static void
+gpm_dpms_init (GpmDpms *dpms)
+{
+	dpms->priv = gpm_dpms_get_instance_private (dpms);
+
+	/* DPMSCapable() can never change for a given display */
+	dpms->priv->display = GDK_DISPLAY_XDISPLAY (gdk_display_get_default());
+	dpms->priv->dpms_capable = DPMSCapable (dpms->priv->display);
+	dpms->priv->timer_id = g_timeout_add_seconds (GPM_DPMS_POLL_TIME, (GSourceFunc)gpm_dpms_poll_mode_cb, dpms);
+	g_source_set_name_by_id (dpms->priv->timer_id, "[GpmDpms] poll");
+
+	/* ensure we clear the default timeouts (Standby: 1200s, Suspend: 1800s, Off: 2400s) */
+	gpm_dpms_clear_timeouts (dpms);
+}
+
+/**
+ * gpm_dpms_finalize:
+ **/
+static void
+gpm_dpms_finalize (GObject *object)
+{
+	GpmDpms *dpms;
+
+	g_return_if_fail (object != NULL);
+	g_return_if_fail (GPM_IS_DPMS (object));
+
+	dpms = GPM_DPMS (object);
+
+	g_return_if_fail (dpms->priv != NULL);
+
+	if (dpms->priv->timer_id != 0) {
+		g_source_remove (dpms->priv->timer_id);
+		dpms->priv->timer_id = 0;
+	}
+
+	G_OBJECT_CLASS (gpm_dpms_parent_class)->finalize (object);
+}
+
+/**
+ * gpm_dpms_new:
+ **/
+GpmDpms *
+gpm_dpms_new (void)
+{
+	if (gpm_dpms_object != NULL) {
+		g_object_ref (gpm_dpms_object);
+	} else {
+		gpm_dpms_object = g_object_new (GPM_TYPE_DPMS, NULL);
+		g_object_add_weak_pointer (gpm_dpms_object, &gpm_dpms_object);
+	}
+	return GPM_DPMS (gpm_dpms_object);
+}
+
+/***************************************************************************
+ ***                          MAKE CHECK TESTS                           ***
+ ***************************************************************************/
+#ifdef EGG_TEST
+#include "egg-test.h"
+
+void
+gpm_dpms_test (gpointer data)
+{
+	GpmDpms *dpms;
+	gboolean ret;
+	GError *error = NULL;
+	EggTest *test = (EggTest *) data;
+
+	if (!egg_test_start (test, "GpmDpms"))
+		return;
+
+	/************************************************************/
+	egg_test_title (test, "get object");
+	dpms = gpm_dpms_new ();
+	if (dpms != NULL)
+		egg_test_success (test, NULL);
+	else
+		egg_test_failed (test, "got no object");
+
+	/************************************************************/
+	egg_test_title (test, "set on");
+	ret = gpm_dpms_set_mode (dpms, GPM_DPMS_MODE_ON, &error);
+	if (ret)
+		egg_test_success (test, NULL);
+	else
+		egg_test_failed (test, "failed: %s", error->message);
+
+	g_usleep (2*1000*1000);
+
+	/************************************************************/
+	egg_test_title (test, "set STANDBY");
+	ret = gpm_dpms_set_mode (dpms, GPM_DPMS_MODE_STANDBY, &error);
+	if (ret)
+		egg_test_success (test, NULL);
+	else
+		egg_test_failed (test, "failed: %s", error->message);
+
+	g_usleep (2*1000*1000);
+
+	/************************************************************/
+	egg_test_title (test, "set SUSPEND");
+	ret = gpm_dpms_set_mode (dpms, GPM_DPMS_MODE_SUSPEND, &error);
+	if (ret)
+		egg_test_success (test, NULL);
+	else
+		egg_test_failed (test, "failed: %s", error->message);
+
+	g_usleep (2*1000*1000);
+
+	/************************************************************/
+	egg_test_title (test, "set OFF");
+	ret = gpm_dpms_set_mode (dpms, GPM_DPMS_MODE_OFF, &error);
+	if (ret)
+		egg_test_success (test, NULL);
+	else
+		egg_test_failed (test, "failed: %s", error->message);
+
+	g_usleep (2*1000*1000);
+
+	/************************************************************/
+	egg_test_title (test, "set on");
+	ret = gpm_dpms_set_mode (dpms, GPM_DPMS_MODE_ON, &error);
+	if (ret)
+		egg_test_success (test, NULL);
+	else
+		egg_test_failed (test, "failed: %s", error->message);
+
+	g_usleep (2*1000*1000);
+
+	g_object_unref (dpms);
+
+	egg_test_end (test);
+}
+
+#endif
+
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/77.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/77.html new file mode 100644 index 0000000..a4f3ebb --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/77.html @@ -0,0 +1,2175 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
+603
+604
+605
+606
+607
+608
+609
+610
+611
+612
+613
+614
+615
+616
+617
+618
+619
+620
+621
+622
+623
+624
+625
+626
+627
+628
+629
+630
+631
+632
+633
+634
+635
+636
+637
+638
+639
+640
+641
+642
+643
+644
+645
+646
+647
+648
+649
+650
+651
+652
+653
+654
+655
+656
+657
+658
+659
+660
+661
+662
+663
+664
+665
+666
+667
+668
+669
+670
+671
+672
+673
+674
+675
+676
+677
+678
+679
+680
+681
+682
+683
+684
+685
+686
+687
+688
+689
+690
+691
+692
+693
+694
+695
+696
+697
+698
+699
+700
+701
+702
+703
+704
+705
+706
+707
+708
+709
+710
+711
+712
+713
+714
+715
+716
+717
+718
+719
+720
+721
+722
+723
+724
+725
+726
+727
+728
+729
+730
+731
+732
+733
+734
+735
+736
+737
+738
+739
+740
+741
+742
+743
+744
+745
+746
+747
+748
+749
+750
+751
+752
+753
+754
+755
+756
+757
+758
+759
+760
+761
+762
+763
+764
+765
+766
+767
+768
+769
+770
+771
+772
+773
+774
+775
+776
+777
+778
+779
+780
+781
+782
+783
+784
+785
+786
+787
+788
+789
+790
+791
+792
+793
+794
+795
+796
+797
+798
+799
+800
+801
+802
+803
+804
+805
+806
+807
+808
+809
+810
+811
+812
+813
+814
+815
+816
+817
+818
+819
+820
+821
+822
+823
+824
+825
+826
+827
+828
+829
+830
+831
+832
+833
+834
+835
+836
+837
+838
+839
+840
+841
+842
+843
+844
+845
+846
+847
+848
+849
+850
+851
+852
+853
+854
+855
+856
+857
+858
+859
+860
+861
+862
+863
+864
+865
+866
+867
+868
+869
+870
+871
+872
+873
+874
+875
+876
+877
+878
+879
+880
+881
+882
+883
+884
+885
+886
+887
+888
+889
+890
+891
+892
+893
+894
+895
+896
+897
+898
+899
+900
+901
+902
+903
+904
+905
+906
+907
+908
+909
+910
+911
+912
+913
+914
+915
+916
+917
+918
+919
+920
+921
+922
+923
+924
+925
+926
+927
+928
+929
+930
+931
+932
+933
+934
+935
+936
+937
+938
+939
+940
+941
+942
+943
+944
+945
+946
+947
+948
+949
+950
+951
+952
+953
+954
+955
+956
+957
+958
+959
+960
+961
+962
+963
+964
+965
+966
+967
+968
+969
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007-2008 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "config.h"<--- Include file: "config.h" not found.
+
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <libupower-glib/upower.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "gpm-common.h"
+#include "gpm-upower.h"
+#include "gpm-marshal.h"
+#include "gpm-engine.h"
+#include "gpm-icon-names.h"
+#include "gpm-phone.h"
+
+static void     gpm_engine_finalize   (GObject	  *object);
+
+#define GPM_ENGINE_RESUME_DELAY		2*1000
+#define GPM_ENGINE_WARN_ACCURACY	20
+
+struct GpmEnginePrivate
+{
+	GSettings		*settings;
+	UpClient		*client;
+	UpDevice		*battery_composite;
+	GPtrArray		*array;
+	GpmPhone		*phone;
+	GpmIconPolicy		 icon_policy;
+	gchar			*previous_icon;
+	gchar			*previous_summary;
+
+	gboolean		 use_time_primary;
+	gboolean		 time_is_accurate;
+
+	guint			 low_percentage;
+	guint			 critical_percentage;
+	guint			 action_percentage;
+	guint			 low_time;
+	guint			 critical_time;
+	guint			 action_time;
+};
+
+enum {
+	ICON_CHANGED,
+	SUMMARY_CHANGED,
+	FULLY_CHARGED,
+	CHARGE_LOW,
+	CHARGE_CRITICAL,
+	CHARGE_ACTION,
+	DISCHARGING,
+	LOW_CAPACITY,
+	DEVICES_CHANGED,
+	LAST_SIGNAL
+};
+
+static guint signals [LAST_SIGNAL] = { 0 };
+static gpointer gpm_engine_object = NULL;
+
+G_DEFINE_TYPE_WITH_PRIVATE (GpmEngine, gpm_engine, G_TYPE_OBJECT)<--- There is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
+
+static UpDevice *gpm_engine_get_composite_device (GpmEngine *engine, UpDevice *original_device);
+static UpDevice *gpm_engine_update_composite_device (GpmEngine *engine, UpDevice *original_device);
+static void gpm_engine_device_changed_cb (UpDevice *device, GParamSpec *pspec, GpmEngine *engine);
+
+#define GPM_ENGINE_WARNING_NONE UP_DEVICE_LEVEL_NONE
+#define GPM_ENGINE_WARNING_DISCHARGING UP_DEVICE_LEVEL_DISCHARGING
+#define GPM_ENGINE_WARNING_LOW UP_DEVICE_LEVEL_LOW
+#define GPM_ENGINE_WARNING_CRITICAL UP_DEVICE_LEVEL_CRITICAL
+#define GPM_ENGINE_WARNING_ACTION UP_DEVICE_LEVEL_ACTION
+
+/**
+ * gpm_engine_get_warning:
+ *
+ * This gets the possible engine state for the device according to the
+ * policy, which could be per-percent, or per-time.
+ *
+ * Return value: A GpmEngine state, e.g. GPM_ENGINE_WARNING_DISCHARGING
+ **/
+static UpDeviceLevel
+gpm_engine_get_warning (GpmEngine *engine, UpDevice *device)
+{
+	UpDeviceLevel warning;
+	g_object_get (device, "warning-level", &warning, NULL);
+	return warning;
+}
+
+/**
+ * gpm_engine_get_summary:
+ * @engine: This engine class instance
+ * @string: The returned string
+ *
+ * Returns the complete tooltip ready for display
+ **/
+gchar *
+gpm_engine_get_summary (GpmEngine *engine)
+{
+	guint i;
+	GPtrArray *array;
+	UpDevice *device;
+	UpDeviceState state;
+	GString *tooltip = NULL;
+	gchar *part;
+	gboolean is_present;
+
+	g_return_val_if_fail (GPM_IS_ENGINE (engine), NULL);
+
+	/* need to get AC state */
+	tooltip = g_string_new ("");
+
+	/* do we have specific device types? */
+	array = engine->priv->array;
+	for (i=0;i<array->len;i++) {
+		device = g_ptr_array_index (engine->priv->array, i);
+		g_object_get (device,
+			      "is-present", &is_present,
+			      "state", &state,
+			      NULL);
+		if (!is_present)
+			continue;
+		if (state == UP_DEVICE_STATE_EMPTY)
+			continue;
+		part = gpm_upower_get_device_summary (device);
+		if (part != NULL)
+			g_string_append_printf (tooltip, "%s\n", part);
+		g_free (part);
+	}
+
+	/* remove the last \n */
+	g_string_truncate (tooltip, tooltip->len-1);
+
+	g_debug ("tooltip: %s", tooltip->str);
+
+	return g_string_free (tooltip, FALSE);
+}
+
+/**
+ * gpm_engine_get_icon_priv:
+ *
+ * Returns the icon
+ **/
+static gchar *
+gpm_engine_get_icon_priv (GpmEngine *engine, UpDeviceKind device_kind, UpDeviceLevel warning, gboolean use_state)
+{
+	guint i;
+	GPtrArray *array;
+	UpDevice *device;
+	UpDeviceLevel warning_temp;
+	UpDeviceKind kind;
+	UpDeviceState state;
+	gboolean is_present;
+
+	/* do we have specific device types? */
+	array = engine->priv->array;
+	for (i=0;i<array->len;i++) {
+		device = g_ptr_array_index (engine->priv->array, i);
+
+		/* get device properties */
+		g_object_get (device,
+			      "kind", &kind,
+			      "state", &state,
+			      "is-present", &is_present,
+			      NULL);
+
+		/* if battery then use composite device to cope with multiple batteries */
+		if (kind == UP_DEVICE_KIND_BATTERY)
+			device = gpm_engine_get_composite_device (engine, device);
+
+		warning_temp = GPOINTER_TO_INT(g_object_get_data (G_OBJECT(device), "engine-warning-old"));
+		if (kind == device_kind && is_present) {
+			if (warning != GPM_ENGINE_WARNING_NONE) {
+				if (warning_temp == warning)
+					return gpm_upower_get_device_icon (device);
+				continue;
+			}
+			if (use_state) {
+				if (state == UP_DEVICE_STATE_CHARGING || state == UP_DEVICE_STATE_DISCHARGING)
+					return gpm_upower_get_device_icon (device);
+				continue;
+			}
+			return gpm_upower_get_device_icon (device);
+		}
+	}
+	return NULL;
+}
+
+/**
+ * gpm_engine_get_icon:
+ *
+ * Returns the icon
+ **/
+gchar *
+gpm_engine_get_icon (GpmEngine *engine)
+{
+	gchar *icon = NULL;
+
+	g_return_val_if_fail (GPM_IS_ENGINE (engine), NULL);
+
+	/* policy */
+	if (engine->priv->icon_policy == GPM_ICON_POLICY_NEVER) {
+		g_debug ("no icon allowed, so no icon will be displayed.");
+		return NULL;
+	}
+
+	/* we try CRITICAL: BATTERY, UPS, MOUSE, KEYBOARD */
+	icon = gpm_engine_get_icon_priv (engine, UP_DEVICE_KIND_BATTERY, GPM_ENGINE_WARNING_CRITICAL, FALSE);
+	if (icon != NULL)
+		return icon;
+	icon = gpm_engine_get_icon_priv (engine, UP_DEVICE_KIND_UPS, GPM_ENGINE_WARNING_CRITICAL, FALSE);
+	if (icon != NULL)
+		return icon;
+	icon = gpm_engine_get_icon_priv (engine, UP_DEVICE_KIND_MOUSE, GPM_ENGINE_WARNING_CRITICAL, FALSE);
+	if (icon != NULL)
+		return icon;
+	icon = gpm_engine_get_icon_priv (engine, UP_DEVICE_KIND_KEYBOARD, GPM_ENGINE_WARNING_CRITICAL, FALSE);
+	if (icon != NULL)
+		return icon;
+
+	/* policy */
+	if (engine->priv->icon_policy == GPM_ICON_POLICY_CRITICAL) {
+		g_debug ("no devices critical, so no icon will be displayed.");
+		return NULL;
+	}
+
+	/* we try CRITICAL: BATTERY, UPS, MOUSE, KEYBOARD */
+	icon = gpm_engine_get_icon_priv (engine, UP_DEVICE_KIND_BATTERY, GPM_ENGINE_WARNING_LOW, FALSE);
+	if (icon != NULL)
+		return icon;
+	icon = gpm_engine_get_icon_priv (engine, UP_DEVICE_KIND_UPS, GPM_ENGINE_WARNING_LOW, FALSE);
+	if (icon != NULL)
+		return icon;
+	icon = gpm_engine_get_icon_priv (engine, UP_DEVICE_KIND_MOUSE, GPM_ENGINE_WARNING_LOW, FALSE);
+	if (icon != NULL)
+		return icon;
+	icon = gpm_engine_get_icon_priv (engine, UP_DEVICE_KIND_KEYBOARD, GPM_ENGINE_WARNING_LOW, FALSE);
+	if (icon != NULL)
+		return icon;
+
+	/* policy */
+	if (engine->priv->icon_policy == GPM_ICON_POLICY_LOW) {
+		g_debug ("no devices low, so no icon will be displayed.");
+		return NULL;
+	}
+
+	/* we try (DIS)CHARGING: BATTERY, UPS */
+	icon = gpm_engine_get_icon_priv (engine, UP_DEVICE_KIND_BATTERY, GPM_ENGINE_WARNING_NONE, TRUE);
+	if (icon != NULL)
+		return icon;
+	icon = gpm_engine_get_icon_priv (engine, UP_DEVICE_KIND_UPS, GPM_ENGINE_WARNING_NONE, TRUE);
+	if (icon != NULL)
+		return icon;
+
+	/* policy */
+	if (engine->priv->icon_policy == GPM_ICON_POLICY_CHARGE) {
+		g_debug ("no devices (dis)charging, so no icon will be displayed.");
+		return NULL;
+	}
+
+	/* we try PRESENT: BATTERY, UPS */
+	icon = gpm_engine_get_icon_priv (engine, UP_DEVICE_KIND_BATTERY, GPM_ENGINE_WARNING_NONE, FALSE);
+	if (icon != NULL)
+		return icon;
+	icon = gpm_engine_get_icon_priv (engine, UP_DEVICE_KIND_UPS, GPM_ENGINE_WARNING_NONE, FALSE);
+	if (icon != NULL)
+		return icon;
+
+	/* policy */
+	if (engine->priv->icon_policy == GPM_ICON_POLICY_PRESENT) {
+		g_debug ("no devices present, so no icon will be displayed.");
+		return NULL;
+	}
+
+	/* we fallback to the ac_adapter icon */
+	g_debug ("Using fallback");
+	return g_strdup (GPM_ICON_AC_ADAPTER);
+}
+
+/**
+ * gpm_engine_recalculate_state_icon:
+ */
+static gboolean
+gpm_engine_recalculate_state_icon (GpmEngine *engine)
+{
+	gchar *icon;
+
+	g_return_val_if_fail (engine != NULL, FALSE);
+	g_return_val_if_fail (GPM_IS_ENGINE (engine), FALSE);
+
+	/* show a different icon if we are disconnected */
+	icon = gpm_engine_get_icon (engine);
+	if (icon == NULL) {
+		/* none before, now none */
+		if (engine->priv->previous_icon == NULL)
+			return FALSE;
+		/* icon before, now none */
+		g_debug ("** EMIT: icon-changed: none");
+		g_signal_emit (engine, signals [ICON_CHANGED], 0, NULL);
+
+		g_free (engine->priv->previous_icon);
+		engine->priv->previous_icon = NULL;
+		return TRUE;
+	}
+
+	/* no icon before, now icon */
+	if (engine->priv->previous_icon == NULL) {
+		g_debug ("** EMIT: icon-changed: %s", icon);
+		g_signal_emit (engine, signals [ICON_CHANGED], 0, icon);
+		engine->priv->previous_icon = icon;
+		return TRUE;
+	}
+
+	/* icon before, now different */
+	if (strcmp (engine->priv->previous_icon, icon) != 0) {
+		g_free (engine->priv->previous_icon);
+		engine->priv->previous_icon = icon;
+		g_debug ("** EMIT: icon-changed: %s", icon);
+		g_signal_emit (engine, signals [ICON_CHANGED], 0, icon);
+		return TRUE;
+	}
+
+	g_debug ("no change");
+	/* nothing to do */
+	g_free (icon);
+	return FALSE;
+}
+
+/**
+ * gpm_engine_recalculate_state_summary:
+ */
+static gboolean
+gpm_engine_recalculate_state_summary (GpmEngine *engine)
+{
+	gchar *summary;
+
+	summary = gpm_engine_get_summary (engine);
+	if (engine->priv->previous_summary == NULL) {
+		engine->priv->previous_summary = summary;
+		g_debug ("** EMIT: summary-changed(1): %s", summary);
+		g_signal_emit (engine, signals [SUMMARY_CHANGED], 0, summary);
+		return TRUE;
+	}
+
+	if (strcmp (engine->priv->previous_summary, summary) != 0) {
+		g_free (engine->priv->previous_summary);
+		engine->priv->previous_summary = summary;
+		g_debug ("** EMIT: summary-changed(2): %s", summary);
+		g_signal_emit (engine, signals [SUMMARY_CHANGED], 0, summary);
+		return TRUE;
+	}
+	g_debug ("no change");
+	/* nothing to do */
+	g_free (summary);
+	return FALSE;
+}
+
+/**
+ * gpm_engine_recalculate_state:
+ */
+static void
+gpm_engine_recalculate_state (GpmEngine *engine)
+{
+
+	g_return_if_fail (engine != NULL);
+	g_return_if_fail (GPM_IS_ENGINE (engine));
+
+	gpm_engine_recalculate_state_icon (engine);
+	gpm_engine_recalculate_state_summary (engine);
+
+	g_signal_emit (engine, signals [DEVICES_CHANGED], 0);
+}
+
+/**
+ * gpm_engine_settings_key_changed_cb:
+ **/
+static void
+gpm_engine_settings_key_changed_cb (GSettings *settings, const gchar *key, GpmEngine *engine)
+{
+
+	if (g_strcmp0 (key, GPM_SETTINGS_USE_TIME_POLICY) == 0) {
+		engine->priv->use_time_primary = g_settings_get_boolean (settings, key);
+
+	} else if (g_strcmp0 (key, GPM_SETTINGS_ICON_POLICY) == 0) {
+
+		/* do we want to display the icon in the tray */
+		engine->priv->icon_policy = g_settings_get_enum (settings, key);
+
+		/* perhaps change icon */
+		gpm_engine_recalculate_state_icon (engine);
+	}
+}
+
+/**
+ * gpm_engine_device_check_capacity:
+ **/
+static gboolean
+gpm_engine_device_check_capacity (GpmEngine *engine, UpDevice *device)
+{
+	gboolean ret;
+	UpDeviceKind kind;
+	gdouble capacity;
+
+	/* get device properties */
+	g_object_get (device,
+		      "kind", &kind,
+		      "capacity", &capacity,
+		      NULL);
+
+	/* not laptop battery */
+	if (kind != UP_DEVICE_KIND_BATTERY)
+		return FALSE;
+
+	/* capacity okay */
+	if (capacity > 50.0f)
+		return FALSE;
+
+	/* capacity invalid */
+	if (capacity < 1.0f)
+		return FALSE;
+
+	/* only emit this if specified in the settings */
+	ret = g_settings_get_boolean (engine->priv->settings, GPM_SETTINGS_NOTIFY_LOW_CAPACITY);
+	if (ret) {
+		g_debug ("** EMIT: low-capacity");
+		g_signal_emit (engine, signals [LOW_CAPACITY], 0, device);
+	}
+	return TRUE;
+}
+
+/**
+ * gpm_engine_get_composite_device:
+ **/
+static UpDevice *
+gpm_engine_get_composite_device (GpmEngine *engine, UpDevice *original_device)
+{
+	return engine->priv->battery_composite;
+}
+
+/**
+ * gpm_engine_update_composite_device:
+ **/
+static UpDevice *
+gpm_engine_update_composite_device (GpmEngine *engine, UpDevice *original_device)
+{
+	gchar *text;
+
+	text = up_device_to_text (engine->priv->battery_composite);
+	g_debug ("composite:\n%s", text);
+	g_free (text);
+
+	/* force update of icon */
+	gpm_engine_recalculate_state_icon (engine);
+
+	return engine->priv->battery_composite;
+}
+
+/**
+ * gpm_engine_device_add:
+ **/
+static void
+gpm_engine_device_add (GpmEngine *engine, UpDevice *device)
+{
+	UpDeviceLevel warning;
+	UpDeviceState state;
+	UpDeviceKind kind;
+	UpDevice *composite;
+
+	/* assign warning */
+	warning = gpm_engine_get_warning (engine, device);
+	g_object_set_data (G_OBJECT(device), "engine-warning-old", GUINT_TO_POINTER(warning));
+
+	/* check capacity */
+	gpm_engine_device_check_capacity (engine, device);
+
+	/* get device properties */
+	g_object_get (device,
+		      "kind", &kind,
+		      "state", &state,
+		      NULL);
+
+	/* add old state for transitions */
+	g_debug ("adding %s with state %s", up_device_get_object_path (device), up_device_state_to_string (state));
+	g_object_set_data (G_OBJECT(device), "engine-state-old", GUINT_TO_POINTER(state));
+
+	if (kind == UP_DEVICE_KIND_BATTERY) {
+		g_debug ("updating because we added a device");
+		composite = gpm_engine_update_composite_device (engine, device);
+
+		/* get the same values for the composite device */
+		warning = gpm_engine_get_warning (engine, composite);
+		g_object_set_data (G_OBJECT(composite), "engine-warning-old", GUINT_TO_POINTER(warning));
+		g_object_get (composite, "state", &state, NULL);
+		g_object_set_data (G_OBJECT(composite), "engine-state-old", GUINT_TO_POINTER(state));
+	}
+
+	g_signal_connect (device, "notify", G_CALLBACK (gpm_engine_device_changed_cb), engine);
+	g_ptr_array_add (engine->priv->array, g_object_ref (device));
+	gpm_engine_recalculate_state (engine);
+}
+
+/**
+ * gpm_engine_coldplug_idle_cb:
+ **/
+static gboolean
+gpm_engine_coldplug_idle_cb (GpmEngine *engine)
+{
+	guint i;
+	GPtrArray *array = NULL;
+	UpDevice *device;
+
+	g_return_val_if_fail (engine != NULL, FALSE);
+	g_return_val_if_fail (GPM_IS_ENGINE (engine), FALSE);
+	/* connected mobile phones */
+	gpm_phone_coldplug (engine->priv->phone);
+
+	gpm_engine_recalculate_state (engine);
+
+	/* add to database */
+	array = up_client_get_devices2 (engine->priv->client);
+	for (i=0;i<array->len;i++) {
+		device = g_ptr_array_index (array, i);
+		gpm_engine_device_add (engine, device);
+	}
+	if (array != NULL)
+		g_ptr_array_unref (array);
+	/* never repeat */
+	return FALSE;
+}
+
+/**
+ * gpm_engine_device_added_cb:
+ **/
+static void
+gpm_engine_device_added_cb (UpClient *client, UpDevice *device, GpmEngine *engine)
+{
+	gpm_engine_device_add (engine, device);
+}
+
+/**
+ * gpm_engine_device_removed_cb:
+ **/
+static void
+gpm_engine_device_removed_cb (UpClient *client, const char *object_path, GpmEngine *engine)
+{
+	guint i;
+
+	for (i = 0; i < engine->priv->array->len; i++) {
+		UpDevice *device = g_ptr_array_index (engine->priv->array, i);
+
+		if (g_strcmp0 (object_path, up_device_get_object_path (device)) == 0) {
+			g_ptr_array_remove_index (engine->priv->array, i);
+			break;
+		}
+	}
+	gpm_engine_recalculate_state (engine);
+}
+
+/**
+ * gpm_engine_device_changed_cb:
+ **/
+static void
+gpm_engine_device_changed_cb (UpDevice *device, GParamSpec *pspec, GpmEngine *engine)
+{
+	UpDeviceKind kind;
+	UpDeviceState state;
+	UpDeviceState state_old;
+	UpDeviceLevel warning_old;
+	UpDeviceLevel warning;
+
+	/* get device properties */
+	g_object_get (device,
+		      "kind", &kind,
+		      NULL);
+
+	/* if battery then use composite device to cope with multiple batteries */
+	if (kind == UP_DEVICE_KIND_BATTERY) {
+		g_debug ("updating because %s changed", up_device_get_object_path (device));
+		device = gpm_engine_update_composite_device (engine, device);
+	}
+
+	/* get device properties (may be composite) */
+	g_object_get (device,
+		      "state", &state,
+		      NULL);
+
+	g_debug ("%s state is now %s", up_device_get_object_path (device), up_device_state_to_string (state));
+
+	/* see if any interesting state changes have happened */
+	state_old = GPOINTER_TO_INT(g_object_get_data (G_OBJECT(device), "engine-state-old"));
+	if (state_old != state) {
+		if (state == UP_DEVICE_STATE_DISCHARGING) {
+			g_debug ("** EMIT: discharging");
+			g_signal_emit (engine, signals [DISCHARGING], 0, device);
+		} else if (state == UP_DEVICE_STATE_FULLY_CHARGED) {
+			g_debug ("** EMIT: fully charged");
+			g_signal_emit (engine, signals [FULLY_CHARGED], 0, device);
+		}
+
+		/* save new state */
+		g_object_set_data (G_OBJECT(device), "engine-state-old", GUINT_TO_POINTER(state));
+	}
+
+	/* check the warning state has not changed */
+	warning_old = GPOINTER_TO_INT(g_object_get_data (G_OBJECT(device), "engine-warning-old"));
+	warning = gpm_engine_get_warning (engine, device);
+	if (warning != warning_old) {
+		if (warning == GPM_ENGINE_WARNING_LOW) {
+			g_debug ("** EMIT: charge-low");
+			g_signal_emit (engine, signals [CHARGE_LOW], 0, device);
+		} else if (warning == GPM_ENGINE_WARNING_CRITICAL) {
+			g_debug ("** EMIT: charge-critical");
+			g_signal_emit (engine, signals [CHARGE_CRITICAL], 0, device);
+		} else if (warning == GPM_ENGINE_WARNING_ACTION) {
+			g_debug ("** EMIT: charge-action");
+			g_signal_emit (engine, signals [CHARGE_ACTION], 0, device);
+		}
+		/* save new state */
+		g_object_set_data (G_OBJECT(device), "engine-warning-old", GUINT_TO_POINTER(warning));
+	}
+
+	gpm_engine_recalculate_state (engine);
+}
+
+/**
+ * gpm_engine_get_devices:
+ *
+ * Return value: the UpDevice array, free with g_ptr_array_unref()
+ **/
+GPtrArray *
+gpm_engine_get_devices (GpmEngine *engine)
+{
+	return g_ptr_array_ref (engine->priv->array);
+}
+
+/**
+ * gpm_engine_get_primary_device:
+ *
+ * Return value: the #UpDevice, free with g_object_unref()
+ **/
+UpDevice *
+gpm_engine_get_primary_device (GpmEngine *engine)
+{
+	guint i;
+	UpDevice *device = NULL;
+	UpDevice *device_tmp;
+	UpDeviceKind kind;
+	UpDeviceState state;
+	gboolean is_present;
+
+	for (i=0; i<engine->priv->array->len; i++) {
+		device_tmp = g_ptr_array_index (engine->priv->array, i);
+
+		/* get device properties */
+		g_object_get (device_tmp,
+			      "kind", &kind,
+			      "state", &state,
+			      "is-present", &is_present,
+			      NULL);
+
+		/* not present */
+		if (!is_present)
+			continue;
+
+		/* not discharging */
+		if (state != UP_DEVICE_STATE_DISCHARGING)
+			continue;
+
+		/* not battery */
+		if (kind != UP_DEVICE_KIND_BATTERY)
+			continue;
+
+		/* use composite device to cope with multiple batteries */
+		device = g_object_ref (gpm_engine_get_composite_device (engine, device_tmp));
+		break;
+	}
+	return device;
+}
+
+/**
+ * phone_device_added_cb:
+ **/
+static void
+phone_device_added_cb (GpmPhone *phone, guint idx, GpmEngine *engine)
+{
+	UpDevice *device;
+	device = up_device_new ();
+
+	g_debug ("phone added %u", idx);
+
+	/* get device properties */
+	g_object_set (device,
+		      "kind", UP_DEVICE_KIND_PHONE,
+		      "is-rechargeable", TRUE,
+		      "native-path", g_strdup_printf ("dummy:phone_%u", idx),
+		      "is-present", TRUE,
+		      NULL);
+
+	/* state changed */
+	gpm_engine_device_add (engine, device);
+	g_ptr_array_add (engine->priv->array, g_object_ref (device));
+	gpm_engine_recalculate_state (engine);
+}
+
+/**
+ * phone_device_removed_cb:
+ **/
+static void
+phone_device_removed_cb (GpmPhone *phone, guint idx, GpmEngine *engine)
+{
+	guint i;
+	UpDevice *device;
+	UpDeviceKind kind;
+
+	g_debug ("phone removed %u", idx);
+
+	for (i=0; i<engine->priv->array->len; i++) {
+		device = g_ptr_array_index (engine->priv->array, i);
+
+		/* get device properties */
+		g_object_get (device,
+			      "kind", &kind,
+			      NULL);
+
+		if (kind == UP_DEVICE_KIND_PHONE) {
+			g_ptr_array_remove_index (engine->priv->array, i);
+			break;
+		}
+	}
+
+	/* state changed */
+	gpm_engine_recalculate_state (engine);
+}
+
+/**
+ * phone_device_refresh_cb:
+ **/
+static void
+phone_device_refresh_cb (GpmPhone *phone, guint idx, GpmEngine *engine)
+{
+	guint i;
+	UpDevice *device;
+	UpDeviceKind kind;
+	UpDeviceState state;
+	gboolean is_present;
+	gdouble percentage;
+
+	g_debug ("phone refresh %u", idx);
+
+	for (i=0; i<engine->priv->array->len; i++) {
+		device = g_ptr_array_index (engine->priv->array, i);
+
+		/* get device properties */
+		g_object_get (device,
+			      "kind", &kind,
+			      "state", &state,
+			      "percentage", &percentage,
+			      "is-present", &is_present,
+			      NULL);
+
+		if (kind == UP_DEVICE_KIND_PHONE) {
+			is_present = gpm_phone_get_present (phone, idx);
+			state = gpm_phone_get_on_ac (phone, idx) ? UP_DEVICE_STATE_CHARGING : UP_DEVICE_STATE_DISCHARGING;
+			percentage = gpm_phone_get_percentage (phone, idx);
+			break;
+		}
+	}
+
+	/* state changed */
+	gpm_engine_recalculate_state (engine);
+}
+
+/**
+ * gpm_engine_init:
+ * @engine: This class instance
+ **/
+static void
+gpm_engine_init (GpmEngine *engine)
+{
+	guint idle_id;
+	engine->priv = gpm_engine_get_instance_private (engine);
+
+	engine->priv->array = g_ptr_array_new_with_free_func (g_object_unref);
+	engine->priv->client = up_client_new ();
+	g_signal_connect (engine->priv->client, "device-added",
+			  G_CALLBACK (gpm_engine_device_added_cb), engine);
+	g_signal_connect (engine->priv->client, "device-removed",
+			  G_CALLBACK (gpm_engine_device_removed_cb), engine);
+
+	engine->priv->settings = g_settings_new (GPM_SETTINGS_SCHEMA);
+	g_signal_connect (engine->priv->settings, "changed",
+			  G_CALLBACK (gpm_engine_settings_key_changed_cb), engine);
+
+	engine->priv->phone = gpm_phone_new ();
+	g_signal_connect (engine->priv->phone, "device-added",
+			  G_CALLBACK (phone_device_added_cb), engine);
+	g_signal_connect (engine->priv->phone, "device-removed",
+			  G_CALLBACK (phone_device_removed_cb), engine);
+	g_signal_connect (engine->priv->phone, "device-refresh",
+			  G_CALLBACK (phone_device_refresh_cb), engine);
+
+	/* create a fake virtual composite battery */
+	engine->priv->battery_composite = up_client_get_display_device (engine->priv->client);
+	g_signal_connect (engine->priv->battery_composite, "notify",
+			  G_CALLBACK (gpm_engine_device_changed_cb), engine);
+
+	engine->priv->previous_icon = NULL;
+	engine->priv->previous_summary = NULL;
+
+	/* do we want to display the icon in the tray */
+	engine->priv->icon_policy = g_settings_get_enum (engine->priv->settings, GPM_SETTINGS_ICON_POLICY);
+
+	/* get percentage policy */
+	engine->priv->low_percentage = g_settings_get_int (engine->priv->settings, GPM_SETTINGS_PERCENTAGE_LOW);
+	engine->priv->critical_percentage = g_settings_get_int (engine->priv->settings, GPM_SETTINGS_PERCENTAGE_CRITICAL);
+	engine->priv->action_percentage = g_settings_get_int (engine->priv->settings, GPM_SETTINGS_PERCENTAGE_ACTION);
+
+	/* get time policy */
+	engine->priv->low_time = g_settings_get_int (engine->priv->settings, GPM_SETTINGS_TIME_LOW);
+	engine->priv->critical_time = g_settings_get_int (engine->priv->settings, GPM_SETTINGS_TIME_CRITICAL);
+	engine->priv->action_time = g_settings_get_int (engine->priv->settings, GPM_SETTINGS_TIME_ACTION);
+
+	/* we can disable this if the time remaining is inaccurate or just plain wrong */
+	engine->priv->use_time_primary = g_settings_get_boolean (engine->priv->settings, GPM_SETTINGS_USE_TIME_POLICY);
+	if (engine->priv->use_time_primary)
+		g_debug ("Using per-time notification policy");
+	else
+		g_debug ("Using percentage notification policy");
+
+	idle_id = g_idle_add ((GSourceFunc) gpm_engine_coldplug_idle_cb, engine);
+	g_source_set_name_by_id (idle_id, "[GpmEngine] coldplug");
+}
+
+/**
+ * gpm_engine_class_init:
+ * @engine: This class instance
+ **/
+static void
+gpm_engine_class_init (GpmEngineClass *klass)
+{
+	GObjectClass *object_class = G_OBJECT_CLASS (klass);
+	object_class->finalize = gpm_engine_finalize;
+
+	signals [ICON_CHANGED] =
+		g_signal_new ("icon-changed",
+			      G_TYPE_FROM_CLASS (object_class),
+			      G_SIGNAL_RUN_LAST,
+			      G_STRUCT_OFFSET (GpmEngineClass, icon_changed),
+			      NULL, NULL, g_cclosure_marshal_VOID__STRING,
+			      G_TYPE_NONE, 1, G_TYPE_STRING);
+	signals [SUMMARY_CHANGED] =
+		g_signal_new ("summary-changed",
+			      G_TYPE_FROM_CLASS (object_class),
+			      G_SIGNAL_RUN_LAST,
+			      G_STRUCT_OFFSET (GpmEngineClass, summary_changed),
+			      NULL, NULL, g_cclosure_marshal_VOID__STRING,
+			      G_TYPE_NONE, 1, G_TYPE_STRING);
+	signals [LOW_CAPACITY] =
+		g_signal_new ("low-capacity",
+			      G_TYPE_FROM_CLASS (object_class),
+			      G_SIGNAL_RUN_LAST,
+			      G_STRUCT_OFFSET (GpmEngineClass, low_capacity),
+			      NULL, NULL, g_cclosure_marshal_VOID__POINTER,
+			      G_TYPE_NONE, 1, G_TYPE_POINTER);
+	signals [FULLY_CHARGED] =
+		g_signal_new ("fully-charged",
+			      G_TYPE_FROM_CLASS (object_class),
+			      G_SIGNAL_RUN_LAST,
+			      G_STRUCT_OFFSET (GpmEngineClass, fully_charged),
+			      NULL, NULL, g_cclosure_marshal_VOID__POINTER,
+			      G_TYPE_NONE, 1, G_TYPE_POINTER);
+	signals [DISCHARGING] =
+		g_signal_new ("discharging",
+			      G_TYPE_FROM_CLASS (object_class),
+			      G_SIGNAL_RUN_LAST,
+			      G_STRUCT_OFFSET (GpmEngineClass, discharging),
+			      NULL, NULL, g_cclosure_marshal_VOID__POINTER,
+			      G_TYPE_NONE, 1, G_TYPE_POINTER);
+	signals [CHARGE_ACTION] =
+		g_signal_new ("charge-action",
+			      G_TYPE_FROM_CLASS (object_class),
+			      G_SIGNAL_RUN_LAST,
+			      G_STRUCT_OFFSET (GpmEngineClass, charge_action),
+			      NULL, NULL, g_cclosure_marshal_VOID__POINTER,
+			      G_TYPE_NONE, 1, G_TYPE_POINTER);
+	signals [CHARGE_LOW] =
+		g_signal_new ("charge-low",
+			      G_TYPE_FROM_CLASS (object_class),
+			      G_SIGNAL_RUN_LAST,
+			      G_STRUCT_OFFSET (GpmEngineClass, charge_low),
+			      NULL, NULL, g_cclosure_marshal_VOID__POINTER,
+			      G_TYPE_NONE, 1, G_TYPE_POINTER);
+	signals [CHARGE_CRITICAL] =
+		g_signal_new ("charge-critical",
+			      G_TYPE_FROM_CLASS (object_class),
+			      G_SIGNAL_RUN_LAST,
+			      G_STRUCT_OFFSET (GpmEngineClass, charge_critical),
+			      NULL, NULL, g_cclosure_marshal_VOID__POINTER,
+			      G_TYPE_NONE, 1, G_TYPE_POINTER);
+	signals [DEVICES_CHANGED] =
+		g_signal_new ("devices-changed",
+			      G_TYPE_FROM_CLASS (object_class),
+			      G_SIGNAL_RUN_LAST,
+			      G_STRUCT_OFFSET (GpmEngineClass, devices_changed),
+			      NULL, NULL, g_cclosure_marshal_VOID__VOID,
+			      G_TYPE_NONE, 0);
+}
+
+/**
+ * gpm_engine_finalize:
+ * @object: This class instance
+ **/
+static void
+gpm_engine_finalize (GObject *object)
+{
+	GpmEngine *engine;
+
+	g_return_if_fail (object != NULL);
+	g_return_if_fail (GPM_IS_ENGINE (object));
+
+	engine = GPM_ENGINE (object);
+	engine->priv = gpm_engine_get_instance_private (engine);
+
+	g_ptr_array_unref (engine->priv->array);
+	g_object_unref (engine->priv->client);
+	g_object_unref (engine->priv->phone);
+	g_object_unref (engine->priv->battery_composite);
+
+	g_free (engine->priv->previous_icon);
+	g_free (engine->priv->previous_summary);
+
+	G_OBJECT_CLASS (gpm_engine_parent_class)->finalize (object);
+}
+
+/**
+ * gpm_engine_new:
+ * Return value: new class instance.
+ **/
+GpmEngine *
+gpm_engine_new (void)
+{
+	if (gpm_engine_object != NULL) {
+		g_object_ref (gpm_engine_object);
+	} else {
+		gpm_engine_object = g_object_new (GPM_TYPE_ENGINE, NULL);
+		g_object_add_weak_pointer (gpm_engine_object, &gpm_engine_object);
+	}
+	return GPM_ENGINE (gpm_engine_object);
+
+}
+
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/78.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/78.html new file mode 100644 index 0000000..4a92ea3 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/78.html @@ -0,0 +1,321 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __GPM_DEVICEKIT_H
+#define __GPM_DEVICEKIT_H
+
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <libupower-glib/upower.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+G_BEGIN_DECLS
+
+const gchar	*gpm_device_kind_to_localised_string	(UpDeviceKind	 kind,
+							 guint		 number);
+const gchar	*gpm_device_kind_to_icon		(UpDeviceKind	 kind);
+const gchar	*gpm_device_technology_to_localised_string (UpDeviceTechnology technology_enum);
+const gchar	*gpm_device_state_to_localised_string	(UpDeviceState	 state);
+gchar		*gpm_upower_get_device_icon		(UpDevice *device);
+gchar		*gpm_upower_get_device_summary		(UpDevice *device);
+gchar		*gpm_upower_get_device_description	(UpDevice *device);
+
+G_END_DECLS
+
+#endif	/* __GPM_DEVICEKIT_H */
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/79.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/79.html new file mode 100644 index 0000000..4868908 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/79.html @@ -0,0 +1,393 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007-2008 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __GPM_ENGINE_H
+#define __GPM_ENGINE_H
+
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <libupower-glib/upower.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+G_BEGIN_DECLS
+
+#define GPM_TYPE_ENGINE		(gpm_engine_get_type ())
+#define GPM_ENGINE(o)		(G_TYPE_CHECK_INSTANCE_CAST ((o), GPM_TYPE_ENGINE, GpmEngine))
+#define GPM_ENGINE_CLASS(k)	(G_TYPE_CHECK_CLASS_CAST((k), GPM_TYPE_ENGINE, GpmEngineClass))
+#define GPM_IS_ENGINE(o)	(G_TYPE_CHECK_INSTANCE_TYPE ((o), GPM_TYPE_ENGINE))
+#define GPM_IS_ENGINE_CLASS(k)	(G_TYPE_CHECK_CLASS_TYPE ((k), GPM_TYPE_ENGINE))
+#define GPM_ENGINE_GET_CLASS(o)	(G_TYPE_INSTANCE_GET_CLASS ((o), GPM_TYPE_ENGINE, GpmEngineClass))
+
+typedef struct GpmEnginePrivate GpmEnginePrivate;
+
+typedef struct
+{
+	GObject		 parent;
+	GpmEnginePrivate *priv;
+} GpmEngine;
+
+typedef struct
+{
+	GObjectClass	parent_class;
+	void		(* icon_changed)	(GpmEngine	*engine,
+						 gchar		*icon);
+	void		(* summary_changed)	(GpmEngine	*engine,
+						 gchar		*status);
+	void		(* low_capacity)	(GpmEngine	*engine,
+						 UpDevice	*device);
+	void		(* charge_low)		(GpmEngine	*engine,
+						 UpDevice	*device);
+	void		(* charge_critical)	(GpmEngine	*engine,
+						 UpDevice	*device);
+	void		(* charge_action)	(GpmEngine	*engine,
+						 UpDevice	*device);
+	void		(* fully_charged)	(GpmEngine	*engine,
+						 UpDevice	*device);
+	void		(* discharging)		(GpmEngine	*engine,
+						 UpDevice	*device);
+	void		(* devices_changed)	(GpmEngine	*engine);
+} GpmEngineClass;
+
+GType		 gpm_engine_get_type		(void);
+GpmEngine	*gpm_engine_new			(void);
+gchar		*gpm_engine_get_icon		(GpmEngine	*engine);
+gchar		*gpm_engine_get_summary		(GpmEngine	*engine);
+GPtrArray	*gpm_engine_get_devices		(GpmEngine	*engine);
+UpDevice	*gpm_engine_get_primary_device	(GpmEngine	*engine);
+
+G_END_DECLS
+
+#endif	/* __GPM_ENGINE_H */
+
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/8.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/8.html new file mode 100644 index 0000000..f909f1f --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/8.html @@ -0,0 +1,1769 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
+603
+604
+605
+606
+607
+608
+609
+610
+611
+612
+613
+614
+615
+616
+617
+618
+619
+620
+621
+622
+623
+624
+625
+626
+627
+628
+629
+630
+631
+632
+633
+634
+635
+636
+637
+638
+639
+640
+641
+642
+643
+644
+645
+646
+647
+648
+649
+650
+651
+652
+653
+654
+655
+656
+657
+658
+659
+660
+661
+662
+663
+664
+665
+666
+667
+668
+669
+670
+671
+672
+673
+674
+675
+676
+677
+678
+679
+680
+681
+682
+683
+684
+685
+686
+687
+688
+689
+690
+691
+692
+693
+694
+695
+696
+697
+698
+699
+700
+701
+702
+703
+704
+705
+706
+707
+708
+709
+710
+711
+712
+713
+714
+715
+716
+717
+718
+719
+720
+721
+722
+723
+724
+725
+726
+727
+728
+729
+730
+731
+732
+733
+734
+735
+736
+737
+738
+739
+740
+741
+742
+743
+744
+745
+746
+747
+748
+749
+750
+751
+752
+753
+754
+755
+756
+757
+758
+759
+760
+761
+762
+763
+764
+765
+766
/* mate-bg-crossfade.h - fade window background between two surfaces
+ *
+ * Copyright (C) 2008 Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public License
+ * as published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ *
+ * Author: Ray Strode <rstrode@redhat.com>
+*/
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <math.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdarg.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <gio/gio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <gdk/gdk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdk/gdkx.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <X11/Xlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <X11/Xatom.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <cairo.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <cairo-xlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#define MATE_DESKTOP_USE_UNSTABLE_API
+#include <mate-bg.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include "mate-bg-crossfade.h"
+
+struct _MateBGCrossfadePrivate
+{
+    GdkWindow       *window;
+    GtkWidget       *widget;
+    int              width;
+    int              height;
+    cairo_surface_t *fading_surface;
+    cairo_surface_t *start_surface;
+    cairo_surface_t *end_surface;
+    gdouble          start_time;
+    gdouble          total_duration;
+    guint            timeout_id;
+    guint            is_first_frame : 1;
+};
+
+enum {
+    PROP_0,
+    PROP_WIDTH,
+    PROP_HEIGHT,
+};
+
+enum {
+    FINISHED,
+    NUMBER_OF_SIGNALS
+};
+
+static guint signals[NUMBER_OF_SIGNALS] = { 0 };
+
+G_DEFINE_TYPE_WITH_PRIVATE (MateBGCrossfade, mate_bg_crossfade, G_TYPE_OBJECT)<--- There is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
+
+static void
+mate_bg_crossfade_set_property (GObject      *object,
+                                guint         property_id,
+                                const GValue *value,
+                                GParamSpec   *pspec)
+{
+    MateBGCrossfade *fade;
+
+    g_assert (MATE_IS_BG_CROSSFADE (object));
+
+    fade = MATE_BG_CROSSFADE (object);
+
+    switch (property_id)
+    {
+    case PROP_WIDTH:
+        fade->priv->width = g_value_get_int (value);
+        break;
+    case PROP_HEIGHT:
+        fade->priv->height = g_value_get_int (value);
+        break;
+    default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+        break;
+    }
+}
+
+static void
+mate_bg_crossfade_get_property (GObject    *object,
+                                guint       property_id,
+                                GValue     *value,
+                                GParamSpec *pspec)
+{
+    MateBGCrossfade *fade;
+
+    g_assert (MATE_IS_BG_CROSSFADE (object));
+
+    fade = MATE_BG_CROSSFADE (object);
+
+    switch (property_id)
+    {
+    case PROP_WIDTH:
+        g_value_set_int (value, fade->priv->width);
+        break;
+    case PROP_HEIGHT:
+        g_value_set_int (value, fade->priv->height);
+        break;
+
+    default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+        break;
+    }
+}
+
+static void
+mate_bg_crossfade_finalize (GObject *object)
+{
+    MateBGCrossfade *fade;
+
+    fade = MATE_BG_CROSSFADE (object);
+
+    mate_bg_crossfade_stop (fade);
+
+    if (fade->priv->fading_surface != NULL) {
+        cairo_surface_destroy (fade->priv->fading_surface);
+        fade->priv->fading_surface = NULL;
+    }
+
+    if (fade->priv->start_surface != NULL) {
+        cairo_surface_destroy (fade->priv->start_surface);
+        fade->priv->start_surface = NULL;
+    }
+
+    if (fade->priv->end_surface != NULL) {
+        cairo_surface_destroy (fade->priv->end_surface);
+        fade->priv->end_surface = NULL;
+    }
+}
+
+static void
+mate_bg_crossfade_class_init (MateBGCrossfadeClass *fade_class)
+{
+    GObjectClass *gobject_class;
+
+    gobject_class = G_OBJECT_CLASS (fade_class);
+
+    gobject_class->get_property = mate_bg_crossfade_get_property;
+    gobject_class->set_property = mate_bg_crossfade_set_property;
+    gobject_class->finalize = mate_bg_crossfade_finalize;
+
+    /**
+     * MateBGCrossfade:width:
+     *
+     * When a crossfade is running, this is width of the fading
+     * surface.
+     */
+    g_object_class_install_property (gobject_class,
+                                     PROP_WIDTH,
+                                     g_param_spec_int ("width",
+                                     "Window Width",
+                                     "Width of window to fade",
+                                     0, G_MAXINT, 0,
+                                     G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
+
+    /**
+     * MateBGCrossfade:height:
+     *
+     * When a crossfade is running, this is height of the fading
+     * surface.
+     */
+    g_object_class_install_property (gobject_class,
+                                     PROP_HEIGHT,
+                                     g_param_spec_int ("height", "Window Height",
+                                     "Height of window to fade on",
+                                     0, G_MAXINT, 0,
+                                     G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
+
+    /**
+     * MateBGCrossfade::finished:
+     * @fade: the #MateBGCrossfade that received the signal
+     * @window: the #GdkWindow the crossfade happend on.
+     *
+     * When a crossfade finishes, @window will have a copy
+     * of the end surface as its background, and this signal will
+     * get emitted.
+     */
+    signals[FINISHED] = g_signal_new ("finished",
+                                      G_OBJECT_CLASS_TYPE (gobject_class),
+                                      G_SIGNAL_RUN_LAST, 0, NULL, NULL,
+                                      g_cclosure_marshal_VOID__OBJECT,
+                                      G_TYPE_NONE, 1, G_TYPE_OBJECT);
+}
+
+static void
+mate_bg_crossfade_init (MateBGCrossfade *fade)
+{
+    fade->priv = mate_bg_crossfade_get_instance_private (fade);
+
+    fade->priv->window = NULL;
+    fade->priv->widget = NULL;
+    fade->priv->fading_surface = NULL;
+    fade->priv->start_surface = NULL;
+    fade->priv->end_surface = NULL;
+    fade->priv->timeout_id = 0;
+}
+
+/**
+ * mate_bg_crossfade_new:
+ * @width: The width of the crossfading window
+ * @height: The height of the crossfading window
+ *
+ * Creates a new object to manage crossfading a
+ * window background between two #cairo_surface_ts.
+ *
+ * Return value: the new #MateBGCrossfade
+ **/
+MateBGCrossfade* mate_bg_crossfade_new (int width, int height)
+{
+    GObject* object;
+
+    object = g_object_new(MATE_TYPE_BG_CROSSFADE,
+                          "width", width,
+                          "height", height,
+                          NULL);
+
+    return (MateBGCrossfade*) object;
+}
+
+static cairo_surface_t *
+tile_surface (cairo_surface_t *surface,
+              int              width,
+              int              height)
+{
+    cairo_surface_t *copy;
+    cairo_t *cr;
+
+    if (surface == NULL)
+    {
+        copy = gdk_window_create_similar_surface (gdk_get_default_root_window (),
+                                                  CAIRO_CONTENT_COLOR,
+                                                  width, height);
+    }
+    else
+    {
+        copy = cairo_surface_create_similar (surface,
+                                             cairo_surface_get_content (surface),
+                                             width, height);
+    }
+
+    cr = cairo_create (copy);
+
+    if (surface != NULL)
+    {
+        cairo_pattern_t *pattern;
+        cairo_set_source_surface (cr, surface, 0.0, 0.0);
+        pattern = cairo_get_source (cr);
+        cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT);
+    }
+    else
+    {
+        static GtkCssProvider *provider = NULL;
+        GtkStyleContext *context;
+        GdkRGBA bg;
+
+        if (provider == NULL)
+              provider = gtk_css_provider_new ();
+
+        context = gtk_style_context_new ();
+        gtk_style_context_add_provider (context,
+                                        GTK_STYLE_PROVIDER (provider),
+                                        GTK_STYLE_PROVIDER_PRIORITY_THEME);
+        gtk_style_context_get_background_color (context, GTK_STATE_FLAG_NORMAL, &bg);
+        gdk_cairo_set_source_rgba(cr, &bg);
+        g_object_unref (G_OBJECT (context));
+    }
+
+    cairo_paint (cr);
+
+    if (cairo_status (cr) != CAIRO_STATUS_SUCCESS)
+    {
+        cairo_surface_destroy (copy);
+        copy = NULL;
+    }
+
+    cairo_destroy(cr);
+
+    return copy;
+}
+
+/**
+ * mate_bg_crossfade_set_start_surface:
+ * @fade: a #MateBGCrossfade
+ * @surface: The cairo surface to fade from
+ *
+ * Before initiating a crossfade with mate_bg_crossfade_start()
+ * a start and end surface have to be set.  This function sets
+ * the surface shown at the beginning of the crossfade effect.
+ *
+ * Return value: %TRUE if successful, or %FALSE if the surface
+ * could not be copied.
+ **/
+gboolean
+mate_bg_crossfade_set_start_surface (MateBGCrossfade* fade, cairo_surface_t *surface)
+{
+    g_return_val_if_fail (MATE_IS_BG_CROSSFADE (fade), FALSE);
+
+    if (fade->priv->start_surface != NULL)
+    {
+        cairo_surface_destroy (fade->priv->start_surface);
+        fade->priv->start_surface = NULL;
+    }
+
+    fade->priv->start_surface = tile_surface (surface,
+                                              fade->priv->width,
+                                              fade->priv->height);
+
+    return fade->priv->start_surface != NULL;
+}
+
+#if GLIB_CHECK_VERSION(2,61,2)
+static gdouble
+get_current_time (void)
+{
+    const double microseconds_per_second = (double) G_USEC_PER_SEC;
+    gint64 tv;
+
+    tv = g_get_real_time ();
+
+    return (double) (tv / microseconds_per_second);
+}
+#else
+static gdouble
+get_current_time (void)
+{
+    const double microseconds_per_second = (double) G_USEC_PER_SEC;
+    double timestamp;
+    GTimeVal now;
+
+    g_get_current_time (&now);
+
+    timestamp = ((microseconds_per_second * now.tv_sec) + now.tv_usec) /
+                microseconds_per_second;
+
+    return timestamp;
+}
+#endif
+
+/**
+ * mate_bg_crossfade_set_end_surface:
+ * @fade: a #MateBGCrossfade
+ * @surface: The cairo surface to fade to
+ *
+ * Before initiating a crossfade with mate_bg_crossfade_start()
+ * a start and end surface have to be set.  This function sets
+ * the surface shown at the end of the crossfade effect.
+ *
+ * Return value: %TRUE if successful, or %FALSE if the surface
+ * could not be copied.
+ **/
+gboolean
+mate_bg_crossfade_set_end_surface (MateBGCrossfade* fade, cairo_surface_t *surface)
+{
+    g_return_val_if_fail (MATE_IS_BG_CROSSFADE (fade), FALSE);
+
+    if (fade->priv->end_surface != NULL) {
+        cairo_surface_destroy (fade->priv->end_surface);
+        fade->priv->end_surface = NULL;
+    }
+
+    fade->priv->end_surface = tile_surface (surface,
+                                            fade->priv->width,
+                                            fade->priv->height);
+
+    /* Reset timer in case we're called while animating
+     */
+    fade->priv->start_time = get_current_time ();
+    return fade->priv->end_surface != NULL;
+}
+
+static gboolean
+animations_are_disabled (MateBGCrossfade *fade)
+{
+    GtkSettings *settings;
+    GdkScreen *screen;
+    gboolean are_enabled;
+
+    g_assert (fade->priv->window != NULL);
+
+    screen = gdk_window_get_screen(fade->priv->window);
+
+    settings = gtk_settings_get_for_screen (screen);
+
+    g_object_get (settings, "gtk-enable-animations", &are_enabled, NULL);
+
+    return !are_enabled;
+}
+
+static void
+send_root_property_change_notification (MateBGCrossfade *fade)
+{
+        long zero_length_pixmap = 0;
+
+        /* We do a zero length append to force a change notification,
+         * without changing the value */
+        XChangeProperty (GDK_WINDOW_XDISPLAY (fade->priv->window),
+                         GDK_WINDOW_XID (fade->priv->window),
+                         gdk_x11_get_xatom_by_name ("_XROOTPMAP_ID"),
+                         XA_PIXMAP, 32, PropModeAppend,
+                         (unsigned char *) &zero_length_pixmap, 0);
+}
+
+static void
+draw_background (MateBGCrossfade *fade)
+{
+    if (fade->priv->widget != NULL) {
+        gtk_widget_queue_draw (fade->priv->widget);
+    } else if (gdk_window_get_window_type (fade->priv->window) != GDK_WINDOW_ROOT) {
+        cairo_t           *cr;
+        cairo_region_t    *region;
+        GdkDrawingContext *draw_context;
+
+        region = gdk_window_get_visible_region (fade->priv->window);
+        draw_context = gdk_window_begin_draw_frame (fade->priv->window,
+                                                    region);
+        cr = gdk_drawing_context_get_cairo_context (draw_context);
+        cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
+        cairo_set_source_surface (cr, fade->priv->fading_surface, 0, 0);
+        cairo_paint (cr);
+        gdk_window_end_draw_frame (fade->priv->window, draw_context);
+        cairo_region_destroy (region);
+    } else {
+        Display *xdisplay = GDK_WINDOW_XDISPLAY (fade->priv->window);
+        GdkDisplay *display;
+        display = gdk_display_get_default ();
+        gdk_x11_display_error_trap_push (display);
+        XGrabServer (xdisplay);
+        XClearWindow (xdisplay, GDK_WINDOW_XID (fade->priv->window));
+        send_root_property_change_notification (fade);
+        XFlush (xdisplay);
+        XUngrabServer (xdisplay);
+        gdk_x11_display_error_trap_pop_ignored (display);
+    }
+}
+
+static gboolean
+on_widget_draw (GtkWidget       *widget,
+                cairo_t         *cr,
+                MateBGCrossfade *fade)
+{
+    g_assert (fade->priv->fading_surface != NULL);
+
+    cairo_set_source_surface (cr, fade->priv->fading_surface, 0, 0);
+    cairo_pattern_set_extend (cairo_get_source (cr), CAIRO_EXTEND_REPEAT);
+    cairo_paint (cr);
+
+    return FALSE;
+}
+
+static gboolean
+on_tick (MateBGCrossfade *fade)
+{
+    gdouble now, percent_done;
+    cairo_t *cr;
+    cairo_status_t status;
+
+    g_return_val_if_fail (MATE_IS_BG_CROSSFADE (fade), FALSE);
+
+    now = get_current_time ();
+
+    percent_done = (now - fade->priv->start_time) / fade->priv->total_duration;
+    percent_done = CLAMP (percent_done, 0.0, 1.0);
+
+    /* If it's taking a long time to get to the first frame,
+     * then lengthen the duration, so the user will get to see
+     * the effect.
+     */
+    if (fade->priv->is_first_frame && percent_done > .33) {
+        fade->priv->is_first_frame = FALSE;
+        fade->priv->total_duration *= 1.5;
+        return on_tick (fade);
+    }
+
+    if (fade->priv->fading_surface == NULL ||
+        fade->priv->end_surface == NULL) {
+        return FALSE;
+    }
+
+    if (animations_are_disabled (fade)) {
+        return FALSE;
+    }
+
+    /* We accumulate the results in place for performance reasons.
+     *
+     * This means 1) The fade is exponential, not linear (looks good!)
+     * 2) The rate of fade is not independent of frame rate. Slower machines
+     * will get a slower fade (but never longer than .75 seconds), and
+     * even the fastest machines will get *some* fade because the framerate
+     * is capped.
+     */
+    cr = cairo_create (fade->priv->fading_surface);
+
+    cairo_set_source_surface (cr, fade->priv->end_surface,
+                              0.0, 0.0);
+    cairo_paint_with_alpha (cr, percent_done);
+
+    status = cairo_status (cr);
+    cairo_destroy (cr);
+
+    if (status == CAIRO_STATUS_SUCCESS) {
+        draw_background (fade);
+    }
+    return percent_done <= .99;
+}
+
+static void
+on_finished (MateBGCrossfade *fade)
+{
+    cairo_t *cr;
+
+    if (fade->priv->timeout_id == 0)
+        return;
+
+    g_assert (fade->priv->fading_surface != NULL);
+    g_assert (fade->priv->end_surface != NULL);
+
+    cr = cairo_create (fade->priv->fading_surface);
+    cairo_set_source_surface (cr, fade->priv->end_surface, 0, 0);
+    cairo_paint (cr);
+    cairo_destroy (cr);
+    draw_background (fade);
+
+    cairo_surface_destroy (fade->priv->fading_surface);
+    fade->priv->fading_surface = NULL;
+
+    cairo_surface_destroy (fade->priv->end_surface);
+    fade->priv->end_surface = NULL;
+
+    g_assert (fade->priv->start_surface != NULL);
+
+    cairo_surface_destroy (fade->priv->start_surface);
+    fade->priv->start_surface = NULL;
+
+    if (fade->priv->widget != NULL) {
+        g_signal_handlers_disconnect_by_func (fade->priv->widget,
+                                              (GCallback) on_widget_draw,
+                                              fade);
+    }
+    fade->priv->widget = NULL;
+
+    fade->priv->timeout_id = 0;
+    g_signal_emit (fade, signals[FINISHED], 0, fade->priv->window);
+}
+
+/* This function queries the _XROOTPMAP_ID property from the root window
+ * to determine the current root window background pixmap and returns a
+ * surface to draw directly to it.
+ * If _XROOTPMAP_ID is not set, then NULL returned.
+ */
+static cairo_surface_t *
+get_root_pixmap_id_surface (GdkDisplay *display)
+{
+    GdkScreen       *screen;
+    Display         *xdisplay;
+    Visual          *xvisual;
+    Window           xroot;
+    Atom             type;
+    int              format, result;
+    unsigned long    nitems, bytes_after;
+    unsigned char   *data;
+    cairo_surface_t *surface = NULL;
+
+    g_return_val_if_fail (display != NULL, NULL);
+
+    screen   = gdk_display_get_default_screen (display);
+    xdisplay = GDK_DISPLAY_XDISPLAY (display);
+    xvisual  = GDK_VISUAL_XVISUAL (gdk_screen_get_system_visual (screen));
+    xroot    = RootWindow (xdisplay, GDK_SCREEN_XNUMBER (screen));
+
+    result = XGetWindowProperty (xdisplay, xroot,
+                                 gdk_x11_get_xatom_by_name ("_XROOTPMAP_ID"),
+                                 0L, 1L, False, XA_PIXMAP,
+                                 &type, &format, &nitems, &bytes_after,
+                                 &data);
+
+    if (result != Success || type != XA_PIXMAP ||
+        format != 32 || nitems != 1) {
+        XFree (data);
+        data = NULL;
+    }
+
+    if (data != NULL) {
+        Pixmap pixmap = *(Pixmap *) data;
+        Window root_ret;
+        int x_ret, y_ret;
+        unsigned int w_ret, h_ret, bw_ret, depth_ret;
+
+        gdk_x11_display_error_trap_push (display);
+        if (XGetGeometry (xdisplay, pixmap, &root_ret,
+                          &x_ret, &y_ret, &w_ret, &h_ret,
+                          &bw_ret, &depth_ret))
+        {
+            surface = cairo_xlib_surface_create (xdisplay,
+                                                 pixmap, xvisual,
+                                                 w_ret, h_ret);
+        }
+
+        gdk_x11_display_error_trap_pop_ignored (display);
+        XFree (data);
+    }
+
+    gdk_display_flush (display);
+    return surface;
+}
+
+/**
+ * mate_bg_crossfade_start:
+ * @fade: a #MateBGCrossfade
+ * @window: The #GdkWindow to draw crossfade on
+ *
+ * This function initiates a quick crossfade between two surfaces on
+ * the background of @window. Before initiating the crossfade both
+ * mate_bg_crossfade_set_start_surface() and
+ * mate_bg_crossfade_set_end_surface() need to be called. If animations
+ * are disabled, the crossfade is skipped, and the window background is
+ * set immediately to the end surface.
+ **/
+void
+mate_bg_crossfade_start (MateBGCrossfade *fade,
+                         GdkWindow       *window)
+{
+    GSource *source;
+    GMainContext *context;
+
+    g_return_if_fail (MATE_IS_BG_CROSSFADE (fade));
+    g_return_if_fail (window != NULL);
+    g_return_if_fail (fade->priv->start_surface != NULL);
+    g_return_if_fail (fade->priv->end_surface != NULL);
+    g_return_if_fail (!mate_bg_crossfade_is_started (fade));
+    g_return_if_fail (gdk_window_get_window_type (window) != GDK_WINDOW_FOREIGN);
+
+    /* If drawing is done on the root window,
+     * it is essential to have the root pixmap.
+     */
+    if (gdk_window_get_window_type (window) == GDK_WINDOW_ROOT) {
+        GdkDisplay *display = gdk_window_get_display (window);
+        cairo_surface_t *surface = get_root_pixmap_id_surface (display);
+
+        g_return_if_fail (surface != NULL);
+        cairo_surface_destroy (surface);
+    }
+
+    if (fade->priv->fading_surface != NULL) {
+        cairo_surface_destroy (fade->priv->fading_surface);
+        fade->priv->fading_surface = NULL;
+    }
+
+    fade->priv->window = window;
+    if (gdk_window_get_window_type (fade->priv->window) != GDK_WINDOW_ROOT) {
+        fade->priv->fading_surface = tile_surface (fade->priv->start_surface,
+                                                   fade->priv->width,
+                                                   fade->priv->height);
+        if (fade->priv->widget != NULL) {
+            g_signal_connect (fade->priv->widget, "draw",
+                              (GCallback) on_widget_draw, fade);
+        }
+    } else {
+        cairo_t   *cr;
+        GdkDisplay *display = gdk_window_get_display (fade->priv->window);
+
+        fade->priv->fading_surface = get_root_pixmap_id_surface (display);
+        cr = cairo_create (fade->priv->fading_surface);
+        cairo_set_source_surface (cr, fade->priv->start_surface, 0, 0);
+        cairo_paint (cr);
+        cairo_destroy (cr);
+    }
+    draw_background (fade);
+
+    source = g_timeout_source_new (1000 / 60.0);
+    g_source_set_callback (source,
+                           (GSourceFunc) on_tick,
+                           fade,
+                           (GDestroyNotify) on_finished);
+    context = g_main_context_default ();
+    fade->priv->timeout_id = g_source_attach (source, context);
+    g_source_unref (source);
+
+    fade->priv->is_first_frame = TRUE;
+    fade->priv->total_duration = .75;
+    fade->priv->start_time = get_current_time ();
+}
+
+/**
+ * mate_bg_crossfade_start_widget:
+ * @fade: a #MateBGCrossfade
+ * @widget: The #GtkWidget to draw crossfade on
+ *
+ * This function initiates a quick crossfade between two surfaces on
+ * the background of @widget. Before initiating the crossfade both
+ * mate_bg_crossfade_set_start_surface() and
+ * mate_bg_crossfade_set_end_surface() need to be called. If animations
+ * are disabled, the crossfade is skipped, and the window background is
+ * set immediately to the end surface.
+ **/
+void
+mate_bg_crossfade_start_widget (MateBGCrossfade *fade,
+                                GtkWidget       *widget)
+{
+    GdkWindow *window;
+
+    g_return_if_fail (MATE_IS_BG_CROSSFADE (fade));
+    g_return_if_fail (widget != NULL);
+
+    fade->priv->widget = widget;
+    gtk_widget_realize (fade->priv->widget);
+    window = gtk_widget_get_window (fade->priv->widget);
+
+    mate_bg_crossfade_start (fade, window);
+}
+
+/**
+ * mate_bg_crossfade_is_started:
+ * @fade: a #MateBGCrossfade
+ *
+ * This function reveals whether or not @fade is currently
+ * running on a window.  See mate_bg_crossfade_start() for
+ * information on how to initiate a crossfade.
+ *
+ * Return value: %TRUE if fading, or %FALSE if not fading
+ **/
+gboolean
+mate_bg_crossfade_is_started (MateBGCrossfade *fade)
+{
+    g_return_val_if_fail (MATE_IS_BG_CROSSFADE (fade), FALSE);
+
+    return fade->priv->timeout_id != 0;
+}
+
+/**
+ * mate_bg_crossfade_stop:
+ * @fade: a #MateBGCrossfade
+ *
+ * This function stops any in progress crossfades that may be
+ * happening.  It's harmless to call this function if @fade is
+ * already stopped.
+ **/
+void
+mate_bg_crossfade_stop (MateBGCrossfade *fade)
+{
+    g_return_if_fail (MATE_IS_BG_CROSSFADE (fade));
+
+    if (!mate_bg_crossfade_is_started (fade))
+        return;
+
+    g_assert (fade->priv->timeout_id != 0);
+    g_source_remove (fade->priv->timeout_id);
+    fade->priv->timeout_id = 0;
+}
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/80.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/80.html new file mode 100644 index 0000000..c5f0379 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/80.html @@ -0,0 +1,391 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __GPMPHONE_H
+#define __GPMPHONE_H
+
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+G_BEGIN_DECLS
+
+#define GPM_TYPE_PHONE		(gpm_phone_get_type ())
+#define GPM_PHONE(o)		(G_TYPE_CHECK_INSTANCE_CAST ((o), GPM_TYPE_PHONE, GpmPhone))
+#define GPM_PHONE_CLASS(k)	(G_TYPE_CHECK_CLASS_CAST((k), GPM_TYPE_PHONE, GpmPhoneClass))
+#define GPM_IS_PHONE(o)		(G_TYPE_CHECK_INSTANCE_TYPE ((o), GPM_TYPE_PHONE))
+#define GPM_IS_PHONE_CLASS(k)	(G_TYPE_CHECK_CLASS_TYPE ((k), GPM_TYPE_PHONE))
+#define GPM_PHONE_GET_CLASS(o)	(G_TYPE_INSTANCE_GET_CLASS ((o), GPM_TYPE_PHONE, GpmPhoneClass))
+
+#define MATE_PHONE_MANAGER_DBUS_SERVICE	"org.gnome.phone"
+#define MATE_PHONE_MANAGER_DBUS_PATH		"/org/gnome/phone/Manager"
+#define MATE_PHONE_MANAGER_DBUS_INTERFACE	"org.gnome.phone.Manager"
+
+typedef struct GpmPhonePrivate GpmPhonePrivate;
+
+typedef struct
+{
+	GObject		       parent;
+	GpmPhonePrivate *priv;
+} GpmPhone;
+
+typedef struct
+{
+	GObjectClass	parent_class;
+	void		(* device_added)		(GpmPhone	*phone,
+							 guint		 idx);
+	void		(* device_removed)		(GpmPhone	*phone,
+							 guint		 idx);
+	void		(* device_refresh)		(GpmPhone	*phone,
+							 guint		 idx);
+} GpmPhoneClass;
+
+GType		 gpm_phone_get_type			(void);
+GpmPhone	*gpm_phone_new				(void);
+
+gboolean	 gpm_phone_get_present			(GpmPhone	*phone,
+							 guint		 idx);
+guint		 gpm_phone_get_percentage		(GpmPhone	*phone,
+							 guint		 idx);
+gboolean	 gpm_phone_get_on_ac			(GpmPhone	*phone,
+							 guint		 idx);
+guint		 gpm_phone_get_num_batteries		(GpmPhone	*phone);
+gboolean	 gpm_phone_coldplug			(GpmPhone	*phone);
+#ifdef EGG_TEST
+void		 gpm_phone_test				(gpointer	 data);
+#endif
+
+G_END_DECLS
+
+#endif	/* __GPMPHONE_H */
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/81.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/81.html new file mode 100644 index 0000000..650e793 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/81.html @@ -0,0 +1,2597 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
   1
+   2
+   3
+   4
+   5
+   6
+   7
+   8
+   9
+  10
+  11
+  12
+  13
+  14
+  15
+  16
+  17
+  18
+  19
+  20
+  21
+  22
+  23
+  24
+  25
+  26
+  27
+  28
+  29
+  30
+  31
+  32
+  33
+  34
+  35
+  36
+  37
+  38
+  39
+  40
+  41
+  42
+  43
+  44
+  45
+  46
+  47
+  48
+  49
+  50
+  51
+  52
+  53
+  54
+  55
+  56
+  57
+  58
+  59
+  60
+  61
+  62
+  63
+  64
+  65
+  66
+  67
+  68
+  69
+  70
+  71
+  72
+  73
+  74
+  75
+  76
+  77
+  78
+  79
+  80
+  81
+  82
+  83
+  84
+  85
+  86
+  87
+  88
+  89
+  90
+  91
+  92
+  93
+  94
+  95
+  96
+  97
+  98
+  99
+ 100
+ 101
+ 102
+ 103
+ 104
+ 105
+ 106
+ 107
+ 108
+ 109
+ 110
+ 111
+ 112
+ 113
+ 114
+ 115
+ 116
+ 117
+ 118
+ 119
+ 120
+ 121
+ 122
+ 123
+ 124
+ 125
+ 126
+ 127
+ 128
+ 129
+ 130
+ 131
+ 132
+ 133
+ 134
+ 135
+ 136
+ 137
+ 138
+ 139
+ 140
+ 141
+ 142
+ 143
+ 144
+ 145
+ 146
+ 147
+ 148
+ 149
+ 150
+ 151
+ 152
+ 153
+ 154
+ 155
+ 156
+ 157
+ 158
+ 159
+ 160
+ 161
+ 162
+ 163
+ 164
+ 165
+ 166
+ 167
+ 168
+ 169
+ 170
+ 171
+ 172
+ 173
+ 174
+ 175
+ 176
+ 177
+ 178
+ 179
+ 180
+ 181
+ 182
+ 183
+ 184
+ 185
+ 186
+ 187
+ 188
+ 189
+ 190
+ 191
+ 192
+ 193
+ 194
+ 195
+ 196
+ 197
+ 198
+ 199
+ 200
+ 201
+ 202
+ 203
+ 204
+ 205
+ 206
+ 207
+ 208
+ 209
+ 210
+ 211
+ 212
+ 213
+ 214
+ 215
+ 216
+ 217
+ 218
+ 219
+ 220
+ 221
+ 222
+ 223
+ 224
+ 225
+ 226
+ 227
+ 228
+ 229
+ 230
+ 231
+ 232
+ 233
+ 234
+ 235
+ 236
+ 237
+ 238
+ 239
+ 240
+ 241
+ 242
+ 243
+ 244
+ 245
+ 246
+ 247
+ 248
+ 249
+ 250
+ 251
+ 252
+ 253
+ 254
+ 255
+ 256
+ 257
+ 258
+ 259
+ 260
+ 261
+ 262
+ 263
+ 264
+ 265
+ 266
+ 267
+ 268
+ 269
+ 270
+ 271
+ 272
+ 273
+ 274
+ 275
+ 276
+ 277
+ 278
+ 279
+ 280
+ 281
+ 282
+ 283
+ 284
+ 285
+ 286
+ 287
+ 288
+ 289
+ 290
+ 291
+ 292
+ 293
+ 294
+ 295
+ 296
+ 297
+ 298
+ 299
+ 300
+ 301
+ 302
+ 303
+ 304
+ 305
+ 306
+ 307
+ 308
+ 309
+ 310
+ 311
+ 312
+ 313
+ 314
+ 315
+ 316
+ 317
+ 318
+ 319
+ 320
+ 321
+ 322
+ 323
+ 324
+ 325
+ 326
+ 327
+ 328
+ 329
+ 330
+ 331
+ 332
+ 333
+ 334
+ 335
+ 336
+ 337
+ 338
+ 339
+ 340
+ 341
+ 342
+ 343
+ 344
+ 345
+ 346
+ 347
+ 348
+ 349
+ 350
+ 351
+ 352
+ 353
+ 354
+ 355
+ 356
+ 357
+ 358
+ 359
+ 360
+ 361
+ 362
+ 363
+ 364
+ 365
+ 366
+ 367
+ 368
+ 369
+ 370
+ 371
+ 372
+ 373
+ 374
+ 375
+ 376
+ 377
+ 378
+ 379
+ 380
+ 381
+ 382
+ 383
+ 384
+ 385
+ 386
+ 387
+ 388
+ 389
+ 390
+ 391
+ 392
+ 393
+ 394
+ 395
+ 396
+ 397
+ 398
+ 399
+ 400
+ 401
+ 402
+ 403
+ 404
+ 405
+ 406
+ 407
+ 408
+ 409
+ 410
+ 411
+ 412
+ 413
+ 414
+ 415
+ 416
+ 417
+ 418
+ 419
+ 420
+ 421
+ 422
+ 423
+ 424
+ 425
+ 426
+ 427
+ 428
+ 429
+ 430
+ 431
+ 432
+ 433
+ 434
+ 435
+ 436
+ 437
+ 438
+ 439
+ 440
+ 441
+ 442
+ 443
+ 444
+ 445
+ 446
+ 447
+ 448
+ 449
+ 450
+ 451
+ 452
+ 453
+ 454
+ 455
+ 456
+ 457
+ 458
+ 459
+ 460
+ 461
+ 462
+ 463
+ 464
+ 465
+ 466
+ 467
+ 468
+ 469
+ 470
+ 471
+ 472
+ 473
+ 474
+ 475
+ 476
+ 477
+ 478
+ 479
+ 480
+ 481
+ 482
+ 483
+ 484
+ 485
+ 486
+ 487
+ 488
+ 489
+ 490
+ 491
+ 492
+ 493
+ 494
+ 495
+ 496
+ 497
+ 498
+ 499
+ 500
+ 501
+ 502
+ 503
+ 504
+ 505
+ 506
+ 507
+ 508
+ 509
+ 510
+ 511
+ 512
+ 513
+ 514
+ 515
+ 516
+ 517
+ 518
+ 519
+ 520
+ 521
+ 522
+ 523
+ 524
+ 525
+ 526
+ 527
+ 528
+ 529
+ 530
+ 531
+ 532
+ 533
+ 534
+ 535
+ 536
+ 537
+ 538
+ 539
+ 540
+ 541
+ 542
+ 543
+ 544
+ 545
+ 546
+ 547
+ 548
+ 549
+ 550
+ 551
+ 552
+ 553
+ 554
+ 555
+ 556
+ 557
+ 558
+ 559
+ 560
+ 561
+ 562
+ 563
+ 564
+ 565
+ 566
+ 567
+ 568
+ 569
+ 570
+ 571
+ 572
+ 573
+ 574
+ 575
+ 576
+ 577
+ 578
+ 579
+ 580
+ 581
+ 582
+ 583
+ 584
+ 585
+ 586
+ 587
+ 588
+ 589
+ 590
+ 591
+ 592
+ 593
+ 594
+ 595
+ 596
+ 597
+ 598
+ 599
+ 600
+ 601
+ 602
+ 603
+ 604
+ 605
+ 606
+ 607
+ 608
+ 609
+ 610
+ 611
+ 612
+ 613
+ 614
+ 615
+ 616
+ 617
+ 618
+ 619
+ 620
+ 621
+ 622
+ 623
+ 624
+ 625
+ 626
+ 627
+ 628
+ 629
+ 630
+ 631
+ 632
+ 633
+ 634
+ 635
+ 636
+ 637
+ 638
+ 639
+ 640
+ 641
+ 642
+ 643
+ 644
+ 645
+ 646
+ 647
+ 648
+ 649
+ 650
+ 651
+ 652
+ 653
+ 654
+ 655
+ 656
+ 657
+ 658
+ 659
+ 660
+ 661
+ 662
+ 663
+ 664
+ 665
+ 666
+ 667
+ 668
+ 669
+ 670
+ 671
+ 672
+ 673
+ 674
+ 675
+ 676
+ 677
+ 678
+ 679
+ 680
+ 681
+ 682
+ 683
+ 684
+ 685
+ 686
+ 687
+ 688
+ 689
+ 690
+ 691
+ 692
+ 693
+ 694
+ 695
+ 696
+ 697
+ 698
+ 699
+ 700
+ 701
+ 702
+ 703
+ 704
+ 705
+ 706
+ 707
+ 708
+ 709
+ 710
+ 711
+ 712
+ 713
+ 714
+ 715
+ 716
+ 717
+ 718
+ 719
+ 720
+ 721
+ 722
+ 723
+ 724
+ 725
+ 726
+ 727
+ 728
+ 729
+ 730
+ 731
+ 732
+ 733
+ 734
+ 735
+ 736
+ 737
+ 738
+ 739
+ 740
+ 741
+ 742
+ 743
+ 744
+ 745
+ 746
+ 747
+ 748
+ 749
+ 750
+ 751
+ 752
+ 753
+ 754
+ 755
+ 756
+ 757
+ 758
+ 759
+ 760
+ 761
+ 762
+ 763
+ 764
+ 765
+ 766
+ 767
+ 768
+ 769
+ 770
+ 771
+ 772
+ 773
+ 774
+ 775
+ 776
+ 777
+ 778
+ 779
+ 780
+ 781
+ 782
+ 783
+ 784
+ 785
+ 786
+ 787
+ 788
+ 789
+ 790
+ 791
+ 792
+ 793
+ 794
+ 795
+ 796
+ 797
+ 798
+ 799
+ 800
+ 801
+ 802
+ 803
+ 804
+ 805
+ 806
+ 807
+ 808
+ 809
+ 810
+ 811
+ 812
+ 813
+ 814
+ 815
+ 816
+ 817
+ 818
+ 819
+ 820
+ 821
+ 822
+ 823
+ 824
+ 825
+ 826
+ 827
+ 828
+ 829
+ 830
+ 831
+ 832
+ 833
+ 834
+ 835
+ 836
+ 837
+ 838
+ 839
+ 840
+ 841
+ 842
+ 843
+ 844
+ 845
+ 846
+ 847
+ 848
+ 849
+ 850
+ 851
+ 852
+ 853
+ 854
+ 855
+ 856
+ 857
+ 858
+ 859
+ 860
+ 861
+ 862
+ 863
+ 864
+ 865
+ 866
+ 867
+ 868
+ 869
+ 870
+ 871
+ 872
+ 873
+ 874
+ 875
+ 876
+ 877
+ 878
+ 879
+ 880
+ 881
+ 882
+ 883
+ 884
+ 885
+ 886
+ 887
+ 888
+ 889
+ 890
+ 891
+ 892
+ 893
+ 894
+ 895
+ 896
+ 897
+ 898
+ 899
+ 900
+ 901
+ 902
+ 903
+ 904
+ 905
+ 906
+ 907
+ 908
+ 909
+ 910
+ 911
+ 912
+ 913
+ 914
+ 915
+ 916
+ 917
+ 918
+ 919
+ 920
+ 921
+ 922
+ 923
+ 924
+ 925
+ 926
+ 927
+ 928
+ 929
+ 930
+ 931
+ 932
+ 933
+ 934
+ 935
+ 936
+ 937
+ 938
+ 939
+ 940
+ 941
+ 942
+ 943
+ 944
+ 945
+ 946
+ 947
+ 948
+ 949
+ 950
+ 951
+ 952
+ 953
+ 954
+ 955
+ 956
+ 957
+ 958
+ 959
+ 960
+ 961
+ 962
+ 963
+ 964
+ 965
+ 966
+ 967
+ 968
+ 969
+ 970
+ 971
+ 972
+ 973
+ 974
+ 975
+ 976
+ 977
+ 978
+ 979
+ 980
+ 981
+ 982
+ 983
+ 984
+ 985
+ 986
+ 987
+ 988
+ 989
+ 990
+ 991
+ 992
+ 993
+ 994
+ 995
+ 996
+ 997
+ 998
+ 999
+1000
+1001
+1002
+1003
+1004
+1005
+1006
+1007
+1008
+1009
+1010
+1011
+1012
+1013
+1014
+1015
+1016
+1017
+1018
+1019
+1020
+1021
+1022
+1023
+1024
+1025
+1026
+1027
+1028
+1029
+1030
+1031
+1032
+1033
+1034
+1035
+1036
+1037
+1038
+1039
+1040
+1041
+1042
+1043
+1044
+1045
+1046
+1047
+1048
+1049
+1050
+1051
+1052
+1053
+1054
+1055
+1056
+1057
+1058
+1059
+1060
+1061
+1062
+1063
+1064
+1065
+1066
+1067
+1068
+1069
+1070
+1071
+1072
+1073
+1074
+1075
+1076
+1077
+1078
+1079
+1080
+1081
+1082
+1083
+1084
+1085
+1086
+1087
+1088
+1089
+1090
+1091
+1092
+1093
+1094
+1095
+1096
+1097
+1098
+1099
+1100
+1101
+1102
+1103
+1104
+1105
+1106
+1107
+1108
+1109
+1110
+1111
+1112
+1113
+1114
+1115
+1116
+1117
+1118
+1119
+1120
+1121
+1122
+1123
+1124
+1125
+1126
+1127
+1128
+1129
+1130
+1131
+1132
+1133
+1134
+1135
+1136
+1137
+1138
+1139
+1140
+1141
+1142
+1143
+1144
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2006-2007 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "config.h"<--- Include file: "config.h" not found.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <pango/pangocairo.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <math.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "gpm-common.h"
+#include "gpm-point-obj.h"
+#include "gpm-graph-widget.h"
+
+#include "egg-color.h"
+#include "egg-precision.h"
+
+#define GPM_GRAPH_WIDGET_FONT "Sans 8"
+
+struct GpmGraphWidgetPrivate
+{
+	gboolean		 use_grid;
+	gboolean		 use_legend;
+	gboolean		 autorange_x;
+	gboolean		 autorange_y;
+
+	GSList			*key_data; /* lines */
+
+	gint			 stop_x;
+	gint			 stop_y;
+	gint			 start_x;
+	gint			 start_y;
+	gint			 box_x; /* size of the white box, not the widget */
+	gint			 box_y;
+	gint			 box_width;
+	gint			 box_height;
+
+	gfloat			 unit_x; /* 10th width of graph */
+	gfloat			 unit_y; /* 10th width of graph */
+
+	GpmGraphWidgetType	 type_x;
+	GpmGraphWidgetType	 type_y;
+	gchar			*title;<--- struct member 'GpmGraphWidgetPrivate::title' is never used.
+
+	cairo_t			*cr;
+	PangoLayout 		*layout;
+
+	GPtrArray		*data_list;
+	GPtrArray		*plot_list;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (GpmGraphWidget, gpm_graph_widget, GTK_TYPE_DRAWING_AREA);
+
+static gboolean gpm_graph_widget_draw (GtkWidget *graph, cairo_t *cr);
+static void	gpm_graph_widget_finalize (GObject *object);
+
+enum
+{
+	PROP_0,
+	PROP_USE_LEGEND,
+	PROP_USE_GRID,
+	PROP_TYPE_X,
+	PROP_TYPE_Y,
+	PROP_AUTORANGE_X,
+	PROP_AUTORANGE_Y,
+	PROP_START_X,
+	PROP_START_Y,
+	PROP_STOP_X,
+	PROP_STOP_Y,
+};
+
+/**
+ * gpm_graph_widget_key_data_clear:
+ **/
+static gboolean
+gpm_graph_widget_key_data_clear (GpmGraphWidget *graph)
+{
+	GpmGraphWidgetKeyData *keyitem;
+	guint i;
+
+	g_return_val_if_fail (GPM_IS_GRAPH_WIDGET (graph), FALSE);
+
+	/* remove items in list and free */
+	for (i=0; i<g_slist_length (graph->priv->key_data); i++) {
+		keyitem = (GpmGraphWidgetKeyData *) g_slist_nth_data (graph->priv->key_data, i);
+		g_free (keyitem->desc);
+		g_free (keyitem);
+	}
+	g_slist_free (graph->priv->key_data);
+	graph->priv->key_data = NULL;
+
+	return TRUE;
+}
+
+/**
+ * gpm_graph_widget_key_data_add:
+ **/
+gboolean
+gpm_graph_widget_key_data_add (GpmGraphWidget *graph, guint32 color, const gchar *desc)
+{
+	GpmGraphWidgetKeyData *keyitem;
+
+	g_return_val_if_fail (GPM_IS_GRAPH_WIDGET (graph), FALSE);
+
+	g_debug ("add to list %s", desc);
+	keyitem = g_new0 (GpmGraphWidgetKeyData, 1);
+
+	keyitem->color = color;
+	keyitem->desc = g_strdup (desc);
+
+	graph->priv->key_data = g_slist_append (graph->priv->key_data, (gpointer) keyitem);
+	return TRUE;
+}
+
+/**
+ * up_graph_get_property:
+ **/
+static void
+up_graph_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+{
+	GpmGraphWidget *graph = GPM_GRAPH_WIDGET (object);
+	switch (prop_id) {
+	case PROP_USE_LEGEND:
+		g_value_set_boolean (value, graph->priv->use_legend);
+		break;
+	case PROP_USE_GRID:
+		g_value_set_boolean (value, graph->priv->use_grid);
+		break;
+	case PROP_TYPE_X:
+		g_value_set_uint (value, graph->priv->type_x);
+		break;
+	case PROP_TYPE_Y:
+		g_value_set_uint (value, graph->priv->type_y);
+		break;
+	case PROP_AUTORANGE_X:
+		g_value_set_boolean (value, graph->priv->autorange_x);
+		break;
+	case PROP_AUTORANGE_Y:
+		g_value_set_boolean (value, graph->priv->autorange_y);
+		break;
+	case PROP_START_X:
+		g_value_set_int (value, graph->priv->start_x);
+		break;
+	case PROP_START_Y:
+		g_value_set_int (value, graph->priv->start_y);
+		break;
+	case PROP_STOP_X:
+		g_value_set_int (value, graph->priv->stop_x);
+		break;
+	case PROP_STOP_Y:
+		g_value_set_int (value, graph->priv->stop_y);
+		break;
+	default:
+		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+		break;
+	}
+}
+
+/**
+ * up_graph_set_property:
+ **/
+static void
+up_graph_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+{
+	GpmGraphWidget *graph = GPM_GRAPH_WIDGET (object);
+
+	switch (prop_id) {
+	case PROP_USE_LEGEND:
+		graph->priv->use_legend = g_value_get_boolean (value);
+		break;
+	case PROP_USE_GRID:
+		graph->priv->use_grid = g_value_get_boolean (value);
+		break;
+	case PROP_TYPE_X:
+		graph->priv->type_x = g_value_get_uint (value);
+		break;
+	case PROP_TYPE_Y:
+		graph->priv->type_y = g_value_get_uint (value);
+		break;
+	case PROP_AUTORANGE_X:
+		graph->priv->autorange_x = g_value_get_boolean (value);
+		break;
+	case PROP_AUTORANGE_Y:
+		graph->priv->autorange_y = g_value_get_boolean (value);
+		break;
+	case PROP_START_X:
+		graph->priv->start_x = g_value_get_int (value);
+		break;
+	case PROP_START_Y:
+		graph->priv->start_y = g_value_get_int (value);
+		break;
+	case PROP_STOP_X:
+		graph->priv->stop_x = g_value_get_int (value);
+		break;
+	case PROP_STOP_Y:
+		graph->priv->stop_y = g_value_get_int (value);
+		break;
+	default:
+		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+		break;
+	}
+
+	/* refresh widget */
+	gtk_widget_hide (GTK_WIDGET (graph));
+	gtk_widget_show (GTK_WIDGET (graph));
+}
+
+/**
+ * gpm_graph_widget_class_init:
+ * @class: This graph class instance
+ **/
+static void
+gpm_graph_widget_class_init (GpmGraphWidgetClass *class)
+{
+	GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
+	GObjectClass *object_class = G_OBJECT_CLASS (class);
+
+	widget_class->draw = gpm_graph_widget_draw;
+	object_class->get_property = up_graph_get_property;
+	object_class->set_property = up_graph_set_property;
+	object_class->finalize = gpm_graph_widget_finalize;
+
+	/* properties */
+	g_object_class_install_property (object_class,
+					 PROP_USE_LEGEND,
+					 g_param_spec_boolean ("use-legend", NULL, NULL,
+							       FALSE,
+							       G_PARAM_READWRITE));
+	g_object_class_install_property (object_class,
+					 PROP_USE_GRID,
+					 g_param_spec_boolean ("use-grid", NULL, NULL,
+							       TRUE,
+							       G_PARAM_READWRITE));
+	g_object_class_install_property (object_class,
+					 PROP_TYPE_X,
+					 g_param_spec_uint ("type-x", NULL, NULL,
+							    GPM_GRAPH_WIDGET_TYPE_INVALID,
+							    GPM_GRAPH_WIDGET_TYPE_UNKNOWN,
+							    GPM_GRAPH_WIDGET_TYPE_TIME,
+							    G_PARAM_READWRITE));
+	g_object_class_install_property (object_class,
+					 PROP_TYPE_Y,
+					 g_param_spec_uint ("type-y", NULL, NULL,
+							    GPM_GRAPH_WIDGET_TYPE_INVALID,
+							    GPM_GRAPH_WIDGET_TYPE_UNKNOWN,
+							    GPM_GRAPH_WIDGET_TYPE_PERCENTAGE,
+							    G_PARAM_READWRITE));
+	g_object_class_install_property (object_class,
+					 PROP_AUTORANGE_X,
+					 g_param_spec_boolean ("autorange-x", NULL, NULL,
+							       TRUE,
+							       G_PARAM_READWRITE));
+	g_object_class_install_property (object_class,
+					 PROP_AUTORANGE_Y,
+					 g_param_spec_boolean ("autorange-y", NULL, NULL,
+							       TRUE,
+							       G_PARAM_READWRITE));
+	g_object_class_install_property (object_class,
+					 PROP_START_X,
+					 g_param_spec_int ("start-x", NULL, NULL,
+							   G_MININT, G_MAXINT, 0,
+							   G_PARAM_READWRITE));
+	g_object_class_install_property (object_class,
+					 PROP_START_Y,
+					 g_param_spec_int ("start-y", NULL, NULL,
+							   G_MININT, G_MAXINT, 0,
+							   G_PARAM_READWRITE));
+	g_object_class_install_property (object_class,
+					 PROP_STOP_X,
+					 g_param_spec_int ("stop-x", NULL, NULL,
+							   G_MININT, G_MAXINT, 60,
+							   G_PARAM_READWRITE));
+	g_object_class_install_property (object_class,
+					 PROP_STOP_Y,
+					 g_param_spec_int ("stop-y", NULL, NULL,
+							   G_MININT, G_MAXINT, 100,
+							   G_PARAM_READWRITE));
+}
+
+/**
+ * gpm_graph_widget_init:
+ * @graph: This class instance
+ **/
+static void
+gpm_graph_widget_init (GpmGraphWidget *graph)
+{
+	PangoFontMap *fontmap;
+	PangoContext *context;
+	PangoFontDescription *desc;
+
+	graph->priv = gpm_graph_widget_get_instance_private (graph);
+	graph->priv->start_x = 0;
+	graph->priv->start_y = 0;
+	graph->priv->stop_x = 60;
+	graph->priv->stop_y = 100;
+	graph->priv->use_grid = TRUE;
+	graph->priv->use_legend = FALSE;
+	graph->priv->data_list = g_ptr_array_new_with_free_func ((GDestroyNotify) g_ptr_array_unref);
+	graph->priv->plot_list = g_ptr_array_new ();
+	graph->priv->key_data = NULL;
+	graph->priv->type_x = GPM_GRAPH_WIDGET_TYPE_TIME;
+	graph->priv->type_y = GPM_GRAPH_WIDGET_TYPE_PERCENTAGE;
+
+	/* do pango stuff */
+	fontmap = pango_cairo_font_map_get_default ();
+	context = pango_font_map_create_context (PANGO_FONT_MAP (fontmap));
+	pango_context_set_base_gravity (context, PANGO_GRAVITY_AUTO);
+
+	graph->priv->layout = pango_layout_new (context);
+	desc = pango_font_description_from_string (GPM_GRAPH_WIDGET_FONT);
+	pango_layout_set_font_description (graph->priv->layout, desc);
+	pango_font_description_free (desc);
+}
+
+/**
+ * gpm_graph_widget_data_clear:
+ **/
+gboolean
+gpm_graph_widget_data_clear (GpmGraphWidget *graph)
+{
+	g_return_val_if_fail (GPM_IS_GRAPH_WIDGET (graph), FALSE);
+
+	g_ptr_array_set_size (graph->priv->data_list, 0);
+	g_ptr_array_set_size (graph->priv->plot_list, 0);
+
+	return TRUE;
+}
+
+/**
+ * gpm_graph_widget_finalize:
+ * @object: This graph class instance
+ **/
+static void
+gpm_graph_widget_finalize (GObject *object)
+{
+	PangoContext *context;
+	GpmGraphWidget *graph = (GpmGraphWidget*) object;
+
+	/* clear key and data */
+	gpm_graph_widget_key_data_clear (graph);
+	gpm_graph_widget_data_clear (graph);
+
+	/* free data */
+	g_ptr_array_unref (graph->priv->data_list);
+	g_ptr_array_unref (graph->priv->plot_list);
+
+	context = pango_layout_get_context (graph->priv->layout);
+	g_object_unref (graph->priv->layout);
+	g_object_unref (context);
+	G_OBJECT_CLASS (gpm_graph_widget_parent_class)->finalize (object);
+}
+
+/**
+ * gpm_graph_widget_data_assign:
+ * @graph: This class instance
+ * @data: an array of GpmPointObj's
+ *
+ * Sets the data for the graph
+ **/
+gboolean
+gpm_graph_widget_data_assign (GpmGraphWidget *graph, GpmGraphWidgetPlot plot, GPtrArray *data)
+{
+	GPtrArray *copy;
+	GpmPointObj *obj;
+	guint i;
+
+	g_return_val_if_fail (data != NULL, FALSE);
+	g_return_val_if_fail (GPM_IS_GRAPH_WIDGET (graph), FALSE);
+
+	/* make a deep copy */
+	copy = g_ptr_array_new_with_free_func ((GDestroyNotify) gpm_point_obj_free);
+	for (i=0; i<data->len; i++) {
+		obj = gpm_point_obj_copy (g_ptr_array_index (data, i));
+		g_ptr_array_add (copy, obj);
+	}
+
+	/* get the new data */
+	g_ptr_array_add (graph->priv->data_list, copy);
+	g_ptr_array_add (graph->priv->plot_list, GUINT_TO_POINTER(plot));
+
+	/* refresh */
+	gtk_widget_queue_draw (GTK_WIDGET (graph));
+
+	return TRUE;
+}
+
+/**
+ * gpm_get_axis_label:
+ * @axis: The axis type, e.g. GPM_GRAPH_WIDGET_TYPE_TIME
+ * @value: The data value, e.g. 120
+ *
+ * Unit is:
+ * GPM_GRAPH_WIDGET_TYPE_TIME:		seconds
+ * GPM_GRAPH_WIDGET_TYPE_POWER: 	Wh (not Ah)
+ * GPM_GRAPH_WIDGET_TYPE_PERCENTAGE:	%
+ *
+ * Return value: a string value depending on the axis type and the value.
+ **/
+static gchar *
+gpm_get_axis_label (GpmGraphWidgetType axis, gfloat value)
+{
+	gchar *text = NULL;
+	if (axis == GPM_GRAPH_WIDGET_TYPE_TIME) {
+		gint time_s = abs((gint) value);
+		gint minutes = time_s / 60;
+		gint seconds = time_s - (minutes * 60);
+		gint hours = minutes / 60;
+		gint days = hours / 24;
+		minutes = minutes - (hours * 60);
+		hours = hours - (days * 24);
+		if (days > 0) {
+			if (hours == 0) {
+				/*Translators: This is %i days*/
+				text = g_strdup_printf (_("%id"), days);
+			} else {
+				/*Translators: This is %i days %02i hours*/
+				text = g_strdup_printf (_("%id%02ih"), days, hours);
+			}
+		} else if (hours > 0) {
+			if (minutes == 0) {
+				/*Translators: This is %i hours*/
+				text = g_strdup_printf (_("%ih"), hours);
+			} else {
+				/*Translators: This is %i hours %02i minutes*/
+				text = g_strdup_printf (_("%ih%02im"), hours, minutes);
+			}
+		} else if (minutes > 0) {
+			if (seconds == 0) {
+				/*Translators: This is %2i minutes*/
+				text = g_strdup_printf (_("%2im"), minutes);
+			} else {
+				/*Translators: This is %2i minutes %02i seconds*/
+				text = g_strdup_printf (_("%2im%02i"), minutes, seconds);
+			}
+		} else {
+			/*Translators: This is %2i seconds*/
+			text = g_strdup_printf (_("%2is"), seconds);
+		}
+	} else if (axis == GPM_GRAPH_WIDGET_TYPE_PERCENTAGE) {
+		/*Translators: This is %i Percentage*/
+		text = g_strdup_printf (_("%i%%"), (gint) value);
+	} else if (axis == GPM_GRAPH_WIDGET_TYPE_POWER) {
+		/*Translators: This is %.1f Watts*/
+		text = g_strdup_printf (_("%.1fW"), value);
+	} else if (axis == GPM_GRAPH_WIDGET_TYPE_FACTOR) {
+		text = g_strdup_printf ("%.1f", value);
+	} else if (axis == GPM_GRAPH_WIDGET_TYPE_VOLTAGE) {
+		/*Translators: This is %.1f Volts*/
+		text = g_strdup_printf (_("%.1fV"), value);
+	} else {
+		text = g_strdup_printf ("%i", (gint) value);
+	}
+	return text;
+}
+
+/**
+ * gpm_graph_widget_draw_grid:
+ * @graph: This class instance
+ * @cr: Cairo drawing context
+ *
+ * Draw the 10x10 dotted grid onto the graph.
+ **/
+static void
+gpm_graph_widget_draw_grid (GpmGraphWidget *graph, cairo_t *cr)
+{
+	guint i;
+	gfloat b;
+	gdouble dotted[] = {1., 2.};
+	gfloat divwidth  = (gfloat)graph->priv->box_width / 10.0f;
+	gfloat divheight = (gfloat)graph->priv->box_height / 10.0f;
+
+	cairo_save (cr);
+
+	cairo_set_line_width (cr, 1);
+	cairo_set_dash (cr, dotted, 2, 0.0);
+
+	/* do vertical lines */
+	cairo_set_source_rgb (cr, 0.1, 0.1, 0.1);
+	for (i=1; i<10; i++) {
+		b = graph->priv->box_x + ((gfloat) i * divwidth);
+		cairo_move_to (cr, (gint)b + 0.5f, graph->priv->box_y);
+		cairo_line_to (cr, (gint)b + 0.5f, graph->priv->box_y + graph->priv->box_height);
+		cairo_stroke (cr);
+	}
+
+	/* do horizontal lines */
+	for (i=1; i<10; i++) {
+		b = graph->priv->box_y + ((gfloat) i * divheight);
+		cairo_move_to (cr, graph->priv->box_x, (gint)b + 0.5f);
+		cairo_line_to (cr, graph->priv->box_x + graph->priv->box_width, (int)b + 0.5f);
+		cairo_stroke (cr);
+	}
+
+	cairo_restore (cr);
+}
+
+/**
+ * gpm_graph_widget_draw_labels:
+ * @graph: This class instance
+ * @cr: Cairo drawing context
+ *
+ * Draw the X and the Y labels onto the graph.
+ **/
+static void
+gpm_graph_widget_draw_labels (GpmGraphWidget *graph, cairo_t *cr)
+{
+	guint i;
+	gfloat b;
+	gchar *text;
+	gfloat value;
+	gfloat divwidth  = (gfloat)graph->priv->box_width / 10.0f;
+	gfloat divheight = (gfloat)graph->priv->box_height / 10.0f;
+	gint length_x = graph->priv->stop_x - graph->priv->start_x;
+	gint length_y = graph->priv->stop_y - graph->priv->start_y;
+	PangoRectangle ink_rect, logical_rect;
+	gfloat offsetx = 0;<--- Variable 'offsetx' is assigned a value that is never used.
+	gfloat offsety = 0;<--- Variable 'offsety' is assigned a value that is never used.
+
+	cairo_save (cr);
+
+	/* do x text */
+	cairo_set_source_rgb (cr, 0, 0, 0);
+	for (i=0; i<11; i++) {
+		b = graph->priv->box_x + ((gfloat) i * divwidth);
+		value = ((length_x / 10.0f) * (gfloat) i) + (gfloat) graph->priv->start_x;
+		text = gpm_get_axis_label (graph->priv->type_x, value);
+
+		pango_layout_set_text (graph->priv->layout, text, -1);
+		pango_layout_get_pixel_extents (graph->priv->layout, &ink_rect, &logical_rect);
+		/* have data points 0 and 10 bounded, but 1..9 centered */
+		if (i == 0)
+			offsetx = 2.0;
+		else if (i == 10)
+			offsetx = ink_rect.width;
+		else
+			offsetx = (ink_rect.width / 2.0f);
+
+		cairo_move_to (cr, b - offsetx,
+			       graph->priv->box_y + graph->priv->box_height + 2.0);
+
+		pango_cairo_show_layout (cr, graph->priv->layout);
+		g_free (text);
+	}
+
+	/* do y text */
+	for (i=0; i<11; i++) {
+		b = graph->priv->box_y + ((gfloat) i * divheight);
+		value = ((gfloat) length_y / 10.0f) * (10 - (gfloat) i) + graph->priv->start_y;
+		text = gpm_get_axis_label (graph->priv->type_y, value);
+
+		pango_layout_set_text (graph->priv->layout, text, -1);
+		pango_layout_get_pixel_extents (graph->priv->layout, &ink_rect, &logical_rect);
+
+		/* have data points 0 and 10 bounded, but 1..9 centered */
+		if (i == 10)
+			offsety = 0;
+		else if (i == 0)
+			offsety = ink_rect.height;
+		else
+			offsety = (ink_rect.height / 2.0f);
+		offsetx = ink_rect.width + 7;
+		offsety -= 10;
+		cairo_move_to (cr, graph->priv->box_x - offsetx - 2, b + offsety);
+		pango_cairo_show_layout (cr, graph->priv->layout);
+		g_free (text);
+	}
+
+	cairo_restore (cr);
+}
+
+/**
+ * gpm_graph_widget_get_y_label_max_width:
+ * @graph: This class instance
+ * @cr: Cairo drawing context
+ *
+ * Draw the X and the Y labels onto the graph.
+ **/
+static guint
+gpm_graph_widget_get_y_label_max_width (GpmGraphWidget *graph, cairo_t *cr)
+{
+	guint i;
+	gchar *text;
+	gint value;
+	gint length_y = graph->priv->stop_y - graph->priv->start_y;
+	PangoRectangle ink_rect, logical_rect;
+	guint biggest = 0;
+
+	/* do y text */
+	for (i=0; i<11; i++) {
+		value = (length_y / 10) * (10 - (gfloat) i) + graph->priv->start_y;
+		text = gpm_get_axis_label (graph->priv->type_y, value);
+		pango_layout_set_text (graph->priv->layout, text, -1);
+		pango_layout_get_pixel_extents (graph->priv->layout, &ink_rect, &logical_rect);
+		if (ink_rect.width > (gint) biggest)
+			biggest = ink_rect.width;
+		g_free (text);
+	}
+	return biggest;
+}
+
+/**
+ * gpm_graph_widget_autorange_x:
+ * @graph: This class instance
+ *
+ * Autoranges the graph axis depending on the axis type, and the maximum
+ * value of the data. We have to be careful to choose a number that gives good
+ * resolution but also a number that scales "well" to a 10x10 grid.
+ **/
+static void
+gpm_graph_widget_autorange_x (GpmGraphWidget *graph)
+{
+	gfloat biggest_x = G_MINFLOAT;
+	gfloat smallest_x = G_MAXFLOAT;
+	guint rounding_x = 1;
+	GPtrArray *data;
+	GpmPointObj *point;<--- Variable 'point' can be declared as pointer to const
+	guint i, j;
+	guint len = 0;
+	GPtrArray *array;
+
+	array = graph->priv->data_list;
+
+	/* find out if we have no data */
+	for (j=0; j<array->len; j++) {
+		data = g_ptr_array_index (array, j);
+		len = data->len;
+		if (len > 0)
+			break;
+	}
+
+	/* no data in any array */
+	if (len == 0) {
+		g_debug ("no data");
+		graph->priv->start_x = 0;
+		graph->priv->stop_x = 10;
+		return;
+	}
+
+	/* get the range for the graph */
+	for (j=0; j<array->len; j++) {
+		data = g_ptr_array_index (array, j);
+		for (i=0; i < data->len; i++) {
+			point = (GpmPointObj *) g_ptr_array_index (data, i);
+			if (point->x > biggest_x)
+				biggest_x = point->x;
+			if (point->x < smallest_x)
+				smallest_x = point->x;
+		}
+	}
+	g_debug ("Data range is %f<x<%f", smallest_x, biggest_x);
+	/* don't allow no difference */
+	if (biggest_x - smallest_x < 0.0001) {
+		biggest_x++;
+		smallest_x--;
+	}
+
+	if (graph->priv->type_x == GPM_GRAPH_WIDGET_TYPE_PERCENTAGE) {
+		rounding_x = 10;
+	} else if (graph->priv->type_x == GPM_GRAPH_WIDGET_TYPE_FACTOR) {
+		rounding_x = 1;
+	} else if (graph->priv->type_x == GPM_GRAPH_WIDGET_TYPE_POWER) {
+		rounding_x = 10;
+	} else if (graph->priv->type_x == GPM_GRAPH_WIDGET_TYPE_VOLTAGE) {
+		rounding_x = 1000;
+	} else if (graph->priv->type_x == GPM_GRAPH_WIDGET_TYPE_TIME) {
+		if (biggest_x-smallest_x < 150)
+			rounding_x = 150;
+		else if (biggest_x-smallest_x < 5*60)
+			rounding_x = 5 * 60;
+		else
+			rounding_x = 10 * 60;
+	}
+
+	graph->priv->start_x = egg_precision_round_down (smallest_x, rounding_x);
+	graph->priv->stop_x = egg_precision_round_up (biggest_x, rounding_x);
+
+	g_debug ("Processed(1) range is %i<x<%i",
+		   graph->priv->start_x, graph->priv->stop_x);
+
+	/* if percentage, and close to the end points, then extend */
+	if (graph->priv->type_x == GPM_GRAPH_WIDGET_TYPE_PERCENTAGE) {
+		if (graph->priv->stop_x >= 90)
+			graph->priv->stop_x = 100;
+		if (graph->priv->start_x > 0 && graph->priv->start_x <= 10)
+			graph->priv->start_x = 0;
+	} else if (graph->priv->type_x == GPM_GRAPH_WIDGET_TYPE_TIME) {
+		if (graph->priv->start_x > 0 && graph->priv->start_x <= 60*10)
+			graph->priv->start_x = 0;
+	}
+
+	g_debug ("Processed range is %i<x<%i",
+		   graph->priv->start_x, graph->priv->stop_x);
+}
+
+/**
+ * gpm_graph_widget_autorange_y:
+ * @graph: This class instance
+ *
+ * Autoranges the graph axis depending on the axis type, and the maximum
+ * value of the data. We have to be careful to choose a number that gives good
+ * resolution but also a number that scales "well" to a 10x10 grid.
+ **/
+static void
+gpm_graph_widget_autorange_y (GpmGraphWidget *graph)
+{
+	gfloat biggest_y = G_MINFLOAT;
+	gfloat smallest_y = G_MAXFLOAT;
+	guint rounding_y = 1;
+	GPtrArray *data;
+	GpmPointObj *point;<--- Variable 'point' can be declared as pointer to const
+	guint i, j;
+	guint len = 0;
+	GPtrArray *array;
+
+	array = graph->priv->data_list;
+
+	/* find out if we have no data */
+	for (j=0; j<array->len; j++) {
+		data = g_ptr_array_index (array, j);
+		len = data->len;
+		if (len > 0)
+			break;
+	}
+
+	/* no data in any array */
+	if (len == 0) {
+		g_debug ("no data");
+		graph->priv->start_y = 0;
+		graph->priv->stop_y = 10;
+		return;
+	}
+
+	/* get the range for the graph */
+	for (j=0; j<array->len; j++) {
+		data = g_ptr_array_index (array, j);
+		for (i=0; i < data->len; i++) {
+			point = (GpmPointObj *) g_ptr_array_index (data, i);
+			if (point->y > biggest_y)
+				biggest_y = point->y;
+			if (point->y < smallest_y)
+				smallest_y = point->y;
+		}
+	}
+	g_debug ("Data range is %f<y<%f", smallest_y, biggest_y);
+	/* don't allow no difference */
+	if (biggest_y - smallest_y < 0.0001) {
+		biggest_y++;
+		smallest_y--;
+	}
+
+	if (graph->priv->type_y == GPM_GRAPH_WIDGET_TYPE_PERCENTAGE) {
+		rounding_y = 10;
+	} else if (graph->priv->type_y == GPM_GRAPH_WIDGET_TYPE_FACTOR) {
+		rounding_y = 1;
+	} else if (graph->priv->type_y == GPM_GRAPH_WIDGET_TYPE_POWER) {
+		rounding_y = 10;
+	} else if (graph->priv->type_y == GPM_GRAPH_WIDGET_TYPE_VOLTAGE) {
+		rounding_y = 1000;
+	} else if (graph->priv->type_y == GPM_GRAPH_WIDGET_TYPE_TIME) {
+		if (biggest_y-smallest_y < 150)
+			rounding_y = 150;
+		else if (biggest_y < 5*60)
+			rounding_y = 5 * 60;
+		else
+			rounding_y = 10 * 60;
+	}
+
+	graph->priv->start_y = egg_precision_round_down (smallest_y, rounding_y);
+	graph->priv->stop_y = egg_precision_round_up (biggest_y, rounding_y);
+
+	/* a factor graph always is centered around zero */
+	if (graph->priv->type_y == GPM_GRAPH_WIDGET_TYPE_FACTOR) {
+		if (abs (graph->priv->stop_y) > abs (graph->priv->start_y))
+			graph->priv->start_y = -graph->priv->stop_y;
+		else
+			graph->priv->stop_y = -graph->priv->start_y;
+	}
+
+	g_debug ("Processed(1) range is %i<y<%i",
+		   graph->priv->start_y, graph->priv->stop_y);
+
+	if (graph->priv->type_y == GPM_GRAPH_WIDGET_TYPE_PERCENTAGE) {
+		if (graph->priv->stop_y >= 90)
+			graph->priv->stop_y = 100;
+		if (graph->priv->start_y > 0 && graph->priv->start_y <= 10)
+			graph->priv->start_y = 0;
+	} else if (graph->priv->type_y == GPM_GRAPH_WIDGET_TYPE_TIME) {
+		if (graph->priv->start_y <= 60*10)
+			graph->priv->start_y = 0;
+	}
+
+	g_debug ("Processed range is %i<y<%i",
+		   graph->priv->start_y, graph->priv->stop_y);
+}
+
+/**
+ * gpm_graph_widget_set_color:
+ * @cr: Cairo drawing context
+ * @color: The color enum
+ **/
+static void
+gpm_graph_widget_set_color (cairo_t *cr, guint32 color)
+{
+	guint8 r, g, b;
+	egg_color_to_rgb (color, &r, &g, &b);
+	cairo_set_source_rgb (cr, ((gdouble) r)/256.0f, ((gdouble) g)/256.0f, ((gdouble) b)/256.0f);
+}
+
+/**
+ * gpm_graph_widget_draw_legend_line:
+ * @cr: Cairo drawing context
+ * @x: The X-coordinate for the center
+ * @y: The Y-coordinate for the center
+ * @color: The color enum
+ *
+ * Draw the legend line on the graph of a specified color
+ **/
+static void
+gpm_graph_widget_draw_legend_line (cairo_t *cr, gfloat x, gfloat y, guint32 color)
+{
+	gfloat width = 10;
+	gfloat height = 2;<--- 'height' is assigned value '2' here.
+	/* background */
+	cairo_rectangle (cr, (int) (x - (width/2)) + 0.5, (int) (y - (height/2)) + 0.5, width, height);
+	gpm_graph_widget_set_color (cr, color);
+	cairo_fill (cr);
+	/* solid outline box */
+	cairo_rectangle (cr, (int) (x - (width/2)) + 0.5, (int) (y - (height/2)) + 0.5, width, height);
+	cairo_set_source_rgb (cr, 0.1, 0.1, 0.1);
+	cairo_set_line_width (cr, 1);
+	cairo_stroke (cr);
+}
+
+/**
+ * gpm_graph_widget_get_pos_on_graph:
+ * @graph: This class instance
+ * @data_x: The data X-coordinate
+ * @data_y: The data Y-coordinate
+ * @x: The returned X position on the cairo surface
+ * @y: The returned Y position on the cairo surface
+ **/
+static void
+gpm_graph_widget_get_pos_on_graph (GpmGraphWidget *graph, gfloat data_x, gfloat data_y, float *x, float *y)
+{
+	*x = graph->priv->box_x + (graph->priv->unit_x * (data_x - graph->priv->start_x)) + 1;
+	*y = graph->priv->box_y + (graph->priv->unit_y * (gfloat)(graph->priv->stop_y - data_y)) + 1.5;
+}
+
+/**
+ * gpm_graph_widget_draw_dot:
+ **/
+static void
+gpm_graph_widget_draw_dot (cairo_t *cr, gfloat x, gfloat y, guint32 color)
+{
+	gfloat width;
+	/* box */
+	width = 2.0;
+	cairo_rectangle (cr, (gint)x + 0.5f - (width/2), (gint)y + 0.5f - (width/2), width, width);
+	gpm_graph_widget_set_color (cr, color);
+	cairo_fill (cr);
+	cairo_rectangle (cr, (gint)x + 0.5f - (width/2), (gint)y + 0.5f - (width/2), width, width);
+	cairo_set_source_rgb (cr, 0, 0, 0);
+	cairo_set_line_width (cr, 1);
+	cairo_stroke (cr);
+}
+
+/**
+ * gpm_graph_widget_draw_line:
+ * @graph: This class instance
+ * @cr: Cairo drawing context
+ *
+ * Draw the data line onto the graph with a big green line. We should already
+ * limit the data to < ~100 values, so this shouldn't take too long.
+ **/
+static void
+gpm_graph_widget_draw_line (GpmGraphWidget *graph, cairo_t *cr)
+{
+	gfloat oldx, oldy;
+	gfloat newx, newy;
+	GPtrArray *data;
+	GPtrArray *array;
+	GpmGraphWidgetPlot plot;
+	GpmPointObj *point;
+	guint i, j;
+
+	if (graph->priv->data_list->len == 0) {
+		g_debug ("no data");
+		return;
+	}
+	cairo_save (cr);
+
+	array = graph->priv->data_list;
+
+	/* do each line */
+	for (j=0; j<array->len; j++) {
+		data = g_ptr_array_index (array, j);
+		if (data->len == 0)
+			continue;
+		plot = GPOINTER_TO_UINT (g_ptr_array_index (graph->priv->plot_list, j));
+
+		/* get the very first point so we can work out the old */
+		point = (GpmPointObj *) g_ptr_array_index (data, 0);
+		oldx = 0;
+		oldy = 0;
+		gpm_graph_widget_get_pos_on_graph (graph, point->x, point->y, &oldx, &oldy);
+		if (plot == GPM_GRAPH_WIDGET_PLOT_POINTS || plot == GPM_GRAPH_WIDGET_PLOT_BOTH)
+			gpm_graph_widget_draw_dot (cr, oldx, oldy, point->color);
+
+		for (i=1; i < data->len; i++) {
+			point = (GpmPointObj *) g_ptr_array_index (data, i);
+
+			gpm_graph_widget_get_pos_on_graph (graph, point->x, point->y, &newx, &newy);
+
+			/* ignore white lines */
+			if (point->color == 0xffffff) {
+				oldx = newx;
+				oldy = newy;
+				continue;
+			}
+
+			/* draw line */
+			if (plot == GPM_GRAPH_WIDGET_PLOT_LINE || plot == GPM_GRAPH_WIDGET_PLOT_BOTH) {
+				cairo_move_to (cr, oldx, oldy);
+				cairo_line_to (cr, newx, newy);
+				cairo_set_line_width (cr, 1.5);
+				gpm_graph_widget_set_color (cr, point->color);
+				cairo_stroke (cr);
+			}
+
+			/* draw data dot */
+			if (plot == GPM_GRAPH_WIDGET_PLOT_POINTS || plot == GPM_GRAPH_WIDGET_PLOT_BOTH)
+				gpm_graph_widget_draw_dot (cr, newx, newy, point->color);
+
+			/* save old */
+			oldx = newx;
+			oldy = newy;
+		}
+	}
+
+	cairo_restore (cr);
+}
+
+/**
+ * gpm_graph_widget_draw_bounding_box:
+ * @cr: Cairo drawing context
+ * @x: The X-coordinate for the top-left
+ * @y: The Y-coordinate for the top-left
+ * @width: The item width
+ * @height: The item height
+ **/
+static void
+gpm_graph_widget_draw_bounding_box (cairo_t *cr, gint x, gint y, gint width, gint height)
+{
+	/* background */
+	cairo_rectangle (cr, x, y, width, height);
+	cairo_set_source_rgb (cr, 1, 1, 1);
+	cairo_fill (cr);
+	/* solid outline box */
+	cairo_rectangle (cr, x + 0.5f, y + 0.5f, width - 1, height - 1);
+	cairo_set_source_rgb (cr, 0.1, 0.1, 0.1);
+	cairo_set_line_width (cr, 1);
+	cairo_stroke (cr);
+}
+
+/**
+ * gpm_graph_widget_draw_legend:
+ * @cr: Cairo drawing context
+ * @x: The X-coordinate for the top-left
+ * @y: The Y-coordinate for the top-left
+ * @width: The item width
+ * @height: The item height
+ **/
+static void
+gpm_graph_widget_draw_legend (GpmGraphWidget *graph, gint x, gint y, gint width, gint height)
+{
+	cairo_t *cr = graph->priv->cr;
+	gint y_count;
+	guint i;
+	GpmGraphWidgetKeyData *keydataitem;
+
+	gpm_graph_widget_draw_bounding_box (cr, x, y, width, height);
+	y_count = y + 10;
+
+	/* add the line colors to the legend */
+	for (i=0; i<g_slist_length (graph->priv->key_data); i++) {
+		keydataitem = (GpmGraphWidgetKeyData *) g_slist_nth_data (graph->priv->key_data, i);
+		if (keydataitem == NULL) {
+			/* this shouldn't ever happen */
+			g_warning ("keydataitem NULL!");
+			break;
+		}
+		gpm_graph_widget_draw_legend_line (cr, x + 8, y_count, keydataitem->color);
+		cairo_move_to (cr, x + 8 + 10, y_count - 6);
+		cairo_set_source_rgb (cr, 0, 0, 0);
+		pango_layout_set_text (graph->priv->layout, keydataitem->desc, -1);
+		pango_cairo_show_layout (cr, graph->priv->layout);
+		y_count = y_count + GPM_GRAPH_WIDGET_LEGEND_SPACING;
+	}
+}
+
+/**
+ * gpm_graph_widget_legend_calculate_width:
+ * @graph: This class instance
+ * @cr: Cairo drawing context
+ * Return value: The width of the legend, including borders.
+ *
+ * We have to find the maximum size of the text so we know the width of the
+ * legend box. We can't hardcode this as the dpi or font size might differ
+ * from machine to machine.
+ **/
+static gboolean
+gpm_graph_widget_legend_calculate_size (GpmGraphWidget *graph, cairo_t *cr,
+					guint *width, guint *height)
+{
+	guint i;
+	PangoRectangle ink_rect, logical_rect;
+	GpmGraphWidgetKeyData *keydataitem;
+
+	g_return_val_if_fail (GPM_IS_GRAPH_WIDGET (graph), FALSE);
+
+	/* set defaults */
+	*width = 0;
+	*height = 0;
+
+	/* add the line colors to the legend */
+	for (i=0; i<g_slist_length (graph->priv->key_data); i++) {
+		keydataitem = (GpmGraphWidgetKeyData *) g_slist_nth_data (graph->priv->key_data, i);
+		*height = *height + GPM_GRAPH_WIDGET_LEGEND_SPACING;
+		pango_layout_set_text (graph->priv->layout, keydataitem->desc, -1);
+		pango_layout_get_pixel_extents (graph->priv->layout, &ink_rect, &logical_rect);
+		if ((gint) *width < ink_rect.width)
+			*width = ink_rect.width;
+	}
+
+	/* have we got no entries? */
+	if (*width == 0 && *height == 0)
+		return TRUE;
+
+	/* add for borders */
+	*width += 25;
+	*height += 3;
+
+	return TRUE;
+}
+
+/**
+ * gpm_graph_widget_draw:
+ * @graph: This class instance
+ * @event: The expose event
+ *
+ * Just repaint the entire graph widget on expose.
+ **/
+static gboolean
+gpm_graph_widget_draw (GtkWidget *widget, cairo_t *cr)
+{
+	GtkAllocation allocation;
+	gint legend_x = 0;
+	gint legend_y = 0;
+	guint legend_height = 0;
+	guint legend_width = 0;
+	gfloat data_x;
+	gfloat data_y;
+
+	GpmGraphWidget *graph = (GpmGraphWidget*) widget;
+	g_return_val_if_fail (graph != NULL, FALSE);
+	g_return_val_if_fail (GPM_IS_GRAPH_WIDGET (graph), FALSE);
+
+	gpm_graph_widget_legend_calculate_size (graph, cr, &legend_width, &legend_height);
+	cairo_save (cr);
+
+	/* we need this so we know the y text */
+	if (graph->priv->autorange_x)
+		gpm_graph_widget_autorange_x (graph);
+	if (graph->priv->autorange_y)
+		gpm_graph_widget_autorange_y (graph);
+
+	graph->priv->box_x = gpm_graph_widget_get_y_label_max_width (graph, cr) + 10;
+	graph->priv->box_y = 5;
+
+	gtk_widget_get_allocation (widget, &allocation);
+	graph->priv->box_height = allocation.height - (20 + graph->priv->box_y);
+
+	/* make size adjustment for legend */
+	if (graph->priv->use_legend && legend_height > 0) {
+		graph->priv->box_width = allocation.width -
+					 (3 + legend_width + 5 + graph->priv->box_x);
+		legend_x = graph->priv->box_x + graph->priv->box_width + 6;
+		legend_y = graph->priv->box_y;
+	} else {
+		graph->priv->box_width = allocation.width -
+					 (3 + graph->priv->box_x);
+	}
+
+	/* graph background */
+	gpm_graph_widget_draw_bounding_box (cr, graph->priv->box_x, graph->priv->box_y,
+				     graph->priv->box_width, graph->priv->box_height);
+	if (graph->priv->use_grid)
+		gpm_graph_widget_draw_grid (graph, cr);
+
+	/* -3 is so we can keep the lines inside the box at both extremes */
+	data_x = graph->priv->stop_x - graph->priv->start_x;
+	data_y = graph->priv->stop_y - graph->priv->start_y;
+	graph->priv->unit_x = (float)(graph->priv->box_width - 3) / (float) data_x;
+	graph->priv->unit_y = (float)(graph->priv->box_height - 3) / (float) data_y;
+
+	gpm_graph_widget_draw_labels (graph, cr);
+	gpm_graph_widget_draw_line (graph, cr);
+
+	if (graph->priv->use_legend && legend_height > 0)
+		gpm_graph_widget_draw_legend (graph, legend_x, legend_y, legend_width, legend_height);
+
+	cairo_restore (cr);
+	return FALSE;
+}
+
+/**
+ * gpm_graph_widget_new:
+ * Return value: A new GpmGraphWidget object.
+ **/
+GtkWidget *
+gpm_graph_widget_new (void)
+{
+	return g_object_new (GPM_TYPE_GRAPH_WIDGET, NULL);
+}
+
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/82.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/82.html new file mode 100644 index 0000000..7e416d4 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/82.html @@ -0,0 +1,323 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifndef __GPM_POINT_OBJ_H__
+#define __GPM_POINT_OBJ_H__
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+G_BEGIN_DECLS
+
+typedef struct
+{
+	gfloat		 x;
+	gfloat		 y;
+	guint32		 color;
+} GpmPointObj;
+
+GpmPointObj	*gpm_point_obj_new		(void);
+GpmPointObj	*gpm_point_obj_copy		(const GpmPointObj	*cobj);
+void		 gpm_point_obj_free		(GpmPointObj		*obj);
+
+G_END_DECLS
+
+#endif /* __GPM_POINT_OBJ_H__ */
+
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/83.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/83.html new file mode 100644 index 0000000..5072a15 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/83.html @@ -0,0 +1,417 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+82
+83
+84
+85
+86
+87
+88
+89
+90
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2006-2007 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __GPM_GRAPH_WIDGET_H__
+#define __GPM_GRAPH_WIDGET_H__
+
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include "gpm-point-obj.h"
+
+G_BEGIN_DECLS
+
+#define GPM_TYPE_GRAPH_WIDGET		(gpm_graph_widget_get_type ())
+#define GPM_GRAPH_WIDGET(obj)		(G_TYPE_CHECK_INSTANCE_CAST ((obj), GPM_TYPE_GRAPH_WIDGET, GpmGraphWidget))
+#define GPM_GRAPH_WIDGET_CLASS(obj)	(G_TYPE_CHECK_CLASS_CAST ((obj), GPM_GRAPH_WIDGET, GpmGraphWidgetClass))
+#define GPM_IS_GRAPH_WIDGET(obj)	(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GPM_TYPE_GRAPH_WIDGET))
+#define GPM_IS_GRAPH_WIDGET_CLASS(obj)	(G_TYPE_CHECK_CLASS_TYPE ((obj), EFF_TYPE_GRAPH_WIDGET))
+#define GPM_GRAPH_WIDGET_GET_CLASS	(G_TYPE_INSTANCE_GET_CLASS ((obj), GPM_TYPE_GRAPH_WIDGET, GpmGraphWidgetClass))
+
+#define GPM_GRAPH_WIDGET_LEGEND_SPACING		17
+
+typedef struct GpmGraphWidget		GpmGraphWidget;
+typedef struct GpmGraphWidgetClass	GpmGraphWidgetClass;
+typedef struct GpmGraphWidgetPrivate	GpmGraphWidgetPrivate;
+
+typedef enum {
+	GPM_GRAPH_WIDGET_TYPE_INVALID,
+	GPM_GRAPH_WIDGET_TYPE_PERCENTAGE,
+	GPM_GRAPH_WIDGET_TYPE_FACTOR,
+	GPM_GRAPH_WIDGET_TYPE_TIME,
+	GPM_GRAPH_WIDGET_TYPE_POWER,
+	GPM_GRAPH_WIDGET_TYPE_VOLTAGE,
+	GPM_GRAPH_WIDGET_TYPE_UNKNOWN
+} GpmGraphWidgetType;
+
+typedef enum {
+	GPM_GRAPH_WIDGET_PLOT_LINE,
+	GPM_GRAPH_WIDGET_PLOT_POINTS,
+	GPM_GRAPH_WIDGET_PLOT_BOTH
+} GpmGraphWidgetPlot;
+
+/* the different kinds of lines in the key */
+typedef struct {
+	guint32			 color;
+	gchar			*desc;
+} GpmGraphWidgetKeyData;
+
+struct GpmGraphWidget
+{
+	GtkDrawingArea		 parent;
+	GpmGraphWidgetPrivate	*priv;
+};
+
+struct GpmGraphWidgetClass
+{
+	GtkDrawingAreaClass parent_class;
+};
+
+GType		 gpm_graph_widget_get_type		(void);
+GtkWidget	*gpm_graph_widget_new			(void);
+
+gboolean	 gpm_graph_widget_data_clear		(GpmGraphWidget		*graph);
+gboolean	 gpm_graph_widget_data_assign		(GpmGraphWidget		*graph,
+							 GpmGraphWidgetPlot	 plot,
+							 GPtrArray		*array);
+gboolean	 gpm_graph_widget_key_data_add		(GpmGraphWidget		*graph,
+							 guint32		 color,
+							 const gchar		*desc);
+
+G_END_DECLS
+
+#endif
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/84.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/84.html new file mode 100644 index 0000000..18aeca8 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/84.html @@ -0,0 +1,1705 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
+603
+604
+605
+606
+607
+608
+609
+610
+611
+612
+613
+614
+615
+616
+617
+618
+619
+620
+621
+622
+623
+624
+625
+626
+627
+628
+629
+630
+631
+632
+633
+634
+635
+636
+637
+638
+639
+640
+641
+642
+643
+644
+645
+646
+647
+648
+649
+650
+651
+652
+653
+654
+655
+656
+657
+658
+659
+660
+661
+662
+663
+664
+665
+666
+667
+668
+669
+670
+671
+672
+673
+674
+675
+676
+677
+678
+679
+680
+681
+682
+683
+684
+685
+686
+687
+688
+689
+690
+691
+692
+693
+694
+695
+696
+697
+698
+699
+700
+701
+702
+703
+704
+705
+706
+707
+708
+709
+710
+711
+712
+713
+714
+715
+716
+717
+718
+719
+720
+721
+722
+723
+724
+725
+726
+727
+728
+729
+730
+731
+732
+733
+734
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2005 William Jon McCann <mccann@jhu.edu>
+ * Copyright (C) 2005-2009 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "config.h"<--- Include file: "config.h" not found.
+
+#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <time.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <errno.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/time.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/types.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#ifdef HAVE_UNISTD_H
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif /* HAVE_UNISTD_H */
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "egg-idletime.h"
+
+#include "gpm-idle.h"
+#include "gpm-load.h"
+#include "gpm-session.h"
+
+/* Sets the idle percent limit, i.e. how hard the computer can work
+   while considered "at idle" */
+#define GPM_IDLE_CPU_LIMIT			5
+#define	GPM_IDLE_IDLETIME_ID			1
+
+struct GpmIdlePrivate
+{
+	EggIdletime	*idletime;
+	GpmLoad		*load;
+	GpmSession	*session;
+	GpmIdleMode	 mode;
+	guint		 timeout_dim;		/* in seconds */
+	guint		 timeout_blank;		/* in seconds */
+	guint		 timeout_sleep;		/* in seconds */
+	guint		 timeout_blank_id;
+	guint		 timeout_sleep_id;
+	gboolean	 x_idle;
+	gboolean	 check_type_cpu;
+};
+
+enum {
+	IDLE_CHANGED,
+	LAST_SIGNAL
+};
+
+static guint signals [LAST_SIGNAL] = { 0 };
+static gpointer gpm_idle_object = NULL;
+
+G_DEFINE_TYPE_WITH_PRIVATE (GpmIdle, gpm_idle, G_TYPE_OBJECT)<--- There is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
+
+/**
+ * gpm_idle_mode_to_string:
+ **/
+static const gchar *
+gpm_idle_mode_to_string (GpmIdleMode mode)
+{
+	if (mode == GPM_IDLE_MODE_NORMAL)
+		return "normal";
+	if (mode == GPM_IDLE_MODE_DIM)
+		return "dim";
+	if (mode == GPM_IDLE_MODE_BLANK)
+		return "blank";
+	if (mode == GPM_IDLE_MODE_SLEEP)
+		return "sleep";
+	return "unknown";
+}
+
+/**
+ * gpm_idle_set_mode:
+ * @mode: The new mode, e.g. GPM_IDLE_MODE_SLEEP
+ **/
+static void
+gpm_idle_set_mode (GpmIdle *idle, GpmIdleMode mode)
+{
+	g_return_if_fail (GPM_IS_IDLE (idle));
+
+	if (mode != idle->priv->mode) {
+		idle->priv->mode = mode;
+		g_debug ("Doing a state transition: %s", gpm_idle_mode_to_string (mode));
+		g_signal_emit (idle, signals [IDLE_CHANGED], 0, mode);
+	}
+}
+
+/**
+ * gpm_idle_set_check_cpu:
+ * @check_type_cpu: If we should check the CPU before mode becomes
+ *		    GPM_IDLE_MODE_SLEEP and the event is done.
+ **/
+void
+gpm_idle_set_check_cpu (GpmIdle *idle, gboolean check_type_cpu)
+{
+	g_return_if_fail (GPM_IS_IDLE (idle));
+	g_debug ("Setting the CPU load check to %i", check_type_cpu);
+	idle->priv->check_type_cpu = check_type_cpu;
+}
+
+/**
+ * gpm_idle_get_mode:
+ * Return value: The current mode, e.g. GPM_IDLE_MODE_SLEEP
+ **/
+GpmIdleMode
+gpm_idle_get_mode (GpmIdle *idle)
+{
+	return idle->priv->mode;
+}
+
+/**
+ * gpm_idle_blank_cb:
+ **/
+static gboolean
+gpm_idle_blank_cb (GpmIdle *idle)
+{
+	if (idle->priv->mode > GPM_IDLE_MODE_BLANK) {
+		g_debug ("ignoring current mode %s", gpm_idle_mode_to_string (idle->priv->mode));
+		return FALSE;
+	}
+	gpm_idle_set_mode (idle, GPM_IDLE_MODE_BLANK);
+	return FALSE;
+}
+
+/**
+ * gpm_idle_sleep_cb:
+ **/
+static gboolean
+gpm_idle_sleep_cb (GpmIdle *idle)
+{
+	gdouble load;
+	gboolean ret = FALSE;
+
+	/* get our computed load value */
+	if (idle->priv->check_type_cpu) {
+		load = gpm_load_get_current (idle->priv->load);
+		if (load > GPM_IDLE_CPU_LIMIT) {
+			/* check if system is "idle" enough */
+			g_debug ("Detected that the CPU is busy");
+			ret = TRUE;
+			goto out;
+		}
+	}
+	gpm_idle_set_mode (idle, GPM_IDLE_MODE_SLEEP);
+out:
+	return ret;
+}
+
+/**
+ * gpm_idle_evaluate:
+ **/
+static void
+gpm_idle_evaluate (GpmIdle *idle)
+{
+	gboolean is_idle;
+	gboolean is_idle_inhibited;
+	gboolean is_suspend_inhibited;
+
+	is_idle = gpm_session_get_idle (idle->priv->session);
+	is_idle_inhibited = gpm_session_get_idle_inhibited (idle->priv->session);
+	is_suspend_inhibited = gpm_session_get_suspend_inhibited (idle->priv->session);
+	g_debug ("session_idle=%i, idle_inhibited=%i, suspend_inhibited=%i, x_idle=%i", is_idle, is_idle_inhibited, is_suspend_inhibited, idle->priv->x_idle);
+
+	/* check we are really idle */
+	if (!idle->priv->x_idle) {
+		gpm_idle_set_mode (idle, GPM_IDLE_MODE_NORMAL);
+		g_debug ("X not idle");
+		if (idle->priv->timeout_blank_id != 0) {
+			g_source_remove (idle->priv->timeout_blank_id);
+			idle->priv->timeout_blank_id = 0;
+		}
+		if (idle->priv->timeout_sleep_id != 0) {
+			g_source_remove (idle->priv->timeout_sleep_id);
+			idle->priv->timeout_sleep_id = 0;
+		}
+		goto out;
+	}
+
+	/* are we inhibited from going idle */
+	if (is_idle_inhibited) {
+		g_debug ("inhibited, so using normal state");
+		gpm_idle_set_mode (idle, GPM_IDLE_MODE_NORMAL);
+		if (idle->priv->timeout_blank_id != 0) {
+			g_source_remove (idle->priv->timeout_blank_id);
+			idle->priv->timeout_blank_id = 0;
+		}
+		if (idle->priv->timeout_sleep_id != 0) {
+			g_source_remove (idle->priv->timeout_sleep_id);
+			idle->priv->timeout_sleep_id = 0;
+		}
+		goto out;
+	}
+
+	/* normal to dim */
+	if (idle->priv->mode == GPM_IDLE_MODE_NORMAL) {
+		g_debug ("normal to dim");
+		gpm_idle_set_mode (idle, GPM_IDLE_MODE_DIM);
+	}
+
+	/* set up blank callback even when session is not idle,
+	 * but only if we actually want to blank. */
+	if (idle->priv->timeout_blank_id == 0 &&
+	    idle->priv->timeout_blank != 0) {
+		g_debug ("setting up blank callback for %us", idle->priv->timeout_blank);
+		idle->priv->timeout_blank_id = g_timeout_add_seconds (idle->priv->timeout_blank,
+								      (GSourceFunc) gpm_idle_blank_cb, idle);
+		g_source_set_name_by_id (idle->priv->timeout_blank_id, "[GpmIdle] blank");
+	}
+
+	/* are we inhibited from sleeping */
+	if (is_suspend_inhibited) {
+		g_debug ("suspend inhibited");
+		if (idle->priv->timeout_sleep_id != 0) {
+			g_source_remove (idle->priv->timeout_sleep_id);
+			idle->priv->timeout_sleep_id = 0;
+		}
+	} else if (is_idle) {
+	/* only do the sleep timeout when the session is idle and we aren't inhibited from sleeping */
+		if (idle->priv->timeout_sleep_id == 0 &&
+		    idle->priv->timeout_sleep != 0) {
+			g_debug ("setting up sleep callback %us", idle->priv->timeout_sleep);
+			idle->priv->timeout_sleep_id = g_timeout_add_seconds (idle->priv->timeout_sleep,
+									      (GSourceFunc) gpm_idle_sleep_cb, idle);
+			g_source_set_name_by_id (idle->priv->timeout_sleep_id, "[GpmIdle] sleep");
+		}
+	}
+out:
+	return;
+}
+
+/**
+ *  gpm_idle_adjust_timeout_dim:
+ *  @idle_time: The new timeout we want to set, in seconds.
+ *  @timeout: Current idle time, in seconds.
+ *
+ *  On slow machines, or machines that have lots to load duing login,
+ *  the current idle time could be bigger than the requested timeout.
+ *  In this case the scheduled idle timeout will never fire, unless
+ *  some user activity (keyboard, mouse) resets the current idle time.
+ *  Instead of relying on user activity to correct this issue, we need
+ *  to adjust timeout, as related to current idle time, so the idle
+ *  timeout will fire as designed.
+ *
+ *  Return value: timeout to set, adjusted acccording to current idle time.
+ **/
+static guint
+gpm_idle_adjust_timeout_dim (guint idle_time, guint timeout)
+{
+	/* allow 2 sec margin for messaging delay. */
+	idle_time += 2;
+
+	/* Double timeout until it's larger than current idle time.
+	 * Give up for ultra slow machines. (86400 sec = 24 hours) */
+	while (timeout < idle_time && timeout < 86400 && timeout > 0) {
+		timeout *= 2;
+	}
+	return timeout;
+}
+
+/**
+ * gpm_idle_set_timeout_dim:
+ * @timeout: The new timeout we want to set, in seconds
+ **/
+gboolean
+gpm_idle_set_timeout_dim (GpmIdle *idle, guint timeout)
+{
+	gint64 idle_time_in_msec;
+	guint timeout_adjusted;
+
+	g_return_val_if_fail (GPM_IS_IDLE (idle), FALSE);
+
+	idle_time_in_msec = egg_idletime_get_time (idle->priv->idletime);
+	timeout_adjusted  = gpm_idle_adjust_timeout_dim (idle_time_in_msec / 1000, timeout);
+	g_debug ("Current idle time=%lldms, timeout was %us, becomes %us after adjustment",
+		   (long long int)idle_time_in_msec, timeout, timeout_adjusted);
+	timeout = timeout_adjusted;
+
+	g_debug ("Setting dim idle timeout: %us", timeout);
+	if (idle->priv->timeout_dim != timeout) {
+		idle->priv->timeout_dim = timeout;
+
+		if (timeout > 0)
+			egg_idletime_alarm_set (idle->priv->idletime, GPM_IDLE_IDLETIME_ID, timeout * 1000);
+		else
+			egg_idletime_alarm_remove (idle->priv->idletime, GPM_IDLE_IDLETIME_ID);
+	}
+	return TRUE;
+}
+
+/**
+ * gpm_idle_set_timeout_blank:
+ * @timeout: The new timeout we want to set, in seconds
+ **/
+gboolean
+gpm_idle_set_timeout_blank (GpmIdle *idle, guint timeout)
+{
+	g_return_val_if_fail (GPM_IS_IDLE (idle), FALSE);
+
+	g_debug ("Setting blank idle timeout: %us", timeout);
+	if (idle->priv->timeout_blank != timeout) {
+		idle->priv->timeout_blank = timeout;
+		gpm_idle_evaluate (idle);
+	}
+	return TRUE;
+}
+
+/**
+ * gpm_idle_set_timeout_sleep:
+ * @timeout: The new timeout we want to set, in seconds
+ **/
+gboolean
+gpm_idle_set_timeout_sleep (GpmIdle *idle, guint timeout)
+{
+	g_return_val_if_fail (GPM_IS_IDLE (idle), FALSE);
+
+	g_debug ("Setting sleep idle timeout: %us", timeout);
+	if (idle->priv->timeout_sleep != timeout) {
+		idle->priv->timeout_sleep = timeout;
+		gpm_idle_evaluate (idle);
+	}
+	return TRUE;
+}
+
+/**
+ * gpm_idle_session_idle_changed_cb:
+ * @is_idle: If the session is idle
+ *
+ * The SessionIdleChanged callback from mate-session.
+ **/
+static void
+gpm_idle_session_idle_changed_cb (GpmSession *session, gboolean is_idle, GpmIdle *idle)
+{
+	g_debug ("Received mate session idle changed: %i", is_idle);
+	idle->priv->x_idle = is_idle;
+	gpm_idle_evaluate (idle);
+}
+
+/**
+ * gpm_idle_session_inhibited_changed_cb:
+ **/
+static void
+gpm_idle_session_inhibited_changed_cb (GpmSession *session, gboolean is_idle_inhibited, gboolean is_suspend_inhibited, GpmIdle *idle)
+{
+	g_debug ("Received mate session inhibited changed: idle=(%i), suspend=(%i)", is_idle_inhibited, is_suspend_inhibited);
+	gpm_idle_evaluate (idle);
+}
+
+/**
+ * gpm_idle_idletime_alarm_expired_cb:
+ *
+ * We're idle, something timed out
+ **/
+static void
+gpm_idle_idletime_alarm_expired_cb (EggIdletime *idletime, guint alarm_id, GpmIdle *idle)
+{
+	g_debug ("idletime alarm: %u", alarm_id);
+
+	/* set again */
+	idle->priv->x_idle = TRUE;
+	gpm_idle_evaluate (idle);
+}
+
+/**
+ * gpm_idle_idletime_reset_cb:
+ *
+ * We're no longer idle, the user moved
+ **/
+static void
+gpm_idle_idletime_reset_cb (EggIdletime *idletime, GpmIdle *idle)
+{
+	g_debug ("idletime reset");
+
+	idle->priv->x_idle = FALSE;
+	gpm_idle_evaluate (idle);
+}
+
+/**
+ * gpm_idle_finalize:
+ * @object: This class instance
+ **/
+static void
+gpm_idle_finalize (GObject *object)
+{
+	GpmIdle *idle;
+
+	g_return_if_fail (object != NULL);
+	g_return_if_fail (GPM_IS_IDLE (object));
+
+	idle = GPM_IDLE (object);
+
+	g_return_if_fail (idle->priv != NULL);
+
+	if (idle->priv->timeout_blank_id != 0) {
+		g_source_remove (idle->priv->timeout_blank_id);
+		idle->priv->timeout_blank_id = 0;
+	}
+
+	if (idle->priv->timeout_sleep_id != 0) {
+		g_source_remove (idle->priv->timeout_sleep_id);
+		idle->priv->timeout_sleep_id = 0;
+	}
+
+	g_object_unref (idle->priv->load);
+	g_object_unref (idle->priv->session);
+
+	egg_idletime_alarm_remove (idle->priv->idletime, GPM_IDLE_IDLETIME_ID);
+	g_object_unref (idle->priv->idletime);
+
+	G_OBJECT_CLASS (gpm_idle_parent_class)->finalize (object);
+}
+
+/**
+ * gpm_idle_class_init:
+ * @klass: This class instance
+ **/
+static void
+gpm_idle_class_init (GpmIdleClass *klass)
+{
+	GObjectClass   *object_class = G_OBJECT_CLASS (klass);
+
+	object_class->finalize = gpm_idle_finalize;
+
+	signals [IDLE_CHANGED] =
+		g_signal_new ("idle-changed",
+			      G_TYPE_FROM_CLASS (object_class),
+			      G_SIGNAL_RUN_LAST,
+			      G_STRUCT_OFFSET (GpmIdleClass, idle_changed),
+			      NULL, NULL, g_cclosure_marshal_VOID__INT,
+			      G_TYPE_NONE, 1, G_TYPE_INT);
+}
+
+/**
+ * gpm_idle_init:
+ *
+ * Gets a DBUS connection, and aquires the session connection so we can
+ * get session changed events.
+ *
+ **/
+static void
+gpm_idle_init (GpmIdle *idle)
+{
+	idle->priv = gpm_idle_get_instance_private (idle);
+
+	idle->priv->timeout_dim = G_MAXUINT;
+	idle->priv->timeout_blank = G_MAXUINT;
+	idle->priv->timeout_sleep = G_MAXUINT;
+	idle->priv->timeout_blank_id = 0;
+	idle->priv->timeout_sleep_id = 0;
+	idle->priv->x_idle = FALSE;
+	idle->priv->load = gpm_load_new ();
+	idle->priv->session = gpm_session_new ();
+	g_signal_connect (idle->priv->session, "idle-changed", G_CALLBACK (gpm_idle_session_idle_changed_cb), idle);
+	g_signal_connect (idle->priv->session, "inhibited-changed", G_CALLBACK (gpm_idle_session_inhibited_changed_cb), idle);
+
+	idle->priv->idletime = egg_idletime_new ();
+	g_signal_connect (idle->priv->idletime, "reset", G_CALLBACK (gpm_idle_idletime_reset_cb), idle);
+	g_signal_connect (idle->priv->idletime, "alarm-expired", G_CALLBACK (gpm_idle_idletime_alarm_expired_cb), idle);
+
+	gpm_idle_evaluate (idle);
+}
+
+/**
+ * gpm_idle_new:
+ * Return value: A new GpmIdle instance.
+ **/
+GpmIdle *
+gpm_idle_new (void)
+{
+	if (gpm_idle_object != NULL) {
+		g_object_ref (gpm_idle_object);
+	} else {
+		gpm_idle_object = g_object_new (GPM_TYPE_IDLE, NULL);
+		g_object_add_weak_pointer (gpm_idle_object, &gpm_idle_object);
+	}
+	return GPM_IDLE (gpm_idle_object);
+}
+
+/***************************************************************************
+ ***                          MAKE CHECK TESTS                           ***
+ ***************************************************************************/
+#ifdef EGG_TEST
+#include "egg-test.h"
+#include "gpm-dpms.h"
+
+static GpmIdleMode _mode = 0;
+
+static void
+gpm_idle_test_idle_changed_cb (GpmIdle *idle, GpmIdleMode mode, EggTest *test)
+{
+	_mode = mode;
+	g_debug ("idle-changed %s", gpm_idle_mode_to_string (mode));
+	egg_test_loop_quit (test);
+}
+
+static gboolean
+gpm_idle_test_delay_cb (EggTest *test)
+{
+	g_warning ("timing out");
+	egg_test_loop_quit (test);
+	return FALSE;
+}
+
+void
+gpm_idle_test (gpointer data)
+{
+	GpmIdle *idle;
+	gboolean ret;
+	EggTest *test = (EggTest *) data;
+	GpmIdleMode mode;
+	GpmDpms *dpms;
+
+	if (!egg_test_start (test, "GpmIdle"))
+		return;
+
+	/************************************************************/
+	egg_test_title (test, "get object");
+	idle = gpm_idle_new ();
+	if (idle != NULL)
+		egg_test_success (test, NULL);
+	else
+		egg_test_failed (test, "got no object");
+
+	/* set up defaults */
+	gpm_idle_set_check_cpu (idle, FALSE);
+	gpm_idle_set_timeout_dim (idle, 4);
+	gpm_idle_set_timeout_blank (idle, 5);
+	gpm_idle_set_timeout_sleep (idle, 15);
+	g_signal_connect (idle, "idle-changed",
+			  G_CALLBACK (gpm_idle_test_idle_changed_cb), test);
+
+	/************************************************************/
+	egg_test_title (test, "check cpu type");
+	egg_test_assert (test, (idle->priv->check_type_cpu == FALSE));
+
+	/************************************************************/
+	egg_test_title (test, "check timeout dim");
+	egg_test_assert (test, (idle->priv->timeout_dim == 4));
+
+	/************************************************************/
+	egg_test_title (test, "check timeout blank");
+	egg_test_assert (test, (idle->priv->timeout_blank == 5));
+
+	/************************************************************/
+	egg_test_title (test, "check timeout sleep");
+	egg_test_assert (test, (idle->priv->timeout_sleep == 15));
+
+	/************************************************************/
+	egg_test_title (test, "check x_idle");
+	egg_test_assert (test, (idle->priv->x_idle == FALSE));
+
+	/************************************************************/
+	egg_test_title (test, "check blank id");
+	egg_test_assert (test, (idle->priv->timeout_blank_id == 0));
+
+	/************************************************************/
+	egg_test_title (test, "check sleep id");
+	egg_test_assert (test, (idle->priv->timeout_sleep_id == 0));
+
+	/************************************************************/
+	egg_test_title (test, "check normal at startup");
+	mode = gpm_idle_get_mode (idle);
+	if (mode == GPM_IDLE_MODE_NORMAL)
+		egg_test_success (test, NULL);
+	else
+		egg_test_failed (test, "mode: %s", gpm_idle_mode_to_string (mode));
+
+	/************************************************************/
+	g_print ("*****************************\n");
+	g_print ("*** DO NOT MOVE THE MOUSE ***\n");
+	g_print ("*****************************\n");
+	egg_test_loop_wait (test, 2000 + 10000);
+	egg_test_loop_check (test);
+
+	/************************************************************/
+	egg_test_title (test, "check callback mode");
+	if (_mode == GPM_IDLE_MODE_DIM)
+		egg_test_success (test, NULL);
+	else
+		egg_test_failed (test, "mode: %s", gpm_idle_mode_to_string (mode));
+
+	/************************************************************/
+	egg_test_title (test, "check current mode");
+	mode = gpm_idle_get_mode (idle);
+	if (mode == GPM_IDLE_MODE_DIM)
+		egg_test_success (test, NULL);
+	else
+		egg_test_failed (test, "mode: %s", gpm_idle_mode_to_string (mode));
+
+	/************************************************************/
+	egg_test_title (test, "check x_idle");
+	egg_test_assert (test, (idle->priv->x_idle == TRUE));
+
+	/************************************************************/
+	egg_test_title (test, "check blank id");
+	egg_test_assert (test, (idle->priv->timeout_blank_id != 0));
+
+	/************************************************************/
+	egg_test_title (test, "check sleep id");
+	egg_test_assert (test, (idle->priv->timeout_sleep_id == 0));
+
+	/************************************************************/
+	egg_test_loop_wait (test, 5000 + 1000);
+	egg_test_loop_check (test);
+
+	/************************************************************/
+	egg_test_title (test, "check callback mode");
+	if (_mode == GPM_IDLE_MODE_BLANK)
+		egg_test_success (test, NULL);
+	else
+		egg_test_failed (test, "mode: %s", gpm_idle_mode_to_string (mode));
+
+	/************************************************************/
+	egg_test_title (test, "check current mode");
+	mode = gpm_idle_get_mode (idle);
+	if (mode == GPM_IDLE_MODE_BLANK)
+		egg_test_success (test, NULL);
+	else
+		egg_test_failed (test, "mode: %s", gpm_idle_mode_to_string (mode));
+
+	/************************************************************/
+	g_print ("**********************\n");
+	g_print ("*** MOVE THE MOUSE ***\n");
+	g_print ("**********************\n");
+	egg_test_loop_wait (test, G_MAXUINT);
+	egg_test_loop_check (test);
+
+	/************************************************************/
+	egg_test_title (test, "check callback mode");
+	if (_mode == GPM_IDLE_MODE_NORMAL)
+		egg_test_success (test, NULL);
+	else
+		egg_test_failed (test, "mode: %s", gpm_idle_mode_to_string (mode));
+
+	/************************************************************/
+	egg_test_title (test, "check current mode");
+	mode = gpm_idle_get_mode (idle);
+	if (mode == GPM_IDLE_MODE_NORMAL)
+		egg_test_success (test, NULL);
+	else
+		egg_test_failed (test, "mode: %s", gpm_idle_mode_to_string (mode));
+
+	/************************************************************/
+	egg_test_title (test, "check x_idle");
+	egg_test_assert (test, (idle->priv->x_idle == FALSE));
+
+	/************************************************************/
+	egg_test_title (test, "check blank id");
+	egg_test_assert (test, (idle->priv->timeout_blank_id == 0));
+
+	/************************************************************/
+	g_print ("*****************************\n");
+	g_print ("*** DO NOT MOVE THE MOUSE ***\n");
+	g_print ("*****************************\n");
+	egg_test_loop_wait (test, 4000 + 1500);
+	egg_test_loop_check (test);
+
+	/************************************************************/
+	egg_test_title (test, "check current mode");
+	mode = gpm_idle_get_mode (idle);
+	if (mode == GPM_IDLE_MODE_DIM)
+		egg_test_success (test, NULL);
+	else
+		egg_test_failed (test, "mode: %s", gpm_idle_mode_to_string (mode));
+
+	/************************************************************/
+	egg_test_title (test, "check x_idle");
+	egg_test_assert (test, (idle->priv->x_idle == TRUE));
+
+	egg_test_loop_wait (test, 15000);
+	egg_test_loop_check (test);
+
+	/************************************************************/
+	egg_test_title (test, "check current mode");
+	mode = gpm_idle_get_mode (idle);
+	if (mode == GPM_IDLE_MODE_BLANK)
+		egg_test_success (test, NULL);
+	else
+		egg_test_failed (test, "mode: %s", gpm_idle_mode_to_string (mode));
+
+	/************************************************************/
+	egg_test_title (test, "set dpms off");
+	dpms = gpm_dpms_new ();
+	ret = gpm_dpms_set_mode (dpms, GPM_DPMS_MODE_OFF, NULL);
+	egg_test_assert (test, ret);
+
+	/* wait for normal event to be suppressed */
+	g_timeout_add (2000, (GSourceFunc) gpm_idle_test_delay_cb, test);
+	egg_test_loop_wait (test, G_MAXUINT);
+	egg_test_loop_check (test);
+
+	/************************************************************/
+	egg_test_title (test, "check current mode");
+	mode = gpm_idle_get_mode (idle);
+	if (mode == GPM_IDLE_MODE_BLANK)
+		egg_test_success (test, NULL);
+	else
+		egg_test_failed (test, "mode: %s", gpm_idle_mode_to_string (mode));
+
+	/************************************************************/
+	egg_test_title (test, "check x_idle");
+	egg_test_assert (test, (idle->priv->x_idle == TRUE));
+
+	gpm_dpms_set_mode (dpms, GPM_DPMS_MODE_ON, NULL);
+
+	g_object_unref (idle);
+	g_object_unref (dpms);
+
+	egg_test_end (test);
+}
+
+#endif
+
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/85.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/85.html new file mode 100644 index 0000000..c7be301 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/85.html @@ -0,0 +1,351 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2006-2007 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __GPM_LOAD_H
+#define __GPM_LOAD_H
+
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+G_BEGIN_DECLS
+
+#define GPM_TYPE_LOAD		(gpm_load_get_type ())
+#define GPM_LOAD(o)		(G_TYPE_CHECK_INSTANCE_CAST ((o), GPM_TYPE_LOAD, GpmLoad))
+#define GPM_LOAD_CLASS(k)	(G_TYPE_CHECK_CLASS_CAST((k), GPM_TYPE_LOAD, GpmLoadClass))
+#define GPM_IS_LOAD(o)		(G_TYPE_CHECK_INSTANCE_TYPE ((o), GPM_TYPE_LOAD))
+#define GPM_IS_LOAD_CLASS(k)	(G_TYPE_CHECK_CLASS_TYPE ((k), GPM_TYPE_LOAD))
+#define GPM_LOAD_GET_CLASS(o)	(G_TYPE_INSTANCE_GET_CLASS ((o), GPM_TYPE_LOAD, GpmLoadClass))
+
+typedef struct GpmLoadPrivate GpmLoadPrivate;
+
+typedef struct
+{
+	GObject		 parent;
+	GpmLoadPrivate	*priv;
+} GpmLoad;
+
+typedef struct
+{
+	GObjectClass	parent_class;
+} GpmLoadClass;
+
+GType		 gpm_load_get_type		(void);
+GpmLoad		*gpm_load_new			(void);
+
+gdouble		 gpm_load_get_current		(GpmLoad	*load);
+
+G_END_DECLS
+
+#endif /* __GPM_LOAD_H */
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/86.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/86.html new file mode 100644 index 0000000..b3002de --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/86.html @@ -0,0 +1,397 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __GPM_SESSION_H
+#define __GPM_SESSION_H
+
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+G_BEGIN_DECLS
+
+#define GPM_TYPE_SESSION		(gpm_session_get_type ())
+#define GPM_SESSION(o)			(G_TYPE_CHECK_INSTANCE_CAST ((o), GPM_TYPE_SESSION, GpmSession))
+#define GPM_SESSION_CLASS(k)		(G_TYPE_CHECK_CLASS_CAST((k), GPM_TYPE_SESSION, GpmSessionClass))
+#define GPM_IS_SESSION(o)		(G_TYPE_CHECK_INSTANCE_TYPE ((o), GPM_TYPE_SESSION))
+#define GPM_IS_SESSION_CLASS(k)		(G_TYPE_CHECK_CLASS_TYPE ((k), GPM_TYPE_SESSION))
+#define GPM_SESSION_GET_CLASS(o)	(G_TYPE_INSTANCE_GET_CLASS ((o), GPM_TYPE_SESSION, GpmSessionClass))
+
+typedef struct GpmSessionPrivate GpmSessionPrivate;
+
+typedef struct
+{
+	GObject			 parent;
+	GpmSessionPrivate	*priv;
+} GpmSession;
+
+typedef struct
+{
+	GObjectClass	parent_class;
+	void		(* idle_changed)		(GpmSession	*session,
+							 gboolean	 is_idle);
+	void		(* inhibited_changed)		(GpmSession	*session,
+							 gboolean	 is_idle_inhibited,
+							 gboolean        is_suspend_inhibited);
+	/* just exit */
+	void		(* stop)			(GpmSession	*session);
+	/* reply with EndSessionResponse */
+	void		(* query_end_session)		(GpmSession	*session,
+							 guint		 flags);
+	/* reply with EndSessionResponse */
+	void		(* end_session)			(GpmSession	*session,
+							 guint		 flags);
+	void		(* cancel_end_session)		(GpmSession	*session);
+} GpmSessionClass;
+
+GType		 gpm_session_get_type			(void);
+GpmSession	*gpm_session_new			(void);
+
+gboolean	 gpm_session_logout			(GpmSession	*session);
+gboolean	 gpm_session_get_idle			(GpmSession	*session);
+gboolean	 gpm_session_get_idle_inhibited		(GpmSession	*session);
+gboolean	 gpm_session_get_suspend_inhibited	(GpmSession	*session);
+gboolean	 gpm_session_register_client		(GpmSession	*session,
+							 const gchar	*app_id,
+							 const gchar	*client_startup_id);
+gboolean	 gpm_session_end_session_response	(GpmSession	*session,
+							 gboolean	 is_okay,
+							 const gchar	*reason);
+
+G_END_DECLS
+
+#endif	/* __GPM_SESSION_H */
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/87.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/87.html new file mode 100644 index 0000000..eec0e76 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/87.html @@ -0,0 +1,1661 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
+603
+604
+605
+606
+607
+608
+609
+610
+611
+612
+613
+614
+615
+616
+617
+618
+619
+620
+621
+622
+623
+624
+625
+626
+627
+628
+629
+630
+631
+632
+633
+634
+635
+636
+637
+638
+639
+640
+641
+642
+643
+644
+645
+646
+647
+648
+649
+650
+651
+652
+653
+654
+655
+656
+657
+658
+659
+660
+661
+662
+663
+664
+665
+666
+667
+668
+669
+670
+671
+672
+673
+674
+675
+676
+677
+678
+679
+680
+681
+682
+683
+684
+685
+686
+687
+688
+689
+690
+691
+692
+693
+694
+695
+696
+697
+698
+699
+700
+701
+702
+703
+704
+705
+706
+707
+708
+709
+710
+711
+712
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2010 Alex Launi <alex launi canonical com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <gio/gio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <libupower-glib/upower.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "gpm-button.h"
+#include "gpm-common.h"
+#include "gpm-control.h"
+#include "gpm-idle.h"
+#include "gpm-kbd-backlight.h"
+#include "gsd-media-keys-window.h"
+
+struct GpmKbdBacklightPrivate
+{
+    UpClient        *client;
+    GpmButton       *button;
+    GSettings       *settings;
+    GpmControl      *control;
+    GpmIdle         *idle;
+    gboolean         can_dim;
+    gboolean         system_is_idle;
+    GTimer          *idle_timer;
+    guint            idle_dim_timeout;
+    guint            master_percentage;
+    guint            brightness;
+    guint            max_brightness;
+    guint            brightness_percent;
+    GDBusProxy      *upower_proxy;
+    GDBusConnection     *bus_connection;
+    guint            bus_object_id;
+    GtkWidget		*popup;
+};
+
+enum {
+   BRIGHTNESS_CHANGED,
+   LAST_SIGNAL
+};
+
+static guint signals [LAST_SIGNAL] = { 0 };
+
+G_DEFINE_TYPE_WITH_PRIVATE (GpmKbdBacklight, gpm_kbd_backlight, G_TYPE_OBJECT)<--- There is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
+
+/**
+ * gpm_kbd_backlight_error_quark:
+ * Return value: Our personal error quark.
+ **/
+GQuark
+gpm_kbd_backlight_error_quark (void)
+{
+   static GQuark quark = 0;
+   if (!quark)
+       quark = g_quark_from_static_string ("gpm_kbd_backlight_error");
+   return quark;
+}
+
+/**
+ * gpm_kbd_backlight_get_brightness:
+ * @backlight:
+ * @brightness:
+ * @error:
+ *
+ * Return value:
+ */
+gboolean
+gpm_kbd_backlight_get_brightness (GpmKbdBacklight *backlight,
+                 guint *brightness,
+                 GError **error)
+{
+   g_return_val_if_fail (backlight != NULL, FALSE);
+   g_return_val_if_fail (GPM_IS_KBD_BACKLIGHT (backlight), FALSE);
+   g_return_val_if_fail (brightness != NULL, FALSE);
+
+   if (backlight->priv->can_dim == FALSE) {
+       g_set_error_literal (error, gpm_kbd_backlight_error_quark (),
+                    GPM_KBD_BACKLIGHT_ERROR_HARDWARE_NOT_PRESENT,
+                    "Dim capable hardware not present");
+       return FALSE;
+   }
+
+   *brightness = backlight->priv->brightness_percent;
+   return TRUE;
+}
+
+static gboolean
+gpm_kbd_backlight_set (GpmKbdBacklight *backlight,
+              guint percentage)
+{
+   gint scale;
+   guint goal;
+
+   g_return_val_if_fail (GPM_IS_KBD_BACKLIGHT (backlight), FALSE);
+   /* avoid warnings if no keyboard brightness is available */
+   if (backlight->priv->max_brightness < 1)
+       return FALSE;
+   /* if we're setting the same we are, don't bother */
+   //g_return_val_if_fail (backlight->priv->brightness_percent != percentage, FALSE);
+
+   goal = gpm_discrete_from_percent (percentage, backlight->priv->max_brightness);
+   scale = percentage > backlight->priv->brightness_percent ? 1 : -1;
+
+   /* if percentage change too small force next value */
+   if (goal == backlight->priv->brightness) {
+       goal += percentage == backlight->priv->brightness_percent ? 0 : scale;
+   }
+
+   /* step loop down by 1 for a dimming effect */
+   while (backlight->priv->brightness != goal) {
+       backlight->priv->brightness += scale;
+       backlight->priv->brightness_percent = gpm_discrete_to_percent (backlight->priv->brightness, backlight->priv->max_brightness);
+
+       g_dbus_proxy_call (backlight->priv->upower_proxy,
+                      "SetBrightness",
+                   g_variant_new ("(i)", (gint) backlight->priv->brightness),
+                   G_DBUS_CALL_FLAGS_NONE,
+                   -1,
+                   NULL,
+                   NULL,
+                   NULL);
+   }
+   g_debug("Set brightness to %u", backlight->priv->brightness);
+   return TRUE;
+}
+
+/**
+ * gpm_kbd_backlight_dialog_init
+ **/
+static void
+gpm_kbd_backlight_dialog_init (GpmKbdBacklight *backlight)
+{
+    if (backlight->priv->popup != NULL
+	    && !msd_osd_window_is_valid (MSD_OSD_WINDOW (backlight->priv->popup))) {
+		gtk_widget_destroy (backlight->priv->popup);
+		backlight->priv->popup = NULL;
+	}
+
+	if (backlight->priv->popup == NULL) {
+		backlight->priv->popup= msd_media_keys_window_new ();
+		msd_media_keys_window_set_action_custom (MSD_MEDIA_KEYS_WINDOW (backlight->priv->popup),
+							 "gpm-brightness-kbd",
+							 TRUE);
+		gtk_window_set_position (GTK_WINDOW (backlight->priv->popup), GTK_WIN_POS_NONE);
+
+    }
+}
+/**
+ * gpm_kbd_backlight_dialog_show:
+ *
+ * Show the brightness popup, and place it nicely on the screen.
+ **/
+static void
+gpm_kbd_backlight_dialog_show (GpmKbdBacklight *backlight)
+{
+	int            orig_w;
+	int            orig_h;
+	int            screen_w;
+	int            screen_h;
+	int            x;
+	int            y;
+	int            pointer_x;
+	int            pointer_y;
+	GtkRequisition win_req;
+	GdkScreen     *pointer_screen;
+	GdkRectangle   geometry;
+	GdkMonitor    *monitor;
+	GdkDisplay    *display;
+	GdkSeat       *seat;
+	GdkDevice     *device;
+
+	/*
+	 * get the window size
+	 * if the window hasn't been mapped, it doesn't necessarily
+	 * know its true size, yet, so we need to jump through hoops
+	 */
+	gtk_window_get_default_size (GTK_WINDOW (backlight->priv->popup), &orig_w, &orig_h);
+	gtk_widget_get_preferred_size (backlight->priv->popup, NULL, &win_req);
+
+	if (win_req.width > orig_w) {
+		orig_w = win_req.width;
+	}
+	if (win_req.height > orig_h) {
+		orig_h = win_req.height;
+	}
+
+	pointer_screen = NULL;
+	display = gtk_widget_get_display (backlight->priv->popup);
+	seat = gdk_display_get_default_seat (display);
+	device = gdk_seat_get_pointer (seat);
+	gdk_device_get_position (device,
+	                         &pointer_screen,
+	                         &pointer_x,
+	                         &pointer_y);
+
+	monitor = gdk_display_get_monitor_at_point (gdk_screen_get_display (pointer_screen),
+						    pointer_x,
+						    pointer_y);
+
+	gdk_monitor_get_geometry (monitor, &geometry);
+
+	screen_w = geometry.width;
+	screen_h = geometry.height;
+
+	x = ((screen_w - orig_w) / 2) + geometry.x;
+	y = geometry.y + (screen_h / 2) + (screen_h / 2 - orig_h) / 2;
+
+	gtk_window_move (GTK_WINDOW (backlight->priv->popup), x, y);
+
+	gtk_widget_show (backlight->priv->popup);
+
+	gdk_display_sync (gtk_widget_get_display (backlight->priv->popup));
+}
+
+/**
+ * gpm_kbd_backlight_brightness_up:
+ **/
+static gboolean
+gpm_kbd_backlight_brightness_up (GpmKbdBacklight *backlight)
+{
+   guint new;
+
+   new = MIN (backlight->priv->brightness_percent + GPM_KBD_BACKLIGHT_STEP, 100u);
+   return gpm_kbd_backlight_set (backlight, new);
+}
+
+/**
+ * gpm_kbd_backlight_brightness_down:
+ **/
+static gboolean
+gpm_kbd_backlight_brightness_down (GpmKbdBacklight *backlight)
+{
+   guint new;
+
+   // we can possibly go below 0 here, so by converting to a gint we avoid underflow errors.
+   new = MAX ((gint) backlight->priv->brightness_percent - GPM_KBD_BACKLIGHT_STEP, 0);
+   return gpm_kbd_backlight_set (backlight, new);
+}
+
+/**
+ * gpm_kbd_backlight_set_brightness:
+ * @backlight:
+ * @percentage:
+ * @error:
+ *
+ * Return value:
+ **/
+gboolean
+gpm_kbd_backlight_set_brightness (GpmKbdBacklight *backlight,
+                 guint percentage,
+                 GError **error)
+{
+   gboolean ret;
+
+   g_return_val_if_fail (backlight != NULL, FALSE);
+   g_return_val_if_fail (GPM_IS_KBD_BACKLIGHT (backlight), FALSE);
+
+   if (backlight->priv->can_dim == FALSE) {
+       g_set_error_literal (error, gpm_kbd_backlight_error_quark (),
+                    GPM_KBD_BACKLIGHT_ERROR_HARDWARE_NOT_PRESENT,
+                    "Dim capable hardware not present");
+       return FALSE;
+   }
+
+   backlight->priv->master_percentage = percentage;
+
+   ret = gpm_kbd_backlight_set (backlight, percentage);
+   if (!ret) {
+       g_set_error_literal (error, gpm_kbd_backlight_error_quark (),
+                    GPM_KBD_BACKLIGHT_ERROR_GENERAL,
+                    "Cannot set keyboard backlight brightness");
+   }
+
+   return ret;
+}
+
+static void
+gpm_kbd_backlight_on_brightness_changed (GpmKbdBacklight *backlight,
+                    guint value)
+{
+   backlight->priv->brightness = value;
+   backlight->priv->brightness_percent = gpm_discrete_to_percent (value, backlight->priv->max_brightness);
+   backlight->priv->master_percentage = backlight->priv->brightness_percent;
+   g_signal_emit (backlight, signals [BRIGHTNESS_CHANGED], 0, backlight->priv->brightness_percent);
+}
+
+/**
+ * gpm_kbd_backlight_on_dbus_signal:
+ **/
+static void
+gpm_kbd_backlight_on_dbus_signal (GDBusProxy *proxy,
+                 gchar      *sender_name,
+                 gchar      *signal_name,
+                 GVariant   *parameters,
+                 gpointer    user_data)
+{
+   guint value;
+   GpmKbdBacklight *backlight = GPM_KBD_BACKLIGHT (user_data);
+
+   if (g_strcmp0 (signal_name, "BrightnessChanged") == 0) {
+       g_variant_get (parameters, "(i)", &value);
+       gpm_kbd_backlight_on_brightness_changed (backlight, value);
+       return;
+   }
+
+   g_debug ("signal '%s' not handled!", signal_name);
+}
+
+static gboolean
+gpm_kbd_backlight_evaluate_power_source_and_set (GpmKbdBacklight *backlight)
+{
+   gfloat brightness;
+   gfloat scale;
+   gboolean on_battery;
+   gboolean battery_reduce;
+   guint value;
+   gboolean ret;
+
+   brightness = backlight->priv->master_percentage;
+
+   g_object_get (backlight->priv->client,
+             "on-battery",
+             &on_battery,
+             NULL);
+
+   battery_reduce = g_settings_get_boolean (backlight->priv->settings, GPM_SETTINGS_KBD_BACKLIGHT_BATT_REDUCE);
+
+   if (on_battery) {
+      if (battery_reduce) {
+         value = g_settings_get_int (backlight->priv->settings, GPM_SETTINGS_KBD_BRIGHTNESS_DIM_BY_ON_BATT);
+
+         if (value > 100) {
+            g_warning ("Cannot scale brightness down by more than 100%%. Scaling by 50%%");
+            value = 50;
+         }
+
+         scale = (100 - value) / 100.0f;
+         brightness *= scale;
+
+         value = (guint) brightness;
+
+      } else {
+         // do not change keyboard backlight
+         return TRUE;
+      }
+
+   } else {
+       value = g_settings_get_int (backlight->priv->settings, GPM_SETTINGS_KBD_BRIGHTNESS_ON_AC);
+   }
+
+   ret = gpm_kbd_backlight_set (backlight, value);
+   return ret;
+}
+
+/**
+ * gpm_kbd_backlight_control_resume_cb:
+ * @control: The control class instance
+ * @backlight: This backlight class instance
+ *
+ * Just make sure that the backlight is back on
+ **/
+static void
+gpm_kbd_backlight_control_resume_cb (GpmControl *control,
+                    GpmControlAction action,
+                    GpmKbdBacklight *backlight)
+{
+   gboolean ret;
+
+   ret = gpm_kbd_backlight_evaluate_power_source_and_set (backlight);
+   if (!ret)
+       g_warning ("Failed to turn kbd brightness back on after resuming");
+}
+
+/**
+ * gpm_kbd_backlight_client_changed_cb:
+ * @client: The up_client class instance
+ * @backlight: This class instance
+ *
+ * Does the actions when the ac power source is inserted/removed.
+ **/
+static void
+gpm_kbd_backlight_client_changed_cb (UpClient *client,
+                                     GParamSpec *pspec,
+                                     GpmKbdBacklight *backlight)
+{
+   gpm_kbd_backlight_evaluate_power_source_and_set (backlight);
+}
+
+/**
+ * gpm_kbd_backlight_button_pressed_cb:
+ * @power: The power class instance
+ * @type: The button type, but here we only care about keyboard brightness buttons
+ * @backlight: This class instance
+ **/
+static void
+gpm_kbd_backlight_button_pressed_cb (GpmButton *button,
+                    const gchar *type,
+                    GpmKbdBacklight *backlight)
+{
+   static guint saved_brightness;
+   gboolean ret;
+
+   saved_brightness = backlight->priv->master_percentage;
+
+   if (g_strcmp0 (type, GPM_BUTTON_KBD_BRIGHT_UP) == 0) {
+       ret = gpm_kbd_backlight_brightness_up (backlight);
+
+        if (ret) {
+            g_debug("Going to display OSD");
+            gpm_kbd_backlight_dialog_init (backlight);
+			msd_media_keys_window_set_volume_level (MSD_MEDIA_KEYS_WINDOW (backlight->priv->popup), backlight->priv->brightness_percent);
+            gpm_kbd_backlight_dialog_show (backlight);
+        }
+
+   } else if (g_strcmp0 (type, GPM_BUTTON_KBD_BRIGHT_DOWN) == 0) {
+       ret = gpm_kbd_backlight_brightness_down (backlight);
+
+        if (ret) {
+            g_debug("Going to display OSD");
+            gpm_kbd_backlight_dialog_init (backlight);
+			msd_media_keys_window_set_volume_level (MSD_MEDIA_KEYS_WINDOW (backlight->priv->popup), backlight->priv->brightness_percent);
+            gpm_kbd_backlight_dialog_show (backlight);
+        }
+
+   } else if (g_strcmp0 (type, GPM_BUTTON_KBD_BRIGHT_TOGGLE) == 0) {
+       if (backlight->priv->master_percentage == 0) {
+           /* backlight is off turn it back on */
+           gpm_kbd_backlight_set (backlight, saved_brightness);
+       } else {
+           /* backlight is on, turn it off and save current value */
+           saved_brightness = backlight->priv->master_percentage;
+           gpm_kbd_backlight_set (backlight, 0);
+       }
+   }
+}
+
+/**
+ * gpm_kbd_backlight_idle_changed_cb:
+ * @idle: The idle class instance
+ * @mode: The idle mode, e.g. GPM_IDLE_MODE_BLANK
+ * @backlight: This class instance
+ *
+ * This callback is called when mate-screensaver detects that the idle state
+ * has changed. GPM_IDLE_MODE_BLANK is when the session has become inactive,
+ * and GPM_IDLE_MODE_SLEEP is where the session has become inactive, AND the
+ * session timeout has elapsed for the idle action.
+ **/
+static void
+gpm_kbd_backlight_idle_changed_cb (GpmIdle *idle,
+                  GpmIdleMode mode,
+                  GpmKbdBacklight *backlight)
+{
+   gfloat brightness;
+   gfloat scale;
+   guint value;
+   gboolean lid_closed;
+   gboolean on_battery;
+   gboolean enable_action;
+
+   g_debug("Idle changed");
+
+   lid_closed = gpm_button_is_lid_closed (backlight->priv->button);
+
+   if (lid_closed)
+       return;
+
+   g_object_get (backlight->priv->client,
+                 "on-battery",
+                 &on_battery,
+                 NULL);
+
+   enable_action = on_battery
+       ? g_settings_get_boolean (backlight->priv->settings, GPM_SETTINGS_IDLE_DIM_BATT)
+         && g_settings_get_boolean (backlight->priv->settings, GPM_SETTINGS_KBD_BACKLIGHT_BATT_REDUCE)
+       : g_settings_get_boolean (backlight->priv->settings, GPM_SETTINGS_IDLE_DIM_AC);
+
+   if (!enable_action)
+       return;
+
+   if (mode == GPM_IDLE_MODE_NORMAL) {
+       g_debug ("GPM_IDLE_MODE_NORMAL");
+       backlight->priv->master_percentage = 100;
+       gpm_kbd_backlight_evaluate_power_source_and_set (backlight);
+   } else if (mode == GPM_IDLE_MODE_DIM) {
+       g_debug ("GPM_IDLE_MODE_DIM");
+       brightness = backlight->priv->master_percentage;
+       value = g_settings_get_int (backlight->priv->settings, GPM_SETTINGS_KBD_BRIGHTNESS_DIM_BY_ON_IDLE);
+
+       if (value > 100) {
+           g_warning ("Cannot scale brightness down by more than 100%%. Scaling by 50%%");
+           value = 50;
+       }
+
+       scale = (100 - value) / 100.0f;
+       brightness *= scale;
+
+       value = (guint) brightness;
+       gpm_kbd_backlight_set (backlight, value);
+   } else if (mode == GPM_IDLE_MODE_BLANK) {
+       gpm_kbd_backlight_set (backlight, 0u);
+   }
+}
+
+/**
+ * gpm_kbd_backlight_finalize:
+ * @object:
+ **/
+static void
+gpm_kbd_backlight_finalize (GObject *object)
+{
+   GpmKbdBacklight *backlight;
+
+   g_return_if_fail (object != NULL);
+   g_return_if_fail (GPM_IS_KBD_BACKLIGHT (object));
+
+   backlight = GPM_KBD_BACKLIGHT (object);
+
+   if (backlight->priv->upower_proxy != NULL) {
+       g_object_unref (backlight->priv->upower_proxy);
+   }
+   if (backlight->priv->bus_connection != NULL) {
+       g_dbus_connection_unregister_object (backlight->priv->bus_connection,
+                            backlight->priv->bus_object_id);
+       g_object_unref (backlight->priv->bus_connection);
+   }
+
+   g_timer_destroy (backlight->priv->idle_timer);
+
+   g_object_unref (backlight->priv->control);
+   g_object_unref (backlight->priv->settings);
+   g_object_unref (backlight->priv->client);
+   g_object_unref (backlight->priv->button);
+   g_object_unref (backlight->priv->idle);
+
+   g_return_if_fail (backlight->priv != NULL);
+   G_OBJECT_CLASS (gpm_kbd_backlight_parent_class)->finalize (object);
+}
+
+/**
+ * gpm_kbd_backlight_class_init:
+ * @klass:
+ **/
+static void
+gpm_kbd_backlight_class_init (GpmKbdBacklightClass *klass)
+{
+   GObjectClass *object_class = G_OBJECT_CLASS (klass);
+   object_class->finalize = gpm_kbd_backlight_finalize;
+
+   signals [BRIGHTNESS_CHANGED] =
+       g_signal_new ("brightness-changed",
+                  G_TYPE_FROM_CLASS (object_class),
+                  G_SIGNAL_RUN_LAST,
+                  G_STRUCT_OFFSET (GpmKbdBacklightClass, brightness_changed),
+                  NULL,
+                  NULL,
+                  g_cclosure_marshal_VOID__UINT,
+                  G_TYPE_NONE,
+                  1,
+                  G_TYPE_UINT);
+}
+
+/**
+ * gpm_kbd_backlight_init:
+ * @backlight: This KbdBacklight class instance
+ *
+ * Initializes the KbdBacklight class.
+ **/
+static void
+gpm_kbd_backlight_init (GpmKbdBacklight *backlight)
+{
+   GVariant *u_brightness;
+   GVariant *u_max_brightness;
+   GError   *error = NULL;
+
+   backlight->priv = gpm_kbd_backlight_get_instance_private (backlight);
+
+   backlight->priv->upower_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
+                                      G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
+                                      NULL,
+                                      "org.freedesktop.UPower",
+                                      "/org/freedesktop/UPower/KbdBacklight",
+                                      "org.freedesktop.UPower.KbdBacklight",
+                                      NULL,
+                                      &error);
+   if (backlight->priv->upower_proxy == NULL) {
+       g_printerr ("Could not connect to UPower system bus: %s", error->message);
+       g_error_free (error);
+       goto err;
+   }
+
+   g_signal_connect (backlight->priv->upower_proxy,
+             "g-signal",
+             G_CALLBACK (gpm_kbd_backlight_on_dbus_signal),
+             backlight);
+
+   u_brightness = g_dbus_proxy_call_sync (backlight->priv->upower_proxy,
+                          "GetBrightness",
+                          NULL,
+                          G_DBUS_CALL_FLAGS_NONE,
+                          -1,
+                          NULL,
+                          &error);
+   if (u_brightness == NULL) {
+       if (error->domain != G_DBUS_ERROR || error->code != G_DBUS_ERROR_UNKNOWN_METHOD)
+           g_warning ("Failed to get brightness: %s", error->message);
+       g_error_free (error);
+       goto err;
+   }
+
+   error = NULL;
+   u_max_brightness = g_dbus_proxy_call_sync (backlight->priv->upower_proxy,
+                          "GetMaxBrightness",
+                          NULL,
+                          G_DBUS_CALL_FLAGS_NONE,
+                          -1,
+                          NULL,
+                          &error);
+   if (u_max_brightness == NULL) {
+       g_warning ("Failed to get max brightness: %s", error->message);
+       g_error_free (error);
+       g_variant_unref (u_brightness);
+       goto err;
+   }
+
+   g_variant_get (u_brightness, "(i)", &backlight->priv->brightness);
+   g_variant_get (u_max_brightness, "(i)", &backlight->priv->max_brightness);
+
+   backlight->priv->brightness_percent = gpm_discrete_to_percent (backlight->priv->brightness,
+                                      backlight->priv->max_brightness);
+
+   g_variant_unref (u_brightness);
+   g_variant_unref (u_max_brightness);
+   goto noerr;
+
+err:
+   backlight->priv->brightness = 0;
+   backlight->priv->brightness_percent = 100;
+   backlight->priv->max_brightness = 0;
+
+noerr:
+   /* Initialize the master to full power. It will get scaled if needed */
+   backlight->priv->master_percentage = 100u;
+
+   backlight->priv->idle_timer = g_timer_new ();
+   backlight->priv->can_dim = backlight->priv->max_brightness > 1;
+
+   /* Use upower for ac changed signal */
+   backlight->priv->client = up_client_new ();
+   g_signal_connect (backlight->priv->client, "notify",
+             G_CALLBACK (gpm_kbd_backlight_client_changed_cb), backlight);
+
+   backlight->priv->settings = g_settings_new (GPM_SETTINGS_SCHEMA);
+
+   /* watch for kbd brightness up and down button presses */
+   backlight->priv->button = gpm_button_new ();
+   g_signal_connect (backlight->priv->button, "button-pressed",
+             G_CALLBACK (gpm_kbd_backlight_button_pressed_cb), backlight);
+
+   backlight->priv->idle = gpm_idle_new ();
+   g_signal_connect (backlight->priv->idle, "idle-changed",
+             G_CALLBACK (gpm_kbd_backlight_idle_changed_cb), backlight);
+
+    /* use a visual widget */
+   backlight->priv->popup = msd_media_keys_window_new ();
+   msd_media_keys_window_set_action_custom (MSD_MEDIA_KEYS_WINDOW (backlight->priv->popup),
+                                            "gpm-brightness-kbd", TRUE);
+   gtk_window_set_position (GTK_WINDOW (backlight->priv->popup), GTK_WIN_POS_NONE);
+
+   /* since gpm is just starting we can pretty safely assume that we're not idle */
+   backlight->priv->system_is_idle = FALSE;
+   backlight->priv->idle_dim_timeout = g_settings_get_int (backlight->priv->settings, GPM_SETTINGS_IDLE_DIM_TIME);
+   gpm_idle_set_timeout_dim (backlight->priv->idle, backlight->priv->idle_dim_timeout);
+
+   /* make sure we turn the keyboard backlight back on after resuming */
+   backlight->priv->control = gpm_control_new ();
+   g_signal_connect (backlight->priv->control, "resume",
+             G_CALLBACK (gpm_kbd_backlight_control_resume_cb), backlight);
+
+   /* set initial values for whether we're on AC or battery*/
+   gpm_kbd_backlight_evaluate_power_source_and_set (backlight);
+}
+
+/**
+ * gpm_kbd_backlight_new:
+ * Return value: A new GpmKbdBacklight class instance.
+ **/
+GpmKbdBacklight *
+gpm_kbd_backlight_new (void)
+{
+   GpmKbdBacklight *backlight = g_object_new (GPM_TYPE_KBD_BACKLIGHT, NULL);
+   return backlight;
+}
+
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/88.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/88.html new file mode 100644 index 0000000..c03f300 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/88.html @@ -0,0 +1,397 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2010 Alex Launi <alex launi canonical com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __GPM_KBD_BACKLIGHT_H
+#define __GPM_KBD_BACKLIGHT_H
+
+#include <gio/gio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+G_BEGIN_DECLS
+
+#define GPM_TYPE_KBD_BACKLIGHT     (gpm_kbd_backlight_get_type ())
+#define GPM_KBD_BACKLIGHT(o)       (G_TYPE_CHECK_INSTANCE_CAST ((o), GPM_TYPE_KBD_BACKLIGHT, GpmKbdBacklight))
+#define GPM_KBD_BACKLIGHT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GPM_TYPE_KBD_BACKLIGHT, GpmKbdBacklightClass))
+#define GPM_IS_KBD_BACKLIGHT(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), GPM_TYPE_KBD_BACKLIGHT))
+#define GPM_IS_KBD_BACKLIGHT_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), GPM_TYPE_KBD_BACKLIGHT))
+#define GPM_KBD_BACKLIGHT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GPM_TYPE_KBD_BACKLIGHT, GpmKbdBacklightClass))
+
+#define GPM_KBD_BACKLIGHT_DIM_INTERVAL 5 /* ms */
+#define GPM_KBD_BACKLIGHT_STEP 10 /* change by 10% each step */
+
+typedef struct GpmKbdBacklightPrivate GpmKbdBacklightPrivate;
+
+typedef struct
+{
+   GObject         parent;
+   GpmKbdBacklightPrivate *priv;
+} GpmKbdBacklight;
+
+typedef struct
+{
+   GObjectClass parent_class;
+   void         (* brightness_changed) (GpmKbdBacklight *backlight,
+                        gint         brightness);
+} GpmKbdBacklightClass;
+
+typedef enum
+{
+    GPM_KBD_BACKLIGHT_ERROR_GENERAL,
+    GPM_KBD_BACKLIGHT_ERROR_DATA_NOT_AVAILABLE,
+    GPM_KBD_BACKLIGHT_ERROR_HARDWARE_NOT_PRESENT
+} GpmKbdBacklightError;
+
+GType          gpm_kbd_backlight_get_type      (void);
+GQuark         gpm_kbd_backlight_error_quark       (void);
+GpmKbdBacklight           *gpm_kbd_backlight_new           (void);
+gboolean       gpm_kbd_backlight_get_brightness    (GpmKbdBacklight *backlight,
+                                guint *brightness,
+                                GError **error);
+gboolean       gpm_kbd_backlight_set_brightness    (GpmKbdBacklight *backlight,
+                                guint brightness,
+                                GError **error);
+void           gpm_kbd_backlight_register_dbus     (GpmKbdBacklight *backlight,
+                                GDBusConnection *connection,
+                                GError **error);
+
+G_END_DECLS
+
+#endif /* __GPM_KBD_BACKLIGHT_H */
+
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/89.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/89.html new file mode 100644 index 0000000..e8cc144 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/89.html @@ -0,0 +1,795 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "config.h"<--- Include file: "config.h" not found.
+
+#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <time.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <errno.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/time.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/types.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#if defined(sun) && defined(__SVR4)
+#include <kstat.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/sysinfo.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+#ifdef HAVE_UNISTD_H
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif /* HAVE_UNISTD_H */
+
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "gpm-common.h"
+#include "gpm-marshal.h"
+
+#include "gpm-load.h"
+
+static void     gpm_load_finalize   (GObject	  *object);
+
+struct GpmLoadPrivate
+{
+	long unsigned	 old_idle;
+	long unsigned	 old_total;
+};
+
+static gpointer gpm_load_object = NULL;
+
+G_DEFINE_TYPE_WITH_PRIVATE (GpmLoad, gpm_load, G_TYPE_OBJECT)<--- There is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
+
+/**
+ * gpm_load_class_init:
+ * @klass: This class instance
+ **/
+static void
+gpm_load_class_init (GpmLoadClass *klass)
+{
+	GObjectClass *object_class = G_OBJECT_CLASS (klass);
+	object_class->finalize = gpm_load_finalize;
+}
+
+#if defined(sun) && defined(__SVR4)
+
+/**
+ * gpm_load_get_cpu_values:
+ * @cpu_idle: The idle time reported by the CPU
+ * @cpu_total: The total time reported by the CPU
+ * Return value: Success of reading /proc/stat.
+ **/
+static gboolean
+gpm_load_get_cpu_values (long unsigned *cpu_idle, long unsigned *cpu_total)
+{
+	long unsigned cpu_user = 0;
+	long unsigned cpu_kernel = 0;
+	long unsigned cpu_wait = 0;
+	kstat_ctl_t *kc = NULL;
+	kstat_named_t *kn = NULL;
+	kstat_t *ks = NULL;
+	cpu_stat_t  data;
+	int ncpus;
+	int count;
+
+	kc = kstat_open();
+	if (!kc) {
+		g_warning ("Cannot open kstat!\n");
+		return FALSE;
+	}
+
+	ks = kstat_lookup(kc, "unix", 0, "system_misc");
+  	if (kstat_read(kc, ks, NULL) == -1) {
+		g_warning ("Cannot read kstat on module unix!\n");
+		goto out;
+	}
+	kn = kstat_data_lookup (ks, "ncpus");
+	if (!kn) {
+		g_warning ("Cannot get number of cpus in current system!\n");
+		goto out;
+	}
+	ncpus = kn->value.ui32;
+
+	/*
+ 	 * To aggresive ticks used of all cpus,
+	 * traverse kstat chain to access very cpu_stat instane.
+	 */
+	for(count = 0, *cpu_idle =0, *cpu_total = 0; count < ncpus; count++){
+
+		ks = kstat_lookup(kc, "cpu_stat", count, NULL);
+		if (ks == NULL) {
+			g_warning ("Null output for kstat on cpu%d\n", count);
+			goto out;
+		}
+
+		if (kstat_read(kc, ks, &data) == -1) {
+			g_warning ("Cannot read kstat entry on cpu%d\n", count);
+			goto out;
+		}
+
+		g_debug ("cpu%d:\t%lu\t%lu\t%lu\t%lu\n", count,
+		         data.cpu_sysinfo.cpu[CPU_IDLE],
+		         data.cpu_sysinfo.cpu[CPU_USER],
+		         data.cpu_sysinfo.cpu[CPU_KERNEL],
+		         data.cpu_sysinfo.cpu[CPU_WAIT]);
+
+		*cpu_idle += data.cpu_sysinfo.cpu[CPU_IDLE];
+		cpu_user += data.cpu_sysinfo.cpu[CPU_USER];
+		cpu_kernel += data.cpu_sysinfo.cpu[CPU_KERNEL];
+		cpu_wait += data.cpu_sysinfo.cpu[CPU_WAIT];
+	}
+	kstat_close(kc);
+	/*
+         * Summing up all these times gives you the system uptime.
+         * This is what the uptime command does.
+         */
+        *cpu_total = cpu_user + cpu_kernel + cpu_wait + *cpu_idle;
+        return TRUE;
+
+out:
+	kstat_close(kc);
+	return FALSE;
+}
+
+#else
+
+/**
+ * gpm_load_get_cpu_values:
+ * @cpu_idle: The idle time reported by the CPU
+ * @cpu_total: The total time reported by the CPU
+ * Return value: Success of reading /proc/stat.
+ **/
+static gboolean
+gpm_load_get_cpu_values (long unsigned *cpu_idle, long unsigned *cpu_total)
+{
+	long unsigned cpu_user;
+	long unsigned cpu_nice;
+	long unsigned cpu_system;
+	int len;
+	char tmp[5];
+	char str[80];
+	FILE *fd;
+	char *suc;
+	gboolean ret = FALSE;
+
+	/* open file */
+	fd = fopen("/proc/stat", "r");
+	if (!fd)
+		goto out;
+
+	/* get data */
+	suc = fgets (str, 80, fd);
+	if (suc == NULL)
+		goto out;
+
+	/* parse */
+	len = sscanf (str, "%s %lu %lu %lu %lu", tmp,
+		      &cpu_user, &cpu_nice, &cpu_system, cpu_idle);
+	if (len != 5)
+		goto out;
+
+	/* summing up all these times gives you the system uptime in jiffies */
+	*cpu_total = cpu_user + cpu_nice + cpu_system + *cpu_idle;
+	ret = TRUE;
+out:
+	if (fd)
+		fclose (fd);
+	return ret;
+}
+#endif /* sun & __SVR4 */
+
+/**
+ * gpm_load_get_current:
+ * @load: This class instance
+ * Return value: The CPU idle load
+ **/
+gdouble
+gpm_load_get_current (GpmLoad *load)
+{
+	double percentage_load;
+	long unsigned cpu_idle;
+	long unsigned cpu_total;
+	long unsigned diff_idle;
+	long unsigned diff_total;
+	gboolean ret;
+
+	/* work out the differences */
+	ret = gpm_load_get_cpu_values (&cpu_idle, &cpu_total);
+	if (!ret)
+		return 0.0;
+
+	diff_idle = cpu_idle - load->priv->old_idle;
+	diff_total = cpu_total - load->priv->old_total;
+
+	/* If we divide the total time by idle time we get the load. */
+	if (diff_idle > 0)
+		percentage_load = (double) diff_total / (double) diff_idle;
+	else
+		percentage_load = 100;
+
+	load->priv->old_idle = cpu_idle;
+	load->priv->old_total = cpu_total;
+
+	return percentage_load;
+}
+
+/**
+ * gpm_load_init:
+ */
+static void
+gpm_load_init (GpmLoad *load)
+{
+	load->priv = gpm_load_get_instance_private (load);
+
+	load->priv->old_idle = 0;
+	load->priv->old_total = 0;
+
+	/* we have to populate the values at startup */
+	gpm_load_get_cpu_values (&load->priv->old_idle, &load->priv->old_total);
+}
+
+/**
+ * gpm_load_coldplug:
+ *
+ * @object: This load instance
+ */
+static void
+gpm_load_finalize (GObject *object)
+{
+	GpmLoad *load;
+	g_return_if_fail (object != NULL);
+	g_return_if_fail (GPM_IS_LOAD (object));
+	load = GPM_LOAD (object);
+	g_return_if_fail (load->priv != NULL);
+	G_OBJECT_CLASS (gpm_load_parent_class)->finalize (object);
+}
+
+/**
+ * gpm_load_new:
+ * Return value: new GpmLoad instance.
+ **/
+GpmLoad *
+gpm_load_new (void)
+{
+	if (gpm_load_object != NULL) {
+		g_object_ref (gpm_load_object);
+	} else {
+		gpm_load_object = g_object_new (GPM_TYPE_LOAD, NULL);
+		g_object_add_weak_pointer (gpm_load_object, &gpm_load_object);
+	}
+	return GPM_LOAD (gpm_load_object);
+}
+
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/9.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/9.html new file mode 100644 index 0000000..f44d095 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/9.html @@ -0,0 +1,397 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
/* mate-bg-crossfade.h - fade window background between two pixmaps
+
+   Copyright 2008, Red Hat, Inc.
+
+   This file is part of the Mate Library.
+
+   The Mate Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The Mate Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the Mate Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
+   Floor, Boston, MA 02110-1301 US.
+
+   Author: Ray Strode <rstrode@redhat.com>
+*/
+
+#ifndef __MATE_BG_CROSSFADE_H__
+#define __MATE_BG_CROSSFADE_H__
+
+#ifndef MATE_DESKTOP_USE_UNSTABLE_API
+#error    MateBGCrossfade is unstable API. You must define MATE_DESKTOP_USE_UNSTABLE_API before including mate-bg-crossfade.h
+#endif
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdk/gdk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+G_BEGIN_DECLS
+
+#define MATE_TYPE_BG_CROSSFADE            (mate_bg_crossfade_get_type ())
+#define MATE_BG_CROSSFADE(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), MATE_TYPE_BG_CROSSFADE, MateBGCrossfade))
+#define MATE_BG_CROSSFADE_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass),  MATE_TYPE_BG_CROSSFADE, MateBGCrossfadeClass))
+#define MATE_IS_BG_CROSSFADE(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MATE_TYPE_BG_CROSSFADE))
+#define MATE_IS_BG_CROSSFADE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),  MATE_TYPE_BG_CROSSFADE))
+#define MATE_BG_CROSSFADE_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj),  MATE_TYPE_BG_CROSSFADE, MateBGCrossfadeClass))
+
+typedef struct _MateBGCrossfadePrivate MateBGCrossfadePrivate;
+typedef struct _MateBGCrossfade MateBGCrossfade;
+typedef struct _MateBGCrossfadeClass MateBGCrossfadeClass;
+
+struct _MateBGCrossfade
+{
+    GObject parent_object;
+
+    MateBGCrossfadePrivate *priv;
+};
+
+struct _MateBGCrossfadeClass
+{
+    GObjectClass parent_class;
+
+    void (* finished) (MateBGCrossfade *fade, GdkWindow *window);
+};
+
+GType             mate_bg_crossfade_get_type (void);
+MateBGCrossfade   *mate_bg_crossfade_new (int width, int height);
+
+gboolean          mate_bg_crossfade_set_start_surface (MateBGCrossfade *fade,
+                                                       cairo_surface_t *surface);
+gboolean          mate_bg_crossfade_set_end_surface (MateBGCrossfade *fade,
+                                                     cairo_surface_t *surface);
+
+void              mate_bg_crossfade_start (MateBGCrossfade *fade,
+                                           GdkWindow        *window);
+void              mate_bg_crossfade_start_widget (MateBGCrossfade *fade,
+                                                  GtkWidget       *widget);
+gboolean          mate_bg_crossfade_is_started (MateBGCrossfade *fade);
+void              mate_bg_crossfade_stop (MateBGCrossfade *fade);
+
+G_END_DECLS
+
+#endif
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/90.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/90.html new file mode 100644 index 0000000..836ccaa --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/90.html @@ -0,0 +1,793 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2005-2007 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * Taken in part from:
+ *  - lshal   (C) 2003 David Zeuthen, <david@fubar.dk>
+ *  - notibat (C) 2004 Benjamin Kahn, <xkahn@zoned.net>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "config.h"<--- Include file: "config.h" not found.
+
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <errno.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <locale.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <dbus/dbus-glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <dbus/dbus-glib-lowlevel.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "gpm-icon-names.h"
+#include "gpm-common.h"
+#include "gpm-manager.h"
+#include "gpm-session.h"
+
+#include "org.mate.PowerManager.h"
+
+/**
+ * gpm_object_register:
+ * @connection: What we want to register to
+ * @object: The GObject we want to register
+ *
+ * Register org.mate.PowerManager on the session bus.
+ * This function MUST be called before DBUS service will work.
+ *
+ * Return value: success
+ **/
+static gboolean
+gpm_object_register (DBusGConnection *connection,
+		     GObject	     *object)
+{
+	DBusGProxy *bus_proxy = NULL;
+	GError *error = NULL;
+	guint request_name_result;
+	gboolean ret;
+
+	bus_proxy = dbus_g_proxy_new_for_name (connection,
+					       DBUS_SERVICE_DBUS,
+					       DBUS_PATH_DBUS,
+					       DBUS_INTERFACE_DBUS);
+
+	ret = dbus_g_proxy_call (bus_proxy, "RequestName", &error,
+				 G_TYPE_STRING, GPM_DBUS_SERVICE,
+				 G_TYPE_UINT, 0,
+				 G_TYPE_INVALID,
+				 G_TYPE_UINT, &request_name_result,
+				 G_TYPE_INVALID);
+	if (error) {
+		g_debug ("ERROR: %s", error->message);
+		g_error_free (error);
+	}
+	if (!ret) {
+		/* abort as the DBUS method failed */
+		g_warning ("RequestName failed!");
+		return FALSE;
+	}
+
+	/* free the bus_proxy */
+	g_object_unref (G_OBJECT (bus_proxy));
+
+	/* already running */
+ 	if (request_name_result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
+		return FALSE;
+	}
+
+	dbus_g_object_type_install_info (GPM_TYPE_MANAGER, &dbus_glib_gpm_manager_object_info);
+	dbus_g_error_domain_register (GPM_MANAGER_ERROR, NULL, GPM_MANAGER_TYPE_ERROR);
+	dbus_g_connection_register_g_object (connection, GPM_DBUS_PATH, object);
+
+	return TRUE;
+}
+
+/**
+ * timed_exit_cb:
+ * @loop: The main loop
+ *
+ * Exits the main loop, which is helpful for valgrinding g-p-m.
+ *
+ * Return value: FALSE, as we don't want to repeat this action.
+ **/
+static gboolean
+timed_exit_cb (GMainLoop *loop)
+{
+	g_main_loop_quit (loop);
+	return FALSE;
+}
+
+/**
+ * gpm_main_stop_cb:
+ **/
+static void
+gpm_main_stop_cb (GpmSession *session, GMainLoop *loop)
+{
+	g_main_loop_quit (loop);
+}
+
+/**
+ * gpm_main_query_end_session_cb:
+ **/
+static void
+gpm_main_query_end_session_cb (GpmSession *session, guint flags, GMainLoop *loop)
+{
+	/* just send response */
+	gpm_session_end_session_response (session, TRUE, NULL);
+}
+
+/**
+ * gpm_main_end_session_cb:
+ **/
+static void
+gpm_main_end_session_cb (GpmSession *session, guint flags, GMainLoop *loop)
+{
+	/* send response */
+	gpm_session_end_session_response (session, TRUE, NULL);
+
+	/* exit loop, will unref manager */
+	g_main_loop_quit (loop);
+}
+
+/**
+ * main:
+ **/
+int
+main (int argc, char *argv[])
+{
+	GMainLoop *loop;
+	DBusGConnection *system_connection;
+	DBusGConnection *session_connection;
+	gboolean version = FALSE;
+	gboolean timed_exit = FALSE;
+	gboolean immediate_exit = FALSE;
+	GpmSession *session = NULL;
+	GpmManager *manager = NULL;
+	GError *error = NULL;
+	GOptionContext *context;
+	gint ret;
+	guint timer_id;
+
+	const GOptionEntry options[] = {
+		{ "version", '\0', 0, G_OPTION_ARG_NONE, &version,
+		  N_("Show version of installed program and exit"), NULL },
+		{ "timed-exit", '\0', 0, G_OPTION_ARG_NONE, &timed_exit,
+		  N_("Exit after a small delay (for debugging)"), NULL },
+		{ "immediate-exit", '\0', 0, G_OPTION_ARG_NONE, &immediate_exit,
+		  N_("Exit after the manager has loaded (for debugging)"), NULL },
+		{ NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL }
+	};
+
+	setlocale (LC_ALL, "");
+	bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR);
+	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+	textdomain (GETTEXT_PACKAGE);
+
+	dbus_g_thread_init ();
+
+	context = g_option_context_new (N_("MATE Power Manager"));
+	/* TRANSLATORS: program name, a simple app to view pending updates */
+	g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE);
+	g_option_context_set_translation_domain(context, GETTEXT_PACKAGE);
+	g_option_context_set_summary (context, _("MATE Power Manager"));
+	g_option_context_parse (context, &argc, &argv, NULL);
+
+	if (version) {
+		g_print ("Version %s\n", VERSION);
+		goto unref_program;
+	}
+
+	dbus_g_thread_init ();
+
+	gtk_init (&argc, &argv);
+
+	g_debug ("MATE %s %s", GPM_NAME, VERSION);
+
+	/* check dbus connections, exit if not valid */
+	system_connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
+	if (error) {
+		g_warning ("%s", error->message);
+		g_error_free (error);
+		g_error ("This program cannot start until you start "
+		         "the dbus system service.\n"
+		         "It is <b>strongly recommended</b> you reboot "
+		         "your computer after starting this service.");
+	}
+
+	session_connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+	if (error) {
+		g_warning ("%s", error->message);
+		g_error_free (error);
+		g_error ("This program cannot start until you start the "
+		         "dbus session service.\n\n"
+		         "This is usually started automatically in X "
+		         "or mate startup when you start a new session.");
+	}
+
+	/* add application specific icons to search path */
+	gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (),
+                                           GPM_ICONS_DATA);
+
+	loop = g_main_loop_new (NULL, FALSE);
+
+	/* optionally register with the session */
+	session = gpm_session_new ();
+	g_signal_connect (session, "stop", G_CALLBACK (gpm_main_stop_cb), loop);
+	g_signal_connect (session, "query-end-session", G_CALLBACK (gpm_main_query_end_session_cb), loop);
+	g_signal_connect (session, "end-session", G_CALLBACK (gpm_main_end_session_cb), loop);
+	gpm_session_register_client (session, "mate-power-manager", getenv ("DESKTOP_AUTOSTART_ID"));
+
+	/* create a new gui object */
+	manager = gpm_manager_new ();
+
+	if (!gpm_object_register (session_connection, G_OBJECT (manager))) {
+		g_error ("%s is already running in this session.", GPM_NAME);
+		goto unref_program;
+	}
+
+	/* register to be a policy agent, just like kpackagekit does */
+	ret = dbus_bus_request_name(dbus_g_connection_get_connection(system_connection),
+				    "org.freedesktop.Policy.Power",
+				    DBUS_NAME_FLAG_REPLACE_EXISTING, NULL);
+	switch (ret) {
+	case DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER:
+		g_debug ("Successfully acquired interface org.freedesktop.Policy.Power.");
+		break;
+	case DBUS_REQUEST_NAME_REPLY_IN_QUEUE:
+		g_debug ("Queued for interface org.freedesktop.Policy.Power.");
+		break;
+	default:
+		break;
+	};
+
+	/* Only timeout and close the mainloop if we have specified it
+	 * on the command line */
+	if (timed_exit) {
+		timer_id = g_timeout_add_seconds (20, (GSourceFunc) timed_exit_cb, loop);
+		g_source_set_name_by_id (timer_id, "[GpmMain] timed-exit");
+	}
+
+	if (immediate_exit == FALSE) {
+		g_main_loop_run (loop);
+	}
+
+	g_main_loop_unref (loop);
+
+	g_object_unref (session);
+	g_object_unref (manager);
+unref_program:
+	g_option_context_free (context);
+	return 0;
+}
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/91.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/91.html new file mode 100644 index 0000000..186c1c4 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/91.html @@ -0,0 +1,395 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2005 William Jon McCann <mccann@jhu.edu>
+ * Copyright (C) 2005-2007 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __GPM_MANAGER_H
+#define __GPM_MANAGER_H
+
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <dbus/dbus-glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+G_BEGIN_DECLS
+
+#define GPM_TYPE_MANAGER	 (gpm_manager_get_type ())
+#define GPM_MANAGER(o)		 (G_TYPE_CHECK_INSTANCE_CAST ((o), GPM_TYPE_MANAGER, GpmManager))
+#define GPM_MANAGER_CLASS(k)	 (G_TYPE_CHECK_CLASS_CAST((k), GPM_TYPE_MANAGER, GpmManagerClass))
+#define GPM_IS_MANAGER(o)	 (G_TYPE_CHECK_INSTANCE_TYPE ((o), GPM_TYPE_MANAGER))
+#define GPM_IS_MANAGER_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), GPM_TYPE_MANAGER))
+#define GPM_MANAGER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GPM_TYPE_MANAGER, GpmManagerClass))
+#define GPM_MANAGER_ERROR	 (gpm_manager_error_quark ())
+#define GPM_MANAGER_TYPE_ERROR	 (gpm_manager_error_get_type ())
+
+typedef struct GpmManagerPrivate GpmManagerPrivate;
+
+typedef struct
+{
+	 GObject		 parent;
+	 GpmManagerPrivate	*priv;
+} GpmManager;
+
+typedef struct
+{
+	GObjectClass	parent_class;
+} GpmManagerClass;
+
+typedef enum
+{
+	GPM_MANAGER_ERROR_DENIED,
+	GPM_MANAGER_ERROR_NO_HW,
+	GPM_MANAGER_ERROR_LAST
+} GpmManagerError;
+
+GQuark		 gpm_manager_error_quark		(void);
+GType		 gpm_manager_error_get_type		(void);
+GType		 gpm_manager_get_type		  	(void);
+GpmManager	*gpm_manager_new			(void);
+
+gboolean	 gpm_manager_suspend			(GpmManager	*manager,
+							 GError		**error);
+gboolean	 gpm_manager_hibernate			(GpmManager	*manager,
+							 GError		**error);
+gboolean	 gpm_manager_can_suspend		(GpmManager	*manager,
+							 gboolean	*can_suspend,
+							 GError		**error);
+gboolean	 gpm_manager_can_hibernate		(GpmManager	*manager,
+							 gboolean	*can_hibernate,
+							 GError		**error);
+
+G_END_DECLS
+
+#endif /* __GPM_MANAGER_H */
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/92.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/92.html new file mode 100644 index 0000000..f6fb9d8 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/92.html @@ -0,0 +1,363 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
/* Generated by dbus-binding-tool; do not edit! */
+
+/* This file is generated by glib-genmarshal, do not modify it. This code is licensed under the same license as the containing project. Note that it links to GLib, so must comply with the LGPL linking clauses. */
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#ifdef G_ENABLE_DEBUG
+#define g_marshal_value_peek_boolean(v)  g_value_get_boolean (v)
+#define g_marshal_value_peek_char(v)     g_value_get_schar (v)
+#define g_marshal_value_peek_uchar(v)    g_value_get_uchar (v)
+#define g_marshal_value_peek_int(v)      g_value_get_int (v)
+#define g_marshal_value_peek_uint(v)     g_value_get_uint (v)
+#define g_marshal_value_peek_long(v)     g_value_get_long (v)
+#define g_marshal_value_peek_ulong(v)    g_value_get_ulong (v)
+#define g_marshal_value_peek_int64(v)    g_value_get_int64 (v)
+#define g_marshal_value_peek_uint64(v)   g_value_get_uint64 (v)
+#define g_marshal_value_peek_enum(v)     g_value_get_enum (v)
+#define g_marshal_value_peek_flags(v)    g_value_get_flags (v)
+#define g_marshal_value_peek_float(v)    g_value_get_float (v)
+#define g_marshal_value_peek_double(v)   g_value_get_double (v)
+#define g_marshal_value_peek_string(v)   (char*) g_value_get_string (v)
+#define g_marshal_value_peek_param(v)    g_value_get_param (v)
+#define g_marshal_value_peek_boxed(v)    g_value_get_boxed (v)
+#define g_marshal_value_peek_pointer(v)  g_value_get_pointer (v)
+#define g_marshal_value_peek_object(v)   g_value_get_object (v)
+#define g_marshal_value_peek_variant(v)  g_value_get_variant (v)
+#else /* !G_ENABLE_DEBUG */
+/* WARNING: This code accesses GValues directly, which is UNSUPPORTED API.
+ *          Do not access GValues directly in your code. Instead, use the
+ *          g_value_get_*() functions
+ */
+#define g_marshal_value_peek_boolean(v)  (v)->data[0].v_int
+#define g_marshal_value_peek_char(v)     (v)->data[0].v_int
+#define g_marshal_value_peek_uchar(v)    (v)->data[0].v_uint
+#define g_marshal_value_peek_int(v)      (v)->data[0].v_int
+#define g_marshal_value_peek_uint(v)     (v)->data[0].v_uint
+#define g_marshal_value_peek_long(v)     (v)->data[0].v_long
+#define g_marshal_value_peek_ulong(v)    (v)->data[0].v_ulong
+#define g_marshal_value_peek_int64(v)    (v)->data[0].v_int64
+#define g_marshal_value_peek_uint64(v)   (v)->data[0].v_uint64
+#define g_marshal_value_peek_enum(v)     (v)->data[0].v_long
+#define g_marshal_value_peek_flags(v)    (v)->data[0].v_ulong
+#define g_marshal_value_peek_float(v)    (v)->data[0].v_float
+#define g_marshal_value_peek_double(v)   (v)->data[0].v_double
+#define g_marshal_value_peek_string(v)   (v)->data[0].v_pointer
+#define g_marshal_value_peek_param(v)    (v)->data[0].v_pointer
+#define g_marshal_value_peek_boxed(v)    (v)->data[0].v_pointer
+#define g_marshal_value_peek_pointer(v)  (v)->data[0].v_pointer
+#define g_marshal_value_peek_object(v)   (v)->data[0].v_pointer
+#define g_marshal_value_peek_variant(v)  (v)->data[0].v_pointer
+#endif /* !G_ENABLE_DEBUG */
+
+#include <dbus/dbus-glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+static const DBusGMethodInfo dbus_glib_gpm_manager_methods[] = {
+};
+
+const DBusGObjectInfo dbus_glib_gpm_manager_object_info = {  1,
+  dbus_glib_gpm_manager_methods,
+  0,
+"\0",
+"\0",
+"\0"
+};
+
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/93.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/93.html new file mode 100644 index 0000000..3580ba3 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/93.html @@ -0,0 +1,4273 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
   1
+   2
+   3
+   4
+   5
+   6
+   7
+   8
+   9
+  10
+  11
+  12
+  13
+  14
+  15
+  16
+  17
+  18
+  19
+  20
+  21
+  22
+  23
+  24
+  25
+  26
+  27
+  28
+  29
+  30
+  31
+  32
+  33
+  34
+  35
+  36
+  37
+  38
+  39
+  40
+  41
+  42
+  43
+  44
+  45
+  46
+  47
+  48
+  49
+  50
+  51
+  52
+  53
+  54
+  55
+  56
+  57
+  58
+  59
+  60
+  61
+  62
+  63
+  64
+  65
+  66
+  67
+  68
+  69
+  70
+  71
+  72
+  73
+  74
+  75
+  76
+  77
+  78
+  79
+  80
+  81
+  82
+  83
+  84
+  85
+  86
+  87
+  88
+  89
+  90
+  91
+  92
+  93
+  94
+  95
+  96
+  97
+  98
+  99
+ 100
+ 101
+ 102
+ 103
+ 104
+ 105
+ 106
+ 107
+ 108
+ 109
+ 110
+ 111
+ 112
+ 113
+ 114
+ 115
+ 116
+ 117
+ 118
+ 119
+ 120
+ 121
+ 122
+ 123
+ 124
+ 125
+ 126
+ 127
+ 128
+ 129
+ 130
+ 131
+ 132
+ 133
+ 134
+ 135
+ 136
+ 137
+ 138
+ 139
+ 140
+ 141
+ 142
+ 143
+ 144
+ 145
+ 146
+ 147
+ 148
+ 149
+ 150
+ 151
+ 152
+ 153
+ 154
+ 155
+ 156
+ 157
+ 158
+ 159
+ 160
+ 161
+ 162
+ 163
+ 164
+ 165
+ 166
+ 167
+ 168
+ 169
+ 170
+ 171
+ 172
+ 173
+ 174
+ 175
+ 176
+ 177
+ 178
+ 179
+ 180
+ 181
+ 182
+ 183
+ 184
+ 185
+ 186
+ 187
+ 188
+ 189
+ 190
+ 191
+ 192
+ 193
+ 194
+ 195
+ 196
+ 197
+ 198
+ 199
+ 200
+ 201
+ 202
+ 203
+ 204
+ 205
+ 206
+ 207
+ 208
+ 209
+ 210
+ 211
+ 212
+ 213
+ 214
+ 215
+ 216
+ 217
+ 218
+ 219
+ 220
+ 221
+ 222
+ 223
+ 224
+ 225
+ 226
+ 227
+ 228
+ 229
+ 230
+ 231
+ 232
+ 233
+ 234
+ 235
+ 236
+ 237
+ 238
+ 239
+ 240
+ 241
+ 242
+ 243
+ 244
+ 245
+ 246
+ 247
+ 248
+ 249
+ 250
+ 251
+ 252
+ 253
+ 254
+ 255
+ 256
+ 257
+ 258
+ 259
+ 260
+ 261
+ 262
+ 263
+ 264
+ 265
+ 266
+ 267
+ 268
+ 269
+ 270
+ 271
+ 272
+ 273
+ 274
+ 275
+ 276
+ 277
+ 278
+ 279
+ 280
+ 281
+ 282
+ 283
+ 284
+ 285
+ 286
+ 287
+ 288
+ 289
+ 290
+ 291
+ 292
+ 293
+ 294
+ 295
+ 296
+ 297
+ 298
+ 299
+ 300
+ 301
+ 302
+ 303
+ 304
+ 305
+ 306
+ 307
+ 308
+ 309
+ 310
+ 311
+ 312
+ 313
+ 314
+ 315
+ 316
+ 317
+ 318
+ 319
+ 320
+ 321
+ 322
+ 323
+ 324
+ 325
+ 326
+ 327
+ 328
+ 329
+ 330
+ 331
+ 332
+ 333
+ 334
+ 335
+ 336
+ 337
+ 338
+ 339
+ 340
+ 341
+ 342
+ 343
+ 344
+ 345
+ 346
+ 347
+ 348
+ 349
+ 350
+ 351
+ 352
+ 353
+ 354
+ 355
+ 356
+ 357
+ 358
+ 359
+ 360
+ 361
+ 362
+ 363
+ 364
+ 365
+ 366
+ 367
+ 368
+ 369
+ 370
+ 371
+ 372
+ 373
+ 374
+ 375
+ 376
+ 377
+ 378
+ 379
+ 380
+ 381
+ 382
+ 383
+ 384
+ 385
+ 386
+ 387
+ 388
+ 389
+ 390
+ 391
+ 392
+ 393
+ 394
+ 395
+ 396
+ 397
+ 398
+ 399
+ 400
+ 401
+ 402
+ 403
+ 404
+ 405
+ 406
+ 407
+ 408
+ 409
+ 410
+ 411
+ 412
+ 413
+ 414
+ 415
+ 416
+ 417
+ 418
+ 419
+ 420
+ 421
+ 422
+ 423
+ 424
+ 425
+ 426
+ 427
+ 428
+ 429
+ 430
+ 431
+ 432
+ 433
+ 434
+ 435
+ 436
+ 437
+ 438
+ 439
+ 440
+ 441
+ 442
+ 443
+ 444
+ 445
+ 446
+ 447
+ 448
+ 449
+ 450
+ 451
+ 452
+ 453
+ 454
+ 455
+ 456
+ 457
+ 458
+ 459
+ 460
+ 461
+ 462
+ 463
+ 464
+ 465
+ 466
+ 467
+ 468
+ 469
+ 470
+ 471
+ 472
+ 473
+ 474
+ 475
+ 476
+ 477
+ 478
+ 479
+ 480
+ 481
+ 482
+ 483
+ 484
+ 485
+ 486
+ 487
+ 488
+ 489
+ 490
+ 491
+ 492
+ 493
+ 494
+ 495
+ 496
+ 497
+ 498
+ 499
+ 500
+ 501
+ 502
+ 503
+ 504
+ 505
+ 506
+ 507
+ 508
+ 509
+ 510
+ 511
+ 512
+ 513
+ 514
+ 515
+ 516
+ 517
+ 518
+ 519
+ 520
+ 521
+ 522
+ 523
+ 524
+ 525
+ 526
+ 527
+ 528
+ 529
+ 530
+ 531
+ 532
+ 533
+ 534
+ 535
+ 536
+ 537
+ 538
+ 539
+ 540
+ 541
+ 542
+ 543
+ 544
+ 545
+ 546
+ 547
+ 548
+ 549
+ 550
+ 551
+ 552
+ 553
+ 554
+ 555
+ 556
+ 557
+ 558
+ 559
+ 560
+ 561
+ 562
+ 563
+ 564
+ 565
+ 566
+ 567
+ 568
+ 569
+ 570
+ 571
+ 572
+ 573
+ 574
+ 575
+ 576
+ 577
+ 578
+ 579
+ 580
+ 581
+ 582
+ 583
+ 584
+ 585
+ 586
+ 587
+ 588
+ 589
+ 590
+ 591
+ 592
+ 593
+ 594
+ 595
+ 596
+ 597
+ 598
+ 599
+ 600
+ 601
+ 602
+ 603
+ 604
+ 605
+ 606
+ 607
+ 608
+ 609
+ 610
+ 611
+ 612
+ 613
+ 614
+ 615
+ 616
+ 617
+ 618
+ 619
+ 620
+ 621
+ 622
+ 623
+ 624
+ 625
+ 626
+ 627
+ 628
+ 629
+ 630
+ 631
+ 632
+ 633
+ 634
+ 635
+ 636
+ 637
+ 638
+ 639
+ 640
+ 641
+ 642
+ 643
+ 644
+ 645
+ 646
+ 647
+ 648
+ 649
+ 650
+ 651
+ 652
+ 653
+ 654
+ 655
+ 656
+ 657
+ 658
+ 659
+ 660
+ 661
+ 662
+ 663
+ 664
+ 665
+ 666
+ 667
+ 668
+ 669
+ 670
+ 671
+ 672
+ 673
+ 674
+ 675
+ 676
+ 677
+ 678
+ 679
+ 680
+ 681
+ 682
+ 683
+ 684
+ 685
+ 686
+ 687
+ 688
+ 689
+ 690
+ 691
+ 692
+ 693
+ 694
+ 695
+ 696
+ 697
+ 698
+ 699
+ 700
+ 701
+ 702
+ 703
+ 704
+ 705
+ 706
+ 707
+ 708
+ 709
+ 710
+ 711
+ 712
+ 713
+ 714
+ 715
+ 716
+ 717
+ 718
+ 719
+ 720
+ 721
+ 722
+ 723
+ 724
+ 725
+ 726
+ 727
+ 728
+ 729
+ 730
+ 731
+ 732
+ 733
+ 734
+ 735
+ 736
+ 737
+ 738
+ 739
+ 740
+ 741
+ 742
+ 743
+ 744
+ 745
+ 746
+ 747
+ 748
+ 749
+ 750
+ 751
+ 752
+ 753
+ 754
+ 755
+ 756
+ 757
+ 758
+ 759
+ 760
+ 761
+ 762
+ 763
+ 764
+ 765
+ 766
+ 767
+ 768
+ 769
+ 770
+ 771
+ 772
+ 773
+ 774
+ 775
+ 776
+ 777
+ 778
+ 779
+ 780
+ 781
+ 782
+ 783
+ 784
+ 785
+ 786
+ 787
+ 788
+ 789
+ 790
+ 791
+ 792
+ 793
+ 794
+ 795
+ 796
+ 797
+ 798
+ 799
+ 800
+ 801
+ 802
+ 803
+ 804
+ 805
+ 806
+ 807
+ 808
+ 809
+ 810
+ 811
+ 812
+ 813
+ 814
+ 815
+ 816
+ 817
+ 818
+ 819
+ 820
+ 821
+ 822
+ 823
+ 824
+ 825
+ 826
+ 827
+ 828
+ 829
+ 830
+ 831
+ 832
+ 833
+ 834
+ 835
+ 836
+ 837
+ 838
+ 839
+ 840
+ 841
+ 842
+ 843
+ 844
+ 845
+ 846
+ 847
+ 848
+ 849
+ 850
+ 851
+ 852
+ 853
+ 854
+ 855
+ 856
+ 857
+ 858
+ 859
+ 860
+ 861
+ 862
+ 863
+ 864
+ 865
+ 866
+ 867
+ 868
+ 869
+ 870
+ 871
+ 872
+ 873
+ 874
+ 875
+ 876
+ 877
+ 878
+ 879
+ 880
+ 881
+ 882
+ 883
+ 884
+ 885
+ 886
+ 887
+ 888
+ 889
+ 890
+ 891
+ 892
+ 893
+ 894
+ 895
+ 896
+ 897
+ 898
+ 899
+ 900
+ 901
+ 902
+ 903
+ 904
+ 905
+ 906
+ 907
+ 908
+ 909
+ 910
+ 911
+ 912
+ 913
+ 914
+ 915
+ 916
+ 917
+ 918
+ 919
+ 920
+ 921
+ 922
+ 923
+ 924
+ 925
+ 926
+ 927
+ 928
+ 929
+ 930
+ 931
+ 932
+ 933
+ 934
+ 935
+ 936
+ 937
+ 938
+ 939
+ 940
+ 941
+ 942
+ 943
+ 944
+ 945
+ 946
+ 947
+ 948
+ 949
+ 950
+ 951
+ 952
+ 953
+ 954
+ 955
+ 956
+ 957
+ 958
+ 959
+ 960
+ 961
+ 962
+ 963
+ 964
+ 965
+ 966
+ 967
+ 968
+ 969
+ 970
+ 971
+ 972
+ 973
+ 974
+ 975
+ 976
+ 977
+ 978
+ 979
+ 980
+ 981
+ 982
+ 983
+ 984
+ 985
+ 986
+ 987
+ 988
+ 989
+ 990
+ 991
+ 992
+ 993
+ 994
+ 995
+ 996
+ 997
+ 998
+ 999
+1000
+1001
+1002
+1003
+1004
+1005
+1006
+1007
+1008
+1009
+1010
+1011
+1012
+1013
+1014
+1015
+1016
+1017
+1018
+1019
+1020
+1021
+1022
+1023
+1024
+1025
+1026
+1027
+1028
+1029
+1030
+1031
+1032
+1033
+1034
+1035
+1036
+1037
+1038
+1039
+1040
+1041
+1042
+1043
+1044
+1045
+1046
+1047
+1048
+1049
+1050
+1051
+1052
+1053
+1054
+1055
+1056
+1057
+1058
+1059
+1060
+1061
+1062
+1063
+1064
+1065
+1066
+1067
+1068
+1069
+1070
+1071
+1072
+1073
+1074
+1075
+1076
+1077
+1078
+1079
+1080
+1081
+1082
+1083
+1084
+1085
+1086
+1087
+1088
+1089
+1090
+1091
+1092
+1093
+1094
+1095
+1096
+1097
+1098
+1099
+1100
+1101
+1102
+1103
+1104
+1105
+1106
+1107
+1108
+1109
+1110
+1111
+1112
+1113
+1114
+1115
+1116
+1117
+1118
+1119
+1120
+1121
+1122
+1123
+1124
+1125
+1126
+1127
+1128
+1129
+1130
+1131
+1132
+1133
+1134
+1135
+1136
+1137
+1138
+1139
+1140
+1141
+1142
+1143
+1144
+1145
+1146
+1147
+1148
+1149
+1150
+1151
+1152
+1153
+1154
+1155
+1156
+1157
+1158
+1159
+1160
+1161
+1162
+1163
+1164
+1165
+1166
+1167
+1168
+1169
+1170
+1171
+1172
+1173
+1174
+1175
+1176
+1177
+1178
+1179
+1180
+1181
+1182
+1183
+1184
+1185
+1186
+1187
+1188
+1189
+1190
+1191
+1192
+1193
+1194
+1195
+1196
+1197
+1198
+1199
+1200
+1201
+1202
+1203
+1204
+1205
+1206
+1207
+1208
+1209
+1210
+1211
+1212
+1213
+1214
+1215
+1216
+1217
+1218
+1219
+1220
+1221
+1222
+1223
+1224
+1225
+1226
+1227
+1228
+1229
+1230
+1231
+1232
+1233
+1234
+1235
+1236
+1237
+1238
+1239
+1240
+1241
+1242
+1243
+1244
+1245
+1246
+1247
+1248
+1249
+1250
+1251
+1252
+1253
+1254
+1255
+1256
+1257
+1258
+1259
+1260
+1261
+1262
+1263
+1264
+1265
+1266
+1267
+1268
+1269
+1270
+1271
+1272
+1273
+1274
+1275
+1276
+1277
+1278
+1279
+1280
+1281
+1282
+1283
+1284
+1285
+1286
+1287
+1288
+1289
+1290
+1291
+1292
+1293
+1294
+1295
+1296
+1297
+1298
+1299
+1300
+1301
+1302
+1303
+1304
+1305
+1306
+1307
+1308
+1309
+1310
+1311
+1312
+1313
+1314
+1315
+1316
+1317
+1318
+1319
+1320
+1321
+1322
+1323
+1324
+1325
+1326
+1327
+1328
+1329
+1330
+1331
+1332
+1333
+1334
+1335
+1336
+1337
+1338
+1339
+1340
+1341
+1342
+1343
+1344
+1345
+1346
+1347
+1348
+1349
+1350
+1351
+1352
+1353
+1354
+1355
+1356
+1357
+1358
+1359
+1360
+1361
+1362
+1363
+1364
+1365
+1366
+1367
+1368
+1369
+1370
+1371
+1372
+1373
+1374
+1375
+1376
+1377
+1378
+1379
+1380
+1381
+1382
+1383
+1384
+1385
+1386
+1387
+1388
+1389
+1390
+1391
+1392
+1393
+1394
+1395
+1396
+1397
+1398
+1399
+1400
+1401
+1402
+1403
+1404
+1405
+1406
+1407
+1408
+1409
+1410
+1411
+1412
+1413
+1414
+1415
+1416
+1417
+1418
+1419
+1420
+1421
+1422
+1423
+1424
+1425
+1426
+1427
+1428
+1429
+1430
+1431
+1432
+1433
+1434
+1435
+1436
+1437
+1438
+1439
+1440
+1441
+1442
+1443
+1444
+1445
+1446
+1447
+1448
+1449
+1450
+1451
+1452
+1453
+1454
+1455
+1456
+1457
+1458
+1459
+1460
+1461
+1462
+1463
+1464
+1465
+1466
+1467
+1468
+1469
+1470
+1471
+1472
+1473
+1474
+1475
+1476
+1477
+1478
+1479
+1480
+1481
+1482
+1483
+1484
+1485
+1486
+1487
+1488
+1489
+1490
+1491
+1492
+1493
+1494
+1495
+1496
+1497
+1498
+1499
+1500
+1501
+1502
+1503
+1504
+1505
+1506
+1507
+1508
+1509
+1510
+1511
+1512
+1513
+1514
+1515
+1516
+1517
+1518
+1519
+1520
+1521
+1522
+1523
+1524
+1525
+1526
+1527
+1528
+1529
+1530
+1531
+1532
+1533
+1534
+1535
+1536
+1537
+1538
+1539
+1540
+1541
+1542
+1543
+1544
+1545
+1546
+1547
+1548
+1549
+1550
+1551
+1552
+1553
+1554
+1555
+1556
+1557
+1558
+1559
+1560
+1561
+1562
+1563
+1564
+1565
+1566
+1567
+1568
+1569
+1570
+1571
+1572
+1573
+1574
+1575
+1576
+1577
+1578
+1579
+1580
+1581
+1582
+1583
+1584
+1585
+1586
+1587
+1588
+1589
+1590
+1591
+1592
+1593
+1594
+1595
+1596
+1597
+1598
+1599
+1600
+1601
+1602
+1603
+1604
+1605
+1606
+1607
+1608
+1609
+1610
+1611
+1612
+1613
+1614
+1615
+1616
+1617
+1618
+1619
+1620
+1621
+1622
+1623
+1624
+1625
+1626
+1627
+1628
+1629
+1630
+1631
+1632
+1633
+1634
+1635
+1636
+1637
+1638
+1639
+1640
+1641
+1642
+1643
+1644
+1645
+1646
+1647
+1648
+1649
+1650
+1651
+1652
+1653
+1654
+1655
+1656
+1657
+1658
+1659
+1660
+1661
+1662
+1663
+1664
+1665
+1666
+1667
+1668
+1669
+1670
+1671
+1672
+1673
+1674
+1675
+1676
+1677
+1678
+1679
+1680
+1681
+1682
+1683
+1684
+1685
+1686
+1687
+1688
+1689
+1690
+1691
+1692
+1693
+1694
+1695
+1696
+1697
+1698
+1699
+1700
+1701
+1702
+1703
+1704
+1705
+1706
+1707
+1708
+1709
+1710
+1711
+1712
+1713
+1714
+1715
+1716
+1717
+1718
+1719
+1720
+1721
+1722
+1723
+1724
+1725
+1726
+1727
+1728
+1729
+1730
+1731
+1732
+1733
+1734
+1735
+1736
+1737
+1738
+1739
+1740
+1741
+1742
+1743
+1744
+1745
+1746
+1747
+1748
+1749
+1750
+1751
+1752
+1753
+1754
+1755
+1756
+1757
+1758
+1759
+1760
+1761
+1762
+1763
+1764
+1765
+1766
+1767
+1768
+1769
+1770
+1771
+1772
+1773
+1774
+1775
+1776
+1777
+1778
+1779
+1780
+1781
+1782
+1783
+1784
+1785
+1786
+1787
+1788
+1789
+1790
+1791
+1792
+1793
+1794
+1795
+1796
+1797
+1798
+1799
+1800
+1801
+1802
+1803
+1804
+1805
+1806
+1807
+1808
+1809
+1810
+1811
+1812
+1813
+1814
+1815
+1816
+1817
+1818
+1819
+1820
+1821
+1822
+1823
+1824
+1825
+1826
+1827
+1828
+1829
+1830
+1831
+1832
+1833
+1834
+1835
+1836
+1837
+1838
+1839
+1840
+1841
+1842
+1843
+1844
+1845
+1846
+1847
+1848
+1849
+1850
+1851
+1852
+1853
+1854
+1855
+1856
+1857
+1858
+1859
+1860
+1861
+1862
+1863
+1864
+1865
+1866
+1867
+1868
+1869
+1870
+1871
+1872
+1873
+1874
+1875
+1876
+1877
+1878
+1879
+1880
+1881
+1882
+1883
+1884
+1885
+1886
+1887
+1888
+1889
+1890
+1891
+1892
+1893
+1894
+1895
+1896
+1897
+1898
+1899
+1900
+1901
+1902
+1903
+1904
+1905
+1906
+1907
+1908
+1909
+1910
+1911
+1912
+1913
+1914
+1915
+1916
+1917
+1918
+1919
+1920
+1921
+1922
+1923
+1924
+1925
+1926
+1927
+1928
+1929
+1930
+1931
+1932
+1933
+1934
+1935
+1936
+1937
+1938
+1939
+1940
+1941
+1942
+1943
+1944
+1945
+1946
+1947
+1948
+1949
+1950
+1951
+1952
+1953
+1954
+1955
+1956
+1957
+1958
+1959
+1960
+1961
+1962
+1963
+1964
+1965
+1966
+1967
+1968
+1969
+1970
+1971
+1972
+1973
+1974
+1975
+1976
+1977
+1978
+1979
+1980
+1981
+1982
+1983
+1984
+1985
+1986
+1987
+1988
+1989
+1990
+1991
+1992
+1993
+1994
+1995
+1996
+1997
+1998
+1999
+2000
+2001
+2002
+2003
+2004
+2005
+2006
+2007
+2008
+2009
+2010
+2011
+2012
+2013
+2014
+2015
+2016
+2017
+2018
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2005 William Jon McCann <mccann@jhu.edu>
+ * Copyright (C) 2005-2008 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "config.h"<--- Include file: "config.h" not found.
+
+#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <time.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <errno.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/time.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/types.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#ifdef HAVE_UNISTD_H
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif /* HAVE_UNISTD_H */
+
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gio/gunixfdlist.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <dbus/dbus-glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <dbus/dbus-glib-lowlevel.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <canberra-gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <libupower-glib/upower.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <libnotify/notify.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "egg-console-kit.h"
+
+#include "gpm-button.h"
+#include "gpm-control.h"
+#include "gpm-common.h"
+#include "gpm-dpms.h"
+#include "gpm-idle.h"
+#include "gpm-manager.h"
+#include "gpm-screensaver.h"
+#include "gpm-backlight.h"
+#include "gpm-kbd-backlight.h"
+#include "gpm-session.h"
+#include "gpm-icon-names.h"
+#include "gpm-tray-icon.h"
+#include "gpm-engine.h"
+#include "gpm-upower.h"
+
+#include "org.mate.PowerManager.Backlight.h"
+#include "org.mate.PowerManager.KbdBacklight.h"
+
+static void     gpm_manager_finalize	(GObject	 *object);
+
+#define GPM_MANAGER_NOTIFY_TIMEOUT_NEVER	0 /* ms */
+#define GPM_MANAGER_NOTIFY_TIMEOUT_SHORT	10 * 1000 /* ms */
+#define GPM_MANAGER_NOTIFY_TIMEOUT_LONG		30 * 1000 /* ms */
+
+#define GPM_MANAGER_CRITICAL_ALERT_TIMEOUT      5 /* seconds */
+
+struct GpmManagerPrivate
+{
+	GpmButton		*button;
+	GSettings		*settings;
+	GpmDpms			*dpms;
+	GpmIdle			*idle;
+	GpmControl		*control;
+	GpmScreensaver		*screensaver;
+	GpmTrayIcon		*tray_icon;
+	GpmEngine		*engine;
+	GpmBacklight		*backlight;
+	GpmKbdBacklight		*kbd_backlight;
+	EggConsoleKit		*console;
+	guint32			 screensaver_ac_throttle_id;
+	guint32			 screensaver_dpms_throttle_id;
+	guint32			 screensaver_lid_throttle_id;
+	guint32                  critical_alert_timeout_id;
+	ca_proplist             *critical_alert_loop_props;
+	UpClient		*client;
+	gboolean		 on_battery;
+	gboolean		 just_resumed;
+	GtkStatusIcon		*status_icon;
+	NotifyNotification	*notification_general;
+	NotifyNotification	*notification_warning_low;
+	NotifyNotification	*notification_discharging;
+	NotifyNotification	*notification_fully_charged;
+	gint32                   systemd_inhibit;
+	GDBusProxy              *systemd_inhibit_proxy;
+};
+
+typedef enum {
+	GPM_MANAGER_SOUND_POWER_PLUG,
+	GPM_MANAGER_SOUND_POWER_UNPLUG,
+	GPM_MANAGER_SOUND_LID_OPEN,
+	GPM_MANAGER_SOUND_LID_CLOSE,
+	GPM_MANAGER_SOUND_BATTERY_CAUTION,
+	GPM_MANAGER_SOUND_BATTERY_LOW,
+	GPM_MANAGER_SOUND_BATTERY_FULL,
+	GPM_MANAGER_SOUND_SUSPEND_START,
+	GPM_MANAGER_SOUND_SUSPEND_RESUME,
+	GPM_MANAGER_SOUND_SUSPEND_ERROR,
+	GPM_MANAGER_SOUND_LAST
+} GpmManagerSound;
+
+G_DEFINE_TYPE_WITH_PRIVATE (GpmManager, gpm_manager, G_TYPE_OBJECT)<--- There is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
+
+/**
+ * gpm_manager_error_quark:
+ * Return value: Our personal error quark.
+ **/
+GQuark
+gpm_manager_error_quark (void)
+{
+	static GQuark quark = 0;
+	if (!quark)
+		quark = g_quark_from_static_string ("gpm_manager_error");
+	return quark;
+}
+
+/**
+ * gpm_manager_error_get_type:
+ **/
+#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC }
+GType
+gpm_manager_error_get_type (void)
+{
+	static GType etype = 0;
+
+	if (etype == 0) {
+		static const GEnumValue values[] =
+		{
+			ENUM_ENTRY (GPM_MANAGER_ERROR_DENIED, "PermissionDenied"),
+			ENUM_ENTRY (GPM_MANAGER_ERROR_NO_HW, "NoHardwareSupport"),
+			{ 0, 0, 0 }
+		};
+		etype = g_enum_register_static ("GpmManagerError", values);
+	}
+	return etype;
+}
+
+/**
+ * gpm_manager_play_loop_timeout_cb:
+ **/
+static gboolean
+gpm_manager_play_loop_timeout_cb (GpmManager *manager)
+{
+	ca_context *context;
+	context = ca_gtk_context_get_for_screen (gdk_screen_get_default ());
+	ca_context_play_full (context, 0,
+			      manager->priv->critical_alert_loop_props,
+			      NULL,
+			      NULL);
+	return TRUE;
+}
+
+/**
+ * gpm_manager_play_loop_stop:
+ **/
+static gboolean
+gpm_manager_play_loop_stop (GpmManager *manager)
+{
+	if (manager->priv->critical_alert_timeout_id == 0) {
+		g_warning ("no sound loop present to stop");
+		return FALSE;
+	}
+
+	g_source_remove (manager->priv->critical_alert_timeout_id);
+	ca_proplist_destroy (manager->priv->critical_alert_loop_props);
+
+	manager->priv->critical_alert_loop_props = NULL;
+	manager->priv->critical_alert_timeout_id = 0;
+
+	return TRUE;
+}
+
+/**
+ * gpm_manager_play_loop_start:
+ **/
+static gboolean
+gpm_manager_play_loop_start (GpmManager *manager, GpmManagerSound action, gboolean force, guint timeout)
+{
+	const gchar *id = NULL;
+	const gchar *desc = NULL;
+	gboolean ret;
+	gint retval;
+	ca_context *context;
+
+	ret = g_settings_get_boolean (manager->priv->settings, GPM_SETTINGS_ENABLE_SOUND);
+	if (!ret && !force) {
+		g_debug ("ignoring sound due to policy");
+		return FALSE;
+	}
+
+	if (timeout == 0) {
+		g_warning ("received invalid timeout");
+		return FALSE;
+	}
+
+	/* if a sound loop is already running, stop the existing loop */
+	if (manager->priv->critical_alert_timeout_id != 0) {
+		g_warning ("was instructed to play a sound loop with one already playing");
+		gpm_manager_play_loop_stop (manager);
+	}
+
+	if (action == GPM_MANAGER_SOUND_BATTERY_LOW) {
+		id = "battery-low";
+		/* TRANSLATORS: this is the sound description */
+		desc = _("Battery is very low");
+	}
+
+	/* no match */
+	if (id == NULL) {
+		g_warning ("no sound match for %u", action);
+		return FALSE;
+	}
+
+	ca_proplist_create (&(manager->priv->critical_alert_loop_props));
+	ca_proplist_sets (manager->priv->critical_alert_loop_props,
+			  CA_PROP_EVENT_ID, id);
+	ca_proplist_sets (manager->priv->critical_alert_loop_props,
+			  CA_PROP_EVENT_DESCRIPTION, desc);
+
+	manager->priv->critical_alert_timeout_id = g_timeout_add_seconds (timeout,
+									  (GSourceFunc) gpm_manager_play_loop_timeout_cb,
+									  manager);
+
+	g_source_set_name_by_id (manager->priv->critical_alert_timeout_id, "[GpmManager] play-loop");
+
+	/* play the sound, using sounds from the naming spec */
+	context = ca_gtk_context_get_for_screen (gdk_screen_get_default ());
+	retval = ca_context_play (context, 0,
+				  CA_PROP_EVENT_ID, id,
+				  CA_PROP_EVENT_DESCRIPTION, desc, NULL);
+	if (retval < 0)
+		g_warning ("failed to play %s: %s", id, ca_strerror (retval));
+	return TRUE;
+}
+
+/**
+ * gpm_manager_play:
+ **/
+static gboolean
+gpm_manager_play (GpmManager *manager, GpmManagerSound action, gboolean force)
+{
+	const gchar *id = NULL;
+	const gchar *desc = NULL;
+	gboolean ret;
+	gint retval;
+	ca_context *context;
+
+	ret = g_settings_get_boolean (manager->priv->settings, GPM_SETTINGS_ENABLE_SOUND);
+	if (!ret && !force) {
+		g_debug ("ignoring sound due to policy");
+		return FALSE;
+	}
+
+	if (action == GPM_MANAGER_SOUND_POWER_PLUG) {
+		id = "power-plug";
+		/* TRANSLATORS: this is the sound description */
+		desc = _("Power plugged in");
+	} else if (action == GPM_MANAGER_SOUND_POWER_UNPLUG) {
+		id = "power-unplug";
+		/* TRANSLATORS: this is the sound description */
+		desc = _("Power unplugged");
+	} else if (action == GPM_MANAGER_SOUND_LID_OPEN) {
+		id = "lid-open";
+		/* TRANSLATORS: this is the sound description */
+		desc = _("Lid has opened");
+	} else if (action == GPM_MANAGER_SOUND_LID_CLOSE) {
+		id = "lid-close";
+		/* TRANSLATORS: this is the sound description */
+		desc = _("Lid has closed");
+	} else if (action == GPM_MANAGER_SOUND_BATTERY_CAUTION) {
+		id = "battery-caution";
+		/* TRANSLATORS: this is the sound description */
+		desc = _("Battery is low");
+	} else if (action == GPM_MANAGER_SOUND_BATTERY_LOW) {
+		id = "battery-low";
+		/* TRANSLATORS: this is the sound description */
+		desc = _("Battery is very low");
+	} else if (action == GPM_MANAGER_SOUND_BATTERY_FULL) {
+		id = "battery-full";
+		/* TRANSLATORS: this is the sound description */
+		desc = _("Battery is full");
+	} else if (action == GPM_MANAGER_SOUND_SUSPEND_START) {
+		id = "suspend-start";
+		/* TRANSLATORS: this is the sound description */
+		desc = _("Suspend started");
+	} else if (action == GPM_MANAGER_SOUND_SUSPEND_RESUME) {
+		id = "suspend-resume";
+		/* TRANSLATORS: this is the sound description */
+		desc = _("Resumed");
+	} else if (action == GPM_MANAGER_SOUND_SUSPEND_ERROR) {
+		id = "suspend-error";
+		/* TRANSLATORS: this is the sound description */
+		desc = _("Suspend failed");
+	}
+
+	/* no match */
+	if (id == NULL) {
+		g_warning ("no match");
+		return FALSE;
+	}
+
+	/* play the sound, using sounds from the naming spec */
+	context = ca_gtk_context_get_for_screen (gdk_screen_get_default ());
+	retval = ca_context_play (context, 0,
+				  CA_PROP_EVENT_ID, id,
+				  CA_PROP_EVENT_DESCRIPTION, desc, NULL);
+	if (retval < 0)
+		g_warning ("failed to play %s: %s", id, ca_strerror (retval));
+	return TRUE;
+}
+
+/**
+ * gpm_manager_is_inhibit_valid:
+ * @manager: This class instance
+ * @action: The action we want to do, e.g. "suspend"
+ *
+ * Checks to see if the specific action has been inhibited by a program.
+ *
+ * Return value: TRUE if we can perform the action.
+ **/
+static gboolean
+gpm_manager_is_inhibit_valid (GpmManager *manager, gboolean user_action, const char *action)
+{
+	return TRUE;
+}
+
+/**
+ * gpm_manager_sync_policy_sleep:
+ * @manager: This class instance
+ *
+ * Changes the policy if required, setting brightness, display and computer
+ * timeouts.
+ * We have to make sure mate-screensaver disables screensaving, and enables
+ * monitor DPMS instead when on batteries to save power.
+ **/
+static void
+gpm_manager_sync_policy_sleep (GpmManager *manager)
+{
+	guint sleep_display;
+	guint sleep_computer;
+
+	if (!manager->priv->on_battery) {
+		sleep_computer = g_settings_get_int (manager->priv->settings, GPM_SETTINGS_SLEEP_COMPUTER_AC);
+		sleep_display = g_settings_get_int (manager->priv->settings, GPM_SETTINGS_SLEEP_DISPLAY_AC);
+	} else {
+		sleep_computer = g_settings_get_int (manager->priv->settings, GPM_SETTINGS_SLEEP_COMPUTER_BATT);
+		sleep_display = g_settings_get_int (manager->priv->settings, GPM_SETTINGS_SLEEP_DISPLAY_BATT);
+	}
+
+	/* set the new sleep (inactivity) value */
+	gpm_idle_set_timeout_blank (manager->priv->idle, sleep_display);
+	gpm_idle_set_timeout_sleep (manager->priv->idle, sleep_computer);
+}
+
+/**
+ * gpm_manager_blank_screen:
+ * @manager: This class instance
+ *
+ * Turn off the backlight of the LCD when we shut the lid, and lock
+ * if required. This is required because some laptops do not turn off the
+ * LCD backlight when the lid is closed.
+ * See http://bugzilla.gnome.org/show_bug.cgi?id=321313
+ *
+ * Return value: Success.
+ **/
+static gboolean
+gpm_manager_blank_screen (GpmManager *manager, GError **noerror)
+{
+	gboolean do_lock;
+	gboolean ret = TRUE;
+	GError *error = NULL;
+
+	do_lock = gpm_control_get_lock_policy (manager->priv->control,
+					       GPM_SETTINGS_LOCK_ON_BLANK_SCREEN);
+	if (do_lock) {
+		if (!gpm_screensaver_lock (manager->priv->screensaver))
+			g_debug ("Could not lock screen via mate-screensaver");
+	}
+	gpm_dpms_set_mode (manager->priv->dpms, GPM_DPMS_MODE_OFF, &error);
+	if (error) {
+		g_debug ("Unable to set DPMS mode: %s", error->message);
+		g_error_free (error);
+		ret = FALSE;
+	}
+	return ret;
+}
+
+/**
+ * gpm_manager_unblank_screen:
+ * @manager: This class instance
+ *
+ * Unblank the screen after we have opened the lid of the laptop
+ *
+ * Return value: Success.
+ **/
+static gboolean
+gpm_manager_unblank_screen (GpmManager *manager, GError **noerror)
+{
+	gboolean do_lock;
+	gboolean ret = TRUE;
+	GError *error = NULL;
+
+	gpm_dpms_set_mode (manager->priv->dpms, GPM_DPMS_MODE_ON, &error);
+	if (error) {
+		g_debug ("Unable to set DPMS mode: %s", error->message);
+		g_error_free (error);
+		ret = FALSE;
+	}
+
+	do_lock = gpm_control_get_lock_policy (manager->priv->control, GPM_SETTINGS_LOCK_ON_BLANK_SCREEN);
+	if (do_lock)
+		gpm_screensaver_poke (manager->priv->screensaver);
+	return ret;
+}
+
+/**
+ * gpm_manager_notify_close:
+ **/
+static gboolean
+gpm_manager_notify_close (GpmManager *manager, NotifyNotification *notification)
+{
+	gboolean ret = FALSE;
+	GError *error = NULL;
+
+	/* exists? */
+	if (notification == NULL)
+		goto out;
+
+	/* try to close */
+	ret = notify_notification_close (notification, &error);
+	if (!ret) {
+		g_warning ("failed to close notification: %s", error->message);
+		g_error_free (error);
+		goto out;
+	}
+out:
+	return ret;
+}
+
+/**
+ * gpm_manager_notification_closed_cb:
+ **/
+static void
+gpm_manager_notification_closed_cb (NotifyNotification *notification, NotifyNotification **notification_class)
+{
+	g_debug ("caught notification closed signal %p", notification);
+	/* the object is already unreffed in _close_signal_handler */
+	*notification_class = NULL;
+}
+
+/**
+ * gpm_manager_notify:
+ **/
+static gboolean
+gpm_manager_notify (GpmManager *manager, NotifyNotification **notification_class,
+		    const gchar *title, const gchar *message,
+		    guint timeout, const gchar *icon, NotifyUrgency urgency)
+{
+	gboolean ret;
+	GError *error = NULL;
+	NotifyNotification *notification;
+	GtkWidget *dialog;
+
+	/* close any existing notification of this class */
+	gpm_manager_notify_close (manager, *notification_class);
+
+	/* if the status icon is hidden, don't point at it */
+	if (manager->priv->status_icon != NULL &&
+	    gtk_status_icon_is_embedded (manager->priv->status_icon))
+		notification = notify_notification_new (title, message, gtk_status_icon_get_icon_name(manager->priv->status_icon));
+	else
+		notification = notify_notification_new (title, message, icon);
+	notify_notification_set_timeout (notification, timeout);
+	notify_notification_set_urgency (notification, urgency);
+	g_signal_connect (notification, "closed", G_CALLBACK (gpm_manager_notification_closed_cb), notification_class);
+
+	g_debug ("notification %p: %s : %s", notification, title, message);
+
+	/* try to show */
+	ret = notify_notification_show (notification, &error);
+	if (!ret) {
+		g_warning ("failed to show notification: %s", error->message);
+		g_error_free (error);
+
+		/* show modal dialog as libmatenotify failed */
+		dialog = gtk_message_dialog_new_with_markup (NULL, GTK_DIALOG_DESTROY_WITH_PARENT,
+							     GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE,
+							     "<span size='larger'><b>%s</b></span>", title);
+		gtk_message_dialog_format_secondary_markup (GTK_MESSAGE_DIALOG (dialog), "%s", message);
+
+		/* wait async for close */
+		gtk_widget_show (dialog);
+		g_signal_connect_swapped (dialog, "response", G_CALLBACK (gtk_widget_destroy), dialog);
+
+		g_object_unref (notification);
+		goto out;
+	}
+
+	/* save this local instance as the class instance */
+	g_object_add_weak_pointer (G_OBJECT (notification), (gpointer) &notification);
+	*notification_class = notification;
+out:
+	return ret;
+}
+
+/**
+ * gpm_manager_sleep_failure_response_cb:
+ **/
+static void
+gpm_manager_sleep_failure_response_cb (GtkDialog *dialog, gint response_id, GpmManager *manager)
+{
+	GtkWidget *dialog_error;
+	GError *error = NULL;
+	gboolean ret;
+	gchar *uri = NULL;
+
+	/* user clicked the help button */
+	if (response_id == GTK_RESPONSE_HELP) {
+		uri = g_settings_get_string (manager->priv->settings, GPM_SETTINGS_NOTIFY_SLEEP_FAILED_URI);
+		ret = gtk_show_uri_on_window (GTK_WINDOW (dialog), uri, gtk_get_current_event_time (), &error);
+		if (!ret) {
+			dialog_error = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_INFO, GTK_BUTTONS_OK,
+							       "Failed to show uri %s", error->message);
+			gtk_dialog_run (GTK_DIALOG (dialog_error));
+			g_error_free (error);
+		}
+	}
+
+	gtk_widget_destroy (GTK_WIDGET (dialog));
+	g_free (uri);
+}
+
+/**
+ * gpm_manager_sleep_failure:
+ **/
+static void
+gpm_manager_sleep_failure (GpmManager *manager, gboolean is_suspend, const gchar *detail)
+{
+	gboolean show_sleep_failed;
+	GString *string = NULL;
+	const gchar *title;
+	gchar *uri = NULL;
+	const gchar *icon;
+	GtkWidget *dialog;
+
+	/* only show this if specified in settings */
+	show_sleep_failed = g_settings_get_boolean (manager->priv->settings, GPM_SETTINGS_NOTIFY_SLEEP_FAILED);
+
+	g_debug ("sleep failed");
+	gpm_manager_play (manager, GPM_MANAGER_SOUND_SUSPEND_ERROR, TRUE);
+
+	/* only emit if specified in settings */
+	if (!show_sleep_failed)
+		goto out;
+
+	/* TRANSLATORS: window title: there was a problem putting the machine to sleep */
+	string = g_string_new ("");
+	if (is_suspend) {
+		/* TRANSLATORS: message text */
+		g_string_append (string, _("Computer failed to suspend."));
+		/* TRANSLATORS: title text */
+		title = _("Failed to suspend");
+		icon = GPM_ICON_SUSPEND;
+	} else {
+		/* TRANSLATORS: message text */
+		g_string_append (string, _("Computer failed to hibernate."));
+		/* TRANSLATORS: title text */
+		title = _("Failed to hibernate");
+		icon = GPM_ICON_HIBERNATE;
+	}
+
+	/* TRANSLATORS: message text */
+	g_string_append_printf (string, "\n\n%s %s", _("Failure was reported as:"), detail);
+
+	/* show modal dialog */
+	dialog = gtk_message_dialog_new_with_markup (NULL, GTK_DIALOG_DESTROY_WITH_PARENT,
+						     GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE,
+						     "<span size='larger'><b>%s</b></span>", title);
+	gtk_message_dialog_format_secondary_markup (GTK_MESSAGE_DIALOG (dialog), "%s", string->str);
+	gtk_window_set_icon_name (GTK_WINDOW(dialog), icon);
+
+	/* show a button? */
+	uri = g_settings_get_string (manager->priv->settings, GPM_SETTINGS_NOTIFY_SLEEP_FAILED_URI);
+	if (uri != NULL && uri[0] != '\0') {
+		/* TRANSLATORS: button text, visit the suspend help website */
+		gtk_dialog_add_button (GTK_DIALOG (dialog), _("Visit help page"), GTK_RESPONSE_HELP);
+	}
+
+	/* wait async for close */
+	gtk_widget_show (dialog);
+	g_signal_connect (dialog, "response", G_CALLBACK (gpm_manager_sleep_failure_response_cb), manager);
+out:
+	g_free (uri);
+	g_string_free (string, TRUE);
+}
+
+/**
+ * gpm_manager_action_suspend:
+ **/
+static gboolean
+gpm_manager_action_suspend (GpmManager *manager, const gchar *reason)
+{
+	gboolean ret;
+	GError *error = NULL;
+
+	/* check to see if we are inhibited */
+	if (gpm_manager_is_inhibit_valid (manager, FALSE, "suspend") == FALSE)
+		return FALSE;
+
+	g_debug ("suspending, reason: %s", reason);
+	ret = gpm_control_suspend (manager->priv->control, &error);
+	if (!ret) {
+		gpm_manager_sleep_failure (manager, TRUE, error->message);
+		g_error_free (error);
+	}
+	gpm_button_reset_time (manager->priv->button);
+	return TRUE;
+}
+
+/**
+ * gpm_manager_action_hibernate:
+ **/
+static gboolean
+gpm_manager_action_hibernate (GpmManager *manager, const gchar *reason)
+{
+	gboolean ret;
+	GError *error = NULL;
+
+	/* check to see if we are inhibited */
+	if (gpm_manager_is_inhibit_valid (manager, FALSE, "hibernate") == FALSE)
+		return FALSE;
+
+	g_debug ("hibernating, reason: %s", reason);
+	ret = gpm_control_hibernate (manager->priv->control, &error);
+	if (!ret) {
+		gpm_manager_sleep_failure (manager, TRUE, error->message);
+		g_error_free (error);
+	}
+	gpm_button_reset_time (manager->priv->button);
+	return TRUE;
+}
+
+/**
+ * gpm_manager_perform_policy:
+ * @manager: This class instance
+ * @policy: The policy that we should do, e.g. "suspend"
+ * @reason: The reason we are performing the policy action, e.g. "battery critical"
+ *
+ * Does one of the policy actions specified in the settings.
+ **/
+static gboolean
+gpm_manager_perform_policy (GpmManager  *manager, const gchar *policy_key, const gchar *reason)
+{
+	GpmActionPolicy policy;
+
+	/* are we inhibited? */
+	if (gpm_manager_is_inhibit_valid (manager, FALSE, "policy action") == FALSE)
+		return FALSE;
+
+	policy = g_settings_get_enum (manager->priv->settings, policy_key);
+	g_debug ("action: %s set to %u (%s)", policy_key, policy, reason);
+
+	if (policy == GPM_ACTION_POLICY_NOTHING) {
+		g_debug ("doing nothing, reason: %s", reason);
+	} else if (policy == GPM_ACTION_POLICY_SUSPEND) {
+		gpm_manager_action_suspend (manager, reason);
+
+	} else if (policy == GPM_ACTION_POLICY_HIBERNATE) {
+		gpm_manager_action_hibernate (manager, reason);
+
+	} else if (policy == GPM_ACTION_POLICY_BLANK) {
+		gpm_manager_blank_screen (manager, NULL);
+
+	} else if (policy == GPM_ACTION_POLICY_SHUTDOWN) {
+		g_debug ("shutting down, reason: %s", reason);
+		gpm_control_shutdown (manager->priv->control, NULL);
+
+	} else if (policy == GPM_ACTION_POLICY_INTERACTIVE) {
+		GpmSession *session;
+		g_debug ("logout, reason: %s", reason);
+		session = gpm_session_new ();
+		gpm_session_logout (session);
+		g_object_unref (session);
+	} else {
+		g_warning ("unknown action %u", policy);
+	}
+
+	return TRUE;
+}
+
+/**
+ * gpm_manager_idle_do_sleep:
+ * @manager: This class instance
+ *
+ * This callback is called when we want to sleep. Use the users
+ * preference from the settings, but change it if we can't do the action.
+ **/
+static void
+gpm_manager_idle_do_sleep (GpmManager *manager)
+{
+	gboolean ret;
+	GError *error = NULL;
+	GpmActionPolicy policy;
+
+	if (!manager->priv->on_battery)
+		policy = g_settings_get_enum (manager->priv->settings, GPM_SETTINGS_ACTION_SLEEP_TYPE_AC);
+	else
+		policy = g_settings_get_enum (manager->priv->settings, GPM_SETTINGS_ACTION_SLEEP_TYPE_BATT);
+
+	if (policy == GPM_ACTION_POLICY_NOTHING) {
+		g_debug ("doing nothing as system idle action");
+
+	} else if (policy == GPM_ACTION_POLICY_SUSPEND) {
+		g_debug ("suspending, reason: System idle");
+		ret = gpm_control_suspend (manager->priv->control, &error);
+		if (!ret) {
+			g_warning ("cannot suspend (error: %s), so trying hibernate", error->message);
+			g_error_free (error);
+			error = NULL;
+			ret = gpm_control_hibernate (manager->priv->control, &error);
+			if (!ret) {
+				g_warning ("cannot suspend or hibernate: %s", error->message);
+				g_error_free (error);
+			}
+		}
+
+	} else if (policy == GPM_ACTION_POLICY_HIBERNATE) {
+		g_debug ("hibernating, reason: System idle");
+		ret = gpm_control_hibernate (manager->priv->control, &error);
+		if (!ret) {
+			g_warning ("cannot hibernate (error: %s), so trying suspend", error->message);
+			g_error_free (error);
+			error = NULL;
+			ret = gpm_control_suspend (manager->priv->control, &error);
+			if (!ret) {
+				g_warning ("cannot suspend or hibernate: %s", error->message);
+				g_error_free (error);
+			}
+		}
+	}
+}
+
+/**
+ * gpm_manager_idle_changed_cb:
+ * @idle: The idle class instance
+ * @mode: The idle mode, e.g. GPM_IDLE_MODE_BLANK
+ * @manager: This class instance
+ *
+ * This callback is called when the idle class detects that the idle state
+ * has changed. GPM_IDLE_MODE_BLANK is when the session has become inactive,
+ * and GPM_IDLE_MODE_SLEEP is where the session has become inactive, AND the
+ * session timeout has elapsed for the idle action.
+ **/
+static void
+gpm_manager_idle_changed_cb (GpmIdle *idle, GpmIdleMode mode, GpmManager *manager)
+{
+	/* ConsoleKit/systemd say we are not on active console */
+	if (!LOGIND_RUNNING() && !egg_console_kit_is_active (manager->priv->console)) {
+		g_debug ("ignoring as not on active console");
+		return;
+	}
+
+	/* Ignore back-to-NORMAL events when the lid is closed, as the DPMS is
+	 * already off, and we don't want to re-enable the screen when the user
+	 * moves the mouse on systems that do not support hardware blanking. */
+	if (gpm_button_is_lid_closed (manager->priv->button) &&
+	    mode == GPM_IDLE_MODE_NORMAL) {
+		g_debug ("lid is closed, so we are ignoring ->NORMAL state changes");
+		return;
+	}
+
+	if (mode == GPM_IDLE_MODE_SLEEP) {
+		g_debug ("Idle state changed: SLEEP");
+		if (gpm_manager_is_inhibit_valid (manager, FALSE, "timeout action") == FALSE)
+			return;
+		gpm_manager_idle_do_sleep (manager);
+	}
+}
+
+/**
+ * gpm_manager_lid_button_pressed:
+ * @manager: This class instance
+ * @state: TRUE for closed
+ *
+ * Does actions when the lid is closed, depending on if we are on AC or
+ * battery power.
+ **/
+static void
+gpm_manager_lid_button_pressed (GpmManager *manager, gboolean pressed)
+{
+	if (pressed)
+		gpm_manager_play (manager, GPM_MANAGER_SOUND_LID_CLOSE, FALSE);
+	else
+		gpm_manager_play (manager, GPM_MANAGER_SOUND_LID_OPEN, FALSE);
+
+	if (pressed == FALSE) {
+		/* we turn the lid dpms back on unconditionally */
+		gpm_manager_unblank_screen (manager, NULL);
+		return;
+	}
+
+	if (!manager->priv->on_battery) {
+		g_debug ("Performing AC policy");
+		gpm_manager_perform_policy (manager, GPM_SETTINGS_BUTTON_LID_AC,
+					    "The lid has been closed on ac power.");
+		return;
+	}
+
+	g_debug ("Performing battery policy");
+	gpm_manager_perform_policy (manager, GPM_SETTINGS_BUTTON_LID_BATT,
+				    "The lid has been closed on battery power.");
+}
+
+static void
+gpm_manager_update_dpms_throttle (GpmManager *manager)
+{
+	GpmDpmsMode mode;
+	gpm_dpms_get_mode (manager->priv->dpms, &mode, NULL);
+
+	/* Throttle the manager when DPMS is active since we can't see it anyway */
+	if (mode == GPM_DPMS_MODE_ON) {
+		if (manager->priv->screensaver_dpms_throttle_id != 0) {
+			gpm_screensaver_remove_throttle (manager->priv->screensaver, manager->priv->screensaver_dpms_throttle_id);
+			manager->priv->screensaver_dpms_throttle_id = 0;
+		}
+	} else {
+		/* if throttle already exists then remove */
+		if (manager->priv->screensaver_dpms_throttle_id != 0) {
+			gpm_screensaver_remove_throttle (manager->priv->screensaver, manager->priv->screensaver_dpms_throttle_id);
+		}
+		/* TRANSLATORS: this is the mate-screensaver throttle */
+		manager->priv->screensaver_dpms_throttle_id = gpm_screensaver_add_throttle (manager->priv->screensaver, _("Display DPMS activated"));
+	}
+}
+
+static void
+gpm_manager_update_ac_throttle (GpmManager *manager)
+{
+	/* Throttle the manager when we are not on AC power so we don't
+	   waste the battery */
+	if (!manager->priv->on_battery) {
+		if (manager->priv->screensaver_ac_throttle_id != 0) {
+			gpm_screensaver_remove_throttle (manager->priv->screensaver, manager->priv->screensaver_ac_throttle_id);
+			manager->priv->screensaver_ac_throttle_id = 0;
+		}
+	} else {
+		/* if throttle already exists then remove */
+		if (manager->priv->screensaver_ac_throttle_id != 0)
+			gpm_screensaver_remove_throttle (manager->priv->screensaver, manager->priv->screensaver_ac_throttle_id);
+		/* TRANSLATORS: this is the mate-screensaver throttle */
+		manager->priv->screensaver_ac_throttle_id = gpm_screensaver_add_throttle (manager->priv->screensaver, _("On battery power"));
+	}
+}
+
+static void
+gpm_manager_update_lid_throttle (GpmManager *manager, gboolean lid_is_closed)
+{
+	/* Throttle the screensaver when the lid is close since we can't see it anyway
+	   and it may overheat the laptop */
+	if (lid_is_closed == FALSE) {
+		if (manager->priv->screensaver_lid_throttle_id != 0) {
+			gpm_screensaver_remove_throttle (manager->priv->screensaver, manager->priv->screensaver_lid_throttle_id);
+			manager->priv->screensaver_lid_throttle_id = 0;
+		}
+	} else {
+		/* if throttle already exists then remove */
+		if (manager->priv->screensaver_lid_throttle_id != 0)
+			gpm_screensaver_remove_throttle (manager->priv->screensaver, manager->priv->screensaver_lid_throttle_id);
+		manager->priv->screensaver_lid_throttle_id = gpm_screensaver_add_throttle (manager->priv->screensaver, _("Laptop lid is closed"));
+	}
+}
+
+/**
+ * gpm_manager_button_pressed_cb:
+ * @power: The power class instance
+ * @type: The button type, e.g. "power"
+ * @state: The state, where TRUE is depressed or closed
+ * @manager: This class instance
+ **/
+static void
+gpm_manager_button_pressed_cb (GpmButton *button, const gchar *type, GpmManager *manager)
+{
+	gchar *message;
+	g_debug ("Button press event type=%s", type);
+
+	/* ConsoleKit/systemd say we are not on active console */
+	if (!LOGIND_RUNNING() && !egg_console_kit_is_active (manager->priv->console)) {
+		g_debug ("ignoring as not on active console");
+		return;
+	}
+
+	if (g_strcmp0 (type, GPM_BUTTON_POWER) == 0) {
+		gpm_manager_perform_policy (manager, GPM_SETTINGS_BUTTON_POWER, "The power button has been pressed.");
+	} else if (g_strcmp0 (type, GPM_BUTTON_SLEEP) == 0) {
+		gpm_manager_perform_policy (manager, GPM_SETTINGS_BUTTON_SUSPEND, "The suspend button has been pressed.");
+	} else if (g_strcmp0 (type, GPM_BUTTON_SUSPEND) == 0) {
+		gpm_manager_perform_policy (manager, GPM_SETTINGS_BUTTON_SUSPEND, "The suspend button has been pressed.");
+	} else if (g_strcmp0 (type, GPM_BUTTON_HIBERNATE) == 0) {
+		gpm_manager_perform_policy (manager, GPM_SETTINGS_BUTTON_HIBERNATE, "The hibernate button has been pressed.");
+	} else if (g_strcmp0 (type, GPM_BUTTON_LID_OPEN) == 0) {
+		gpm_manager_lid_button_pressed (manager, FALSE);
+	} else if (g_strcmp0 (type, GPM_BUTTON_LID_CLOSED) == 0) {
+		gpm_manager_lid_button_pressed (manager, TRUE);
+	} else if (g_strcmp0 (type, GPM_BUTTON_BATTERY) == 0) {
+		message = gpm_engine_get_summary (manager->priv->engine);
+		gpm_manager_notify (manager, &manager->priv->notification_general,
+				    _("Power Information"),
+				    message,
+				    GPM_MANAGER_NOTIFY_TIMEOUT_LONG,
+				    "dialog-information",
+				    NOTIFY_URGENCY_NORMAL);
+		g_free (message);
+	}
+
+	/* really belongs in mate-screensaver */
+	if (g_strcmp0 (type, GPM_BUTTON_LOCK) == 0)
+		gpm_screensaver_lock (manager->priv->screensaver);
+
+	/* disable or enable the fancy screensaver, as we don't want
+	 * this starting when the lid is shut */
+	if (g_strcmp0 (type, GPM_BUTTON_LID_CLOSED) == 0)
+		gpm_manager_update_lid_throttle (manager, TRUE);
+	else if (g_strcmp0 (type, GPM_BUTTON_LID_OPEN) == 0)
+		gpm_manager_update_lid_throttle (manager, FALSE);
+}
+
+/**
+ * gpm_manager_client_changed_cb:
+ **/
+static void
+gpm_manager_client_changed_cb (UpClient *client, GParamSpec *pspec, GpmManager *manager)
+{
+	gboolean event_when_closed;
+	gboolean on_battery;
+	gboolean lid_is_closed;
+
+	/* get the client state */
+	g_object_get (client,
+		      "on-battery", &on_battery,
+		      "lid-is-closed", &lid_is_closed,
+		      NULL);
+	if (on_battery == manager->priv->on_battery) {
+		g_debug ("same state as before, ignoring");
+		return;
+	}
+
+	/* close any discharging notifications */
+	if (!on_battery) {
+		g_debug ("clearing notify due ac being present");
+		gpm_manager_notify_close (manager, manager->priv->notification_warning_low);
+		gpm_manager_notify_close (manager, manager->priv->notification_discharging);
+	}
+
+	/* if we are playing a critical charge sound loop, stop it */
+	if (!on_battery && manager->priv->critical_alert_timeout_id) {
+		g_debug ("stopping alert loop due to ac being present");
+		gpm_manager_play_loop_stop (manager);
+	}
+
+	/* save in local cache */
+	manager->priv->on_battery = on_battery;
+
+	/* ConsoleKit/systemd say we are not on active console */
+	if (!LOGIND_RUNNING() && !egg_console_kit_is_active (manager->priv->console)) {
+		g_debug ("ignoring as not on active console");
+		return;
+	}
+
+	g_debug ("on_battery: %d", on_battery);
+
+	gpm_manager_sync_policy_sleep (manager);
+
+	gpm_manager_update_ac_throttle (manager);
+
+	/* simulate user input, but only when the lid is open */
+	if (!lid_is_closed)
+		gpm_screensaver_poke (manager->priv->screensaver);
+
+	if (!on_battery)
+		gpm_manager_play (manager, GPM_MANAGER_SOUND_POWER_PLUG, FALSE);
+	else
+		gpm_manager_play (manager, GPM_MANAGER_SOUND_POWER_UNPLUG, FALSE);
+
+	/* We do the lid close on battery action if the ac adapter is removed
+	   when the laptop is closed and on battery. Fixes #331655 */
+	event_when_closed = g_settings_get_boolean (manager->priv->settings, GPM_SETTINGS_SLEEP_WHEN_CLOSED);
+
+	/* We keep track of the lid state so we can do the
+	   lid close on battery action if the ac adapter is removed when the laptop
+	   is closed. Fixes #331655 */
+	if (event_when_closed && on_battery && lid_is_closed) {
+		gpm_manager_perform_policy (manager, GPM_SETTINGS_BUTTON_LID_BATT,
+					    "The lid has been closed, and the ac adapter "
+					    "removed (and GSettings is okay).");
+	}
+}
+
+/**
+ * manager_critical_action_do:
+ * @manager: This class instance
+ *
+ * This is the stub function when we have waited a few seconds for the user to
+ * see the message, explaining what we are about to do.
+ *
+ * Return value: FALSE, as we don't want to repeat this action on resume.
+ **/
+static gboolean
+manager_critical_action_do (GpmManager *manager)
+{
+	/* stop playing the alert as it's too late to do anything now */
+	if (manager->priv->critical_alert_timeout_id)
+		gpm_manager_play_loop_stop (manager);
+
+	gpm_manager_perform_policy (manager, GPM_SETTINGS_ACTION_CRITICAL_BATT, "Battery is critically low.");
+	return FALSE;
+}
+
+/**
+ * gpm_manager_class_init:
+ * @klass: The GpmManagerClass
+ **/
+static void
+gpm_manager_class_init (GpmManagerClass *klass)
+{
+	GObjectClass *object_class = G_OBJECT_CLASS (klass);
+	object_class->finalize = gpm_manager_finalize;
+}
+
+/**
+ * gpm_manager_settings_changed_cb:
+ *
+ * We might have to do things when the keys change; do them here.
+ **/
+static void
+gpm_manager_settings_changed_cb (GSettings *settings, const gchar *key, GpmManager *manager)
+{
+	if (g_strcmp0 (key, GPM_SETTINGS_SLEEP_COMPUTER_BATT) == 0 ||
+	    g_strcmp0 (key, GPM_SETTINGS_SLEEP_COMPUTER_AC) == 0 ||
+	    g_strcmp0 (key, GPM_SETTINGS_SLEEP_DISPLAY_BATT) == 0 ||
+	    g_strcmp0 (key, GPM_SETTINGS_SLEEP_DISPLAY_AC) == 0)
+		gpm_manager_sync_policy_sleep (manager);
+}
+
+/**
+ * gpm_manager_engine_icon_changed_cb:
+ */
+static void
+gpm_manager_engine_icon_changed_cb (GpmEngine  *engine, gchar *icon, GpmManager *manager)
+{
+	gpm_tray_icon_set_icon (manager->priv->tray_icon, icon);
+}
+
+/**
+ * gpm_manager_engine_summary_changed_cb:
+ */
+static void
+gpm_manager_engine_summary_changed_cb (GpmEngine *engine, gchar *summary, GpmManager *manager)
+{
+	gpm_tray_icon_set_tooltip (manager->priv->tray_icon, summary);
+}
+
+/**
+ * gpm_manager_engine_low_capacity_cb:
+ */
+static void
+gpm_manager_engine_low_capacity_cb (GpmEngine *engine, UpDevice *device, GpmManager *manager)
+{
+	gchar *message = NULL;
+	const gchar *title;
+	gdouble capacity;
+
+	/* don't show when running under GDM */
+	if (g_getenv ("RUNNING_UNDER_GDM") != NULL) {
+		g_debug ("running under gdm, so no notification");
+		goto out;
+	}
+
+	/* get device properties */
+	g_object_get (device,
+		      "capacity", &capacity,
+		      NULL);
+
+	/* We should notify the user if the battery has a low capacity,
+	 * where capacity is the ratio of the last_full capacity with that of
+	 * the design capacity. (#326740) */
+
+	/* TRANSLATORS: battery is old or broken */
+	title = _("Battery may be broken");
+
+	/* TRANSLATORS: notify the user that that battery is broken as the capacity is very low */
+	message = g_strdup_printf (_("Battery has a very low capacity (%1.1f%%), "
+				     "which means that it may be old or broken."), capacity);
+	gpm_manager_notify (manager, &manager->priv->notification_general, title, message, GPM_MANAGER_NOTIFY_TIMEOUT_SHORT,
+			    "dialog-information", NOTIFY_URGENCY_LOW);
+out:
+	g_free (message);
+}
+
+/**
+ * gpm_manager_engine_fully_charged_cb:
+ */
+static void
+gpm_manager_engine_fully_charged_cb (GpmEngine *engine, UpDevice *device, GpmManager *manager)
+{
+	UpDeviceKind kind;
+	gchar *native_path = NULL;
+	gboolean ret;
+	guint plural = 1;
+	const gchar *title;
+
+	/* only action this if specified in the setings */
+	ret = g_settings_get_boolean (manager->priv->settings, GPM_SETTINGS_NOTIFY_FULLY_CHARGED);
+	if (!ret) {
+		g_debug ("no notification");
+		goto out;
+	}
+
+	/* don't show when running under GDM */
+	if (g_getenv ("RUNNING_UNDER_GDM") != NULL) {
+		g_debug ("running under gdm, so no notification");
+		goto out;
+	}
+
+	/* get device properties */
+	g_object_get (device,
+		      "kind", &kind,
+		      "native-path", &native_path,
+		      NULL);
+
+	if (kind == UP_DEVICE_KIND_BATTERY) {
+		/* is this a dummy composite device, which is plural? */
+		if (g_str_has_prefix (native_path, "dummy"))
+			plural = 2;
+
+		/* hide the discharging notification */
+		gpm_manager_notify_close (manager, manager->priv->notification_warning_low);
+		gpm_manager_notify_close (manager, manager->priv->notification_discharging);
+
+		/* TRANSLATORS: show the charged notification */
+		title = ngettext ("Battery Charged", "Batteries Charged", plural);
+		gpm_manager_notify (manager, &manager->priv->notification_fully_charged,
+				    title, NULL, GPM_MANAGER_NOTIFY_TIMEOUT_SHORT,
+				    "dialog-information", NOTIFY_URGENCY_LOW);
+	}
+out:
+	g_free (native_path);
+}
+
+/**
+ * gpm_manager_engine_discharging_cb:
+ */
+static void
+gpm_manager_engine_discharging_cb (GpmEngine *engine, UpDevice *device, GpmManager *manager)
+{
+	UpDeviceKind kind;
+	gboolean ret;
+	const gchar *title;
+	const gchar *message;
+	gdouble percentage;
+	gint64 time_to_empty;
+	gchar *remaining_text = NULL;
+	gchar *icon = NULL;
+	const gchar *kind_desc;
+
+	/* only action this if specified in the settings */
+	ret = g_settings_get_boolean (manager->priv->settings, GPM_SETTINGS_NOTIFY_DISCHARGING);
+	if (!ret) {
+		g_debug ("no notification");
+		goto out;
+	}
+
+	/* get device properties */
+	g_object_get (device,
+		      "kind", &kind,
+		      "percentage", &percentage,
+		      "time-to-empty", &time_to_empty,
+		      NULL);
+
+	/* only show text if there is a valid time */
+	if (time_to_empty > 0)
+		remaining_text = gpm_get_timestring (time_to_empty);
+	kind_desc = gpm_device_kind_to_localised_string (kind, 1);
+
+	if (kind == UP_DEVICE_KIND_BATTERY) {
+		/* TRANSLATORS: laptop battery is now discharging */
+		title = _("Battery Discharging");
+
+		if (remaining_text != NULL) {
+			/* TRANSLATORS: tell the user how much time they have got */
+			message = g_strdup_printf (_("%s of battery power remaining (%.0f%%)"), remaining_text, percentage);
+		} else {
+			/* TRANSLATORS: the device is discharging, but we only have a percentage */
+			message = g_strdup_printf (_("%s discharging (%.0f%%)"),
+						   kind_desc, percentage);
+		}
+	} else if (kind == UP_DEVICE_KIND_UPS) {
+		/* TRANSLATORS: UPS is now discharging */
+		title = _("UPS Discharging");
+
+		if (remaining_text != NULL) {
+			/* TRANSLATORS: tell the user how much time they have got */
+			message = g_strdup_printf (_("%s of UPS backup power remaining (%.0f%%)"), remaining_text, percentage);
+		} else {
+			/* TRANSLATORS: the device is discharging, but we only have a percentage */
+			message = g_strdup_printf (_("%s discharging (%.0f%%)"),
+						   kind_desc, percentage);
+		}
+	} else {
+		/* nothing else of interest */
+		goto out;
+	}
+
+	icon = gpm_upower_get_device_icon (device);
+	/* show the notification */
+	gpm_manager_notify (manager, &manager->priv->notification_discharging, title, message, GPM_MANAGER_NOTIFY_TIMEOUT_LONG,
+			    icon, NOTIFY_URGENCY_NORMAL);
+out:
+	g_free (icon);
+	g_free (remaining_text);
+	return;
+}
+
+/**
+ * gpm_manager_engine_just_laptop_battery:
+ */
+static gboolean
+gpm_manager_engine_just_laptop_battery (GpmManager *manager)
+{
+	UpDevice *device;
+	UpDeviceKind kind;
+	GPtrArray *array;
+	gboolean ret = TRUE;
+	guint i;
+
+	/* find if there are any other device types that mean we have to
+	 * be more specific in our wording */
+	array = gpm_engine_get_devices (manager->priv->engine);
+	for (i=0; i<array->len; i++) {
+		device = g_ptr_array_index (array, i);
+		g_object_get (device, "kind", &kind, NULL);
+		if (kind != UP_DEVICE_KIND_BATTERY) {
+			ret = FALSE;
+			break;
+		}
+	}
+	g_ptr_array_unref (array);
+	return ret;
+}
+
+/**
+ * gpm_manager_engine_charge_low_cb:
+ */
+static void
+gpm_manager_engine_charge_low_cb (GpmEngine *engine, UpDevice *device, GpmManager *manager)
+{
+	const gchar *title = NULL;
+	gchar *message = NULL;
+	gchar *remaining_text;
+	gchar *icon = NULL;
+	UpDeviceKind kind;
+	gdouble percentage;
+	gint64 time_to_empty;
+	gboolean ret;
+
+	/* get device properties */
+	g_object_get (device,
+		      "kind", &kind,
+		      "percentage", &percentage,
+		      "time-to-empty", &time_to_empty,
+		      NULL);
+
+	/* check to see if the batteries have not noticed we are on AC */
+	if (kind == UP_DEVICE_KIND_BATTERY) {
+		if (!manager->priv->on_battery) {
+			g_warning ("ignoring critically low message as we are not on battery power");
+			goto out;
+		}
+	}
+
+	if (kind == UP_DEVICE_KIND_BATTERY) {
+
+		/* if the user has no other batteries, drop the "Laptop" wording */
+		ret = gpm_manager_engine_just_laptop_battery (manager);
+		if (ret) {
+			/* TRANSLATORS: laptop battery low, and we only have one battery */
+			title = _("Battery low");
+		} else {
+			/* TRANSLATORS: laptop battery low, and we have more than one kind of battery */
+			title = _("Laptop battery low");
+		}
+
+		remaining_text = gpm_get_timestring (time_to_empty);
+
+		/* TRANSLATORS: tell the user how much time they have got */
+		message = g_strdup_printf (_("Approximately <b>%s</b> remaining (%.0f%%)"), remaining_text, percentage);
+
+	} else if (kind == UP_DEVICE_KIND_UPS) {
+		/* TRANSLATORS: UPS is starting to get a little low */
+		title = _("UPS low");
+		remaining_text = gpm_get_timestring (time_to_empty);
+
+		/* TRANSLATORS: tell the user how much time they have got */
+		message = g_strdup_printf (_("Approximately <b>%s</b> of remaining UPS backup power (%.0f%%)"),
+					   remaining_text, percentage);
+	} else if (kind == UP_DEVICE_KIND_MOUSE) {
+		gboolean notify = g_settings_get_boolean (manager->priv->settings,
+				GPM_SETTINGS_NOTIFY_LOW_CAPACITY_MOUSE);
+		if(!notify)
+			goto out;
+
+		/* TRANSLATORS: mouse is getting a little low */
+		title = _("Mouse battery low");
+
+		/* TRANSLATORS: tell user more details */
+		message = g_strdup_printf (_("Wireless mouse is low in power (%.0f%%)"), percentage);
+
+	} else if (kind == UP_DEVICE_KIND_KEYBOARD) {
+		/* TRANSLATORS: keyboard is getting a little low */
+		title = _("Keyboard battery low");
+
+		/* TRANSLATORS: tell user more details */
+		message = g_strdup_printf (_("Wireless keyboard is low in power (%.0f%%)"), percentage);
+
+	} else if (kind == UP_DEVICE_KIND_PDA) {
+		/* TRANSLATORS: PDA is getting a little low */
+		title = _("PDA battery low");
+
+		/* TRANSLATORS: tell user more details */
+		message = g_strdup_printf (_("PDA is low in power (%.0f%%)"), percentage);
+
+	} else if (kind == UP_DEVICE_KIND_PHONE) {
+		/* TRANSLATORS: cell phone (mobile) is getting a little low */
+		title = _("Cell phone battery low");
+
+		/* TRANSLATORS: tell user more details */
+		message = g_strdup_printf (_("Cell phone is low in power (%.0f%%)"), percentage);
+
+	} else if (kind == UP_DEVICE_KIND_MEDIA_PLAYER) {
+		/* TRANSLATORS: media player, e.g. mp3 is getting a little low */
+		title = _("Media player battery low");
+
+		/* TRANSLATORS: tell user more details */
+		message = g_strdup_printf (_("Media player is low in power (%.0f%%)"), percentage);
+
+	} else if (kind == UP_DEVICE_KIND_TABLET) {
+		/* TRANSLATORS: graphics tablet, e.g. wacom is getting a little low */
+		title = _("Tablet battery low");
+
+		/* TRANSLATORS: tell user more details */
+		message = g_strdup_printf (_("Tablet is low in power (%.0f%%)"), percentage);
+
+	} else if (kind == UP_DEVICE_KIND_COMPUTER) {
+		/* TRANSLATORS: computer, e.g. ipad is getting a little low */
+		title = _("Attached computer battery low");
+
+		/* TRANSLATORS: tell user more details */
+		message = g_strdup_printf (_("Attached computer is low in power (%.0f%%)"), percentage);
+	}
+
+	/* get correct icon */
+	icon = gpm_upower_get_device_icon (device);
+	gpm_manager_notify (manager, &manager->priv->notification_warning_low, title, message, GPM_MANAGER_NOTIFY_TIMEOUT_LONG, icon, NOTIFY_URGENCY_NORMAL);
+	gpm_manager_play (manager, GPM_MANAGER_SOUND_BATTERY_CAUTION, TRUE);
+out:
+	g_free (icon);
+	g_free (message);
+}
+
+/**
+ * gpm_manager_engine_charge_critical_cb:
+ */
+static void
+gpm_manager_engine_charge_critical_cb (GpmEngine *engine, UpDevice *device, GpmManager *manager)
+{
+	const gchar *title = NULL;
+	gchar *message = NULL;
+	gchar *icon = NULL;
+	UpDeviceKind kind;
+	gdouble percentage;
+	gint64 time_to_empty;
+	GpmActionPolicy policy;
+	gboolean ret;
+
+	/* get device properties */
+	g_object_get (device,
+		      "kind", &kind,
+		      "percentage", &percentage,
+		      "time-to-empty", &time_to_empty,
+		      NULL);
+
+	/* check to see if the batteries have not noticed we are on AC */
+	if (kind == UP_DEVICE_KIND_BATTERY) {
+		if (!manager->priv->on_battery) {
+			g_warning ("ignoring critically low message as we are not on battery power");
+			goto out;
+		}
+	}
+
+	if (kind == UP_DEVICE_KIND_BATTERY) {
+
+		/* if the user has no other batteries, drop the "Laptop" wording */
+		ret = gpm_manager_engine_just_laptop_battery (manager);
+		if (ret) {
+			/* TRANSLATORS: laptop battery critically low, and only have one kind of battery */
+			title = _("Battery critically low");
+		} else {
+			/* TRANSLATORS: laptop battery critically low, and we have more than one type of battery */
+			title = _("Laptop battery critically low");
+		}
+
+		/* we have to do different warnings depending on the policy */
+		policy = g_settings_get_enum (manager->priv->settings, GPM_SETTINGS_ACTION_CRITICAL_BATT);
+
+		/* use different text for different actions */
+		if (policy == GPM_ACTION_POLICY_NOTHING) {
+			/* TRANSLATORS: tell the use to insert the plug, as we're not going to do anything */
+			message = g_strdup (_("Plug in your AC adapter to avoid losing data."));
+
+		} else if (policy == GPM_ACTION_POLICY_SUSPEND) {
+			/* TRANSLATORS: give the user a ultimatum */
+			message = g_strdup_printf (_("Computer will suspend very soon unless it is plugged in."));
+
+		} else if (policy == GPM_ACTION_POLICY_HIBERNATE) {
+			/* TRANSLATORS: give the user a ultimatum */
+			message = g_strdup_printf (_("Computer will hibernate very soon unless it is plugged in."));
+
+		} else if (policy == GPM_ACTION_POLICY_SHUTDOWN) {
+			/* TRANSLATORS: give the user a ultimatum */
+			message = g_strdup_printf (_("Computer will shutdown very soon unless it is plugged in."));
+		}
+
+	} else if (kind == UP_DEVICE_KIND_UPS) {
+		gchar *remaining_text;
+
+		/* TRANSLATORS: the UPS is very low */
+		title = _("UPS critically low");
+		remaining_text = gpm_get_timestring (time_to_empty);
+
+		/* TRANSLATORS: give the user a ultimatum */
+		message = g_strdup_printf (_("Approximately <b>%s</b> of remaining UPS power (%.0f%%). "
+					     "Restore AC power to your computer to avoid losing data."),
+					   remaining_text, percentage);
+		g_free (remaining_text);
+	} else if (kind == UP_DEVICE_KIND_MOUSE) {
+		gboolean notify = g_settings_get_boolean (manager->priv->settings,
+				GPM_SETTINGS_NOTIFY_LOW_CAPACITY_MOUSE);
+		if(!notify)
+			goto out;
+
+		/* TRANSLATORS: the mouse battery is very low */
+		title = _("Mouse battery low");
+
+		/* TRANSLATORS: the device is just going to stop working */
+		message = g_strdup_printf (_("Wireless mouse is very low in power (%.0f%%). "
+					     "This device will soon stop functioning if not charged."),
+					   percentage);
+	} else if (kind == UP_DEVICE_KIND_KEYBOARD) {
+		/* TRANSLATORS: the keyboard battery is very low */
+		title = _("Keyboard battery low");
+
+		/* TRANSLATORS: the device is just going to stop working */
+		message = g_strdup_printf (_("Wireless keyboard is very low in power (%.0f%%). "
+					     "This device will soon stop functioning if not charged."),
+					   percentage);
+	} else if (kind == UP_DEVICE_KIND_PDA) {
+
+		/* TRANSLATORS: the PDA battery is very low */
+		title = _("PDA battery low");
+
+		/* TRANSLATORS: the device is just going to stop working */
+		message = g_strdup_printf (_("PDA is very low in power (%.0f%%). "
+					     "This device will soon stop functioning if not charged."),
+					   percentage);
+
+	} else if (kind == UP_DEVICE_KIND_PHONE) {
+
+		/* TRANSLATORS: the cell battery is very low */
+		title = _("Cell phone battery low");
+
+		/* TRANSLATORS: the device is just going to stop working */
+		message = g_strdup_printf (_("Cell phone is very low in power (%.0f%%). "
+					     "This device will soon stop functioning if not charged."),
+					   percentage);
+
+	} else if (kind == UP_DEVICE_KIND_MEDIA_PLAYER) {
+
+		/* TRANSLATORS: the cell battery is very low */
+		title = _("Cell phone battery low");
+
+		/* TRANSLATORS: the device is just going to stop working */
+		message = g_strdup_printf (_("Media player is very low in power (%.0f%%). "
+					     "This device will soon stop functioning if not charged."),
+					   percentage);
+	} else if (kind == UP_DEVICE_KIND_TABLET) {
+
+		/* TRANSLATORS: the cell battery is very low */
+		title = _("Tablet battery low");
+
+		/* TRANSLATORS: the device is just going to stop working */
+		message = g_strdup_printf (_("Tablet is very low in power (%.0f%%). "
+					     "This device will soon stop functioning if not charged."),
+					   percentage);
+	} else if (kind == UP_DEVICE_KIND_COMPUTER) {
+
+		/* TRANSLATORS: the cell battery is very low */
+		title = _("Attached computer battery low");
+
+		/* TRANSLATORS: the device is just going to stop working */
+		message = g_strdup_printf (_("Attached computer is very low in power (%.0f%%). "
+					     "The device will soon shutdown if not charged."),
+					   percentage);
+	}
+
+	/* get correct icon */
+	icon = gpm_upower_get_device_icon (device);
+	gpm_manager_notify (manager, &manager->priv->notification_warning_low, title, message, GPM_MANAGER_NOTIFY_TIMEOUT_NEVER, icon, NOTIFY_URGENCY_CRITICAL);
+
+	switch (kind) {
+
+	case UP_DEVICE_KIND_BATTERY:
+	case UP_DEVICE_KIND_UPS:
+		g_debug ("critical charge level reached, starting sound loop");
+		gpm_manager_play_loop_start (manager,
+					     GPM_MANAGER_SOUND_BATTERY_LOW,
+					     TRUE,
+					     GPM_MANAGER_CRITICAL_ALERT_TIMEOUT);
+		break;
+
+	default:
+		gpm_manager_play (manager, GPM_MANAGER_SOUND_BATTERY_LOW, TRUE);
+	}
+out:
+	g_free (icon);
+	g_free (message);
+}
+
+/**
+ * gpm_manager_engine_charge_action_cb:
+ */
+static void
+gpm_manager_engine_charge_action_cb (GpmEngine *engine, UpDevice *device, GpmManager *manager)
+{
+	const gchar *title = NULL;
+	gchar *message = NULL;
+	gchar *icon = NULL;
+	UpDeviceKind kind;
+	GpmActionPolicy policy;
+	guint timer_id;
+
+	/* get device properties */
+	g_object_get (device,
+		      "kind", &kind,
+		      NULL);
+
+	/* check to see if the batteries have not noticed we are on AC */
+	if (kind == UP_DEVICE_KIND_BATTERY) {
+		if (!manager->priv->on_battery) {
+			g_warning ("ignoring critically low message as we are not on battery power");
+			goto out;
+		}
+	}
+
+	if (kind == UP_DEVICE_KIND_BATTERY) {
+
+		/* TRANSLATORS: laptop battery is really, really, low */
+		title = _("Laptop battery critically low");
+
+		/* we have to do different warnings depending on the policy */
+		policy = g_settings_get_enum (manager->priv->settings, GPM_SETTINGS_ACTION_CRITICAL_BATT);
+
+		/* use different text for different actions */
+		if (policy == GPM_ACTION_POLICY_NOTHING) {
+			/* TRANSLATORS: computer will shutdown without saving data */
+			message = g_strdup (_("The battery is below the critical level and "
+					      "this computer will <b>power-off</b> when the "
+					      "battery becomes completely empty."));
+
+		} else if (policy == GPM_ACTION_POLICY_SUSPEND) {
+			/* TRANSLATORS: computer will suspend */
+			message = g_strdup (_("The battery is below the critical level and "
+					      "this computer is about to suspend.<br>"
+					      "<b>NOTE:</b> A small amount of power is required "
+					      "to keep your computer in a suspended state."));
+
+		} else if (policy == GPM_ACTION_POLICY_HIBERNATE) {
+			/* TRANSLATORS: computer will hibernate */
+			message = g_strdup (_("The battery is below the critical level and "
+					      "this computer is about to hibernate."));
+
+		} else if (policy == GPM_ACTION_POLICY_SHUTDOWN) {
+			/* TRANSLATORS: computer will just shutdown */
+			message = g_strdup (_("The battery is below the critical level and "
+					      "this computer is about to shutdown."));
+		}
+
+		/* wait 20 seconds for user-panic */
+		timer_id = g_timeout_add_seconds (20, (GSourceFunc) manager_critical_action_do, manager);
+		g_source_set_name_by_id (timer_id, "[GpmManager] battery critical-action");
+
+	} else if (kind == UP_DEVICE_KIND_UPS) {
+		/* TRANSLATORS: UPS is really, really, low */
+		title = _("UPS critically low");
+
+		/* we have to do different warnings depending on the policy */
+		policy = g_settings_get_enum (manager->priv->settings, GPM_SETTINGS_ACTION_CRITICAL_UPS);
+
+		/* use different text for different actions */
+		if (policy == GPM_ACTION_POLICY_NOTHING) {
+			/* TRANSLATORS: computer will shutdown without saving data */
+			message = g_strdup (_("The UPS is below the critical level and "
+				              "this computer will <b>power-off</b> when the "
+				              "UPS becomes completely empty."));
+
+		} else if (policy == GPM_ACTION_POLICY_HIBERNATE) {
+			/* TRANSLATORS: computer will hibernate */
+			message = g_strdup (_("The UPS is below the critical level and "
+				              "this computer is about to hibernate."));
+
+		} else if (policy == GPM_ACTION_POLICY_SHUTDOWN) {
+			/* TRANSLATORS: computer will just shutdown */
+			message = g_strdup (_("The UPS is below the critical level and "
+				              "this computer is about to shutdown."));
+		}
+
+		/* wait 20 seconds for user-panic */
+		timer_id = g_timeout_add_seconds (20, (GSourceFunc) manager_critical_action_do, manager);
+		g_source_set_name_by_id (timer_id, "[GpmManager] ups critical-action");
+
+	}
+
+	/* not all types have actions */
+	if (title == NULL) {
+		g_free (message);
+		return;
+	}
+
+	/* get correct icon */
+	icon = gpm_upower_get_device_icon (device);
+	gpm_manager_notify (manager, &manager->priv->notification_warning_low,
+			    title, message, GPM_MANAGER_NOTIFY_TIMEOUT_NEVER,
+			    icon, NOTIFY_URGENCY_CRITICAL);
+	gpm_manager_play (manager, GPM_MANAGER_SOUND_BATTERY_LOW, TRUE);
+out:
+	g_free (icon);
+	g_free (message);
+}
+
+/**
+ * gpm_manager_dpms_mode_changed_cb:
+ * @mode: The DPMS mode, e.g. GPM_DPMS_MODE_OFF
+ * @info: This class instance
+ *
+ * Log when the DPMS mode is changed.
+ **/
+static void
+gpm_manager_dpms_mode_changed_cb (GpmDpms *dpms, GpmDpmsMode mode, GpmManager *manager)
+{
+	g_debug ("DPMS mode changed: %u", mode);
+
+	if (mode == GPM_DPMS_MODE_ON)
+		g_debug ("dpms on");
+	else if (mode == GPM_DPMS_MODE_STANDBY)
+		g_debug ("dpms standby");
+	else if (mode == GPM_DPMS_MODE_SUSPEND)
+		g_debug ("suspend");
+	else if (mode == GPM_DPMS_MODE_OFF)
+		g_debug ("dpms off");
+
+	gpm_manager_update_dpms_throttle (manager);
+}
+
+/*
+ * gpm_manager_reset_just_resumed_cb
+ */
+static gboolean
+gpm_manager_reset_just_resumed_cb (gpointer user_data)
+{
+	GpmManager *manager = GPM_MANAGER (user_data);
+
+	if (manager->priv->notification_general != NULL)
+		gpm_manager_notify_close (manager, manager->priv->notification_general);
+	if (manager->priv->notification_warning_low != NULL)
+		gpm_manager_notify_close (manager, manager->priv->notification_warning_low);
+	if (manager->priv->notification_discharging != NULL)
+		gpm_manager_notify_close (manager, manager->priv->notification_discharging);
+	if (manager->priv->notification_fully_charged != NULL)
+		gpm_manager_notify_close (manager, manager->priv->notification_fully_charged);
+
+	manager->priv->just_resumed = FALSE;
+	return FALSE;
+}
+
+/**
+ * gpm_manager_control_resume_cb
+ **/
+static void
+gpm_manager_control_resume_cb (GpmControl *control, GpmControlAction action, GpmManager *manager)
+{
+	guint timer_id;
+	manager->priv->just_resumed = TRUE;
+	timer_id = g_timeout_add_seconds (1, gpm_manager_reset_just_resumed_cb, manager);
+	g_source_set_name_by_id (timer_id, "[GpmManager] just-resumed");
+}
+
+/**
+ * gpm_main_systemd_inhibit:
+ *
+ * Return a fd to the to the inhibitor, that we can close on exit.
+ *
+ * Return value: fd, -1 on error
+ **/
+static gint32
+gpm_manager_systemd_inhibit (GDBusProxy *proxy) {
+    GError *error = NULL;
+    gint32 r = -1;
+    gint32 fd = -1;
+    GVariant *res;
+    GUnixFDList *fd_list = NULL;
+
+    /* Should we define these elsewhere? */
+    const char* arg_what = "handle-power-key:handle-suspend-key:handle-lid-switch";
+    const char* arg_who = g_get_user_name ();
+    const char* arg_why = "Mate power manager handles these events";
+    const char* arg_mode = "block";
+
+    g_debug ("Inhibiting systemd sleep");
+    proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
+                                       G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
+                                        NULL,
+                                        "org.freedesktop.login1",
+                                        "/org/freedesktop/login1",
+                                        "org.freedesktop.login1.Manager",
+                                        NULL,
+                                        &error );
+    //append all our arguments
+    if (proxy == NULL) {
+        g_error ("Error connecting to dbus - %s", error->message);
+        g_error_free (error);
+        return -1;
+    }
+    res = g_dbus_proxy_call_with_unix_fd_list_sync (proxy, "Inhibit",
+                            g_variant_new( "(ssss)",
+                                arg_what,
+                                arg_who,
+                                arg_why,
+                                arg_mode
+                            ),
+                            G_DBUS_CALL_FLAGS_NONE,
+                            -1,
+                            NULL,
+                            &fd_list,
+                            NULL,
+                            &error
+                            );
+    if (error != NULL) {
+        g_error ("Error in dbus - %s", error->message);
+        g_error_free (error);
+        return -EIO;
+    }
+    if (res == NULL)
+       return -EIO;
+
+    g_variant_get(res, "(h)", &r);
+    g_debug ("Inhibiting systemd sleep res = %i", r);
+
+    fd = g_unix_fd_list_get (fd_list, r, &error);
+    if (fd == -1) {
+        g_debug("Failed to get systemd inhibitor");
+        return r;
+    }
+
+    g_debug ("System inhibitor fd is %d", fd);
+    g_object_unref (fd_list);
+    g_variant_unref (res);
+    g_debug ("Inhibiting systemd sleep - success");
+    return r;
+}
+
+static void
+on_icon_theme_change (GtkSettings *settings,
+                      GParamSpec  *pspec,
+                      GpmManager  *manager)
+{
+	gchar *icon = gpm_engine_get_icon (manager->priv->engine);
+	if (icon == NULL) {
+		return;
+	}
+
+	gpm_tray_icon_set_icon (manager->priv->tray_icon, icon);
+	g_free (icon);
+}
+
+/**
+ * gpm_manager_init:
+ * @manager: This class instance
+ **/
+static void
+gpm_manager_init (GpmManager *manager)
+{
+	gboolean check_type_cpu;
+	DBusGConnection *connection;
+	GError *error = NULL;
+
+	manager->priv = gpm_manager_get_instance_private (manager);
+	connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+
+	/* We want to inhibit the systemd suspend options, and take care of them ourselves */
+	if (LOGIND_RUNNING()) {
+		manager->priv->systemd_inhibit = gpm_manager_systemd_inhibit (manager->priv->systemd_inhibit_proxy);
+	}
+
+	/* init to unthrottled */
+	manager->priv->screensaver_ac_throttle_id = 0;
+	manager->priv->screensaver_dpms_throttle_id = 0;
+	manager->priv->screensaver_lid_throttle_id = 0;
+
+	manager->priv->critical_alert_timeout_id = 0;
+	manager->priv->critical_alert_loop_props = NULL;
+
+	/* init to not just_resumed */
+	manager->priv->just_resumed = FALSE;
+
+	/* don't apply policy when not active, so listen to ConsoleKit */
+	manager->priv->console = egg_console_kit_new ();
+
+	manager->priv->notification_general = NULL;
+	manager->priv->notification_warning_low = NULL;
+	manager->priv->notification_discharging = NULL;
+	manager->priv->notification_fully_charged = NULL;
+	manager->priv->settings = g_settings_new (GPM_SETTINGS_SCHEMA);
+	g_signal_connect (manager->priv->settings, "changed",
+			  G_CALLBACK (gpm_manager_settings_changed_cb), manager);
+	manager->priv->client = up_client_new ();
+	g_signal_connect (manager->priv->client, "notify::lid-is-closed",
+			  G_CALLBACK (gpm_manager_client_changed_cb), manager);
+	g_signal_connect (manager->priv->client, "notify::on-battery",
+			  G_CALLBACK (gpm_manager_client_changed_cb), manager);
+
+	/* use libmatenotify */
+	notify_init (GPM_NAME);
+
+	/* coldplug so we are in the correct state at startup */
+	g_object_get (manager->priv->client,
+		      "on-battery", &manager->priv->on_battery,
+		      NULL);
+
+	manager->priv->button = gpm_button_new ();
+	g_signal_connect (manager->priv->button, "button-pressed",
+			  G_CALLBACK (gpm_manager_button_pressed_cb), manager);
+
+	/* try and start an interactive service */
+	manager->priv->screensaver = gpm_screensaver_new ();
+
+	/* try an start an interactive service */
+	manager->priv->backlight = gpm_backlight_new ();
+	if (manager->priv->backlight != NULL) {
+		/* add the new brightness lcd DBUS interface */
+		dbus_g_object_type_install_info (GPM_TYPE_BACKLIGHT,
+						 &dbus_glib_gpm_backlight_object_info);
+		dbus_g_connection_register_g_object (connection, GPM_DBUS_PATH_BACKLIGHT,
+						     G_OBJECT (manager->priv->backlight));
+	}
+
+    manager->priv->kbd_backlight = gpm_kbd_backlight_new ();
+    if (manager->priv->kbd_backlight != NULL) {
+    	dbus_g_object_type_install_info (GPM_TYPE_KBD_BACKLIGHT,
+						 &dbus_glib_gpm_kbd_backlight_object_info);
+		dbus_g_connection_register_g_object (connection, GPM_DBUS_PATH_KBD_BACKLIGHT,
+						     G_OBJECT (manager->priv->kbd_backlight));
+
+    }
+
+	manager->priv->idle = gpm_idle_new ();
+	g_signal_connect (manager->priv->idle, "idle-changed",
+			  G_CALLBACK (gpm_manager_idle_changed_cb), manager);
+
+	/* set up the check_type_cpu, so we can disable the CPU load check */
+	check_type_cpu = g_settings_get_boolean (manager->priv->settings, GPM_SETTINGS_IDLE_CHECK_CPU);
+	gpm_idle_set_check_cpu (manager->priv->idle, check_type_cpu);
+
+	manager->priv->dpms = gpm_dpms_new ();
+	g_signal_connect (manager->priv->dpms, "mode-changed",
+			  G_CALLBACK (gpm_manager_dpms_mode_changed_cb), manager);
+
+	/* use the control object */
+	g_debug ("creating new control instance");
+	manager->priv->control = gpm_control_new ();
+	g_signal_connect (manager->priv->control, "resume",
+			  G_CALLBACK (gpm_manager_control_resume_cb), manager);
+
+	g_debug ("creating new tray icon");
+	manager->priv->tray_icon = gpm_tray_icon_new ();
+
+	/* keep a reference for the notifications */
+	manager->priv->status_icon = gpm_tray_icon_get_status_icon (manager->priv->tray_icon);
+
+	gpm_manager_sync_policy_sleep (manager);
+
+	manager->priv->engine = gpm_engine_new ();
+	g_signal_connect (manager->priv->engine, "low-capacity",
+			  G_CALLBACK (gpm_manager_engine_low_capacity_cb), manager);
+	g_signal_connect (manager->priv->engine, "icon-changed",
+			  G_CALLBACK (gpm_manager_engine_icon_changed_cb), manager);
+	g_signal_connect (manager->priv->engine, "summary-changed",
+			  G_CALLBACK (gpm_manager_engine_summary_changed_cb), manager);
+	g_signal_connect (manager->priv->engine, "fully-charged",
+			  G_CALLBACK (gpm_manager_engine_fully_charged_cb), manager);
+	g_signal_connect (manager->priv->engine, "discharging",
+			  G_CALLBACK (gpm_manager_engine_discharging_cb), manager);
+	g_signal_connect (manager->priv->engine, "charge-low",
+			  G_CALLBACK (gpm_manager_engine_charge_low_cb), manager);
+	g_signal_connect (manager->priv->engine, "charge-critical",
+			  G_CALLBACK (gpm_manager_engine_charge_critical_cb), manager);
+	g_signal_connect (manager->priv->engine, "charge-action",
+			  G_CALLBACK (gpm_manager_engine_charge_action_cb), manager);
+
+	g_signal_connect (gtk_settings_get_default (),
+	                  "notify::gtk-icon-theme-name",
+	                  G_CALLBACK (on_icon_theme_change),
+	                  manager);
+
+	/* update ac throttle */
+	gpm_manager_update_ac_throttle (manager);
+}
+
+/**
+ * gpm_manager_finalize:
+ * @object: The object to finalize
+ *
+ * Finalise the manager, by unref'ing all the depending modules.
+ **/
+static void
+gpm_manager_finalize (GObject *object)
+{
+	GpmManager *manager;
+
+	g_return_if_fail (object != NULL);
+	g_return_if_fail (GPM_IS_MANAGER (object));
+
+	manager = GPM_MANAGER (object);
+
+	g_return_if_fail (manager->priv != NULL);
+
+	/* close any notifications (also unrefs them) */
+	if (manager->priv->notification_general != NULL)
+		gpm_manager_notify_close (manager, manager->priv->notification_general);
+	if (manager->priv->notification_warning_low != NULL)
+		gpm_manager_notify_close (manager, manager->priv->notification_warning_low);
+	if (manager->priv->notification_discharging != NULL)
+		gpm_manager_notify_close (manager, manager->priv->notification_discharging);
+	if (manager->priv->notification_fully_charged != NULL)
+		gpm_manager_notify_close (manager, manager->priv->notification_fully_charged);
+
+	if (manager->priv->critical_alert_timeout_id != 0) {
+		g_source_remove (manager->priv->critical_alert_timeout_id);
+		manager->priv->critical_alert_timeout_id = 0;
+	}
+
+	g_signal_handlers_disconnect_by_func (gtk_settings_get_default (),
+	                                      on_icon_theme_change,
+	                                      manager);
+
+	g_object_unref (manager->priv->settings);
+	g_object_unref (manager->priv->dpms);
+	g_object_unref (manager->priv->idle);
+	g_object_unref (manager->priv->engine);
+	g_object_unref (manager->priv->tray_icon);
+	g_object_unref (manager->priv->screensaver);
+	g_object_unref (manager->priv->control);
+	g_object_unref (manager->priv->button);
+	g_object_unref (manager->priv->backlight);
+	g_object_unref (manager->priv->kbd_backlight);
+	g_object_unref (manager->priv->console);
+	g_object_unref (manager->priv->client);
+	g_object_unref (manager->priv->status_icon);
+
+	if (LOGIND_RUNNING()) {
+		/* Let systemd take over again ... */
+		if (manager->priv->systemd_inhibit > 0) {
+			close(manager->priv->systemd_inhibit);
+		}
+		if (manager->priv->systemd_inhibit_proxy != NULL) {
+			g_object_unref (manager->priv->systemd_inhibit_proxy);
+		}
+	}
+
+	G_OBJECT_CLASS (gpm_manager_parent_class)->finalize (object);
+}
+
+/**
+ * gpm_manager_new:
+ *
+ * Return value: a new GpmManager object.
+ **/
+GpmManager *
+gpm_manager_new (void)
+{
+	GpmManager *manager;
+	manager = g_object_new (GPM_TYPE_MANAGER, NULL);
+	return GPM_MANAGER (manager);
+}
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/94.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/94.html new file mode 100644 index 0000000..a6baf94 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/94.html @@ -0,0 +1,365 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2005 William Jon McCann <mccann@jhu.edu>
+ * Copyright (C) 2005-2007 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __GPM_TRAY_ICON_H
+#define __GPM_TRAY_ICON_H
+
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+G_BEGIN_DECLS
+
+#define GPM_TYPE_TRAY_ICON		(gpm_tray_icon_get_type ())
+#define GPM_TRAY_ICON(o)		(G_TYPE_CHECK_INSTANCE_CAST ((o), GPM_TYPE_TRAY_ICON, GpmTrayIcon))
+#define GPM_TRAY_ICON_CLASS(k)		(G_TYPE_CHECK_CLASS_CAST((k), GPM_TYPE_TRAY_ICON, GpmTrayIconClass))
+#define GPM_IS_TRAY_ICON(o)	 	(G_TYPE_CHECK_INSTANCE_TYPE ((o), GPM_TYPE_TRAY_ICON))
+#define GPM_IS_TRAY_ICON_CLASS(k)	(G_TYPE_CHECK_CLASS_TYPE ((k), GPM_TYPE_TRAY_ICON))
+#define GPM_TRAY_ICON_GET_CLASS(o)	(G_TYPE_INSTANCE_GET_CLASS ((o), GPM_TYPE_TRAY_ICON, GpmTrayIconClass))
+
+typedef struct GpmTrayIconPrivate GpmTrayIconPrivate;
+
+typedef struct
+{
+	GObject		    parent;
+	GpmTrayIconPrivate *priv;
+} GpmTrayIcon;
+
+typedef struct
+{
+	GObjectClass	parent_class;
+	void	(* suspend)				(GpmTrayIcon	*tray_icon);
+	void	(* hibernate)				(GpmTrayIcon	*tray_icon);
+} GpmTrayIconClass;
+
+GType		 gpm_tray_icon_get_type			(void);
+GpmTrayIcon	*gpm_tray_icon_new			(void);
+
+gboolean	 gpm_tray_icon_set_tooltip		(GpmTrayIcon	*icon,
+							 const gchar	*tooltip);
+gboolean	 gpm_tray_icon_set_icon			(GpmTrayIcon	*icon,
+							 const gchar	*icon_name);
+GtkStatusIcon	*gpm_tray_icon_get_status_icon		(GpmTrayIcon	*icon);
+
+G_END_DECLS
+
+#endif /* __GPM_TRAY_ICON_H */
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/95.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/95.html new file mode 100644 index 0000000..0f2f82f --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/95.html @@ -0,0 +1,567 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
/* Generated by dbus-binding-tool; do not edit! */
+
+/* This file is generated by glib-genmarshal, do not modify it. This code is licensed under the same license as the containing project. Note that it links to GLib, so must comply with the LGPL linking clauses. */
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#ifdef G_ENABLE_DEBUG
+#define g_marshal_value_peek_boolean(v)  g_value_get_boolean (v)
+#define g_marshal_value_peek_char(v)     g_value_get_schar (v)
+#define g_marshal_value_peek_uchar(v)    g_value_get_uchar (v)
+#define g_marshal_value_peek_int(v)      g_value_get_int (v)
+#define g_marshal_value_peek_uint(v)     g_value_get_uint (v)
+#define g_marshal_value_peek_long(v)     g_value_get_long (v)
+#define g_marshal_value_peek_ulong(v)    g_value_get_ulong (v)
+#define g_marshal_value_peek_int64(v)    g_value_get_int64 (v)
+#define g_marshal_value_peek_uint64(v)   g_value_get_uint64 (v)
+#define g_marshal_value_peek_enum(v)     g_value_get_enum (v)
+#define g_marshal_value_peek_flags(v)    g_value_get_flags (v)
+#define g_marshal_value_peek_float(v)    g_value_get_float (v)
+#define g_marshal_value_peek_double(v)   g_value_get_double (v)
+#define g_marshal_value_peek_string(v)   (char*) g_value_get_string (v)
+#define g_marshal_value_peek_param(v)    g_value_get_param (v)
+#define g_marshal_value_peek_boxed(v)    g_value_get_boxed (v)
+#define g_marshal_value_peek_pointer(v)  g_value_get_pointer (v)
+#define g_marshal_value_peek_object(v)   g_value_get_object (v)
+#define g_marshal_value_peek_variant(v)  g_value_get_variant (v)
+#else /* !G_ENABLE_DEBUG */
+/* WARNING: This code accesses GValues directly, which is UNSUPPORTED API.
+ *          Do not access GValues directly in your code. Instead, use the
+ *          g_value_get_*() functions
+ */
+#define g_marshal_value_peek_boolean(v)  (v)->data[0].v_int
+#define g_marshal_value_peek_char(v)     (v)->data[0].v_int
+#define g_marshal_value_peek_uchar(v)    (v)->data[0].v_uint
+#define g_marshal_value_peek_int(v)      (v)->data[0].v_int
+#define g_marshal_value_peek_uint(v)     (v)->data[0].v_uint
+#define g_marshal_value_peek_long(v)     (v)->data[0].v_long
+#define g_marshal_value_peek_ulong(v)    (v)->data[0].v_ulong
+#define g_marshal_value_peek_int64(v)    (v)->data[0].v_int64
+#define g_marshal_value_peek_uint64(v)   (v)->data[0].v_uint64
+#define g_marshal_value_peek_enum(v)     (v)->data[0].v_long
+#define g_marshal_value_peek_flags(v)    (v)->data[0].v_ulong
+#define g_marshal_value_peek_float(v)    (v)->data[0].v_float
+#define g_marshal_value_peek_double(v)   (v)->data[0].v_double
+#define g_marshal_value_peek_string(v)   (v)->data[0].v_pointer
+#define g_marshal_value_peek_param(v)    (v)->data[0].v_pointer
+#define g_marshal_value_peek_boxed(v)    (v)->data[0].v_pointer
+#define g_marshal_value_peek_pointer(v)  (v)->data[0].v_pointer
+#define g_marshal_value_peek_object(v)   (v)->data[0].v_pointer
+#define g_marshal_value_peek_variant(v)  (v)->data[0].v_pointer
+#endif /* !G_ENABLE_DEBUG */
+
+/* Prototype for -Wmissing-prototypes */
+G_BEGIN_DECLS
+extern
+void dbus_glib_marshal_gpm_backlight_BOOLEAN__POINTER_POINTER (GClosure     *closure,
+                                                               GValue       *return_value,
+                                                               guint         n_param_values,
+                                                               const GValue *param_values,
+                                                               gpointer      invocation_hint,
+                                                               gpointer      marshal_data);
+G_END_DECLS
+void
+dbus_glib_marshal_gpm_backlight_BOOLEAN__POINTER_POINTER (GClosure     *closure,
+                                                          GValue       *return_value,
+                                                          guint         n_param_values,
+                                                          const GValue *param_values,
+                                                          gpointer      invocation_hint G_GNUC_UNUSED,
+                                                          gpointer      marshal_data)
+{
+  typedef gboolean (*GMarshalFunc_BOOLEAN__POINTER_POINTER) (gpointer data1,
+                                                             gpointer arg1,
+                                                             gpointer arg2,
+                                                             gpointer data2);
+  GCClosure *cc = (GCClosure *) closure;
+  gpointer data1, data2;
+  GMarshalFunc_BOOLEAN__POINTER_POINTER callback;
+  gboolean v_return;
+
+  g_return_if_fail (return_value != NULL);
+  g_return_if_fail (n_param_values == 3);
+
+  if (G_CCLOSURE_SWAP_DATA (closure))
+    {
+      data1 = closure->data;
+      data2 = g_value_peek_pointer (param_values + 0);
+    }
+  else
+    {
+      data1 = g_value_peek_pointer (param_values + 0);
+      data2 = closure->data;
+    }
+  callback = (GMarshalFunc_BOOLEAN__POINTER_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+  v_return = callback (data1,
+                       g_marshal_value_peek_pointer (param_values + 1),
+                       g_marshal_value_peek_pointer (param_values + 2),
+                       data2);
+
+  g_value_set_boolean (return_value, v_return);
+}
+
+/* Prototype for -Wmissing-prototypes */
+G_BEGIN_DECLS
+extern
+void dbus_glib_marshal_gpm_backlight_BOOLEAN__UINT_POINTER (GClosure     *closure,
+                                                            GValue       *return_value,
+                                                            guint         n_param_values,
+                                                            const GValue *param_values,
+                                                            gpointer      invocation_hint,
+                                                            gpointer      marshal_data);
+G_END_DECLS
+void
+dbus_glib_marshal_gpm_backlight_BOOLEAN__UINT_POINTER (GClosure     *closure,
+                                                       GValue       *return_value,
+                                                       guint         n_param_values,
+                                                       const GValue *param_values,
+                                                       gpointer      invocation_hint G_GNUC_UNUSED,
+                                                       gpointer      marshal_data)
+{
+  typedef gboolean (*GMarshalFunc_BOOLEAN__UINT_POINTER) (gpointer data1,
+                                                          guint arg1,
+                                                          gpointer arg2,
+                                                          gpointer data2);
+  GCClosure *cc = (GCClosure *) closure;
+  gpointer data1, data2;
+  GMarshalFunc_BOOLEAN__UINT_POINTER callback;
+  gboolean v_return;
+
+  g_return_if_fail (return_value != NULL);
+  g_return_if_fail (n_param_values == 3);
+
+  if (G_CCLOSURE_SWAP_DATA (closure))
+    {
+      data1 = closure->data;
+      data2 = g_value_peek_pointer (param_values + 0);
+    }
+  else
+    {
+      data1 = g_value_peek_pointer (param_values + 0);
+      data2 = closure->data;
+    }
+  callback = (GMarshalFunc_BOOLEAN__UINT_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+  v_return = callback (data1,
+                       g_marshal_value_peek_uint (param_values + 1),
+                       g_marshal_value_peek_pointer (param_values + 2),
+                       data2);
+
+  g_value_set_boolean (return_value, v_return);
+}
+
+#include <dbus/dbus-glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+static const DBusGMethodInfo dbus_glib_gpm_backlight_methods[] = {
+  { (GCallback) gpm_backlight_get_brightness, dbus_glib_marshal_gpm_backlight_BOOLEAN__POINTER_POINTER, 0 },
+  { (GCallback) gpm_backlight_set_brightness, dbus_glib_marshal_gpm_backlight_BOOLEAN__UINT_POINTER, 79 },
+};
+
+const DBusGObjectInfo dbus_glib_gpm_backlight_object_info = {  1,
+  dbus_glib_gpm_backlight_methods,
+  2,
+"org.mate.PowerManager.Backlight\0GetBrightness\0S\0percentage_brightness\0O\0F\0N\0u\0\0org.mate.PowerManager.Backlight\0SetBrightness\0S\0percentage_brightness\0I\0u\0\0\0",
+"org.mate.PowerManager.Backlight\0BrightnessChanged\0\0",
+"\0"
+};
+
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/96.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/96.html new file mode 100644 index 0000000..d4a3922 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/96.html @@ -0,0 +1,567 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
/* Generated by dbus-binding-tool; do not edit! */
+
+/* This file is generated by glib-genmarshal, do not modify it. This code is licensed under the same license as the containing project. Note that it links to GLib, so must comply with the LGPL linking clauses. */
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#ifdef G_ENABLE_DEBUG
+#define g_marshal_value_peek_boolean(v)  g_value_get_boolean (v)
+#define g_marshal_value_peek_char(v)     g_value_get_schar (v)
+#define g_marshal_value_peek_uchar(v)    g_value_get_uchar (v)
+#define g_marshal_value_peek_int(v)      g_value_get_int (v)
+#define g_marshal_value_peek_uint(v)     g_value_get_uint (v)
+#define g_marshal_value_peek_long(v)     g_value_get_long (v)
+#define g_marshal_value_peek_ulong(v)    g_value_get_ulong (v)
+#define g_marshal_value_peek_int64(v)    g_value_get_int64 (v)
+#define g_marshal_value_peek_uint64(v)   g_value_get_uint64 (v)
+#define g_marshal_value_peek_enum(v)     g_value_get_enum (v)
+#define g_marshal_value_peek_flags(v)    g_value_get_flags (v)
+#define g_marshal_value_peek_float(v)    g_value_get_float (v)
+#define g_marshal_value_peek_double(v)   g_value_get_double (v)
+#define g_marshal_value_peek_string(v)   (char*) g_value_get_string (v)
+#define g_marshal_value_peek_param(v)    g_value_get_param (v)
+#define g_marshal_value_peek_boxed(v)    g_value_get_boxed (v)
+#define g_marshal_value_peek_pointer(v)  g_value_get_pointer (v)
+#define g_marshal_value_peek_object(v)   g_value_get_object (v)
+#define g_marshal_value_peek_variant(v)  g_value_get_variant (v)
+#else /* !G_ENABLE_DEBUG */
+/* WARNING: This code accesses GValues directly, which is UNSUPPORTED API.
+ *          Do not access GValues directly in your code. Instead, use the
+ *          g_value_get_*() functions
+ */
+#define g_marshal_value_peek_boolean(v)  (v)->data[0].v_int
+#define g_marshal_value_peek_char(v)     (v)->data[0].v_int
+#define g_marshal_value_peek_uchar(v)    (v)->data[0].v_uint
+#define g_marshal_value_peek_int(v)      (v)->data[0].v_int
+#define g_marshal_value_peek_uint(v)     (v)->data[0].v_uint
+#define g_marshal_value_peek_long(v)     (v)->data[0].v_long
+#define g_marshal_value_peek_ulong(v)    (v)->data[0].v_ulong
+#define g_marshal_value_peek_int64(v)    (v)->data[0].v_int64
+#define g_marshal_value_peek_uint64(v)   (v)->data[0].v_uint64
+#define g_marshal_value_peek_enum(v)     (v)->data[0].v_long
+#define g_marshal_value_peek_flags(v)    (v)->data[0].v_ulong
+#define g_marshal_value_peek_float(v)    (v)->data[0].v_float
+#define g_marshal_value_peek_double(v)   (v)->data[0].v_double
+#define g_marshal_value_peek_string(v)   (v)->data[0].v_pointer
+#define g_marshal_value_peek_param(v)    (v)->data[0].v_pointer
+#define g_marshal_value_peek_boxed(v)    (v)->data[0].v_pointer
+#define g_marshal_value_peek_pointer(v)  (v)->data[0].v_pointer
+#define g_marshal_value_peek_object(v)   (v)->data[0].v_pointer
+#define g_marshal_value_peek_variant(v)  (v)->data[0].v_pointer
+#endif /* !G_ENABLE_DEBUG */
+
+/* Prototype for -Wmissing-prototypes */
+G_BEGIN_DECLS
+extern
+void dbus_glib_marshal_gpm_kbd_backlight_BOOLEAN__POINTER_POINTER (GClosure     *closure,
+                                                                   GValue       *return_value,
+                                                                   guint         n_param_values,
+                                                                   const GValue *param_values,
+                                                                   gpointer      invocation_hint,
+                                                                   gpointer      marshal_data);
+G_END_DECLS
+void
+dbus_glib_marshal_gpm_kbd_backlight_BOOLEAN__POINTER_POINTER (GClosure     *closure,
+                                                              GValue       *return_value,
+                                                              guint         n_param_values,
+                                                              const GValue *param_values,
+                                                              gpointer      invocation_hint G_GNUC_UNUSED,
+                                                              gpointer      marshal_data)
+{
+  typedef gboolean (*GMarshalFunc_BOOLEAN__POINTER_POINTER) (gpointer data1,
+                                                             gpointer arg1,
+                                                             gpointer arg2,
+                                                             gpointer data2);
+  GCClosure *cc = (GCClosure *) closure;
+  gpointer data1, data2;
+  GMarshalFunc_BOOLEAN__POINTER_POINTER callback;
+  gboolean v_return;
+
+  g_return_if_fail (return_value != NULL);
+  g_return_if_fail (n_param_values == 3);
+
+  if (G_CCLOSURE_SWAP_DATA (closure))
+    {
+      data1 = closure->data;
+      data2 = g_value_peek_pointer (param_values + 0);
+    }
+  else
+    {
+      data1 = g_value_peek_pointer (param_values + 0);
+      data2 = closure->data;
+    }
+  callback = (GMarshalFunc_BOOLEAN__POINTER_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+  v_return = callback (data1,
+                       g_marshal_value_peek_pointer (param_values + 1),
+                       g_marshal_value_peek_pointer (param_values + 2),
+                       data2);
+
+  g_value_set_boolean (return_value, v_return);
+}
+
+/* Prototype for -Wmissing-prototypes */
+G_BEGIN_DECLS
+extern
+void dbus_glib_marshal_gpm_kbd_backlight_BOOLEAN__UINT_POINTER (GClosure     *closure,
+                                                                GValue       *return_value,
+                                                                guint         n_param_values,
+                                                                const GValue *param_values,
+                                                                gpointer      invocation_hint,
+                                                                gpointer      marshal_data);
+G_END_DECLS
+void
+dbus_glib_marshal_gpm_kbd_backlight_BOOLEAN__UINT_POINTER (GClosure     *closure,
+                                                           GValue       *return_value,
+                                                           guint         n_param_values,
+                                                           const GValue *param_values,
+                                                           gpointer      invocation_hint G_GNUC_UNUSED,
+                                                           gpointer      marshal_data)
+{
+  typedef gboolean (*GMarshalFunc_BOOLEAN__UINT_POINTER) (gpointer data1,
+                                                          guint arg1,
+                                                          gpointer arg2,
+                                                          gpointer data2);
+  GCClosure *cc = (GCClosure *) closure;
+  gpointer data1, data2;
+  GMarshalFunc_BOOLEAN__UINT_POINTER callback;
+  gboolean v_return;
+
+  g_return_if_fail (return_value != NULL);
+  g_return_if_fail (n_param_values == 3);
+
+  if (G_CCLOSURE_SWAP_DATA (closure))
+    {
+      data1 = closure->data;
+      data2 = g_value_peek_pointer (param_values + 0);
+    }
+  else
+    {
+      data1 = g_value_peek_pointer (param_values + 0);
+      data2 = closure->data;
+    }
+  callback = (GMarshalFunc_BOOLEAN__UINT_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+  v_return = callback (data1,
+                       g_marshal_value_peek_uint (param_values + 1),
+                       g_marshal_value_peek_pointer (param_values + 2),
+                       data2);
+
+  g_value_set_boolean (return_value, v_return);
+}
+
+#include <dbus/dbus-glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+static const DBusGMethodInfo dbus_glib_gpm_kbd_backlight_methods[] = {
+  { (GCallback) gpm_kbd_backlight_get_brightness, dbus_glib_marshal_gpm_kbd_backlight_BOOLEAN__POINTER_POINTER, 0 },
+  { (GCallback) gpm_kbd_backlight_set_brightness, dbus_glib_marshal_gpm_kbd_backlight_BOOLEAN__UINT_POINTER, 82 },
+};
+
+const DBusGObjectInfo dbus_glib_gpm_kbd_backlight_object_info = {  1,
+  dbus_glib_gpm_kbd_backlight_methods,
+  2,
+"org.mate.PowerManager.KbdBacklight\0GetBrightness\0S\0percentage_brightness\0O\0F\0N\0u\0\0org.mate.PowerManager.KbdBacklight\0SetBrightness\0S\0percentage_brightness\0I\0u\0\0\0",
+"org.mate.PowerManager.KbdBacklight\0BrightnessChanged\0\0",
+"\0"
+};
+
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/97.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/97.html new file mode 100644 index 0000000..fc4c598 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/97.html @@ -0,0 +1,1187 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
#include "gpm-marshal.h"
+/* This file is generated by glib-genmarshal, do not modify it. This code is licensed under the same license as the containing project. Note that it links to GLib, so must comply with the LGPL linking clauses. */
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#ifdef G_ENABLE_DEBUG
+#define g_marshal_value_peek_boolean(v)  g_value_get_boolean (v)
+#define g_marshal_value_peek_char(v)     g_value_get_schar (v)
+#define g_marshal_value_peek_uchar(v)    g_value_get_uchar (v)
+#define g_marshal_value_peek_int(v)      g_value_get_int (v)
+#define g_marshal_value_peek_uint(v)     g_value_get_uint (v)
+#define g_marshal_value_peek_long(v)     g_value_get_long (v)
+#define g_marshal_value_peek_ulong(v)    g_value_get_ulong (v)
+#define g_marshal_value_peek_int64(v)    g_value_get_int64 (v)
+#define g_marshal_value_peek_uint64(v)   g_value_get_uint64 (v)
+#define g_marshal_value_peek_enum(v)     g_value_get_enum (v)
+#define g_marshal_value_peek_flags(v)    g_value_get_flags (v)
+#define g_marshal_value_peek_float(v)    g_value_get_float (v)
+#define g_marshal_value_peek_double(v)   g_value_get_double (v)
+#define g_marshal_value_peek_string(v)   (char*) g_value_get_string (v)
+#define g_marshal_value_peek_param(v)    g_value_get_param (v)
+#define g_marshal_value_peek_boxed(v)    g_value_get_boxed (v)
+#define g_marshal_value_peek_pointer(v)  g_value_get_pointer (v)
+#define g_marshal_value_peek_object(v)   g_value_get_object (v)
+#define g_marshal_value_peek_variant(v)  g_value_get_variant (v)
+#else /* !G_ENABLE_DEBUG */
+/* WARNING: This code accesses GValues directly, which is UNSUPPORTED API.
+ *          Do not access GValues directly in your code. Instead, use the
+ *          g_value_get_*() functions
+ */
+#define g_marshal_value_peek_boolean(v)  (v)->data[0].v_int
+#define g_marshal_value_peek_char(v)     (v)->data[0].v_int
+#define g_marshal_value_peek_uchar(v)    (v)->data[0].v_uint
+#define g_marshal_value_peek_int(v)      (v)->data[0].v_int
+#define g_marshal_value_peek_uint(v)     (v)->data[0].v_uint
+#define g_marshal_value_peek_long(v)     (v)->data[0].v_long
+#define g_marshal_value_peek_ulong(v)    (v)->data[0].v_ulong
+#define g_marshal_value_peek_int64(v)    (v)->data[0].v_int64
+#define g_marshal_value_peek_uint64(v)   (v)->data[0].v_uint64
+#define g_marshal_value_peek_enum(v)     (v)->data[0].v_long
+#define g_marshal_value_peek_flags(v)    (v)->data[0].v_ulong
+#define g_marshal_value_peek_float(v)    (v)->data[0].v_float
+#define g_marshal_value_peek_double(v)   (v)->data[0].v_double
+#define g_marshal_value_peek_string(v)   (v)->data[0].v_pointer
+#define g_marshal_value_peek_param(v)    (v)->data[0].v_pointer
+#define g_marshal_value_peek_boxed(v)    (v)->data[0].v_pointer
+#define g_marshal_value_peek_pointer(v)  (v)->data[0].v_pointer
+#define g_marshal_value_peek_object(v)   (v)->data[0].v_pointer
+#define g_marshal_value_peek_variant(v)  (v)->data[0].v_pointer
+#endif /* !G_ENABLE_DEBUG */
+
+/* VOID:INT,BOXED (gpm-marshal.list:1) */
+void
+gpm_marshal_VOID__INT_BOXED (GClosure     *closure,
+                             GValue       *return_value G_GNUC_UNUSED,
+                             guint         n_param_values,
+                             const GValue *param_values,
+                             gpointer      invocation_hint G_GNUC_UNUSED,
+                             gpointer      marshal_data)
+{
+  typedef void (*GMarshalFunc_VOID__INT_BOXED) (gpointer data1,
+                                                gint arg1,
+                                                gpointer arg2,
+                                                gpointer data2);
+  GCClosure *cc = (GCClosure *) closure;
+  gpointer data1, data2;
+  GMarshalFunc_VOID__INT_BOXED callback;
+
+  g_return_if_fail (n_param_values == 3);
+
+  if (G_CCLOSURE_SWAP_DATA (closure))
+    {
+      data1 = closure->data;
+      data2 = g_value_peek_pointer (param_values + 0);
+    }
+  else
+    {
+      data1 = g_value_peek_pointer (param_values + 0);
+      data2 = closure->data;
+    }
+  callback = (GMarshalFunc_VOID__INT_BOXED) (marshal_data ? marshal_data : cc->callback);
+
+  callback (data1,
+            g_marshal_value_peek_int (param_values + 1),
+            g_marshal_value_peek_boxed (param_values + 2),
+            data2);
+}
+
+/* VOID:STRING,STRING (gpm-marshal.list:2) */
+void
+gpm_marshal_VOID__STRING_STRING (GClosure     *closure,
+                                 GValue       *return_value G_GNUC_UNUSED,
+                                 guint         n_param_values,
+                                 const GValue *param_values,
+                                 gpointer      invocation_hint G_GNUC_UNUSED,
+                                 gpointer      marshal_data)
+{
+  typedef void (*GMarshalFunc_VOID__STRING_STRING) (gpointer data1,
+                                                    gpointer arg1,
+                                                    gpointer arg2,
+                                                    gpointer data2);
+  GCClosure *cc = (GCClosure *) closure;
+  gpointer data1, data2;
+  GMarshalFunc_VOID__STRING_STRING callback;
+
+  g_return_if_fail (n_param_values == 3);
+
+  if (G_CCLOSURE_SWAP_DATA (closure))
+    {
+      data1 = closure->data;
+      data2 = g_value_peek_pointer (param_values + 0);
+    }
+  else
+    {
+      data1 = g_value_peek_pointer (param_values + 0);
+      data2 = closure->data;
+    }
+  callback = (GMarshalFunc_VOID__STRING_STRING) (marshal_data ? marshal_data : cc->callback);
+
+  callback (data1,
+            g_marshal_value_peek_string (param_values + 1),
+            g_marshal_value_peek_string (param_values + 2),
+            data2);
+}
+
+/* VOID:POINTER,STRING,STRING (gpm-marshal.list:3) */
+void
+gpm_marshal_VOID__POINTER_STRING_STRING (GClosure     *closure,
+                                         GValue       *return_value G_GNUC_UNUSED,
+                                         guint         n_param_values,
+                                         const GValue *param_values,
+                                         gpointer      invocation_hint G_GNUC_UNUSED,
+                                         gpointer      marshal_data)
+{
+  typedef void (*GMarshalFunc_VOID__POINTER_STRING_STRING) (gpointer data1,
+                                                            gpointer arg1,
+                                                            gpointer arg2,
+                                                            gpointer arg3,
+                                                            gpointer data2);
+  GCClosure *cc = (GCClosure *) closure;
+  gpointer data1, data2;
+  GMarshalFunc_VOID__POINTER_STRING_STRING callback;
+
+  g_return_if_fail (n_param_values == 4);
+
+  if (G_CCLOSURE_SWAP_DATA (closure))
+    {
+      data1 = closure->data;
+      data2 = g_value_peek_pointer (param_values + 0);
+    }
+  else
+    {
+      data1 = g_value_peek_pointer (param_values + 0);
+      data2 = closure->data;
+    }
+  callback = (GMarshalFunc_VOID__POINTER_STRING_STRING) (marshal_data ? marshal_data : cc->callback);
+
+  callback (data1,
+            g_marshal_value_peek_pointer (param_values + 1),
+            g_marshal_value_peek_string (param_values + 2),
+            g_marshal_value_peek_string (param_values + 3),
+            data2);
+}
+
+/* VOID:UINT,UINT,BOOLEAN (gpm-marshal.list:4) */
+void
+gpm_marshal_VOID__UINT_UINT_BOOLEAN (GClosure     *closure,
+                                     GValue       *return_value G_GNUC_UNUSED,
+                                     guint         n_param_values,
+                                     const GValue *param_values,
+                                     gpointer      invocation_hint G_GNUC_UNUSED,
+                                     gpointer      marshal_data)
+{
+  typedef void (*GMarshalFunc_VOID__UINT_UINT_BOOLEAN) (gpointer data1,
+                                                        guint arg1,
+                                                        guint arg2,
+                                                        gboolean arg3,
+                                                        gpointer data2);
+  GCClosure *cc = (GCClosure *) closure;
+  gpointer data1, data2;
+  GMarshalFunc_VOID__UINT_UINT_BOOLEAN callback;
+
+  g_return_if_fail (n_param_values == 4);
+
+  if (G_CCLOSURE_SWAP_DATA (closure))
+    {
+      data1 = closure->data;
+      data2 = g_value_peek_pointer (param_values + 0);
+    }
+  else
+    {
+      data1 = g_value_peek_pointer (param_values + 0);
+      data2 = closure->data;
+    }
+  callback = (GMarshalFunc_VOID__UINT_UINT_BOOLEAN) (marshal_data ? marshal_data : cc->callback);
+
+  callback (data1,
+            g_marshal_value_peek_uint (param_values + 1),
+            g_marshal_value_peek_uint (param_values + 2),
+            g_marshal_value_peek_boolean (param_values + 3),
+            data2);
+}
+
+/* VOID:STRING,STRING,STRING (gpm-marshal.list:5) */
+void
+gpm_marshal_VOID__STRING_STRING_STRING (GClosure     *closure,
+                                        GValue       *return_value G_GNUC_UNUSED,
+                                        guint         n_param_values,
+                                        const GValue *param_values,
+                                        gpointer      invocation_hint G_GNUC_UNUSED,
+                                        gpointer      marshal_data)
+{
+  typedef void (*GMarshalFunc_VOID__STRING_STRING_STRING) (gpointer data1,
+                                                           gpointer arg1,
+                                                           gpointer arg2,
+                                                           gpointer arg3,
+                                                           gpointer data2);
+  GCClosure *cc = (GCClosure *) closure;
+  gpointer data1, data2;
+  GMarshalFunc_VOID__STRING_STRING_STRING callback;
+
+  g_return_if_fail (n_param_values == 4);
+
+  if (G_CCLOSURE_SWAP_DATA (closure))
+    {
+      data1 = closure->data;
+      data2 = g_value_peek_pointer (param_values + 0);
+    }
+  else
+    {
+      data1 = g_value_peek_pointer (param_values + 0);
+      data2 = closure->data;
+    }
+  callback = (GMarshalFunc_VOID__STRING_STRING_STRING) (marshal_data ? marshal_data : cc->callback);
+
+  callback (data1,
+            g_marshal_value_peek_string (param_values + 1),
+            g_marshal_value_peek_string (param_values + 2),
+            g_marshal_value_peek_string (param_values + 3),
+            data2);
+}
+
+/* VOID:STRING,BOOLEAN (gpm-marshal.list:6) */
+void
+gpm_marshal_VOID__STRING_BOOLEAN (GClosure     *closure,
+                                  GValue       *return_value G_GNUC_UNUSED,
+                                  guint         n_param_values,
+                                  const GValue *param_values,
+                                  gpointer      invocation_hint G_GNUC_UNUSED,
+                                  gpointer      marshal_data)
+{
+  typedef void (*GMarshalFunc_VOID__STRING_BOOLEAN) (gpointer data1,
+                                                     gpointer arg1,
+                                                     gboolean arg2,
+                                                     gpointer data2);
+  GCClosure *cc = (GCClosure *) closure;
+  gpointer data1, data2;
+  GMarshalFunc_VOID__STRING_BOOLEAN callback;
+
+  g_return_if_fail (n_param_values == 3);
+
+  if (G_CCLOSURE_SWAP_DATA (closure))
+    {
+      data1 = closure->data;
+      data2 = g_value_peek_pointer (param_values + 0);
+    }
+  else
+    {
+      data1 = g_value_peek_pointer (param_values + 0);
+      data2 = closure->data;
+    }
+  callback = (GMarshalFunc_VOID__STRING_BOOLEAN) (marshal_data ? marshal_data : cc->callback);
+
+  callback (data1,
+            g_marshal_value_peek_string (param_values + 1),
+            g_marshal_value_peek_boolean (param_values + 2),
+            data2);
+}
+
+/* VOID:STRING,STRING,BOOLEAN (gpm-marshal.list:7) */
+void
+gpm_marshal_VOID__STRING_STRING_BOOLEAN (GClosure     *closure,
+                                         GValue       *return_value G_GNUC_UNUSED,
+                                         guint         n_param_values,
+                                         const GValue *param_values,
+                                         gpointer      invocation_hint G_GNUC_UNUSED,
+                                         gpointer      marshal_data)
+{
+  typedef void (*GMarshalFunc_VOID__STRING_STRING_BOOLEAN) (gpointer data1,
+                                                            gpointer arg1,
+                                                            gpointer arg2,
+                                                            gboolean arg3,
+                                                            gpointer data2);
+  GCClosure *cc = (GCClosure *) closure;
+  gpointer data1, data2;
+  GMarshalFunc_VOID__STRING_STRING_BOOLEAN callback;
+
+  g_return_if_fail (n_param_values == 4);
+
+  if (G_CCLOSURE_SWAP_DATA (closure))
+    {
+      data1 = closure->data;
+      data2 = g_value_peek_pointer (param_values + 0);
+    }
+  else
+    {
+      data1 = g_value_peek_pointer (param_values + 0);
+      data2 = closure->data;
+    }
+  callback = (GMarshalFunc_VOID__STRING_STRING_BOOLEAN) (marshal_data ? marshal_data : cc->callback);
+
+  callback (data1,
+            g_marshal_value_peek_string (param_values + 1),
+            g_marshal_value_peek_string (param_values + 2),
+            g_marshal_value_peek_boolean (param_values + 3),
+            data2);
+}
+
+/* VOID:STRING,STRING,BOOLEAN,BOOLEAN,BOOLEAN (gpm-marshal.list:8) */
+void
+gpm_marshal_VOID__STRING_STRING_BOOLEAN_BOOLEAN_BOOLEAN (GClosure     *closure,
+                                                         GValue       *return_value G_GNUC_UNUSED,
+                                                         guint         n_param_values,
+                                                         const GValue *param_values,
+                                                         gpointer      invocation_hint G_GNUC_UNUSED,
+                                                         gpointer      marshal_data)
+{
+  typedef void (*GMarshalFunc_VOID__STRING_STRING_BOOLEAN_BOOLEAN_BOOLEAN) (gpointer data1,
+                                                                            gpointer arg1,
+                                                                            gpointer arg2,
+                                                                            gboolean arg3,
+                                                                            gboolean arg4,
+                                                                            gboolean arg5,
+                                                                            gpointer data2);
+  GCClosure *cc = (GCClosure *) closure;
+  gpointer data1, data2;
+  GMarshalFunc_VOID__STRING_STRING_BOOLEAN_BOOLEAN_BOOLEAN callback;
+
+  g_return_if_fail (n_param_values == 6);
+
+  if (G_CCLOSURE_SWAP_DATA (closure))
+    {
+      data1 = closure->data;
+      data2 = g_value_peek_pointer (param_values + 0);
+    }
+  else
+    {
+      data1 = g_value_peek_pointer (param_values + 0);
+      data2 = closure->data;
+    }
+  callback = (GMarshalFunc_VOID__STRING_STRING_BOOLEAN_BOOLEAN_BOOLEAN) (marshal_data ? marshal_data : cc->callback);
+
+  callback (data1,
+            g_marshal_value_peek_string (param_values + 1),
+            g_marshal_value_peek_string (param_values + 2),
+            g_marshal_value_peek_boolean (param_values + 3),
+            g_marshal_value_peek_boolean (param_values + 4),
+            g_marshal_value_peek_boolean (param_values + 5),
+            data2);
+}
+
+/* VOID:INT,LONG,BOOLEAN,BOOLEAN (gpm-marshal.list:11) */
+void
+gpm_marshal_VOID__INT_LONG_BOOLEAN_BOOLEAN (GClosure     *closure,
+                                            GValue       *return_value G_GNUC_UNUSED,
+                                            guint         n_param_values,
+                                            const GValue *param_values,
+                                            gpointer      invocation_hint G_GNUC_UNUSED,
+                                            gpointer      marshal_data)
+{
+  typedef void (*GMarshalFunc_VOID__INT_LONG_BOOLEAN_BOOLEAN) (gpointer data1,
+                                                               gint arg1,
+                                                               glong arg2,
+                                                               gboolean arg3,
+                                                               gboolean arg4,
+                                                               gpointer data2);
+  GCClosure *cc = (GCClosure *) closure;
+  gpointer data1, data2;
+  GMarshalFunc_VOID__INT_LONG_BOOLEAN_BOOLEAN callback;
+
+  g_return_if_fail (n_param_values == 5);
+
+  if (G_CCLOSURE_SWAP_DATA (closure))
+    {
+      data1 = closure->data;
+      data2 = g_value_peek_pointer (param_values + 0);
+    }
+  else
+    {
+      data1 = g_value_peek_pointer (param_values + 0);
+      data2 = closure->data;
+    }
+  callback = (GMarshalFunc_VOID__INT_LONG_BOOLEAN_BOOLEAN) (marshal_data ? marshal_data : cc->callback);
+
+  callback (data1,
+            g_marshal_value_peek_int (param_values + 1),
+            g_marshal_value_peek_long (param_values + 2),
+            g_marshal_value_peek_boolean (param_values + 3),
+            g_marshal_value_peek_boolean (param_values + 4),
+            data2);
+}
+
+/* VOID:BOOLEAN,BOOLEAN (gpm-marshal.list:12) */
+void
+gpm_marshal_VOID__BOOLEAN_BOOLEAN (GClosure     *closure,
+                                   GValue       *return_value G_GNUC_UNUSED,
+                                   guint         n_param_values,
+                                   const GValue *param_values,
+                                   gpointer      invocation_hint G_GNUC_UNUSED,
+                                   gpointer      marshal_data)
+{
+  typedef void (*GMarshalFunc_VOID__BOOLEAN_BOOLEAN) (gpointer data1,
+                                                      gboolean arg1,
+                                                      gboolean arg2,
+                                                      gpointer data2);
+  GCClosure *cc = (GCClosure *) closure;
+  gpointer data1, data2;
+  GMarshalFunc_VOID__BOOLEAN_BOOLEAN callback;
+
+  g_return_if_fail (n_param_values == 3);
+
+  if (G_CCLOSURE_SWAP_DATA (closure))
+    {
+      data1 = closure->data;
+      data2 = g_value_peek_pointer (param_values + 0);
+    }
+  else
+    {
+      data1 = g_value_peek_pointer (param_values + 0);
+      data2 = closure->data;
+    }
+  callback = (GMarshalFunc_VOID__BOOLEAN_BOOLEAN) (marshal_data ? marshal_data : cc->callback);
+
+  callback (data1,
+            g_marshal_value_peek_boolean (param_values + 1),
+            g_marshal_value_peek_boolean (param_values + 2),
+            data2);
+}
+
+/* VOID:UINT,UINT (gpm-marshal.list:14) */
+void
+gpm_marshal_VOID__UINT_UINT (GClosure     *closure,
+                             GValue       *return_value G_GNUC_UNUSED,
+                             guint         n_param_values,
+                             const GValue *param_values,
+                             gpointer      invocation_hint G_GNUC_UNUSED,
+                             gpointer      marshal_data)
+{
+  typedef void (*GMarshalFunc_VOID__UINT_UINT) (gpointer data1,
+                                                guint arg1,
+                                                guint arg2,
+                                                gpointer data2);
+  GCClosure *cc = (GCClosure *) closure;
+  gpointer data1, data2;
+  GMarshalFunc_VOID__UINT_UINT callback;
+
+  g_return_if_fail (n_param_values == 3);
+
+  if (G_CCLOSURE_SWAP_DATA (closure))
+    {
+      data1 = closure->data;
+      data2 = g_value_peek_pointer (param_values + 0);
+    }
+  else
+    {
+      data1 = g_value_peek_pointer (param_values + 0);
+      data2 = closure->data;
+    }
+  callback = (GMarshalFunc_VOID__UINT_UINT) (marshal_data ? marshal_data : cc->callback);
+
+  callback (data1,
+            g_marshal_value_peek_uint (param_values + 1),
+            g_marshal_value_peek_uint (param_values + 2),
+            data2);
+}
+
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/98.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/98.html new file mode 100644 index 0000000..c5e9a66 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/98.html @@ -0,0 +1,441 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2005-2007 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <dbus/dbus-glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "gpm-networkmanager.h"
+
+#define NM_LISTENER_SERVICE	"org.freedesktop.NetworkManager"
+#define NM_LISTENER_PATH	"/org/freedesktop/NetworkManager"
+#define NM_LISTENER_INTERFACE	"org.freedesktop.NetworkManager"
+
+/**
+ * gpm_networkmanager_sleep:
+ *
+ * Tell NetworkManager to put the network devices to sleep
+ *
+ * Return value: TRUE if NetworkManager is now sleeping.
+ **/
+gboolean
+gpm_networkmanager_sleep (void)
+{
+	DBusGConnection *connection = NULL;
+	DBusGProxy *nm_proxy = NULL;
+	GError *error = NULL;
+
+	connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
+	if (error) {
+		g_warning ("%s", error->message);
+		g_error_free (error);
+		return FALSE;
+	}
+
+	nm_proxy = dbus_g_proxy_new_for_name (connection,
+			NM_LISTENER_SERVICE,
+			NM_LISTENER_PATH,
+			NM_LISTENER_INTERFACE);
+	if (!nm_proxy) {
+		g_warning ("Failed to get name owner");
+		return FALSE;
+	}
+	dbus_g_proxy_call_no_reply (nm_proxy, "sleep", G_TYPE_INVALID);
+	g_object_unref (G_OBJECT (nm_proxy));
+	return TRUE;
+}
+
+/**
+ * gpm_networkmanager_wake:
+ *
+ * Tell NetworkManager to wake up all the network devices
+ *
+ * Return value: TRUE if NetworkManager is now awake.
+ **/
+gboolean
+gpm_networkmanager_wake (void)
+{
+	DBusGConnection *connection = NULL;
+	DBusGProxy *nm_proxy = NULL;
+	GError *error = NULL;
+
+	connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
+	if (error) {
+		g_warning ("%s", error->message);
+		g_error_free (error);
+		return FALSE;
+	}
+
+	nm_proxy = dbus_g_proxy_new_for_name (connection,
+			NM_LISTENER_SERVICE,
+			NM_LISTENER_PATH,
+			NM_LISTENER_INTERFACE);
+	if (!nm_proxy) {
+		g_warning ("Failed to get name owner");
+		return FALSE;
+	}
+	dbus_g_proxy_call_no_reply (nm_proxy, "wake", G_TYPE_INVALID);
+	g_object_unref (G_OBJECT (nm_proxy));
+	return TRUE;
+}
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/99.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/99.html new file mode 100644 index 0000000..9d8fbbd --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/99.html @@ -0,0 +1,1223 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007-2008 Richard Hughes <richard@hughsie.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "config.h"<--- Include file: "config.h" not found.
+
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gio/gio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <dbus/dbus-glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "gpm-phone.h"
+#include "gpm-marshal.h"
+
+static void     gpm_phone_finalize   (GObject	    *object);
+
+struct GpmPhonePrivate
+{
+	DBusGProxy		*proxy;
+	DBusGConnection		*connection;
+	guint			 watch_id;
+	gboolean		 present;
+	guint			 percentage;
+	gboolean		 onac;
+};
+
+enum {
+	DEVICE_ADDED,
+	DEVICE_REMOVED,
+	DEVICE_REFRESH,
+	LAST_SIGNAL
+};
+
+static guint signals [LAST_SIGNAL] = { 0 };
+static gpointer gpm_phone_object = NULL;
+
+G_DEFINE_TYPE_WITH_PRIVATE (GpmPhone, gpm_phone, G_TYPE_OBJECT)<--- There is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
+
+/**
+ * gpm_phone_coldplug:
+ * Return value: Success value, or zero for failure
+ **/
+gboolean
+gpm_phone_coldplug (GpmPhone *phone)
+{
+	GError  *error = NULL;
+	gboolean ret;
+
+	g_return_val_if_fail (phone != NULL, FALSE);
+	g_return_val_if_fail (GPM_IS_PHONE (phone), FALSE);
+
+	if (phone->priv->proxy == NULL) {
+		g_debug ("Phone is not connected");
+		return FALSE;
+	}
+
+	ret = dbus_g_proxy_call (phone->priv->proxy, "Coldplug", &error,
+				 G_TYPE_INVALID, G_TYPE_INVALID);
+	if (error != NULL) {
+		g_warning ("DEBUG: ERROR: %s", error->message);
+		g_error_free (error);
+	}
+
+	return ret;
+}
+
+/**
+ * gpm_phone_coldplug:
+ * Return value: if present
+ **/
+gboolean
+gpm_phone_get_present (GpmPhone	*phone, guint idx)
+{
+	g_return_val_if_fail (phone != NULL, FALSE);
+	g_return_val_if_fail (GPM_IS_PHONE (phone), FALSE);
+	return phone->priv->present;
+}
+
+/**
+ * gpm_phone_coldplug:
+ * Return value: if present
+ **/
+guint
+gpm_phone_get_percentage (GpmPhone *phone, guint idx)
+{
+	g_return_val_if_fail (phone != NULL, 0);
+	g_return_val_if_fail (GPM_IS_PHONE (phone), 0);
+	return phone->priv->percentage;
+}
+
+/**
+ * gpm_phone_coldplug:
+ * Return value: if present
+ **/
+gboolean
+gpm_phone_get_on_ac (GpmPhone *phone, guint idx)
+{
+	g_return_val_if_fail (phone != NULL, FALSE);
+	g_return_val_if_fail (GPM_IS_PHONE (phone), FALSE);
+	return phone->priv->onac;
+}
+
+/**
+ * gpm_phone_get_num_batteries:
+ * Return value: number of phone batteries monitored
+ **/
+guint
+gpm_phone_get_num_batteries (GpmPhone *phone)
+{
+	g_return_val_if_fail (phone != NULL, 0);
+	g_return_val_if_fail (GPM_IS_PHONE (phone), 0);
+	if (phone->priv->present) {
+		return 1;
+	}
+	return 0;
+}
+
+/** Invoked when we get the BatteryStateChanged
+ */
+static void
+gpm_phone_battery_state_changed (DBusGProxy *proxy, guint idx, guint percentage, gboolean on_ac, GpmPhone *phone)
+{
+	g_return_if_fail (GPM_IS_PHONE (phone));
+
+	g_debug ("got BatteryStateChanged %u = %u (%i)", idx, percentage, on_ac);
+	phone->priv->percentage = percentage;
+	phone->priv->onac = on_ac;
+	phone->priv->present = TRUE;
+	g_debug ("emitting device-refresh : (%u)", idx);
+	g_signal_emit (phone, signals [DEVICE_REFRESH], 0, idx);
+}
+
+/** Invoked when we get NumberBatteriesChanged
+ */
+static void
+gpm_phone_num_batteries_changed (DBusGProxy *proxy, guint number, GpmPhone *phone)
+{
+	g_return_if_fail (GPM_IS_PHONE (phone));
+
+	g_debug ("got NumberBatteriesChanged %u", number);
+	if (number > 1) {
+		g_warning ("number not 0 or 1, not valid!");
+		return;
+	}
+
+	/* are we removed? */
+	if (number == 0) {
+		phone->priv->present = FALSE;
+		phone->priv->percentage = 0;
+		phone->priv->onac = FALSE;
+		g_debug ("emitting device-removed : (%i)", 0);
+		g_signal_emit (phone, signals [DEVICE_REMOVED], 0, 0);
+		return;
+	}
+
+	if (phone->priv->present) {
+		g_warning ("duplicate NumberBatteriesChanged with no change");
+		return;
+	}
+
+	/* reset to defaults until we get BatteryStateChanged */
+	phone->priv->present = TRUE;
+	phone->priv->percentage = 0;
+	phone->priv->onac = FALSE;
+	g_debug ("emitting device-added : (%i)", 0);
+	g_signal_emit (phone, signals [DEVICE_ADDED], 0, 0);
+}
+
+/**
+ * gpm_phone_class_init:
+ * @klass: This class instance
+ **/
+static void
+gpm_phone_class_init (GpmPhoneClass *klass)
+{
+	GObjectClass *object_class = G_OBJECT_CLASS (klass);
+	object_class->finalize = gpm_phone_finalize;
+
+	signals [DEVICE_ADDED] =
+		g_signal_new ("device-added",
+			      G_TYPE_FROM_CLASS (object_class),
+			      G_SIGNAL_RUN_LAST,
+			      G_STRUCT_OFFSET (GpmPhoneClass, device_added),
+			      NULL, NULL, g_cclosure_marshal_VOID__UINT,
+			      G_TYPE_NONE, 1, G_TYPE_UINT);
+
+	signals [DEVICE_REMOVED] =
+		g_signal_new ("device-removed",
+			      G_TYPE_FROM_CLASS (object_class),
+			      G_SIGNAL_RUN_LAST,
+			      G_STRUCT_OFFSET (GpmPhoneClass, device_removed),
+			      NULL, NULL, g_cclosure_marshal_VOID__UINT,
+			      G_TYPE_NONE, 1, G_TYPE_UINT);
+
+	signals [DEVICE_REFRESH] =
+		g_signal_new ("device-refresh",
+			      G_TYPE_FROM_CLASS (object_class),
+			      G_SIGNAL_RUN_LAST,
+			      G_STRUCT_OFFSET (GpmPhoneClass, device_refresh),
+			      NULL, NULL, g_cclosure_marshal_VOID__UINT,
+			      G_TYPE_NONE, 1, G_TYPE_UINT);
+}
+
+/**
+ * gpm_phone_service_appeared_cb:
+ */
+static void
+gpm_phone_service_appeared_cb (GDBusConnection *connection,
+			       const gchar *name, const gchar *name_owner,
+			       GpmPhone *phone)
+{
+	GError *error = NULL;
+
+	g_return_if_fail (GPM_IS_PHONE (phone));
+
+	if (phone->priv->connection == NULL) {
+		g_debug ("get connection");
+		g_clear_error (&error);
+		phone->priv->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+		if (error != NULL) {
+			g_warning ("Could not connect to DBUS daemon: %s", error->message);
+			g_error_free (error);
+			phone->priv->connection = NULL;
+			return;
+		}
+	}
+	if (phone->priv->proxy == NULL) {
+		g_debug ("get proxy");
+		g_clear_error (&error);
+		phone->priv->proxy = dbus_g_proxy_new_for_name_owner (phone->priv->connection,
+							 MATE_PHONE_MANAGER_DBUS_SERVICE,
+							 MATE_PHONE_MANAGER_DBUS_PATH,
+							 MATE_PHONE_MANAGER_DBUS_INTERFACE,
+							 &error);
+		if (error != NULL) {
+			g_warning ("Cannot connect, maybe the daemon is not running: %s", error->message);
+			g_error_free (error);
+			phone->priv->proxy = NULL;
+			return;
+		}
+
+		/* complicated type. ick */
+		dbus_g_object_register_marshaller(gpm_marshal_VOID__UINT_UINT_BOOLEAN,
+						  G_TYPE_NONE, G_TYPE_UINT, G_TYPE_UINT,
+						  G_TYPE_BOOLEAN, G_TYPE_INVALID);
+
+		/* get BatteryStateChanged */
+		dbus_g_proxy_add_signal (phone->priv->proxy, "BatteryStateChanged",
+					 G_TYPE_UINT, G_TYPE_UINT, G_TYPE_BOOLEAN, G_TYPE_INVALID);
+		dbus_g_proxy_connect_signal (phone->priv->proxy, "BatteryStateChanged",
+					     G_CALLBACK (gpm_phone_battery_state_changed),
+					     phone, NULL);
+
+		/* get NumberBatteriesChanged */
+		dbus_g_proxy_add_signal (phone->priv->proxy, "NumberBatteriesChanged",
+					 G_TYPE_UINT, G_TYPE_INVALID);
+		dbus_g_proxy_connect_signal (phone->priv->proxy, "NumberBatteriesChanged",
+					     G_CALLBACK (gpm_phone_num_batteries_changed),
+					     phone, NULL);
+
+	}
+}
+
+/**
+ * gpm_phone_service_vanished_cb:
+ */
+static void
+gpm_phone_service_vanished_cb (GDBusConnection *connection,
+			        const gchar *name,
+			        GpmPhone *phone)
+{
+	g_return_if_fail (GPM_IS_PHONE (phone));
+
+	if (phone->priv->proxy != NULL) {
+		g_debug ("removing proxy");
+		g_object_unref (phone->priv->proxy);
+		phone->priv->proxy = NULL;
+		if (phone->priv->present) {
+			phone->priv->present = FALSE;
+			phone->priv->percentage = 0;
+			g_debug ("emitting device-removed : (%i)", 0);
+			g_signal_emit (phone, signals [DEVICE_REMOVED], 0, 0);
+		}
+	}
+	return;
+}
+
+/**
+ * gpm_phone_init:
+ * @phone: This class instance
+ **/
+static void
+gpm_phone_init (GpmPhone *phone)
+{
+	phone->priv = gpm_phone_get_instance_private (phone);
+
+	phone->priv->connection = NULL;
+	phone->priv->proxy = NULL;
+	phone->priv->present = FALSE;
+	phone->priv->percentage = 0;
+	phone->priv->onac = FALSE;
+
+	phone->priv->watch_id = g_bus_watch_name (G_BUS_TYPE_SESSION,
+						  MATE_PHONE_MANAGER_DBUS_SERVICE,
+						  G_BUS_NAME_WATCHER_FLAGS_NONE,
+						  (GBusNameAppearedCallback) gpm_phone_service_appeared_cb,
+						  (GBusNameVanishedCallback) gpm_phone_service_vanished_cb,
+						  phone, NULL);
+}
+
+/**
+ * gpm_phone_finalize:
+ * @object: This class instance
+ **/
+static void
+gpm_phone_finalize (GObject *object)
+{
+	GpmPhone *phone;
+	g_return_if_fail (GPM_IS_PHONE (object));
+
+	phone = GPM_PHONE (object);
+	phone->priv = gpm_phone_get_instance_private (phone);
+
+	if (phone->priv->proxy != NULL)
+		g_object_unref (phone->priv->proxy);
+	g_bus_unwatch_name (phone->priv->watch_id);
+
+	G_OBJECT_CLASS (gpm_phone_parent_class)->finalize (object);
+}
+
+/**
+ * gpm_phone_new:
+ * Return value: new GpmPhone instance.
+ **/
+GpmPhone *
+gpm_phone_new (void)
+{
+	if (gpm_phone_object != NULL) {
+		g_object_ref (gpm_phone_object);
+	} else {
+		gpm_phone_object = g_object_new (GPM_TYPE_PHONE, NULL);
+		g_object_add_weak_pointer (gpm_phone_object, &gpm_phone_object);
+	}
+	return GPM_PHONE (gpm_phone_object);
+}
+
+/***************************************************************************
+ ***                          MAKE CHECK TESTS                           ***
+ ***************************************************************************/
+#ifdef EGG_TEST
+#include "egg-test.h"
+
+static gboolean test_got_refresh = FALSE;
+
+static gboolean
+timeout_main_loop_quit (gpointer data)
+{
+	g_main_loop_quit (data);
+
+	return FALSE;
+}
+
+static void
+egg_test_mainloop_wait (guint ms)
+{
+	GMainLoop *loop;
+	loop = g_main_loop_new (NULL, FALSE);
+	g_timeout_add (ms, (GSourceFunc) timeout_main_loop_quit, loop);
+	g_main_loop_run (loop);
+}
+
+static void
+phone_device_refresh_cb (GpmPhone *phone, guint idx, gpointer *data)
+{
+	g_debug ("idx refresh = %u", idx);
+	if (idx == 0 && GPOINTER_TO_UINT (data) == 44)
+		test_got_refresh = TRUE;
+}
+
+void
+gpm_phone_test (gpointer data)
+{
+	GpmPhone *phone;
+	guint value;
+	gboolean ret;
+	EggTest *test = (EggTest *) data;
+
+	if (egg_test_start (test, "GpmPhone") == FALSE)
+		return;
+
+	/************************************************************/
+	egg_test_title (test, "make sure we get a non null phone");
+	phone = gpm_phone_new ();
+	if (phone != NULL)
+		egg_test_success (test, "got GpmPhone");
+	else
+		egg_test_failed (test, "could not get GpmPhone");
+
+	/* connect signals */
+	g_signal_connect (phone, "device-refresh",
+			  G_CALLBACK (phone_device_refresh_cb), GUINT_TO_POINTER(44));
+
+	/************************************************************/
+	egg_test_title (test, "make sure we got a connection");
+	if (phone->priv->proxy != NULL) {
+		egg_test_success (test, "got connection");
+	} else {
+		/* skip this part of the test */
+		egg_test_success (test, "could not get a connection!");
+		goto out;
+	}
+
+	/************************************************************/
+	egg_test_title (test, "coldplug the data");
+	ret = gpm_phone_coldplug (phone);
+	if (ret) {
+		egg_test_success (test, "coldplug okay");
+	} else {
+		egg_test_failed (test, "could not coldplug");
+	}
+
+	egg_test_mainloop_wait (500);
+
+	/************************************************************/
+	egg_test_title (test, "got refresh");
+	if (test_got_refresh) {
+		egg_test_success (test, NULL);
+	} else {
+		egg_test_failed (test, "did not get refresh");
+	}
+
+	/************************************************************/
+	egg_test_title (test, "check the connected phones");
+	value = gpm_phone_get_num_batteries (phone);
+	if (value == 1) {
+		egg_test_success (test, "connected phone");
+	} else {
+		egg_test_failed (test, "not connected with %i (phone not connected?)", value);
+	}
+
+	/************************************************************/
+	egg_test_title (test, "check the present value");
+	ret = gpm_phone_get_present (phone, 0);
+	if (ret) {
+		egg_test_success (test, "we are here!");
+	} else {
+		egg_test_failed (test, "not here...");
+	}
+
+	/************************************************************/
+	egg_test_title (test, "check the percentage");
+	value = gpm_phone_get_percentage (phone, 0);
+	if (value != 0) {
+		egg_test_success (test, "percentage is %i", phone->priv->percentage);
+	} else {
+		egg_test_failed (test, "could not get value");
+	}
+
+	/************************************************************/
+	egg_test_title (test, "check the ac value");
+	ret = gpm_phone_get_on_ac (phone, 0);
+	if (!ret) {
+		egg_test_success (test, "not charging, correct");
+	} else {
+		egg_test_failed (test, "charging?");
+	}
+out:
+	g_object_unref (phone);
+
+	egg_test_end (test);
+}
+
+#endif
+
+
+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/index.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/index.html new file mode 100644 index 0000000..bc9bd55 --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/index.html @@ -0,0 +1,1060 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
LineIdCWESeverityMessage
checkersReportinformationActive checkers: There was critical errors (use --checkers-report=<filename> to see details)
applets/brightness/brightness-applet.c
26missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <stdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <mate-panel-applet.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
33missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
34missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
35missingIncludeSysteminformationInclude file: <gdk/gdkkeysyms.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
36missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
37missingIncludeSysteminformationInclude file: <dbus/dbus-glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
79unknownMacroerrorThere is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE is a macro then please configure it.
applets/brightness/gpm-common.c
23missingIncludeinformationInclude file: "config.h" not found.
25missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <gdk/gdk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
65missingIncludeinformationInclude file: "egg-test.h" not found.
applets/brightness/gpm-common.h
26missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
applets/inhibit/gpm-common.c
23missingIncludeinformationInclude file: "config.h" not found.
25missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <gdk/gdk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
65missingIncludeinformationInclude file: "egg-test.h" not found.
applets/inhibit/gpm-common.h
26missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
applets/inhibit/inhibit-applet.c
26missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <stdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <mate-panel-applet.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
33missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
34missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
35missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
36missingIncludeSysteminformationInclude file: <dbus/dbus-glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
72unknownMacroerrorThere is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE is a macro then please configure it.
mate-desktop-1.27.1/libmate-desktop/display-name.c
25missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <glib/gi18n-lib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <math.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <stdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
196variableScope398styleThe scope of the variable 'code' can be reduced.
196variableScope398styleThe scope of the variable 'name' can be reduced.
mate-desktop-1.27.1/libmate-desktop/edid-parse.c
26missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <math.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-desktop-1.27.1/libmate-desktop/mate-bg-crossfade.c
22missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
23missingIncludeSysteminformationInclude file: <math.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
24missingIncludeSysteminformationInclude file: <stdarg.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <gio/gio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <gdk/gdk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <gdk/gdkx.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <X11/Xlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <X11/Xatom.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
34missingIncludeSysteminformationInclude file: <cairo.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
35missingIncludeSysteminformationInclude file: <cairo-xlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
38missingIncludeSysteminformationInclude file: <mate-bg.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
69unknownMacroerrorThere is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
mate-desktop-1.27.1/libmate-desktop/mate-bg-crossfade.h
32missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
33missingIncludeSysteminformationInclude file: <gdk/gdk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
34missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-desktop-1.27.1/libmate-desktop/mate-bg.c
33missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
34missingIncludeSysteminformationInclude file: <math.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
35missingIncludeSysteminformationInclude file: <stdarg.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
36missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
38missingIncludeSysteminformationInclude file: <glib/gstdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
39missingIncludeSysteminformationInclude file: <gio/gio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
41missingIncludeSysteminformationInclude file: <gdk/gdkx.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
42missingIncludeSysteminformationInclude file: <X11/Xlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
43missingIncludeSysteminformationInclude file: <X11/Xatom.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
45missingIncludeSysteminformationInclude file: <cairo.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
48missingIncludeSysteminformationInclude file: <mate-bg.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
49missingIncludeSysteminformationInclude file: <mate-bg-crossfade.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
51missingIncludeSysteminformationInclude file: <cairo-xlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
122unknownMacroerrorThere is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE is a macro then please configure it.
mate-desktop-1.27.1/libmate-desktop/mate-colorbutton.c
31missingIncludeinformationInclude file: "config.h" not found.
37missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
38missingIncludeSysteminformationInclude file: <gdk/gdkkeysyms.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
39missingIncludeSysteminformationInclude file: <gdk-pixbuf/gdk-pixbuf.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
40missingIncludeSysteminformationInclude file: <glib/gi18n-lib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
120unknownMacroerrorThere is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
mate-desktop-1.27.1/libmate-desktop/mate-colorbutton.h
35missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
36missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-desktop-1.27.1/libmate-desktop/mate-colorsel.c
28missingIncludeinformationInclude file: "config.h" not found.
30missingIncludeSysteminformationInclude file: <math.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
33missingIncludeSysteminformationInclude file: <gdk/gdkx.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
34missingIncludeSysteminformationInclude file: <gdk/gdkkeysyms.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
35missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
36missingIncludeSysteminformationInclude file: <glib/gi18n-lib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
243unknownMacroerrorThere is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
mate-desktop-1.27.1/libmate-desktop/mate-colorsel.h
31missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-desktop-1.27.1/libmate-desktop/mate-colorseldialog.c
26missingIncludeinformationInclude file: "config.h" not found.
28missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <glib/gi18n-lib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
52unknownMacroerrorThere is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_CODE is a macro then please configure it.
mate-desktop-1.27.1/libmate-desktop/mate-colorseldialog.h
30missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-desktop-1.27.1/libmate-desktop/mate-dconf.c
29missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
34missingIncludeSysteminformationInclude file: <dconf.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-desktop-1.27.1/libmate-desktop/mate-dconf.h
31missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-desktop-1.27.1/libmate-desktop/mate-desktop-item.c
30missingIncludeinformationInclude file: "config.h" not found.
32missingIncludeSysteminformationInclude file: <limits.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
33missingIncludeSysteminformationInclude file: <ctype.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
34missingIncludeSysteminformationInclude file: <stdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
35missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
36missingIncludeSysteminformationInclude file: <sys/types.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
37missingIncludeSysteminformationInclude file: <dirent.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
38missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
39missingIncludeSysteminformationInclude file: <time.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
40missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
41missingIncludeSysteminformationInclude file: <glib/gi18n-lib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
42missingIncludeSysteminformationInclude file: <locale.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
43missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
45missingIncludeSysteminformationInclude file: <gio/gio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
49missingIncludeSysteminformationInclude file: <libsn/sn.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
50missingIncludeSysteminformationInclude file: <gdk/gdk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
51missingIncludeSysteminformationInclude file: <gdk/gdkx.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
52missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
57missingIncludeSysteminformationInclude file: <mate-desktop-item.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
58missingIncludeSysteminformationInclude file: <mate-desktop-utils.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
916constVariablePointer398styleVariable 'li' can be declared as pointer to const
945constVariablePointer398styleVariable 'p' can be declared as pointer to const
2328variableScope398styleThe scope of the variable 'exec' can be reduced.
2834constVariablePointer398styleVariable 'l' can be declared as pointer to const
3146variableScope398styleThe scope of the variable 's' can be reduced.
3165varFuncNullUB475portabilityPassing NULL after the last typed argument to a variadic function leads to undefined behaviour.
3167varFuncNullUB475portabilityPassing NULL after the last typed argument to a variadic function leads to undefined behaviour.
3168varFuncNullUB475portabilityPassing NULL after the last typed argument to a variadic function leads to undefined behaviour.
3169varFuncNullUB475portabilityPassing NULL after the last typed argument to a variadic function leads to undefined behaviour.
3171varFuncNullUB475portabilityPassing NULL after the last typed argument to a variadic function leads to undefined behaviour.
3173varFuncNullUB475portabilityPassing NULL after the last typed argument to a variadic function leads to undefined behaviour.
3175varFuncNullUB475portabilityPassing NULL after the last typed argument to a variadic function leads to undefined behaviour.
3176varFuncNullUB475portabilityPassing NULL after the last typed argument to a variadic function leads to undefined behaviour.
3178varFuncNullUB475portabilityPassing NULL after the last typed argument to a variadic function leads to undefined behaviour.
3179varFuncNullUB475portabilityPassing NULL after the last typed argument to a variadic function leads to undefined behaviour.
3180varFuncNullUB475portabilityPassing NULL after the last typed argument to a variadic function leads to undefined behaviour.
3181varFuncNullUB475portabilityPassing NULL after the last typed argument to a variadic function leads to undefined behaviour.
3182varFuncNullUB475portabilityPassing NULL after the last typed argument to a variadic function leads to undefined behaviour.
3183varFuncNullUB475portabilityPassing NULL after the last typed argument to a variadic function leads to undefined behaviour.
3184varFuncNullUB475portabilityPassing NULL after the last typed argument to a variadic function leads to undefined behaviour.
3185varFuncNullUB475portabilityPassing NULL after the last typed argument to a variadic function leads to undefined behaviour.
3186varFuncNullUB475portabilityPassing NULL after the last typed argument to a variadic function leads to undefined behaviour.
3187varFuncNullUB475portabilityPassing NULL after the last typed argument to a variadic function leads to undefined behaviour.
3188varFuncNullUB475portabilityPassing NULL after the last typed argument to a variadic function leads to undefined behaviour.
3189varFuncNullUB475portabilityPassing NULL after the last typed argument to a variadic function leads to undefined behaviour.
3191varFuncNullUB475portabilityPassing NULL after the last typed argument to a variadic function leads to undefined behaviour.
3193varFuncNullUB475portabilityPassing NULL after the last typed argument to a variadic function leads to undefined behaviour.
3195varFuncNullUB475portabilityPassing NULL after the last typed argument to a variadic function leads to undefined behaviour.
3412constVariablePointer398styleVariable 'brace' can be declared as pointer to const
3487constParameterPointer398styleParameter 'item' can be declared as pointer to const
mate-desktop-1.27.1/libmate-desktop/mate-desktop-thumbnail.c
27missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <glib/gstdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <gdk-pixbuf/gdk-pixbuf.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
33missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
62unknownMacroerrorThere is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
mate-desktop-1.27.1/libmate-desktop/mate-desktop-thumbnail.h
33missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
34missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
35missingIncludeSysteminformationInclude file: <time.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
36missingIncludeSysteminformationInclude file: <gdk-pixbuf/gdk-pixbuf.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-desktop-1.27.1/libmate-desktop/mate-desktop-utils.c
27missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <gio/gio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <glib/gi18n-lib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <gdk/gdk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
35missingIncludeSysteminformationInclude file: <mate-desktop-utils.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
139multiCondition398styleExpression is always true because 'else if' condition is opposite to previous condition at line 133.
243constParameterPointer398styleParameter 'a' can be declared as pointer to const
mate-desktop-1.27.1/libmate-desktop/mate-desktop.h
30missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
33missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-desktop-1.27.1/libmate-desktop/mate-gsettings.h
29missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <gio/gio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-desktop-1.27.1/libmate-desktop/mate-hsv.c
34missingIncludeinformationInclude file: "config.h" not found.
39missingIncludeSysteminformationInclude file: <math.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
40missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
42missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
128unknownMacroerrorThere is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
mate-desktop-1.27.1/libmate-desktop/mate-hsv.h
36missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-desktop-1.27.1/libmate-desktop/mate-image-menu-item.c
18missingIncludeinformationInclude file: "config.h" not found.
19missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
20missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
21missingIncludeSysteminformationInclude file: <glib/gstdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
37unknownMacroerrorThere is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE is a macro then please configure it.
mate-desktop-1.27.1/libmate-desktop/mate-image-menu-item.h
21missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-desktop-1.27.1/libmate-desktop/mate-languages.c
23missingIncludeinformationInclude file: "config.h" not found.
25missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <stdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <errno.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <dirent.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <locale.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <langinfo.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
33missingIncludeSysteminformationInclude file: <sys/stat.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
35missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
36missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
37missingIncludeSysteminformationInclude file: <glib/gstdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
42missingIncludeSysteminformationInclude file: <langinfo.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
401constVariablePointer398styleVariable 'old_locale' can be declared as pointer to const
534variableScope398styleThe scope of the variable 'linep' can be reduced.
587constVariablePointer398styleVariable 'locale' can be declared as pointer to const
mate-desktop-1.27.1/libmate-desktop/mate-languages.h
30missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-desktop-1.27.1/libmate-desktop/mate-rr-config.c
29missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <glib/gi18n-lib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
33missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
34missingIncludeSysteminformationInclude file: <glib/gstdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
36missingIncludeSysteminformationInclude file: <X11/Xlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
37missingIncludeSysteminformationInclude file: <gdk/gdkx.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
94unknownMacroerrorThere is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
mate-desktop-1.27.1/libmate-desktop/mate-rr-config.h
34missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
35missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-desktop-1.27.1/libmate-desktop/mate-rr-labeler.c
30missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <glib/gi18n-lib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
34missingIncludeSysteminformationInclude file: <X11/Xproto.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
35missingIncludeSysteminformationInclude file: <X11/Xlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
36missingIncludeSysteminformationInclude file: <X11/Xutil.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
37missingIncludeSysteminformationInclude file: <X11/Xatom.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
38missingIncludeSysteminformationInclude file: <gdk/gdkx.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
110constVariablePointer398styleVariable 'workareas' can be declared as pointer to const
170constVariablePointer398styleVariable 'xev' can be declared as pointer to const
mate-desktop-1.27.1/libmate-desktop/mate-rr-output-info.c
26missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
33unknownMacroerrorThere is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
mate-desktop-1.27.1/libmate-desktop/mate-rr-private.h
4missingIncludeSysteminformationInclude file: <X11/Xlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
7missingIncludeSysteminformationInclude file: <X11/extensions/Xrandr.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-desktop-1.27.1/libmate-desktop/mate-rr.c
27missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <glib/gi18n-lib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <X11/Xlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
33missingIncludeSysteminformationInclude file: <X11/extensions/Xrandr.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
36missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
37missingIncludeSysteminformationInclude file: <gdk/gdkx.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
38missingIncludeSysteminformationInclude file: <X11/Xatom.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
168unknownMacroerrorThere is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_CODE is a macro then please configure it.
mate-desktop-1.27.1/libmate-desktop/mate-rr.h
31missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <gdk/gdk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-desktop-1.27.1/libmate-desktop/private.h
28missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-desktop-1.27.1/libmate-desktop/test-desktop-thumbnail.c
27missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-desktop-1.27.1/libmate-desktop/test-ditem.c
19missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
20missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
21missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
23missingIncludeSysteminformationInclude file: <mate-desktop-item.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <locale.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
132constVariablePointer398styleVariable 'file' can be declared as pointer to const
mate-desktop-1.27.1/libmate-desktop/test-languages.c
18missingIncludeSysteminformationInclude file: <stdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
19missingIncludeSysteminformationInclude file: <locale.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-desktop-1.27.1/libmate-desktop/test.c
26missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-desktop-1.27.1/mate-about/mate-about.h
25missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-desktop-1.27.1/tools/mate-color-select.c
26missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <libmate-desktop/mate-colorseldialog.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <libmate-desktop/mate-colorsel.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/egg-array-float.c
23missingIncludeinformationInclude file: "config.h" not found.
25missingIncludeSysteminformationInclude file: <math.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <stdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/egg-array-float.h
26missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/egg-color.c
23missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/egg-color.h
26missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/egg-console-kit.c
23missingIncludeinformationInclude file: "config.h" not found.
25missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <stdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <dbus/dbus-glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <dbus/dbus.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
61unknownMacroerrorThere is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
src/egg-console-kit.h
26missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/egg-discrete.c
23missingIncludeSysteminformationInclude file: <math.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
24missingIncludeSysteminformationInclude file: <stdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
134knownConditionTrueFalse571styleCondition 'value==100' is always true
143knownConditionTrueFalse570styleCondition 'fvalue>-0.01' is always false
152knownConditionTrueFalse571styleCondition 'fvalue>-1.01' is always true
152knownConditionTrueFalse570styleCondition 'fvalue<1.01' is always false
src/egg-discrete.h
26missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/egg-idletime.c
24missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <X11/Xlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <X11/extensions/sync.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <gdk/gdkx.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <gdk/gdk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
33missingIncludeSysteminformationInclude file: <stdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
34missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
35missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
73unknownMacroerrorThere is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
src/egg-idletime.h
26missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/egg-precision.c
23missingIncludeSysteminformationInclude file: <math.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
24missingIncludeSysteminformationInclude file: <stdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/egg-precision.h
26missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/egg-test.c
23missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
24missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <glib/gprintf.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
126constParameterPointer398styleParameter 'test' can be declared as pointer to const
264constParameterPointer398styleParameter 'test' can be declared as pointer to const
src/egg-test.h
26missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/gpm-backlight-helper.c
23missingIncludeinformationInclude file: "config.h" not found.
25missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <locale.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <sys/types.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <sys/stat.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <fcntl.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/gpm-backlight.c
25missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <stdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <time.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <errno.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
33missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
34missingIncludeSysteminformationInclude file: <sys/time.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
35missingIncludeSysteminformationInclude file: <sys/types.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
36missingIncludeSysteminformationInclude file: <math.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
38missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
41missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
42missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
43missingIncludeSysteminformationInclude file: <libupower-glib/upower.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
82unknownMacroerrorThere is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
src/gpm-backlight.h
27missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/gpm-brightness.c
24missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <stdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <time.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <errno.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <X11/Xatom.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
33missingIncludeSysteminformationInclude file: <X11/Xlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
34missingIncludeSysteminformationInclude file: <X11/extensions/Xrandr.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
35missingIncludeSysteminformationInclude file: <gdk/gdkx.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
36missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
37missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
38missingIncludeSysteminformationInclude file: <sys/time.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
39missingIncludeSysteminformationInclude file: <sys/types.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
41missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
82unknownMacroerrorThere is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
src/gpm-brightness.h
26missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/gpm-button.c
23missingIncludeinformationInclude file: "config.h" not found.
25missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <X11/X.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <gdk/gdkx.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <X11/XF86keysym.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
33missingIncludeSysteminformationInclude file: <libupower-glib/upower.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
59unknownMacroerrorThere is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
src/gpm-button.h
26missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/gpm-common.c
23missingIncludeinformationInclude file: "config.h" not found.
25missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <gdk/gdk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/gpm-common.h
26missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/gpm-control.c
24missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <stdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <time.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <errno.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
33missingIncludeSysteminformationInclude file: <sys/time.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
34missingIncludeSysteminformationInclude file: <sys/types.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
35missingIncludeSysteminformationInclude file: <sys/wait.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
37missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
40missingIncludeSysteminformationInclude file: <gio/gio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
41missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
44missingIncludeSysteminformationInclude file: <libsecret/secret.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
47missingIncludeSysteminformationInclude file: <gnome-keyring.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
71unknownMacroerrorThere is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
src/gpm-control.h
27missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/gpm-dpms.c
24missingIncludeinformationInclude file: "config.h" not found.
26missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <stdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <time.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <errno.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <sys/time.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
33missingIncludeSysteminformationInclude file: <sys/types.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
35missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
38missingIncludeSysteminformationInclude file: <gdk/gdk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
39missingIncludeSysteminformationInclude file: <gdk/gdkx.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
41missingIncludeSysteminformationInclude file: <X11/Xproto.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
42missingIncludeSysteminformationInclude file: <X11/extensions/dpms.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
67unknownMacroerrorThere is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
src/gpm-engine.c
23missingIncludeinformationInclude file: "config.h" not found.
25missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <libupower-glib/upower.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
80unknownMacroerrorThere is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
src/gpm-engine.h
26missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <libupower-glib/upower.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/gpm-graph-widget.c
23missingIncludeinformationInclude file: "config.h" not found.
24missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <pango/pangocairo.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <math.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
62unusedStructMember563stylestruct member 'GpmGraphWidgetPrivate::title' is never used.
97variableScope398styleThe scope of the variable 'keyitem' can be reduced.
383variableScope398styleThe scope of the variable 'obj' can be reduced.
535unreadVariable563styleVariable 'offsetx' is assigned a value that is never used.
536unreadVariable563styleVariable 'offsety' is assigned a value that is never used.
601variableScope398styleThe scope of the variable 'text' can be reduced.
635constVariablePointer398styleVariable 'point' can be declared as pointer to const
729constVariablePointer398styleVariable 'point' can be declared as pointer to const
843duplicateExpression398styleSame expression on both sides of '/'.
899variableScope398styleThe scope of the variable 'data' can be reduced.
998variableScope398styleThe scope of the variable 'keydataitem' can be reduced.
1036variableScope398styleThe scope of the variable 'keydataitem' can be reduced.
src/gpm-graph-widget.h
26missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/gpm-idle.c
24missingIncludeinformationInclude file: "config.h" not found.
26missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <stdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <time.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <errno.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <sys/time.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
33missingIncludeSysteminformationInclude file: <sys/types.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
35missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
38missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
39missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
75unknownMacroerrorThere is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
src/gpm-idle.h
27missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/gpm-kbd-backlight.c
23missingIncludeSysteminformationInclude file: <gio/gio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
24missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <libupower-glib/upower.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
63unknownMacroerrorThere is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
src/gpm-kbd-backlight.h
26missingIncludeSysteminformationInclude file: <gio/gio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/gpm-load.c
23missingIncludeinformationInclude file: "config.h" not found.
25missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <stdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <time.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <errno.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <sys/time.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <sys/types.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
34missingIncludeSysteminformationInclude file: <kstat.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
35missingIncludeSysteminformationInclude file: <sys/sysinfo.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
38missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
41missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
58unknownMacroerrorThere is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
src/gpm-load.h
26missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/gpm-main.c
27missingIncludeinformationInclude file: "config.h" not found.
29missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <errno.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
33missingIncludeSysteminformationInclude file: <locale.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
34missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
35missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
36missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
37missingIncludeSysteminformationInclude file: <dbus/dbus-glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
38missingIncludeSysteminformationInclude file: <dbus/dbus-glib-lowlevel.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/gpm-manager.c
24missingIncludeinformationInclude file: "config.h" not found.
26missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <stdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <time.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <errno.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <sys/time.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
33missingIncludeSysteminformationInclude file: <sys/types.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
35missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
38missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
39missingIncludeSysteminformationInclude file: <gio/gunixfdlist.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
40missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
41missingIncludeSysteminformationInclude file: <dbus/dbus-glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
42missingIncludeSysteminformationInclude file: <dbus/dbus-glib-lowlevel.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
43missingIncludeSysteminformationInclude file: <canberra-gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
44missingIncludeSysteminformationInclude file: <libupower-glib/upower.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
45missingIncludeSysteminformationInclude file: <libnotify/notify.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
119unknownMacroerrorThere is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
src/gpm-manager.h
27missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <dbus/dbus-glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/gpm-marshal.c
3missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/gpm-marshal.h
5missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/gpm-networkmanager.c
24missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <dbus/dbus-glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/gpm-networkmanager.h
26missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/gpm-phone.c
23missingIncludeinformationInclude file: "config.h" not found.
25missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <gio/gio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <dbus/dbus-glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
56unknownMacroerrorThere is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
src/gpm-phone.h
26missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/gpm-point-obj.c
22missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/gpm-point-obj.h
25missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/gpm-prefs-core.c
25missingIncludeinformationInclude file: "config.h" not found.
27missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <math.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
34missingIncludeSysteminformationInclude file: <libupower-glib/upower.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
74unknownMacroerrorThere is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
src/gpm-prefs-core.h
26missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/gpm-prefs.c
26missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/gpm-screensaver.c
23missingIncludeinformationInclude file: "config.h" not found.
25missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <dbus/dbus-glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
46unknownMacroerrorThere is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
src/gpm-screensaver.h
26missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/gpm-self-test.c
23missingIncludeinformationInclude file: "config.h" not found.
25missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/gpm-session.c
23missingIncludeinformationInclude file: "config.h" not found.
25missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <dbus/dbus-glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
83unknownMacroerrorThere is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
src/gpm-session.h
26missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/gpm-statistics.c
23missingIncludeinformationInclude file: "config.h" not found.
25missingIncludeSysteminformationInclude file: <locale.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <dbus/dbus-glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <libupower-glib/upower.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
204variableScope398styleThe scope of the variable 'point_new' can be reduced.
308constVariablePointer398styleVariable 'time_tm' can be declared as pointer to const
495variableScope398styleThe scope of the variable 'smoothed' can be reduced.
843variableScope398styleThe scope of the variable 'device' can be reduced.
965variableScope398styleThe scope of the variable 'device_tmp' can be reduced.
1435knownConditionTrueFalse570styleCondition 'stats_type==GPM_STATS_CHARGE_TYPE' is always false
1437knownConditionTrueFalse570styleCondition 'stats_type==GPM_STATS_CHARGE_TYPE' is always false
1439knownConditionTrueFalse570styleCondition 'stats_type==GPM_STATS_CHARGE_TYPE' is always false
src/gpm-tray-icon.c
25missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <stdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <time.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <errno.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
33missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
34missingIncludeSysteminformationInclude file: <sys/time.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
35missingIncludeSysteminformationInclude file: <sys/types.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
37missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
40missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
41missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
42missingIncludeSysteminformationInclude file: <libupower-glib/upower.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
44missingIncludeSysteminformationInclude file: <libmate-desktop/mate-image-menu-item.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
62unknownMacroerrorThere is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
src/gpm-tray-icon.h
27missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/gpm-upower.c
23missingIncludeinformationInclude file: "config.h" not found.
25missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <libupower-glib/upower.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/gpm-upower.h
26missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <libupower-glib/upower.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/gsd-media-keys-window.c
25missingIncludeinformationInclude file: "config.h" not found.
27missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <math.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
51unknownMacroerrorThere is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
src/gsd-media-keys-window.h
27missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/mate-power-manager-resources.c
1missingIncludeSysteminformationInclude file: <gio/gio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
9unusedStructMember563styleunion member 'Anonymous0::alignment' is never used.
9unusedStructMember563styleunion member 'Anonymous0::ptr' is never used.
src/mate-power-preferences-resources.c
1missingIncludeSysteminformationInclude file: <gio/gio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
9unusedStructMember563styleunion member 'Anonymous0::alignment' is never used.
9unusedStructMember563styleunion member 'Anonymous0::ptr' is never used.
src/mate-power-statistics-resources.c
1missingIncludeSysteminformationInclude file: <gio/gio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
9unusedStructMember563styleunion member 'Anonymous0::alignment' is never used.
9unusedStructMember563styleunion member 'Anonymous0::ptr' is never used.
src/msd-osd-window.c
31missingIncludeinformationInclude file: "config.h" not found.
33missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
34missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
35missingIncludeSysteminformationInclude file: <math.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
36missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
37missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
38missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
39missingIncludeSysteminformationInclude file: <gdk/gdkx.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
65unknownMacroerrorThere is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
src/msd-osd-window.h
44missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
45missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/org.mate.PowerManager.Backlight.h
4missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
152missingIncludeSysteminformationInclude file: <dbus/dbus-glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/org.mate.PowerManager.KbdBacklight.h
4missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
152missingIncludeSysteminformationInclude file: <dbus/dbus-glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/org.mate.PowerManager.h
4missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
52missingIncludeSysteminformationInclude file: <dbus/dbus-glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/stats.html b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/stats.html new file mode 100644 index 0000000..ab7861f --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/stats.html @@ -0,0 +1,203 @@ + + + + + + Cppcheck - HTML report - mate-power-manager + + + + + +
+ + + +
+

Top 10 files for error severity, total findings: 32
+   1  src/msd-osd-window.c
+   1  src/gsd-media-keys-window.c
+   1  src/gpm-tray-icon.c
+   1  src/gpm-session.c
+   1  src/gpm-screensaver.c
+   1  src/gpm-prefs-core.c
+   1  src/gpm-phone.c
+   1  src/gpm-manager.c
+   1  src/gpm-load.c
+   1  src/gpm-kbd-backlight.c
+

+

Top 10 files for portability severity, total findings: 23
+   23  mate-desktop-1.27.1/libmate-desktop/mate-desktop-item.c
+

+

Top 10 files for style severity, total findings: 49
+   12  src/gpm-graph-widget.c
+   8   src/gpm-statistics.c
+   7   mate-desktop-1.27.1/libmate-desktop/mate-desktop-item.c
+   4   src/egg-discrete.c
+   3   mate-desktop-1.27.1/libmate-desktop/mate-languages.c
+   2   src/mate-power-statistics-resources.c
+   2   src/mate-power-preferences-resources.c
+   2   src/mate-power-manager-resources.c
+   2   src/egg-test.c
+   2   mate-desktop-1.27.1/libmate-desktop/mate-rr-labeler.c
+

+

Top 10 files for information severity, total findings: 521
+   20  mate-desktop-1.27.1/libmate-desktop/mate-desktop-item.c
+   17  src/gpm-manager.c
+   14  src/gpm-control.c
+   14  src/gpm-brightness.c
+   14  mate-desktop-1.27.1/libmate-desktop/mate-languages.c
+   13  src/gpm-tray-icon.c
+   13  src/gpm-dpms.c
+   13  src/gpm-backlight.c
+   13  mate-desktop-1.27.1/libmate-desktop/mate-bg.c
+   12  src/gpm-load.c
+

+ +
+ +
+ + diff --git a/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/style.css b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/style.css new file mode 100644 index 0000000..3897bfa --- /dev/null +++ b/2024-02-25-212232-3050-cppcheck@6561790b0304_v1.28.1/style.css @@ -0,0 +1,177 @@ + +body { + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif; + font-size: 13px; + line-height: 1.5; + height: 100%; + margin: 0; +} + +#wrapper { + position: fixed; + height: 100vh; + width: 100vw; + display: grid; + grid-template-rows: fit-content(8rem) auto fit-content(8rem); + grid-template-columns: fit-content(25%) 1fr; + grid-template-areas: + "header header" + "menu content" + "footer footer"; +} + +h1 { + margin: 0 0 8px -2px; + font-size: 175%; +} + +.header { + padding: 0 0 5px 15px; + grid-area: header; + border-bottom: thin solid #aaa; +} + +.footer { + grid-area: footer; + border-top: thin solid #aaa; + font-size: 85%; + +} + +.footer > p { + margin: 4px; +} + +#menu, +#menu_index { + grid-area: menu; + text-align: left; + overflow: auto; + padding: 0 23px 15px 15px; + border-right: thin solid #aaa; + min-width: 200px; +} + +#menu > a { + display: block; + margin-left: 10px; + font-size: 12px; +} + +#content, +#content_index { + grid-area: content; + padding: 0px 5px 15px 15px; + overflow: auto; +} + +label { + white-space: nowrap; +} + +label.checkBtn.disabled { + color: #606060; + background: #e0e0e0; + font-style: italic; +} + +label.checkBtn, input[type="text"] { + border: 1px solid grey; + border-radius: 4px; + box-shadow: 1px 1px inset; + padding: 1px 5px; +} + +label.checkBtn { + white-space: nowrap; + background: #ccddff; +} + +label.unchecked { + background: #eff8ff; + box-shadow: 1px 1px 1px; +} + +label.checkBtn:hover, label.unchecked:hover{ + box-shadow: 0 0 2px; +} + +label.disabled:hover { + box-shadow: 1px 1px inset; +} + +label.checkBtn > input { + display:none; +} + +.summaryTable { + width: 100%; +} + +table.summaryTable td { padding: 0 5px 0 5px; } + +.statHeader, .severityHeader { + font-weight: bold; +} + +.warning { + background-color: #ffffa7; +} + +.error { + background-color: #ffb7b7; +} + +.error2 { + background-color: #faa; + display: inline-block; + margin-left: 4px; +} + +.inconclusive { + background-color: #b6b6b4; +} + +.inconclusive2 { + background-color: #b6b6b4; + display: inline-block; + margin-left: 4px; +} + +.verbose { + display: inline-block; + vertical-align: top; + cursor: help; +} + +.verbose .content { + display: none; + position: absolute; + padding: 10px; + margin: 4px; + max-width: 40%; + white-space: pre-wrap; + border: 1px solid #000; + background-color: #ffffcc; + cursor: auto; +} + +.highlight .hll { + padding: 1px; +} + +.highlighttable { + background-color: #fff; + position: relative; + margin: -10px; +} + +.linenos { + border-right: thin solid #aaa; + color: #d3d3d3; + padding-right: 6px; +} + +.id-filtered, .severity-filtered, .file-filtered, .tool-filtered, .text-filtered { + visibility: collapse; +} -- cgit v1.2.1