From 6d2348422e742a1f57ccf3b4f7b8c1c3c73546ad Mon Sep 17 00:00:00 2001 From: "raveit65 (via Travis CI)" Date: Sun, 25 Feb 2024 21:14:28 +0000 Subject: Deploy mate-desktop/mate-media to github.com/mate-desktop/mate-media.git:gh-pages --- .../0.html | 863 ++ .../1.html | 1309 +++ .../10.html | 6079 +++++++++++++ .../11.html | 433 + .../12.html | 725 ++ .../13.html | 533 ++ .../14.html | 335 + .../15.html | 8907 ++++++++++++++++++++ .../16.html | 2941 +++++++ .../17.html | 439 + .../18.html | 1159 +++ .../19.html | 339 + .../2.html | 1769 ++++ .../20.html | 3107 +++++++ .../21.html | 1341 +++ .../22.html | 321 + .../23.html | 2915 +++++++ .../24.html | 343 + .../25.html | 4187 +++++++++ .../26.html | 637 ++ .../27.html | 537 ++ .../28.html | 405 + .../29.html | 1333 +++ .../3.html | 397 + .../30.html | 741 ++ .../31.html | 4569 ++++++++++ .../32.html | 365 + .../33.html | 553 ++ .../34.html | 413 + .../35.html | 353 + .../36.html | 327 + .../37.html | 1577 ++++ .../38.html | 417 + .../39.html | 435 + .../4.html | 6753 +++++++++++++++ .../40.html | 367 + .../41.html | 807 ++ .../42.html | 369 + .../43.html | 1367 +++ .../44.html | 403 + .../45.html | 1287 +++ .../46.html | 387 + .../47.html | 2691 ++++++ .../48.html | 467 + .../49.html | 1123 +++ .../5.html | 2025 +++++ .../50.html | 383 + .../51.html | 1815 ++++ .../52.html | 397 + .../53.html | 311 + .../54.html | 5209 ++++++++++++ .../55.html | 347 + .../56.html | 365 + .../57.html | 2451 ++++++ .../58.html | 313 + .../59.html | 1195 +++ .../6.html | 309 + .../60.html | 955 +++ .../61.html | 361 + .../62.html | 375 + .../63.html | 1989 +++++ .../64.html | 1867 ++++ .../65.html | 555 ++ .../66.html | 851 ++ .../67.html | 439 + .../7.html | 437 + .../8.html | 489 ++ .../9.html | 383 + .../index.html | 728 ++ .../stats.html | 199 + .../style.css | 177 + 71 files changed, 92050 insertions(+) create mode 100644 2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/0.html create mode 100644 2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/1.html create mode 100644 2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/10.html create mode 100644 2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/11.html create mode 100644 2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/12.html create mode 100644 2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/13.html create mode 100644 2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/14.html create mode 100644 2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/15.html create mode 100644 2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/16.html create mode 100644 2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/17.html create mode 100644 2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/18.html create mode 100644 2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/19.html create mode 100644 2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/2.html create mode 100644 2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/20.html create mode 100644 2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/21.html create mode 100644 2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/22.html create mode 100644 2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/23.html create mode 100644 2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/24.html create mode 100644 2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/25.html create mode 100644 2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/26.html create mode 100644 2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/27.html create mode 100644 2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/28.html create mode 100644 2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/29.html create mode 100644 2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/3.html create mode 100644 2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/30.html create mode 100644 2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/31.html create mode 100644 2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/32.html create mode 100644 2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/33.html create mode 100644 2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/34.html create mode 100644 2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/35.html create mode 100644 2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/36.html create mode 100644 2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/37.html create mode 100644 2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/38.html create mode 100644 2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/39.html create mode 100644 2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/4.html create mode 100644 2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/40.html create mode 100644 2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/41.html create mode 100644 2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/42.html create mode 100644 2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/43.html create mode 100644 2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/44.html create mode 100644 2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/45.html create mode 100644 2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/46.html create mode 100644 2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/47.html create mode 100644 2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/48.html create mode 100644 2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/49.html create mode 100644 2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/5.html create mode 100644 2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/50.html create mode 100644 2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/51.html create mode 100644 2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/52.html create mode 100644 2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/53.html create mode 100644 2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/54.html create mode 100644 2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/55.html create mode 100644 2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/56.html create mode 100644 2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/57.html create mode 100644 2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/58.html create mode 100644 2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/59.html create mode 100644 2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/6.html create mode 100644 2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/60.html create mode 100644 2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/61.html create mode 100644 2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/62.html create mode 100644 2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/63.html create mode 100644 2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/64.html create mode 100644 2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/65.html create mode 100644 2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/66.html create mode 100644 2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/67.html create mode 100644 2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/7.html create mode 100644 2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/8.html create mode 100644 2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/9.html create mode 100644 2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/index.html create mode 100644 2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/stats.html create mode 100644 2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/style.css (limited to '2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson') diff --git a/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/0.html b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/0.html new file mode 100644 index 0000000..1252057 --- /dev/null +++ b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/0.html @@ -0,0 +1,863 @@ + + + + + + Cppcheck - HTML report - mate-media + + + + + +
+ + + +
+
  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/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/1.html b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/1.html new file mode 100644 index 0000000..c9e581f --- /dev/null +++ b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/1.html @@ -0,0 +1,1309 @@ + + + + + + Cppcheck - HTML report - mate-media + + + + + +
+ + + +
+
  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] = {<--- Variable 'color_type' can be declared as const array
+			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[] = {<--- Variable 'stereo' can be declared as const array
+		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/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/10.html b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/10.html new file mode 100644 index 0000000..e8c57d1 --- /dev/null +++ b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/10.html @@ -0,0 +1,6079 @@ + + + + + + Cppcheck - HTML report - mate-media + + + + + +
+ + + +
+
   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/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/11.html b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/11.html new file mode 100644 index 0000000..8ea33e3 --- /dev/null +++ b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/11.html @@ -0,0 +1,433 @@ + + + + + + Cppcheck - HTML report - mate-media + + + + + +
+ + + +
+
 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/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/12.html b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/12.html new file mode 100644 index 0000000..c73d9c8 --- /dev/null +++ b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/12.html @@ -0,0 +1,725 @@ + + + + + + Cppcheck - HTML report - mate-media + + + + + +
+ + + +
+
  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/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/13.html b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/13.html new file mode 100644 index 0000000..715e86b --- /dev/null +++ b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/13.html @@ -0,0 +1,533 @@ + + + + + + Cppcheck - HTML report - mate-media + + + + + +
+ + + +
+
  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/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/14.html b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/14.html new file mode 100644 index 0000000..0dcc6c0 --- /dev/null +++ b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/14.html @@ -0,0 +1,335 @@ + + + + + + Cppcheck - HTML report - mate-media + + + + + +
+ + + +
+
 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/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/15.html b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/15.html new file mode 100644 index 0000000..719b947 --- /dev/null +++ b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/15.html @@ -0,0 +1,8907 @@ + + + + + + Cppcheck - HTML report - mate-media + + + + + +
+ + + +
+
   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;
+	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;
+	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;
+
+	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;
+
+			/* 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/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/16.html b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/16.html new file mode 100644 index 0000000..a50b191 --- /dev/null +++ b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/16.html @@ -0,0 +1,2941 @@ + + + + + + Cppcheck - HTML report - mate-media + + + + + +
+ + + +
+
   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/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/17.html b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/17.html new file mode 100644 index 0000000..4082ed4 --- /dev/null +++ b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/17.html @@ -0,0 +1,439 @@ + + + + + + Cppcheck - HTML report - mate-media + + + + + +
+ + + +
+
  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/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/18.html b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/18.html new file mode 100644 index 0000000..d877066 --- /dev/null +++ b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/18.html @@ -0,0 +1,1159 @@ + + + + + + Cppcheck - HTML report - mate-media + + + + + +
+ + + +
+
  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/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/19.html b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/19.html new file mode 100644 index 0000000..6973e33 --- /dev/null +++ b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/19.html @@ -0,0 +1,339 @@ + + + + + + Cppcheck - HTML report - mate-media + + + + + +
+ + + +
+
 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/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/2.html b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/2.html new file mode 100644 index 0000000..732eb12 --- /dev/null +++ b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/2.html @@ -0,0 +1,1769 @@ + + + + + + Cppcheck - HTML report - mate-media + + + + + +
+ + + +
+
  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/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/20.html b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/20.html new file mode 100644 index 0000000..1e39ddd --- /dev/null +++ b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/20.html @@ -0,0 +1,3107 @@ + + + + + + Cppcheck - HTML report - mate-media + + + + + +
+ + + +
+
   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/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/21.html b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/21.html new file mode 100644 index 0000000..510b716 --- /dev/null +++ b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/21.html @@ -0,0 +1,1341 @@ + + + + + + Cppcheck - HTML report - mate-media + + + + + +
+ + + +
+
  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/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/22.html b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/22.html new file mode 100644 index 0000000..1e739a7 --- /dev/null +++ b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/22.html @@ -0,0 +1,321 @@ + + + + + + Cppcheck - HTML report - mate-media + + + + + +
+ + + +
+
 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/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/23.html b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/23.html new file mode 100644 index 0000000..9aedb6d --- /dev/null +++ b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/23.html @@ -0,0 +1,2915 @@ + + + + + + Cppcheck - HTML report - mate-media + + + + + +
+ + + +
+
   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;
+        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/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/24.html b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/24.html new file mode 100644 index 0000000..f5feeae --- /dev/null +++ b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/24.html @@ -0,0 +1,343 @@ + + + + + + Cppcheck - HTML report - mate-media + + + + + +
+ + + +
+
 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/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/25.html b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/25.html new file mode 100644 index 0000000..bf95f01 --- /dev/null +++ b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/25.html @@ -0,0 +1,4187 @@ + + + + + + Cppcheck - HTML report - mate-media + + + + + +
+ + + +
+
   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/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/26.html b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/26.html new file mode 100644 index 0000000..a0a54d4 --- /dev/null +++ b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/26.html @@ -0,0 +1,637 @@ + + + + + + Cppcheck - HTML report - mate-media + + + + + +
+ + + +
+
  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/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/27.html b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/27.html new file mode 100644 index 0000000..ab016e8 --- /dev/null +++ b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/27.html @@ -0,0 +1,537 @@ + + + + + + Cppcheck - HTML report - mate-media + + + + + +
+ + + +
+
  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/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/28.html b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/28.html new file mode 100644 index 0000000..0aa834e --- /dev/null +++ b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/28.html @@ -0,0 +1,405 @@ + + + + + + Cppcheck - HTML report - mate-media + + + + + +
+ + + +
+
 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/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/29.html b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/29.html new file mode 100644 index 0000000..5381638 --- /dev/null +++ b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/29.html @@ -0,0 +1,1333 @@ + + + + + + Cppcheck - HTML report - mate-media + + + + + +
+ + + +
+
  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;
+	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;
+
+	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/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/3.html b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/3.html new file mode 100644 index 0000000..30e5d1a --- /dev/null +++ b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/3.html @@ -0,0 +1,397 @@ + + + + + + Cppcheck - HTML report - mate-media + + + + + +
+ + + +
+
 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/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/30.html b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/30.html new file mode 100644 index 0000000..c20bacd --- /dev/null +++ b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/30.html @@ -0,0 +1,741 @@ + + + + + + Cppcheck - HTML report - mate-media + + + + + +
+ + + +
+
  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/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/31.html b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/31.html new file mode 100644 index 0000000..8a882df --- /dev/null +++ b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/31.html @@ -0,0 +1,4569 @@ + + + + + + Cppcheck - HTML report - mate-media + + + + + +
+ + + +
+
   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/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/32.html b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/32.html new file mode 100644 index 0000000..73b0c5e --- /dev/null +++ b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/32.html @@ -0,0 +1,365 @@ + + + + + + Cppcheck - HTML report - mate-media + + + + + +
+ + + +
+
 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/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/33.html b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/33.html new file mode 100644 index 0000000..2f72ef4 --- /dev/null +++ b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/33.html @@ -0,0 +1,553 @@ + + + + + + Cppcheck - HTML report - mate-media + + + + + +
+ + + +
+
  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;
+	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/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/34.html b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/34.html new file mode 100644 index 0000000..775dc3a --- /dev/null +++ b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/34.html @@ -0,0 +1,413 @@ + + + + + + Cppcheck - HTML report - mate-media + + + + + +
+ + + +
+
 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/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/35.html b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/35.html new file mode 100644 index 0000000..85cfe24 --- /dev/null +++ b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/35.html @@ -0,0 +1,353 @@ + + + + + + Cppcheck - HTML report - mate-media + + + + + +
+ + + +
+
 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/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/36.html b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/36.html new file mode 100644 index 0000000..bc564b6 --- /dev/null +++ b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/36.html @@ -0,0 +1,327 @@ + + + + + + Cppcheck - HTML report - mate-media + + + + + +
+ + + +
+
 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/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/37.html b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/37.html new file mode 100644 index 0000000..70032f1 --- /dev/null +++ b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/37.html @@ -0,0 +1,1577 @@ + + + + + + Cppcheck - HTML report - mate-media + + + + + +
+ + + +
+
  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-2023 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/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/38.html b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/38.html new file mode 100644 index 0000000..109238a --- /dev/null +++ b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/38.html @@ -0,0 +1,417 @@ + + + + + + Cppcheck - HTML report - mate-media + + + + + +
+ + + +
+
 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/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/39.html b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/39.html new file mode 100644 index 0000000..2400c0c --- /dev/null +++ b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/39.html @@ -0,0 +1,435 @@ + + + + + + Cppcheck - HTML report - mate-media + + + + + +
+ + + +
+
 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
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 Red Hat, Inc.
+ * Copyright (C) 2014 Michal Ratajsky <michal.ratajsky@gmail.com>
+ * Copyright (C) 2019 Victor Kareh <vkareh@vkareh.net>
+ * 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
+ * Lesser 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: "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-lib.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 <libintl.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 <libmatemixer/matemixer.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 "gvc-applet.h"
+
+static gboolean
+applet_main (MatePanelApplet* applet_widget)
+{
+        GError       *error = NULL;
+        GvcApplet    *applet;
+        GApplication *app = NULL;
+
+        app = g_application_new (GVC_APPLET_DBUS_NAME, G_APPLICATION_FLAGS_NONE);
+
+        if (!g_application_register (app, NULL, &error)) {
+                g_warning ("%s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+        if (g_application_get_is_remote (app)) {
+                g_warning ("Applet is already running, exiting");
+                return TRUE;
+        }
+        if (mate_mixer_init () == FALSE) {
+                g_warning ("libmatemixer initialization failed, exiting");
+                return FALSE;
+        }
+
+        gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (),
+                                           ICON_DATA_DIR);
+
+        applet = gvc_applet_new ();
+
+        gvc_applet_fill (applet, applet_widget);
+        gvc_applet_start (applet);
+
+        g_object_unref (app);
+
+        return TRUE;
+}
+
+/* this function, called by mate-panel, will create the applet */
+static gboolean
+applet_factory (MatePanelApplet* applet, const char* iid, gpointer data)
+{
+        gboolean retval = FALSE;
+
+        if (!g_strcmp0 (iid, "GvcApplet"))
+                retval = applet_main (applet);
+
+        return retval;
+}
+
+#ifdef IN_PROCESS
+/* needed by mate-panel applet library */
+MATE_PANEL_APPLET_IN_PROCESS_FACTORY("GvcAppletFactory",
+                                      PANEL_TYPE_APPLET,
+                                      "Volume Control applet",
+                                      applet_factory,
+                                      NULL)
+#else
+MATE_PANEL_APPLET_OUT_PROCESS_FACTORY("GvcAppletFactory",
+                                      PANEL_TYPE_APPLET,
+                                      "Volume Control applet",
+                                      applet_factory,
+                                      NULL)
+#endif
+
+ +
+ +
+ + diff --git a/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/4.html b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/4.html new file mode 100644 index 0000000..745e73d --- /dev/null +++ b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/4.html @@ -0,0 +1,6753 @@ + + + + + + Cppcheck - HTML report - mate-media + + + + + +
+ + + +
+
   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/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/40.html b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/40.html new file mode 100644 index 0000000..ac49d9f --- /dev/null +++ b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/40.html @@ -0,0 +1,367 @@ + + + + + + Cppcheck - HTML report - mate-media + + + + + +
+ + + +
+
 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
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 Red Hat, Inc.
+ * Copyright (C) 2014 Michal Ratajsky <michal.ratajsky@gmail.com>
+ * Copyright (C) 2019 Victor Kareh <vkareh@vkareh.net>
+ * 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.
+ *
+ */
+
+#ifndef __GVC_APPLET_H
+#define __GVC_APPLET_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.
+
+G_BEGIN_DECLS
+
+#define GVC_APPLET_DBUS_NAME    "org.mate.VolumeControlApplet"
+#define APPLET_ICON             "multimedia-volume-control"
+
+#define GVC_TYPE_APPLET         (gvc_applet_get_type ())
+#define GVC_APPLET(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), GVC_TYPE_APPLET, GvcApplet))
+#define GVC_APPLET_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST ((k), GVC_TYPE_APPLET, GvcAppletClass))
+#define GVC_IS_APPLET(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), GVC_TYPE_APPLET))
+#define GVC_IS_APPLET_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), GVC_TYPE_APPLET))
+#define GVC_APPLET_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GVC_TYPE_APPLET, GvcAppletClass))
+
+typedef struct _GvcApplet         GvcApplet;
+typedef struct _GvcAppletClass    GvcAppletClass;
+typedef struct _GvcAppletPrivate  GvcAppletPrivate;
+
+struct _GvcApplet
+{
+        GObject                 parent;
+        GvcAppletPrivate       *priv;
+};
+
+struct _GvcAppletClass
+{
+        GObjectClass            parent_class;
+};
+
+GType               gvc_applet_get_type            (void) G_GNUC_CONST;
+
+GvcApplet *         gvc_applet_new                 (void);
+void                gvc_applet_start               (GvcApplet *applet);
+gboolean            gvc_applet_fill                (GvcApplet *applet, MatePanelApplet *applet_widget);
+
+G_END_DECLS
+
+#endif /* __GVC_APPLET_H */
+
+ +
+ +
+ + diff --git a/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/41.html b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/41.html new file mode 100644 index 0000000..1bb1d7a --- /dev/null +++ b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/41.html @@ -0,0 +1,807 @@ + + + + + + Cppcheck - HTML report - mate-media + + + + + +
+ + + +
+
  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
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 Red Hat, Inc.
+ * Copyright (C) 2014 Michal Ratajsky <michal.ratajsky@gmail.com>
+ * 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
+ * Lesser 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: "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 <libintl.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 <libmatemixer/matemixer.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "gvc-mixer-dialog.h"
+
+#define DIALOG_POPUP_TIMEOUT 3
+
+static guint       popup_id = 0;
+static gboolean    debug = FALSE;
+static gboolean    show_version = FALSE;
+
+static gchar      *page = NULL;
+static GtkWidget  *app_dialog = NULL;
+static GtkWidget  *warning_dialog = NULL;
+
+static void
+on_dialog_response (GtkDialog *dialog, guint response_id, gpointer data)
+{
+        gboolean destroy = GPOINTER_TO_INT (data);
+
+        if (destroy == TRUE)
+                gtk_widget_destroy (GTK_WIDGET (dialog));
+
+        gtk_main_quit ();
+}
+
+static void
+on_dialog_close (GtkDialog *dialog, gpointer data)
+{
+        gboolean destroy = GPOINTER_TO_INT (data);
+
+        if (destroy == TRUE)
+                gtk_widget_destroy (GTK_WIDGET (dialog));
+
+        gtk_main_quit ();
+}
+
+static void
+remove_warning_dialog (void)
+{
+        if (popup_id != 0) {
+                g_source_remove (popup_id);
+                popup_id = 0;
+        }
+
+        g_clear_pointer (&warning_dialog, gtk_widget_destroy);
+}
+
+static void
+context_ready (MateMixerContext *context, GtkApplication *application)
+{
+        /* The dialog might be already created, e.g. when reconnected
+         * to a sound server */
+        GtkApplication *app;
+        GError *error = NULL;
+
+        app = gtk_application_new ("context.ready", G_APPLICATION_FLAGS_NONE);
+        g_application_register (G_APPLICATION (app), NULL, &error);
+        if (error != NULL)
+        {
+                g_warning ("%s", error->message);
+                g_error_free (error);
+                error = NULL;
+        }
+
+        if (g_application_get_is_remote (G_APPLICATION (app)))
+        {
+                g_application_activate (G_APPLICATION (app));
+                g_object_unref (app);
+                app_dialog = GTK_WIDGET (gvc_mixer_dialog_new (context));
+                gtk_main_quit ();
+        }
+
+        if (app_dialog != NULL)
+                return;
+
+        app_dialog = GTK_WIDGET (gvc_mixer_dialog_new (context));
+
+        g_signal_connect (G_OBJECT (app_dialog),
+                          "response",
+                          G_CALLBACK (on_dialog_response),
+                          GINT_TO_POINTER (FALSE));
+        g_signal_connect (G_OBJECT (app_dialog),
+                          "close",
+                          G_CALLBACK (on_dialog_close),
+                          GINT_TO_POINTER (FALSE));
+
+        gvc_mixer_dialog_set_page (GVC_MIXER_DIALOG (app_dialog), page);
+
+        gtk_widget_show (app_dialog);
+
+        g_signal_connect_swapped (app, "activate", G_CALLBACK (gtk_window_present), app_dialog);
+}
+
+static void
+on_context_state_notify (MateMixerContext *context,
+                         GParamSpec       *pspec,
+                         GtkApplication	  *app)
+{
+        MateMixerState state = mate_mixer_context_get_state (context);
+
+        if (state == MATE_MIXER_STATE_READY) {
+                remove_warning_dialog ();
+                context_ready (context, app);
+        }
+        else if (state == MATE_MIXER_STATE_FAILED) {
+                GtkWidget *dialog;
+
+                remove_warning_dialog ();
+
+                dialog = gtk_message_dialog_new (GTK_WINDOW (app_dialog),
+                                                 0,
+                                                 GTK_MESSAGE_ERROR,
+                                                 GTK_BUTTONS_CLOSE,
+                                                 _("Sound system is not available"));
+
+                g_signal_connect (G_OBJECT (dialog),
+                                  "response",
+                                  G_CALLBACK (on_dialog_response),
+                                  GINT_TO_POINTER (TRUE));
+                g_signal_connect (G_OBJECT (dialog),
+                                  "close",
+                                  G_CALLBACK (on_dialog_close),
+                                  GINT_TO_POINTER (TRUE));
+
+                gtk_widget_show (dialog);
+        }
+}
+
+static gboolean
+dialog_popup_timeout (gpointer data)
+{
+	warning_dialog = gtk_message_dialog_new (GTK_WINDOW (app_dialog),
+	                                         0,
+	                                         GTK_MESSAGE_INFO,
+	                                         GTK_BUTTONS_CANCEL,
+	                                         _("Waiting for sound system to respond"));
+
+	g_signal_connect (G_OBJECT (warning_dialog),
+	                  "response",
+                      G_CALLBACK (on_dialog_response),
+                      GINT_TO_POINTER (TRUE));
+	g_signal_connect (G_OBJECT (warning_dialog),
+	                  "close",
+                      G_CALLBACK (on_dialog_close),
+                      GINT_TO_POINTER (TRUE));
+
+	gtk_widget_show (warning_dialog);
+
+	return FALSE;
+}
+
+int
+main (int argc, char **argv)
+{
+        GError           *error = NULL;
+        gchar            *backend = NULL;
+        MateMixerContext *context;
+        GApplication	 *app;
+
+        GOptionEntry      entries[] = {
+                { "backend", 'b', 0, G_OPTION_ARG_STRING, &backend, N_("Sound system backend"), "pulse|alsa|oss|null" },
+                { "debug",   'd', 0, G_OPTION_ARG_NONE,   &debug, N_("Enable debug"), NULL },
+                { "page",    'p', 0, G_OPTION_ARG_STRING, &page, N_("Startup page"), "effects|hardware|input|output|applications" },
+                { "version", 'v', 0, G_OPTION_ARG_NONE,   &show_version, N_("Version of this application"), NULL },
+                { NULL,        0, 0, G_OPTION_ARG_NONE,   NULL, NULL, NULL }
+        };
+
+        bindtextdomain (GETTEXT_PACKAGE, LOCALE_DIR);
+        bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+        textdomain (GETTEXT_PACKAGE);
+
+        gtk_init_with_args (&argc, &argv,
+                            _(" — MATE Volume Control"),
+                            entries, GETTEXT_PACKAGE,
+                            &error);
+
+        if (error != NULL) {
+                g_warning ("%s", error->message);
+                g_error_free (error);
+                return 1;
+        }
+        if (show_version == TRUE) {
+                g_print ("%s %s\n", argv[0], VERSION);
+                return 0;
+        }
+        if (debug == TRUE) {
+                g_setenv ("G_MESSAGES_DEBUG", "all", FALSE);
+        }
+
+        app = g_application_new (GVC_DIALOG_DBUS_NAME, G_APPLICATION_FLAGS_NONE);
+
+        if (!g_application_register (app, NULL, &error))
+        {
+                g_warning ("%s", error->message);
+                g_error_free (error);
+                return 1;
+        }
+
+        if (mate_mixer_init () == FALSE) {
+                g_warning ("libmatemixer initialization failed, exiting");
+                return 1;
+        }
+
+        context = mate_mixer_context_new ();
+
+        if (backend != NULL) {
+                if (strcmp (backend, "pulse") == 0)
+                        mate_mixer_context_set_backend_type (context, MATE_MIXER_BACKEND_PULSEAUDIO);
+                else if (strcmp (backend, "alsa") == 0)
+                        mate_mixer_context_set_backend_type (context, MATE_MIXER_BACKEND_ALSA);
+                else if (strcmp (backend, "oss") == 0)
+                        mate_mixer_context_set_backend_type (context, MATE_MIXER_BACKEND_OSS);
+                else if (strcmp (backend, "null") == 0)
+                        mate_mixer_context_set_backend_type (context, MATE_MIXER_BACKEND_NULL);
+                else {
+                        g_warning ("Invalid backend: %s", backend);
+                        g_object_unref (context);
+                        g_object_unref (app);
+                        g_free (backend);
+                        return 1;
+                }
+
+                g_free (backend);
+        }
+
+        mate_mixer_context_set_app_name (context, _("Volume Control"));
+        mate_mixer_context_set_app_id (context, GVC_DIALOG_DBUS_NAME);
+        mate_mixer_context_set_app_version (context, VERSION);
+        mate_mixer_context_set_app_icon (context, "multimedia-volume-control");
+
+        g_signal_connect (G_OBJECT (context),
+                          "notify::state",
+                          G_CALLBACK (on_context_state_notify),
+                          app);
+
+        mate_mixer_context_open (context);
+
+        if (mate_mixer_context_get_state (context) == MATE_MIXER_STATE_CONNECTING) {
+                popup_id = g_timeout_add_seconds (DIALOG_POPUP_TIMEOUT,
+                                                  dialog_popup_timeout,
+                                                  NULL);
+        }
+
+        gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (),
+                                           ICON_DATA_DIR);
+
+        gtk_window_set_default_icon_name ("multimedia-volume-control");
+
+        gtk_main ();
+
+        g_object_unref (context);
+        g_object_unref (app);
+
+        return 0;
+}
+
+ +
+ +
+ + diff --git a/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/42.html b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/42.html new file mode 100644 index 0000000..d15a099 --- /dev/null +++ b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/42.html @@ -0,0 +1,369 @@ + + + + + + Cppcheck - HTML report - mate-media + + + + + +
+ + + +
+
 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
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 Red Hat, Inc.
+ * Copyright (C) 2014 Michal Ratajsky <michal.ratajsky@gmail.com>
+ * 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.
+ *
+ */
+
+#ifndef __GVC_MIXER_DIALOG_H
+#define __GVC_MIXER_DIALOG_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.
+
+#include <libmatemixer/matemixer.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+G_BEGIN_DECLS
+
+#define GVC_DIALOG_DBUS_NAME          "org.mate.VolumeControl"
+
+#define GVC_TYPE_MIXER_DIALOG         (gvc_mixer_dialog_get_type ())
+#define GVC_MIXER_DIALOG(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), GVC_TYPE_MIXER_DIALOG, GvcMixerDialog))
+#define GVC_MIXER_DIALOG_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST((k), GVC_TYPE_MIXER_DIALOG, GvcMixerDialogClass))
+#define GVC_IS_MIXER_DIALOG(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), GVC_TYPE_MIXER_DIALOG))
+#define GVC_IS_MIXER_DIALOG_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), GVC_TYPE_MIXER_DIALOG))
+#define GVC_MIXER_DIALOG_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GVC_TYPE_MIXER_DIALOG, GvcMixerDialogClass))
+
+typedef struct _GvcMixerDialog         GvcMixerDialog;
+typedef struct _GvcMixerDialogClass    GvcMixerDialogClass;
+typedef struct _GvcMixerDialogPrivate  GvcMixerDialogPrivate;
+
+struct _GvcMixerDialog
+{
+        GtkDialog              parent;
+        GvcMixerDialogPrivate *priv;
+};
+
+struct _GvcMixerDialogClass
+{
+        GtkDialogClass         parent_class;
+};
+
+GType               gvc_mixer_dialog_get_type            (void) G_GNUC_CONST;
+
+GvcMixerDialog *    gvc_mixer_dialog_new                 (MateMixerContext *context);
+
+gboolean            gvc_mixer_dialog_set_page            (GvcMixerDialog   *dialog,
+                                                          const gchar      *page);
+
+G_END_DECLS
+
+#endif /* __GVC_MIXER_DIALOG_H */
+
+ +
+ +
+ + diff --git a/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/43.html b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/43.html new file mode 100644 index 0000000..1cf5117 --- /dev/null +++ b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/43.html @@ -0,0 +1,1367 @@ + + + + + + Cppcheck - HTML report - mate-media + + + + + +
+ + + +
+
  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
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 Red Hat, Inc.
+ * Copyright (C) 2014 Michal Ratajsky <michal.ratajsky@gmail.com>
+ * Copyright (C) 2019 Victor Kareh <vkareh@vkareh.net>
+ * 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.
+ *
+ */
+
+#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-lib.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 <libmatemixer/matemixer.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 "gvc-applet.h"
+#include "gvc-stream-applet-icon.h"
+
+static const gchar *icon_names_output[] = {
+        "audio-volume-muted",
+        "audio-volume-low",
+        "audio-volume-medium",
+        "audio-volume-high",
+        NULL
+};
+
+static const gchar *icon_names_input[] = {
+        "audio-input-microphone-muted",
+        "audio-input-microphone-low",
+        "audio-input-microphone-medium",
+        "audio-input-microphone-high",
+        NULL
+};
+
+static void menu_output_mute (GtkAction *action, GvcApplet *applet);
+static void menu_activate_open_volume_control (GtkAction *action, GvcApplet *applet);
+static const GtkActionEntry applet_menu_actions [] = {
+        { "Preferences", APPLET_ICON, N_("_Sound Preferences"), NULL, NULL, G_CALLBACK(menu_activate_open_volume_control) },
+        { "MuteOutput", "audio-volume-muted", N_("Mute Output"), NULL, NULL, G_CALLBACK (menu_output_mute) }
+};
+
+static char *ui = "<menuitem name='Preferences' action='Preferences' />"
+                  "<menuitem name='MuteOutput' action='MuteOutput' />";
+
+struct _GvcAppletPrivate
+{
+        GvcStreamAppletIcon *icon_input;
+        GvcStreamAppletIcon *icon_output;
+        gboolean             running;
+        MateMixerContext    *context;
+        MateMixerStream     *output;
+        MateMixerStream     *input;
+
+        MatePanelApplet     *applet;
+        GtkBox              *box;
+        GtkActionGroup      *action_group;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (GvcApplet, gvc_applet, 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
+update_icon_input (GvcApplet *applet)
+{
+        MateMixerStreamControl *control = NULL;
+        gboolean                show = FALSE;
+
+        /* Enable the input icon in case there is an input stream present and there
+         * is a non-mixer application using the input */
+        if (applet->priv->input != NULL) {
+                const gchar *app_id;
+                const GList *inputs = mate_mixer_stream_list_controls (applet->priv->input);
+
+                control = mate_mixer_stream_get_default_control (applet->priv->input);
+
+                const gchar *stream_name = mate_mixer_stream_get_name (applet->priv->input);
+                g_debug ("Got stream name %s", stream_name);
+                if (g_str_has_suffix (stream_name, ".monitor")) {
+                        inputs = NULL;
+                        g_debug ("Stream is a monitor, ignoring");
+                }
+
+                while (inputs != NULL) {
+                        MateMixerStreamControl *input = MATE_MIXER_STREAM_CONTROL (inputs->data);
+                        MateMixerStreamControlRole role = mate_mixer_stream_control_get_role (input);
+
+                        if (role == MATE_MIXER_STREAM_CONTROL_ROLE_APPLICATION) {
+                                MateMixerAppInfo *app_info = mate_mixer_stream_control_get_app_info (input);
+
+                                app_id = mate_mixer_app_info_get_id (app_info);
+                                if (app_id == NULL) {
+                                        /* A recording application which has no
+                                         * identifier set */
+                                        g_debug ("Found a recording application control %s",
+                                                 mate_mixer_stream_control_get_label (input));
+
+                                        if (G_UNLIKELY (control == NULL)) {
+                                                /* In the unlikely case when there is no
+                                                 * default input control, use the application
+                                                 * control for the icon */
+                                                control = input;
+                                        }
+                                        show = TRUE;
+                                        break;
+                                }
+
+                                if (strcmp (app_id, "org.mate.VolumeControl") != 0 &&
+                                    strcmp (app_id, "org.gnome.VolumeControl") != 0 &&
+                                    strcmp (app_id, "org.PulseAudio.pavucontrol") != 0) {
+                                        g_debug ("Found a recording application %s", app_id);
+
+                                        if (G_UNLIKELY (control == NULL))
+                                                control = input;
+
+                                        show = TRUE;
+                                        break;
+                                }
+                        }
+                        inputs = inputs->next;
+                }
+
+                if (show == TRUE)
+                        g_debug ("Input icon enabled");
+                else
+                        g_debug ("There is no recording application, input icon disabled");
+        }
+
+        gvc_stream_applet_icon_set_control (applet->priv->icon_input, control);
+
+        gtk_widget_set_visible (GTK_WIDGET (applet->priv->icon_input), show);
+}
+
+static void
+update_icon_output (GvcApplet *applet)
+{
+        MateMixerStream        *stream;
+        MateMixerStreamControl *control = NULL;
+
+        stream = mate_mixer_context_get_default_output_stream (applet->priv->context);
+        if (stream != NULL)
+                control = mate_mixer_stream_get_default_control (stream);
+
+        gvc_stream_applet_icon_set_control (applet->priv->icon_output, control);
+
+        if (control != NULL) {
+                g_debug ("Output icon enabled");
+                gtk_widget_set_visible (GTK_WIDGET (applet->priv->icon_output), TRUE);
+        }
+        else {
+                g_debug ("There is no output stream/control, output icon disabled");
+                gtk_widget_set_visible (GTK_WIDGET (applet->priv->icon_output), FALSE);
+        }
+}
+
+static void
+on_output_stream_control_added (MateMixerStream *stream,
+                                const gchar     *name,
+                                GvcApplet       *applet)
+{
+        MateMixerStreamControl *control;
+
+        control = mate_mixer_stream_get_control (stream, name);
+        if (G_LIKELY (control != NULL)) {
+                MateMixerStreamControlRole role = mate_mixer_stream_control_get_role (control);
+
+                /* Non-application output control doesn't affect the icon */
+                if (role != MATE_MIXER_STREAM_CONTROL_ROLE_APPLICATION)
+                        return;
+        }
+
+        /* Either an application control has been added or we couldn't
+         * read the control, this shouldn't happen but let's revalidate the
+         * icon to be sure if it does */
+        update_icon_output (applet);
+}
+
+static void
+on_input_stream_control_added (MateMixerStream *stream,
+                               const gchar     *name,
+                               GvcApplet       *applet)
+{
+        MateMixerStreamControl *control;
+
+        control = mate_mixer_stream_get_control (stream, name);
+        if (G_LIKELY (control != NULL)) {
+                MateMixerStreamControlRole role = mate_mixer_stream_control_get_role (control);
+
+                /* Non-application input control doesn't affect the icon */
+                if (role != MATE_MIXER_STREAM_CONTROL_ROLE_APPLICATION)
+                        return;
+        }
+
+        /* Either an application control has been added or we couldn't
+         * read the control, this shouldn't happen but let's revalidate the
+         * icon to be sure if it does */
+        update_icon_input (applet);
+}
+
+static void
+on_output_stream_control_removed (MateMixerStream *stream,
+                                  const gchar     *name,
+                                  GvcApplet       *applet)
+{
+        /* The removed stream could be an application output, which may cause
+         * the output applet icon to disappear */
+        update_icon_output (applet);
+}
+
+static void
+on_input_stream_control_removed (MateMixerStream *stream,
+                                 const gchar     *name,
+                                 GvcApplet       *applet)
+{
+        /* The removed stream could be an application input, which may cause
+         * the input applet icon to disappear */
+        update_icon_input (applet);
+}
+
+static gboolean
+update_default_output_stream (GvcApplet *applet)
+{
+        MateMixerStream *stream;
+
+        stream = mate_mixer_context_get_default_output_stream (applet->priv->context);
+        if (stream == applet->priv->output)
+                return FALSE;
+
+        /* The output stream has changed */
+        if (applet->priv->output != NULL) {
+                g_signal_handlers_disconnect_by_data (G_OBJECT (applet->priv->output), applet);
+                g_object_unref (applet->priv->output);
+        }
+
+        applet->priv->output = (stream == NULL) ? NULL : g_object_ref (stream);
+        if (applet->priv->output != NULL) {
+                g_signal_connect (G_OBJECT (applet->priv->output),
+                                  "control-added",
+                                  G_CALLBACK (on_output_stream_control_added),
+                                  applet);
+                g_signal_connect (G_OBJECT (applet->priv->output),
+                                  "control-removed",
+                                  G_CALLBACK (on_output_stream_control_removed),
+                                  applet);
+        }
+
+        /* Return TRUE if the default output stream has changed */
+        return TRUE;
+}
+
+static gboolean
+update_default_input_stream (GvcApplet *applet)
+{
+        MateMixerStream *stream;
+
+        stream = mate_mixer_context_get_default_input_stream (applet->priv->context);
+        if (stream == applet->priv->input)
+                return FALSE;
+
+        /* The input stream has changed */
+        if (applet->priv->input != NULL) {
+                g_signal_handlers_disconnect_by_data (G_OBJECT (applet->priv->input), applet);
+                g_object_unref (applet->priv->input);
+        }
+
+        applet->priv->input = (stream == NULL) ? NULL : g_object_ref (stream);
+        if (applet->priv->input != NULL) {
+                g_signal_connect (G_OBJECT (applet->priv->input),
+                                  "control-added",
+                                  G_CALLBACK (on_input_stream_control_added),
+                                  applet);
+                g_signal_connect (G_OBJECT (applet->priv->input),
+                                  "control-removed",
+                                  G_CALLBACK (on_input_stream_control_removed),
+                                  applet);
+        }
+
+        /* Return TRUE if the default input stream has changed */
+        return TRUE;
+}
+
+static void
+on_context_state_notify (MateMixerContext *context,
+                         GParamSpec       *pspec,
+                         GvcApplet        *applet)
+{
+        MateMixerState state = mate_mixer_context_get_state (context);
+
+        switch (state) {
+        case MATE_MIXER_STATE_FAILED:
+                g_warning ("Failed to connect to a sound system");
+                break;
+
+        case MATE_MIXER_STATE_READY:
+                update_default_output_stream (applet);
+                update_default_input_stream (applet);
+
+                /* Each applet change may affect the visibility of the icons */
+                update_icon_output (applet);
+                update_icon_input (applet);
+                break;
+        default:
+                break;
+        }
+}
+
+static void
+on_context_default_input_stream_notify (MateMixerContext *context,
+                                        GParamSpec       *pspec,
+                                        GvcApplet        *applet)
+{
+        if (update_default_input_stream (applet) == FALSE)
+                return;
+
+        update_icon_input (applet);
+}
+
+static void
+on_context_default_output_stream_notify (MateMixerContext *control,
+                                         GParamSpec       *pspec,
+                                         GvcApplet        *applet)
+{
+        if (update_default_output_stream (applet) == FALSE)
+                return;
+
+        update_icon_output (applet);
+}
+
+void
+gvc_applet_start (GvcApplet *applet)
+{
+        g_return_if_fail (GVC_IS_APPLET (applet));
+
+        if (G_UNLIKELY (applet->priv->running == TRUE))
+                return;
+
+        if (G_UNLIKELY (mate_mixer_context_open (applet->priv->context) == FALSE)) {
+                /* Normally this should never happen, in the worst case we
+                 * should end up with the Null module */
+                g_warning ("Failed to connect to a sound system");
+        }
+
+        g_debug ("Applet has been started");
+
+        applet->priv->running = TRUE;
+}
+
+static void
+gvc_applet_dispose (GObject *object)
+{
+        GvcApplet *applet = GVC_APPLET (object);
+
+        if (applet->priv->output != NULL) {
+                g_signal_handlers_disconnect_by_data (G_OBJECT (applet->priv->output), applet);
+                g_clear_object (&applet->priv->output);
+        }
+        if (applet->priv->input != NULL) {
+                g_signal_handlers_disconnect_by_data (G_OBJECT (applet->priv->input), applet);
+                g_clear_object (&applet->priv->input);
+        }
+
+        g_clear_object (&applet->priv->context);
+        g_clear_object (&applet->priv->icon_input);
+        g_clear_object (&applet->priv->icon_output);
+
+        G_OBJECT_CLASS (gvc_applet_parent_class)->dispose (object);
+}
+
+static void
+gvc_applet_class_init (GvcAppletClass *klass)
+{
+        GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+        object_class->dispose = gvc_applet_dispose;
+}
+
+static void
+gvc_applet_init (GvcApplet *applet)
+{
+        applet->priv = gvc_applet_get_instance_private (applet);
+
+        applet->priv->icon_input  = gvc_stream_applet_icon_new (NULL, icon_names_input);
+        applet->priv->icon_output = gvc_stream_applet_icon_new (NULL, icon_names_output);
+
+        gvc_stream_applet_icon_set_display_name (applet->priv->icon_input,  _("Input"));
+        gvc_stream_applet_icon_set_display_name (applet->priv->icon_output, _("Output"));
+
+        applet->priv->context = mate_mixer_context_new ();
+
+        mate_mixer_context_set_app_name (applet->priv->context, _("MATE Volume Control Applet"));
+
+        mate_mixer_context_set_app_id (applet->priv->context, GVC_APPLET_DBUS_NAME);
+        mate_mixer_context_set_app_version (applet->priv->context, VERSION);
+        mate_mixer_context_set_app_icon (applet->priv->context, APPLET_ICON);
+
+        g_signal_connect (G_OBJECT (applet->priv->context),
+                          "notify::state",
+                          G_CALLBACK (on_context_state_notify),
+                          applet);
+        g_signal_connect (G_OBJECT (applet->priv->context),
+                          "notify::default-input-stream",
+                          G_CALLBACK (on_context_default_input_stream_notify),
+                          applet);
+        g_signal_connect (G_OBJECT (applet->priv->context),
+                          "notify::default-output-stream",
+                          G_CALLBACK (on_context_default_output_stream_notify),
+                          applet);
+}
+
+GvcApplet *
+gvc_applet_new (void)
+{
+        return g_object_new (GVC_TYPE_APPLET, NULL);
+}
+
+static void
+gvc_applet_set_size(GtkWidget* widget, int size, gpointer user_data)
+{
+        GvcApplet *applet = user_data;
+
+        /*Iterate through the icon sizes so they can be kept sharp*/
+        if (size < 22)
+                size = 16;
+        else if (size < 24)
+                size = 22;
+        else if (size < 32)
+                size = 24;
+        else if (size < 48)
+                size = 32;
+
+        gvc_stream_applet_icon_set_size (applet->priv->icon_input, size);
+        gvc_stream_applet_icon_set_size (applet->priv->icon_output, size);
+}
+
+static void
+gvc_applet_set_mute (GtkWidget* widget, int size, gpointer user_data)
+{
+        GvcApplet *applet = user_data;
+        gboolean is_muted;
+        GtkAction *action;
+
+        is_muted = gvc_stream_applet_icon_get_mute (applet->priv->icon_output);
+
+        action = gtk_action_group_get_action (applet->priv->action_group, "MuteOutput");
+
+        if (is_muted) {
+                gtk_action_set_label (action, _("Unmute Output"));
+                gtk_action_set_icon_name (action, "audio-volume-medium");
+        }
+        else
+        {
+                gtk_action_set_label (action, _("Mute Output"));
+                gtk_action_set_icon_name (action, "audio-volume-muted");
+        }
+}
+
+static void
+gvc_applet_set_orient(GtkWidget *widget, MatePanelAppletOrient orient, gpointer user_data)
+{
+        GvcApplet *applet = user_data;
+
+        gvc_stream_applet_icon_set_orient (applet->priv->icon_input, orient);
+        gvc_stream_applet_icon_set_orient (applet->priv->icon_output, orient);
+}
+
+static void
+menu_output_mute (GtkAction *action, GvcApplet *applet)
+{
+        gboolean               is_muted;
+
+        is_muted = gvc_stream_applet_icon_get_mute(applet->priv->icon_output);
+        if (!is_muted) {
+                gvc_stream_applet_icon_set_mute (applet->priv->icon_output, TRUE);
+                gtk_action_set_label (action, "Unmute Output");
+                gtk_action_set_icon_name( action, "audio-volume-medium");
+
+        }
+        else {
+                gvc_stream_applet_icon_set_mute (applet->priv->icon_output, FALSE);
+                gtk_action_set_label (action, "Mute Output");
+                gtk_action_set_icon_name (action, "audio-volume-muted");
+       }
+}
+
+static void
+menu_activate_open_volume_control (GtkAction *action, GvcApplet *applet)
+{
+        gvc_stream_applet_icon_volume_control (applet->priv->icon_output);
+}
+
+gboolean
+gvc_applet_fill (GvcApplet *applet, MatePanelApplet* applet_widget)
+{
+#ifndef IN_PROCESS
+        g_set_application_name (_("Volume Control Applet"));
+        gtk_window_set_default_icon_name (APPLET_ICON);
+        mate_panel_applet_set_flags (applet_widget, MATE_PANEL_APPLET_EXPAND_MINOR);
+#endif
+        applet->priv->applet = applet_widget;
+        /*FIXME: We haved to set this up BEFORE packing in icons. find a way to update this when the applet is moved that works*/
+        switch (mate_panel_applet_get_orient (applet->priv->applet)) {
+        case MATE_PANEL_APPLET_ORIENT_UP:
+                applet->priv->box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0));
+		break;
+        case MATE_PANEL_APPLET_ORIENT_DOWN:
+                applet->priv->box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0));
+		break;
+        case MATE_PANEL_APPLET_ORIENT_LEFT:
+                applet->priv->box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 0));
+		break;
+        case MATE_PANEL_APPLET_ORIENT_RIGHT:
+                applet->priv->box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 0));
+        break;
+        }
+
+        /* Define an initial size and orientation */
+        gvc_stream_applet_icon_set_size (applet->priv->icon_input, mate_panel_applet_get_size (applet->priv->applet));
+        gvc_stream_applet_icon_set_size (applet->priv->icon_output, mate_panel_applet_get_size (applet->priv->applet));
+        gvc_stream_applet_icon_set_orient (applet->priv->icon_input, mate_panel_applet_get_orient (applet->priv->applet));
+        gvc_stream_applet_icon_set_orient (applet->priv->icon_output, mate_panel_applet_get_orient (applet->priv->applet));
+
+        /* we add the Gtk buttons into the applet */
+        gtk_box_pack_start (applet->priv->box, GTK_WIDGET (applet->priv->icon_input), TRUE, TRUE, 2);
+        gtk_box_pack_start (applet->priv->box, GTK_WIDGET (applet->priv->icon_output), TRUE, TRUE, 2);
+        gtk_container_add (GTK_CONTAINER (applet->priv->applet), GTK_WIDGET (applet->priv->box));
+        gtk_widget_show_all (GTK_WIDGET (applet->priv->applet));
+
+        /* Enable 'scroll-event' signal to be received  */
+        gtk_widget_add_events (GTK_WIDGET(applet->priv->icon_input), GDK_SCROLL_MASK);
+        gtk_widget_add_events (GTK_WIDGET(applet->priv->icon_output), GDK_SCROLL_MASK);
+
+        /* Update icons on size/orientation changes*/
+        g_object_connect (applet->priv->applet,
+                         "signal::change_size", gvc_applet_set_size, applet,
+                         "signal::change_orient", gvc_applet_set_orient, applet,
+                         "signal::event-after", gvc_applet_set_mute, applet,
+                         NULL);
+
+        /* set up context menu */
+        applet->priv->action_group = gtk_action_group_new ("Volume Control Applet Actions");
+        gtk_action_group_set_translation_domain (applet->priv->action_group, GETTEXT_PACKAGE);
+        gtk_action_group_add_actions (applet->priv->action_group, applet_menu_actions,
+                                      G_N_ELEMENTS (applet_menu_actions), applet);
+
+        mate_panel_applet_setup_menu (applet->priv->applet, ui, applet->priv->action_group);
+
+        return TRUE;
+}
+
+ +
+ +
+ + diff --git a/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/44.html b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/44.html new file mode 100644 index 0000000..ef0d813 --- /dev/null +++ b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/44.html @@ -0,0 +1,403 @@ + + + + + + Cppcheck - HTML report - mate-media + + + + + +
+ + + +
+
 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
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 Red Hat, Inc.
+ * Copyright (C) 2014 Michal Ratajsky <michal.ratajsky@gmail.com>
+ * Copyright (C) 2019 Victor Kareh <vkareh@vkareh.net>
+ * 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.
+ *
+ */
+
+#ifndef __GVC_STREAM_APPLET_ICON_H
+#define __GVC_STREAM_APPLET_ICON_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.
+#include <libmatemixer/matemixer.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+G_BEGIN_DECLS
+
+#define GVC_TYPE_STREAM_APPLET_ICON         (gvc_stream_applet_icon_get_type ())
+#define GVC_STREAM_APPLET_ICON(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), GVC_TYPE_STREAM_APPLET_ICON, GvcStreamAppletIcon))
+#define GVC_STREAM_APPLET_ICON_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST ((k), GVC_TYPE_STREAM_APPLET_ICON, GvcStreamAppletIconClass))
+#define GVC_IS_STREAM_APPLET_ICON(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), GVC_TYPE_STREAM_APPLET_ICON))
+#define GVC_IS_STREAM_APPLET_ICON_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), GVC_TYPE_STREAM_APPLET_ICON))
+#define GVC_STREAM_APPLET_ICON_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GVC_TYPE_STREAM_APPLET_ICON, GvcStreamAppletIconClass))
+
+typedef struct _GvcStreamAppletIcon         GvcStreamAppletIcon;
+typedef struct _GvcStreamAppletIconClass    GvcStreamAppletIconClass;
+typedef struct _GvcStreamAppletIconPrivate  GvcStreamAppletIconPrivate;
+
+struct _GvcStreamAppletIcon
+{
+        GtkEventBox                 parent;
+        GvcStreamAppletIconPrivate *priv;
+};
+
+struct _GvcStreamAppletIconClass
+{
+        GtkEventBoxClass            parent_class;
+};
+
+GType                 gvc_stream_applet_icon_get_type         (void) G_GNUC_CONST;
+
+GvcStreamAppletIcon * gvc_stream_applet_icon_new              (MateMixerStreamControl *control,
+                                                               const gchar           **icon_names);
+
+void                  gvc_stream_applet_icon_set_icon_names   (GvcStreamAppletIcon    *icon,
+                                                               const gchar           **icon_names);
+void                  gvc_stream_applet_icon_set_display_name (GvcStreamAppletIcon    *icon,
+                                                                  const gchar         *display_name);
+
+void                  gvc_stream_applet_icon_set_control      (GvcStreamAppletIcon    *icon,
+                                                               MateMixerStreamControl *control);
+
+void                  gvc_stream_applet_icon_set_size         (GvcStreamAppletIcon *icon,
+                                                               guint                size);
+
+void                  gvc_stream_applet_icon_set_orient       (GvcStreamAppletIcon  *icon,
+                                                               MatePanelAppletOrient orient);
+
+gboolean              gvc_stream_applet_icon_get_mute         (GvcStreamAppletIcon *icon);
+
+void                  gvc_stream_applet_icon_set_mute         (GvcStreamAppletIcon *icon,
+                                                               gboolean mute);
+
+void                  gvc_stream_applet_icon_volume_control   (GvcStreamAppletIcon *icon);
+
+G_END_DECLS
+
+#endif /* __GVC_STREAM_APPLET_ICON_H */
+
+ +
+ +
+ + diff --git a/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/45.html b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/45.html new file mode 100644 index 0000000..a736af4 --- /dev/null +++ b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/45.html @@ -0,0 +1,1287 @@ + + + + + + Cppcheck - HTML report - mate-media + + + + + +
+ + + +
+
  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
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 William Jon McCann
+ * Copyright (C) 2014 Michal Ratajsky <michal.ratajsky@gmail.com>
+ * 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.
+ *
+ */
+
+#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-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 <canberra-gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <libmatemixer/matemixer.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "gvc-balance-bar.h"
+
+#define SCALE_SIZE 128
+
+struct _GvcBalanceBarPrivate
+{
+        GvcBalanceType   btype;
+        GtkWidget       *scale_box;
+        GtkWidget       *start_box;
+        GtkWidget       *end_box;
+        GtkWidget       *label;
+        GtkWidget       *scale;
+        GtkAdjustment   *adjustment;
+        GtkSizeGroup    *size_group;
+        gboolean         symmetric;
+        MateMixerStreamControl *control;
+        gint             lfe_channel;
+};
+
+enum
+{
+        PROP_0,
+        PROP_CONTROL,
+        PROP_BALANCE_TYPE,
+        N_PROPERTIES
+};
+
+static GParamSpec *properties[N_PROPERTIES] = { NULL, };
+
+static void     gvc_balance_bar_dispose     (GObject            *object);
+
+static gboolean on_scale_scroll_event       (GtkWidget          *widget,
+                                             GdkEventScroll     *event,
+                                             GvcBalanceBar      *bar);
+
+static void     on_adjustment_value_changed (GtkAdjustment      *adjustment,
+                                             GvcBalanceBar      *bar);
+
+G_DEFINE_TYPE_WITH_PRIVATE (GvcBalanceBar, gvc_balance_bar, 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
+create_scale_box (GvcBalanceBar *bar)
+{
+        bar->priv->scale_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
+        bar->priv->start_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
+        bar->priv->end_box   = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
+        bar->priv->scale     = gtk_scale_new (GTK_ORIENTATION_HORIZONTAL,
+                                              bar->priv->adjustment);
+
+        /* Balance and fade scales do not have an origin */
+        if (bar->priv->btype != BALANCE_TYPE_LFE)
+                gtk_scale_set_has_origin (GTK_SCALE (bar->priv->scale), FALSE);
+
+        gtk_widget_set_size_request (bar->priv->scale, SCALE_SIZE, -1);
+
+        gtk_box_pack_start (GTK_BOX (bar->priv->scale_box),
+                            bar->priv->start_box,
+                            FALSE, FALSE, 0);
+        gtk_box_pack_start (GTK_BOX (bar->priv->start_box),
+                            bar->priv->label,
+                            FALSE, FALSE, 0);
+        gtk_box_pack_start (GTK_BOX (bar->priv->scale_box),
+                            bar->priv->scale,
+                            TRUE, TRUE, 0);
+        gtk_box_pack_start (GTK_BOX (bar->priv->scale_box),
+                            bar->priv->end_box,
+                            FALSE, FALSE, 0);
+
+        ca_gtk_widget_disable_sounds (bar->priv->scale, FALSE);
+
+        gtk_widget_add_events (bar->priv->scale, GDK_SCROLL_MASK);
+
+        g_signal_connect (G_OBJECT (bar->priv->scale),
+                          "scroll-event",
+                          G_CALLBACK (on_scale_scroll_event),
+                          bar);
+
+        if (bar->priv->size_group != NULL) {
+                gtk_size_group_add_widget (bar->priv->size_group,
+                                           bar->priv->start_box);
+
+                if (bar->priv->symmetric)
+                        gtk_size_group_add_widget (bar->priv->size_group,
+                                                   bar->priv->end_box);
+        }
+
+        gtk_scale_set_draw_value (GTK_SCALE (bar->priv->scale), FALSE);
+}
+
+static void
+update_scale_marks (GvcBalanceBar *bar)
+{
+        gchar    *str_lower = NULL,
+                 *str_upper = NULL;
+        gdouble   lower,
+                  upper;
+
+        gtk_scale_clear_marks (GTK_SCALE (bar->priv->scale));
+
+        switch (bar->priv->btype) {
+        case BALANCE_TYPE_RL:
+                str_lower = g_strdup_printf ("<small>%s</small>", C_("balance", "Left"));
+                str_upper = g_strdup_printf ("<small>%s</small>", C_("balance", "Right"));
+                break;
+        case BALANCE_TYPE_FR:
+                str_lower = g_strdup_printf ("<small>%s</small>", C_("balance", "Rear"));
+                str_upper = g_strdup_printf ("<small>%s</small>", C_("balance", "Front"));
+                break;
+        case BALANCE_TYPE_LFE:
+                str_lower = g_strdup_printf ("<small>%s</small>", C_("balance", "Minimum"));
+                str_upper = g_strdup_printf ("<small>%s</small>", C_("balance", "Maximum"));
+                break;
+        }
+
+        lower = gtk_adjustment_get_lower (bar->priv->adjustment);
+        gtk_scale_add_mark (GTK_SCALE (bar->priv->scale),
+                            lower,
+                            GTK_POS_BOTTOM,
+                            str_lower);
+        upper = gtk_adjustment_get_upper (bar->priv->adjustment);
+        gtk_scale_add_mark (GTK_SCALE (bar->priv->scale),
+                            upper,
+                            GTK_POS_BOTTOM,
+                            str_upper);
+        g_free (str_lower);
+        g_free (str_upper);
+
+        if (bar->priv->btype != BALANCE_TYPE_LFE)
+                gtk_scale_add_mark (GTK_SCALE (bar->priv->scale),
+                                    (upper - lower) / 2 + lower,
+                                    GTK_POS_BOTTOM,
+                                    NULL);
+}
+
+void
+gvc_balance_bar_set_size_group (GvcBalanceBar *bar,
+                                GtkSizeGroup  *group,
+                                gboolean       symmetric)
+{
+        g_return_if_fail (GVC_IS_BALANCE_BAR (bar));
+        g_return_if_fail (GTK_IS_SIZE_GROUP (group));
+
+        bar->priv->size_group = group;
+        bar->priv->symmetric = symmetric;
+
+        if (bar->priv->size_group != NULL) {
+                gtk_size_group_add_widget (bar->priv->size_group,
+                                           bar->priv->start_box);
+
+                if (bar->priv->symmetric)
+                        gtk_size_group_add_widget (bar->priv->size_group,
+                                                   bar->priv->end_box);
+        }
+        gtk_widget_queue_draw (GTK_WIDGET (bar));
+}
+
+static void
+update_balance_value (GvcBalanceBar *bar)
+{
+        gdouble value = 0;
+
+        switch (bar->priv->btype) {
+        case BALANCE_TYPE_RL:
+                value = mate_mixer_stream_control_get_balance (bar->priv->control);
+                g_debug ("Balance value changed to %.2f", value);
+                break;
+        case BALANCE_TYPE_FR:
+                value = mate_mixer_stream_control_get_fade (bar->priv->control);
+                g_debug ("Fade value changed to %.2f", value);
+                break;
+        case BALANCE_TYPE_LFE:
+                value = mate_mixer_stream_control_get_channel_volume (bar->priv->control,
+                                                                      bar->priv->lfe_channel);
+
+                g_debug ("Subwoofer volume changed to %.0f", value);
+                break;
+        }
+
+        gtk_adjustment_set_value (bar->priv->adjustment, value);
+}
+
+static void
+on_balance_value_changed (MateMixerStream *stream,
+                          GParamSpec      *pspec,
+                          GvcBalanceBar   *bar)
+{
+        update_balance_value (bar);
+}
+
+static gint
+find_stream_lfe_channel (MateMixerStreamControl *control)
+{
+        guint i;
+
+        for (i = 0; i < mate_mixer_stream_control_get_num_channels (control); i++) {
+                MateMixerChannelPosition position;
+
+                position = mate_mixer_stream_control_get_channel_position (control, i);
+                if (position == MATE_MIXER_CHANNEL_LFE)
+                        return i;
+        }
+
+        return -1;
+}
+
+static void
+gvc_balance_bar_set_control (GvcBalanceBar *bar, MateMixerStreamControl *control)
+{
+        g_return_if_fail (GVC_BALANCE_BAR (bar));
+        g_return_if_fail (MATE_MIXER_IS_STREAM_CONTROL (control));
+
+        if (bar->priv->control != NULL) {
+                g_signal_handlers_disconnect_by_func (G_OBJECT (bar->priv->control),
+                                                      on_balance_value_changed,
+                                                      bar);
+                g_object_unref (bar->priv->control);
+        }
+
+        bar->priv->control = g_object_ref (control);
+
+        if (bar->priv->btype == BALANCE_TYPE_LFE) {
+                gdouble minimum;
+                gdouble maximum;
+
+                minimum = mate_mixer_stream_control_get_min_volume (bar->priv->control);
+                maximum = mate_mixer_stream_control_get_normal_volume (bar->priv->control);
+
+                /* Configure the adjustment for the volume limits of the current
+                 * stream.
+                 * Only subwoofer scale uses volume, balance and fade use fixed
+                 * limits which do not need to be updated as balance type is
+                 * only set during construction. */
+                gtk_adjustment_configure (GTK_ADJUSTMENT (bar->priv->adjustment),
+                                          gtk_adjustment_get_value (bar->priv->adjustment),
+                                          minimum,
+                                          maximum,
+                                          (maximum - minimum) / 100.0,
+                                          (maximum - minimum) / 10.0,
+                                          0.0);
+
+                bar->priv->lfe_channel = find_stream_lfe_channel (bar->priv->control);
+
+                if (G_LIKELY (bar->priv->lfe_channel > -1))
+                        g_debug ("Found LFE channel at position %d", bar->priv->lfe_channel);
+                else
+                        g_warn_if_reached ();
+        } else
+                bar->priv->lfe_channel = -1;
+
+        switch (bar->priv->btype) {
+        case BALANCE_TYPE_RL:
+                g_signal_connect (G_OBJECT (bar->priv->control),
+                                  "notify::balance",
+                                  G_CALLBACK (on_balance_value_changed),
+                                  bar);
+                break;
+        case BALANCE_TYPE_FR:
+                g_signal_connect (G_OBJECT (bar->priv->control),
+                                  "notify::fade",
+                                  G_CALLBACK (on_balance_value_changed),
+                                  bar);
+                break;
+        case BALANCE_TYPE_LFE:
+                g_signal_connect (G_OBJECT (bar->priv->control),
+                                  "notify::volume",
+                                  G_CALLBACK (on_balance_value_changed),
+                                  bar);
+                break;
+        }
+
+        update_balance_value (bar);
+        update_scale_marks (bar);
+
+        g_object_notify_by_pspec (G_OBJECT (bar), properties[PROP_CONTROL]);
+}
+
+static void
+gvc_balance_bar_set_balance_type (GvcBalanceBar *bar, GvcBalanceType btype)
+{
+        GtkWidget     *frame;
+        GtkAdjustment *adjustment;
+
+        /* Create adjustment with limits for balance and fade types because
+         * some limits must be provided.
+         * If subwoofer type is used instead, the limits will be changed when
+         * stream is set. */
+        adjustment = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, -1.0, 1.0, 0.05, 0.5, 0.0));
+
+        bar->priv->btype = btype;
+        bar->priv->adjustment = GTK_ADJUSTMENT (g_object_ref_sink (adjustment));
+
+        g_signal_connect (G_OBJECT (adjustment),
+                          "value-changed",
+                          G_CALLBACK (on_adjustment_value_changed),
+                          bar);
+
+        switch (btype) {
+        case BALANCE_TYPE_RL:
+                bar->priv->label = gtk_label_new_with_mnemonic (_("_Balance:"));
+                break;
+        case BALANCE_TYPE_FR:
+                bar->priv->label = gtk_label_new_with_mnemonic (_("_Fade:"));
+                break;
+        case BALANCE_TYPE_LFE:
+                bar->priv->label = gtk_label_new_with_mnemonic (_("_Subwoofer:"));
+                break;
+        }
+
+        gtk_label_set_xalign (GTK_LABEL (bar->priv->label), 0.0);
+        gtk_label_set_yalign (GTK_LABEL (bar->priv->label), 0.0);
+
+        /* Frame */
+        frame = gtk_frame_new (NULL);
+        gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
+        gtk_box_pack_start (GTK_BOX (bar), frame, TRUE, TRUE, 0);
+
+        /* Box with scale */
+        create_scale_box (bar);
+        gtk_container_add (GTK_CONTAINER (frame), bar->priv->scale_box);
+
+        gtk_label_set_mnemonic_widget (GTK_LABEL (bar->priv->label),
+                                       bar->priv->scale);
+
+        gtk_widget_set_direction (bar->priv->scale, GTK_TEXT_DIR_LTR);
+        gtk_widget_show_all (frame);
+
+        g_object_notify_by_pspec (G_OBJECT (bar), properties[PROP_BALANCE_TYPE]);
+}
+
+static void
+gvc_balance_bar_set_property (GObject       *object,
+                              guint          prop_id,
+                              const GValue  *value,
+                              GParamSpec    *pspec)
+{
+        GvcBalanceBar *self = GVC_BALANCE_BAR (object);
+
+        switch (prop_id) {
+        case PROP_CONTROL:
+                gvc_balance_bar_set_control (self, g_value_get_object (value));
+                break;
+        case PROP_BALANCE_TYPE:
+                gvc_balance_bar_set_balance_type (self, g_value_get_int (value));
+                break;
+        default:
+                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+                break;
+        }
+}
+
+static void
+gvc_balance_bar_get_property (GObject     *object,
+                              guint        prop_id,
+                              GValue      *value,
+                              GParamSpec  *pspec)
+{
+        GvcBalanceBar *self = GVC_BALANCE_BAR (object);
+
+        switch (prop_id) {
+        case PROP_CONTROL:
+                g_value_set_object (value, self->priv->control);
+                break;
+        default:
+                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+                break;
+        }
+}
+
+static void
+gvc_balance_bar_class_init (GvcBalanceBarClass *klass)
+{
+        GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+        object_class->dispose = gvc_balance_bar_dispose;
+        object_class->set_property = gvc_balance_bar_set_property;
+        object_class->get_property = gvc_balance_bar_get_property;
+
+        properties[PROP_CONTROL] =
+                g_param_spec_object ("control",
+                                     "Control",
+                                     "MateMixer stream control",
+                                     MATE_MIXER_TYPE_STREAM_CONTROL,
+                                     G_PARAM_READWRITE |
+                                     G_PARAM_STATIC_STRINGS);
+
+        properties[PROP_BALANCE_TYPE] =
+                g_param_spec_int ("balance-type",
+                                  "balance type",
+                                  "Whether the balance is right-left or front-rear",
+                                  BALANCE_TYPE_RL,
+                                  NUM_BALANCE_TYPES - 1,
+                                  BALANCE_TYPE_RL,
+                                  G_PARAM_READWRITE |
+                                  G_PARAM_CONSTRUCT_ONLY |
+                                  G_PARAM_STATIC_STRINGS);
+
+        g_object_class_install_properties (object_class, N_PROPERTIES, properties);
+}
+
+static gboolean
+on_scale_scroll_event (GtkWidget      *widget,
+                       GdkEventScroll *event,
+                       GvcBalanceBar  *bar)
+{
+        gdouble value;
+        gdouble minimum;
+        gdouble maximum;
+        gdouble step;
+
+        value   = gtk_adjustment_get_value (bar->priv->adjustment);
+        minimum = gtk_adjustment_get_lower (bar->priv->adjustment);
+        maximum = gtk_adjustment_get_upper (bar->priv->adjustment);
+
+        // XXX fix this for GTK3
+
+        if (bar->priv->btype == BALANCE_TYPE_LFE)
+                step = (maximum - minimum) / 100.0;
+        else
+                step = 0.05;
+
+        if (event->direction == GDK_SCROLL_UP) {
+                if (value + step > maximum)
+                        value = maximum;
+                else
+                        value = value + step;
+        } else if (event->direction == GDK_SCROLL_DOWN) {
+                if (value - step < minimum)
+                        value = minimum;
+                else
+                        value = value - step;
+        }
+
+        gtk_adjustment_set_value (bar->priv->adjustment, value);
+        return TRUE;
+}
+
+static void
+on_adjustment_value_changed (GtkAdjustment *adjustment, GvcBalanceBar *bar)
+{
+        gdouble value;
+
+        if (bar->priv->control == NULL)
+                return;
+
+        value = gtk_adjustment_get_value (adjustment);
+
+        switch (bar->priv->btype) {
+        case BALANCE_TYPE_RL:
+                mate_mixer_stream_control_set_balance (bar->priv->control,
+                                                       (gfloat) value);
+                break;
+        case BALANCE_TYPE_FR:
+                mate_mixer_stream_control_set_fade (bar->priv->control,
+                                                    (gfloat) value);
+                break;
+        case BALANCE_TYPE_LFE:
+                mate_mixer_stream_control_set_channel_volume (bar->priv->control,
+                                                              bar->priv->lfe_channel,
+                                                              (guint) value);
+                break;
+        }
+}
+
+static void
+gvc_balance_bar_init (GvcBalanceBar *bar)
+{
+        bar->priv = gvc_balance_bar_get_instance_private (bar);
+}
+
+static void
+gvc_balance_bar_dispose (GObject *object)
+{
+        GvcBalanceBar *bar;
+
+        bar = GVC_BALANCE_BAR (object);
+
+        if (bar->priv->control != NULL) {
+                g_signal_handlers_disconnect_by_func (G_OBJECT (bar->priv->control),
+                                                      on_balance_value_changed,
+                                                      bar);
+                g_clear_object (&bar->priv->control);
+        }
+
+        G_OBJECT_CLASS (gvc_balance_bar_parent_class)->dispose (object);
+}
+
+GtkWidget *
+gvc_balance_bar_new (MateMixerStreamControl *control, GvcBalanceType btype)
+{
+        return g_object_new (GVC_TYPE_BALANCE_BAR,
+                            "balance-type", btype,
+                            "control", control,
+                            "orientation", GTK_ORIENTATION_HORIZONTAL,
+                            NULL);
+}
+
+ +
+ +
+ + diff --git a/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/46.html b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/46.html new file mode 100644 index 0000000..8266833 --- /dev/null +++ b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/46.html @@ -0,0 +1,387 @@ + + + + + + Cppcheck - HTML report - mate-media + + + + + +
+ + + +
+
 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: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 Red Hat, Inc.
+ * Copyright (C) 2014 Michal Ratajsky <michal.ratajsky@gmail.com>
+ * 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.
+ *
+ */
+
+#ifndef __GVC_BALANCE_BAR_H
+#define __GVC_BALANCE_BAR_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.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <libmatemixer/matemixer.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+G_BEGIN_DECLS
+
+#define GVC_TYPE_BALANCE_BAR         (gvc_balance_bar_get_type ())
+#define GVC_BALANCE_BAR(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), GVC_TYPE_BALANCE_BAR, GvcBalanceBar))
+#define GVC_BALANCE_BAR_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST((k), GVC_TYPE_BALANCE_BAR, GvcBalanceBarClass))
+#define GVC_IS_BALANCE_BAR(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), GVC_TYPE_BALANCE_BAR))
+#define GVC_IS_BALANCE_BAR_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), GVC_TYPE_BALANCE_BAR))
+#define GVC_BALANCE_BAR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GVC_TYPE_BALANCE_BAR, GvcBalanceBarClass))
+
+typedef enum {
+        BALANCE_TYPE_RL,
+        BALANCE_TYPE_FR,
+        BALANCE_TYPE_LFE,
+} GvcBalanceType;
+
+#define NUM_BALANCE_TYPES BALANCE_TYPE_LFE + 1
+
+typedef struct _GvcBalanceBar         GvcBalanceBar;
+typedef struct _GvcBalanceBarClass    GvcBalanceBarClass;
+typedef struct _GvcBalanceBarPrivate  GvcBalanceBarPrivate;
+
+struct _GvcBalanceBar
+{
+        GtkBox                parent;
+        GvcBalanceBarPrivate *priv;
+};
+
+struct _GvcBalanceBarClass
+{
+        GtkBoxClass           parent_class;
+};
+
+GType               gvc_balance_bar_get_type            (void) G_GNUC_CONST;
+
+GtkWidget *         gvc_balance_bar_new                 (MateMixerStreamControl *control,
+                                                         GvcBalanceType   btype);
+
+void                gvc_balance_bar_set_size_group      (GvcBalanceBar   *bar,
+                                                         GtkSizeGroup    *group,
+                                                         gboolean         symmetric);
+
+G_END_DECLS
+
+#endif /* __GVC_BALANCE_BAR_H */
+
+ +
+ +
+ + diff --git a/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/47.html b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/47.html new file mode 100644 index 0000000..6422541 --- /dev/null +++ b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/47.html @@ -0,0 +1,2691 @@ + + + + + + Cppcheck - HTML report - mate-media + + + + + +
+ + + +
+
   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
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 William Jon McCann
+ * Copyright (C) 2014 Michal Ratajsky <michal.ratajsky@gmail.com>
+ * 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.
+ *
+ */
+
+#include "config.h"<--- Include file: "config.h" not found.
+
+#include <sys/param.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-lib.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 <canberra-gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <libmatemixer/matemixer.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "gvc-channel-bar.h"
+
+#define SCALE_SIZE 128
+
+struct _GvcChannelBarPrivate
+{
+        GtkOrientation              orientation;
+        GtkWidget                  *scale_box;
+        GtkWidget                  *start_box;
+        GtkWidget                  *end_box;
+        GtkWidget                  *image;
+        GtkWidget                  *label;
+        GtkWidget                  *low_image;
+        GtkWidget                  *scale;
+        GtkWidget                  *high_image;
+        GtkWidget                  *mute_button;
+        GtkAdjustment              *adjustment;
+        gboolean                    show_icons;
+        gboolean                    show_mute;
+        gboolean                    show_marks;
+        gboolean                    show_mark_text;
+        gboolean                    extended;
+        GtkSizeGroup               *size_group;
+        gboolean                    symmetric;
+        gboolean                    click_lock;
+        MateMixerStreamControl     *control;
+        MateMixerStreamControlFlags control_flags;
+};
+
+enum {
+        PROP_0,
+        PROP_CONTROL,
+        PROP_ORIENTATION,
+        PROP_SHOW_ICONS,
+        PROP_SHOW_MUTE,
+        PROP_SHOW_MARKS,
+        PROP_SHOW_MARK_TEXT,
+        PROP_EXTENDED,
+        PROP_NAME,
+        PROP_ICON_NAME,
+        PROP_LOW_ICON_NAME,
+        PROP_HIGH_ICON_NAME,
+        N_PROPERTIES
+};
+
+static GParamSpec *properties[N_PROPERTIES] = { NULL, };
+
+static gboolean on_scale_button_press_event   (GtkWidget          *widget,
+                                               GdkEventButton     *event,
+                                               GvcChannelBar      *bar);
+static gboolean on_scale_button_release_event (GtkWidget          *widget,
+                                               GdkEventButton     *event,
+                                               GvcChannelBar      *bar);
+static gboolean on_scale_scroll_event         (GtkWidget          *widget,
+                                               GdkEventScroll     *event,
+                                               GvcChannelBar      *bar);
+
+G_DEFINE_TYPE_WITH_PRIVATE (GvcChannelBar, gvc_channel_bar, 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
+create_scale_box (GvcChannelBar *bar)
+{
+        bar->priv->scale_box = gtk_box_new (bar->priv->orientation, 6);
+        bar->priv->start_box = gtk_box_new (bar->priv->orientation, 6);
+        bar->priv->end_box   = gtk_box_new (bar->priv->orientation, 6);
+        bar->priv->scale     = gtk_scale_new (bar->priv->orientation,
+                                              bar->priv->adjustment);
+        if (bar->priv->orientation == GTK_ORIENTATION_VERTICAL) {
+                gtk_widget_set_size_request (bar->priv->scale, -1, SCALE_SIZE);
+
+                gtk_range_set_inverted (GTK_RANGE (bar->priv->scale), TRUE);
+
+                gtk_box_pack_start (GTK_BOX (bar->priv->scale_box),
+                                    bar->priv->start_box,
+                                    FALSE, FALSE, 0);
+
+                gtk_box_pack_start (GTK_BOX (bar->priv->start_box),
+                                    bar->priv->image,
+                                    FALSE, FALSE, 0);
+                gtk_box_pack_start (GTK_BOX (bar->priv->start_box),
+                                    bar->priv->label,
+                                    FALSE, FALSE, 0);
+                gtk_box_pack_start (GTK_BOX (bar->priv->start_box),
+                                    bar->priv->high_image,
+                                    FALSE, FALSE, 0);
+
+                gtk_box_pack_start (GTK_BOX (bar->priv->scale_box),
+                                    bar->priv->scale,
+                                    TRUE, TRUE, 0);
+                gtk_box_pack_start (GTK_BOX (bar->priv->scale_box),
+                                    bar->priv->end_box,
+                                    FALSE, FALSE, 0);
+
+                gtk_box_pack_start (GTK_BOX (bar->priv->end_box),
+                                    bar->priv->low_image,
+                                    FALSE, FALSE, 0);
+                gtk_box_pack_start (GTK_BOX (bar->priv->end_box),
+                                    bar->priv->mute_button,
+                                    FALSE, FALSE, 0);
+        } else {
+                gtk_widget_set_size_request (bar->priv->scale, SCALE_SIZE, -1);
+
+                gtk_box_pack_start (GTK_BOX (bar->priv->scale_box),
+                                    bar->priv->image,
+                                    FALSE, FALSE, 0);
+                gtk_box_pack_start (GTK_BOX (bar->priv->scale_box),
+                                    bar->priv->start_box,
+                                    FALSE, FALSE, 0);
+
+                gtk_box_pack_end (GTK_BOX (bar->priv->start_box),
+                                  bar->priv->low_image,
+                                  FALSE, FALSE, 0);
+
+                gtk_box_pack_start (GTK_BOX (bar->priv->start_box),
+                                    bar->priv->label,
+                                    TRUE, TRUE, 0);
+
+                gtk_box_pack_start (GTK_BOX (bar->priv->scale_box),
+                                    bar->priv->scale,
+                                    TRUE, TRUE, 0);
+                gtk_box_pack_start (GTK_BOX (bar->priv->scale_box),
+                                    bar->priv->end_box,
+                                    FALSE, FALSE, 0);
+
+                gtk_box_pack_start (GTK_BOX (bar->priv->end_box),
+                                    bar->priv->high_image,
+                                    FALSE, FALSE, 0);
+                gtk_box_pack_start (GTK_BOX (bar->priv->end_box),
+                                    bar->priv->mute_button,
+                                    FALSE, FALSE, 0);
+        }
+
+        if (bar->priv->show_icons) {
+                gtk_widget_show (bar->priv->low_image);
+                gtk_widget_show (bar->priv->high_image);
+        } else {
+                gtk_widget_hide (bar->priv->low_image);
+                gtk_widget_hide (bar->priv->high_image);
+        }
+
+        ca_gtk_widget_disable_sounds (bar->priv->scale, FALSE);
+
+        gtk_widget_add_events (bar->priv->scale, GDK_SCROLL_MASK);
+
+        g_signal_connect (G_OBJECT (bar->priv->scale),
+                          "button-press-event",
+                          G_CALLBACK (on_scale_button_press_event),
+                          bar);
+        g_signal_connect (G_OBJECT (bar->priv->scale),
+                          "button-release-event",
+                          G_CALLBACK (on_scale_button_release_event),
+                          bar);
+        g_signal_connect (G_OBJECT (bar->priv->scale),
+                          "scroll-event",
+                          G_CALLBACK (on_scale_scroll_event),
+                          bar);
+
+        if (bar->priv->size_group != NULL) {
+                gtk_size_group_add_widget (bar->priv->size_group,
+                                           bar->priv->start_box);
+
+                if (bar->priv->symmetric)
+                        gtk_size_group_add_widget (bar->priv->size_group,
+                                                   bar->priv->end_box);
+        }
+
+        gtk_scale_set_draw_value (GTK_SCALE (bar->priv->scale), FALSE);
+}
+
+static void
+on_adjustment_value_changed (GtkAdjustment *adjustment,
+                             GvcChannelBar *bar)
+{
+        gdouble value;
+        gdouble lower;
+
+        if (bar->priv->control == NULL || bar->priv->click_lock == TRUE)
+                return;
+
+        value = gtk_adjustment_get_value (bar->priv->adjustment);
+        lower = gtk_adjustment_get_lower (bar->priv->adjustment);
+
+        if (bar->priv->control_flags & MATE_MIXER_STREAM_CONTROL_MUTE_WRITABLE)
+                mate_mixer_stream_control_set_mute (bar->priv->control, (value <= lower));
+
+        if (bar->priv->control_flags & MATE_MIXER_STREAM_CONTROL_VOLUME_WRITABLE)
+                mate_mixer_stream_control_set_volume (bar->priv->control, (guint) value);
+}
+
+static void
+on_mute_button_toggled (GtkToggleButton *button, GvcChannelBar *bar)
+{
+        gboolean mute;
+
+        mute = gtk_toggle_button_get_active (button);
+
+        mate_mixer_stream_control_set_mute (bar->priv->control, mute);
+}
+
+static void
+update_layout (GvcChannelBar *bar)
+{
+        GtkWidget *frame;
+
+        if (bar->priv->scale == NULL)
+                return;
+
+        frame = gtk_widget_get_parent (bar->priv->scale_box);
+
+        g_object_ref (bar->priv->image);
+        g_object_ref (bar->priv->label);
+        g_object_ref (bar->priv->mute_button);
+        g_object_ref (bar->priv->low_image);
+        g_object_ref (bar->priv->high_image);
+
+        // XXX this is not the opposite of what is done above
+        gtk_container_remove (GTK_CONTAINER (bar->priv->start_box),
+                              bar->priv->image);
+        gtk_container_remove (GTK_CONTAINER (bar->priv->start_box),
+                              bar->priv->label);
+        gtk_container_remove (GTK_CONTAINER (bar->priv->end_box),
+                              bar->priv->mute_button);
+
+        if (bar->priv->orientation == GTK_ORIENTATION_VERTICAL) {
+                gtk_container_remove (GTK_CONTAINER (bar->priv->start_box),
+                                      bar->priv->low_image);
+                gtk_container_remove (GTK_CONTAINER (bar->priv->end_box),
+                                      bar->priv->high_image);
+        } else {
+                gtk_container_remove (GTK_CONTAINER (bar->priv->end_box),
+                                      bar->priv->low_image);
+                gtk_container_remove (GTK_CONTAINER (bar->priv->start_box),
+                                      bar->priv->high_image);
+        }
+
+        gtk_container_remove (GTK_CONTAINER (bar->priv->scale_box),
+                              bar->priv->start_box);
+        gtk_container_remove (GTK_CONTAINER (bar->priv->scale_box),
+                              bar->priv->scale);
+        gtk_container_remove (GTK_CONTAINER (bar->priv->scale_box),
+                              bar->priv->end_box);
+        gtk_container_remove (GTK_CONTAINER (frame),
+                              bar->priv->scale_box);
+
+        create_scale_box (bar);
+        gtk_container_add (GTK_CONTAINER (frame), bar->priv->scale_box);
+
+        g_object_unref (bar->priv->image);
+        g_object_unref (bar->priv->label);
+        g_object_unref (bar->priv->mute_button);
+        g_object_unref (bar->priv->low_image);
+        g_object_unref (bar->priv->high_image);
+
+        gtk_widget_show_all (frame);
+}
+
+static void
+update_scale_size (GvcChannelBar *bar)
+{
+        gdouble normal_volume;
+        gdouble maximum_volume;
+        int     calculated_scale_size = SCALE_SIZE;
+
+        if (bar->priv->extended && bar->priv->control != NULL)
+        {
+                normal_volume = mate_mixer_stream_control_get_normal_volume (bar->priv->control);
+                maximum_volume = mate_mixer_stream_control_get_max_volume (bar->priv->control);
+                calculated_scale_size = (maximum_volume / normal_volume) * SCALE_SIZE;
+        }
+
+        if (bar->priv->orientation == GTK_ORIENTATION_VERTICAL)
+                gtk_widget_set_size_request (bar->priv->scale,
+                                             -1, calculated_scale_size);
+        else
+                gtk_widget_set_size_request (bar->priv->scale,
+                                             calculated_scale_size, -1);
+}
+
+static void
+update_marks (GvcChannelBar *bar)
+{
+        gdouble  base;
+        gdouble  normal;
+        gboolean has_mark = FALSE;
+
+        gtk_scale_clear_marks (GTK_SCALE (bar->priv->scale));
+
+        if (bar->priv->control == NULL || bar->priv->show_marks == FALSE)
+                return;
+
+        /* Base volume represents unamplified volume, normal volume is the 100%
+         * volume, in many cases they are the same as unamplified volume is unknown */
+        base   = mate_mixer_stream_control_get_base_volume (bar->priv->control);
+        normal = mate_mixer_stream_control_get_normal_volume (bar->priv->control);
+
+        if (normal <= gtk_adjustment_get_lower (bar->priv->adjustment))
+                return;
+
+        if (base < normal) {
+                gchar *str = NULL;
+
+                if (bar->priv->show_mark_text)
+                        str = g_strdup_printf ("<small>%s</small>",
+                                               C_("volume", "Unamplified"));
+
+                gtk_scale_add_mark (GTK_SCALE (bar->priv->scale),
+                                    base,
+                                    GTK_POS_BOTTOM,
+                                    str);
+                has_mark = TRUE;
+                g_free (str);
+        }
+
+        /* Only show 100% mark if the scale is extended beyond 100% and
+         * there is no unamplified mark or it is below the normal volume */
+        if (bar->priv->extended && (base == normal || base < normal)) {
+                gchar *str = NULL;
+
+                if (bar->priv->show_mark_text)
+                        str = g_strdup_printf ("<small>%s</small>",
+                                               C_("volume", "100%"));
+
+                gtk_scale_add_mark (GTK_SCALE (bar->priv->scale),
+                                    normal,
+                                    GTK_POS_BOTTOM,
+                                    str);
+                has_mark = TRUE;
+                g_free (str);
+        }
+
+        if (has_mark) {
+                gtk_widget_set_valign (bar->priv->mute_button, GTK_ALIGN_START);
+
+                gtk_widget_set_halign (bar->priv->low_image, GTK_ALIGN_CENTER);
+                gtk_widget_set_valign (bar->priv->low_image, GTK_ALIGN_START);
+                gtk_widget_set_halign (bar->priv->high_image, GTK_ALIGN_CENTER);
+                gtk_widget_set_valign (bar->priv->high_image, GTK_ALIGN_START);
+
+                gtk_label_set_xalign (GTK_LABEL (bar->priv->label), 0.0);
+                gtk_label_set_yalign (GTK_LABEL (bar->priv->label), 0.0);
+        } else {
+                gtk_widget_set_halign (bar->priv->low_image, GTK_ALIGN_CENTER);
+                gtk_widget_set_valign (bar->priv->low_image, GTK_ALIGN_CENTER);
+                gtk_widget_set_halign (bar->priv->high_image, GTK_ALIGN_CENTER);
+                gtk_widget_set_valign (bar->priv->high_image, GTK_ALIGN_CENTER);
+
+                gtk_label_set_xalign (GTK_LABEL (bar->priv->label), 0.0);
+                gtk_label_set_yalign (GTK_LABEL (bar->priv->label), 0.5);
+        }
+}
+
+static void
+update_adjustment_value (GvcChannelBar *bar)
+{
+        gdouble  value;
+        gboolean set_lower = FALSE;
+
+        /* Move the slider to the minimal value if the stream control is muted or
+         * volume is unavailable */
+        if (bar->priv->control == NULL)
+                set_lower = TRUE;
+        else if (bar->priv->control_flags & MATE_MIXER_STREAM_CONTROL_MUTE_READABLE)
+                set_lower = mate_mixer_stream_control_get_mute (bar->priv->control);
+
+        if (set_lower == TRUE)
+                value = gtk_adjustment_get_lower (bar->priv->adjustment);
+        else
+                value = mate_mixer_stream_control_get_volume (bar->priv->control);
+
+        g_signal_handlers_block_by_func (G_OBJECT (bar->priv->adjustment),
+                                         on_adjustment_value_changed,
+                                         bar);
+
+        gtk_adjustment_set_value (bar->priv->adjustment, value);
+
+        g_signal_handlers_unblock_by_func (G_OBJECT (bar->priv->adjustment),
+                                           on_adjustment_value_changed,
+                                           bar);
+}
+
+static void
+update_adjustment_limits (GvcChannelBar *bar)
+{
+        gdouble minimum = 0.0;
+        gdouble maximum = 0.0;
+
+        if (bar->priv->control != NULL) {
+                minimum = mate_mixer_stream_control_get_min_volume (bar->priv->control);
+                if (bar->priv->extended)
+                        maximum = mate_mixer_stream_control_get_max_volume (bar->priv->control);
+                else
+                        maximum = mate_mixer_stream_control_get_normal_volume (bar->priv->control);
+        }
+
+        gtk_adjustment_configure (bar->priv->adjustment,
+                                  gtk_adjustment_get_value (bar->priv->adjustment),
+                                  minimum,
+                                  maximum,
+                                  (maximum - minimum) / 100.0,
+                                  (maximum - minimum) / 15.0,
+                                  0.0);
+}
+
+static void
+update_mute_button (GvcChannelBar *bar)
+{
+        if (bar->priv->show_mute == TRUE) {
+                gboolean enable = FALSE;
+
+                if (bar->priv->control != NULL &&
+                    bar->priv->control_flags & MATE_MIXER_STREAM_CONTROL_MUTE_READABLE)
+                        enable = TRUE;
+
+                if (enable == TRUE) {
+                        gboolean mute = mate_mixer_stream_control_get_mute (bar->priv->control);
+
+                        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (bar->priv->mute_button),
+                                                      mute);
+                } else {
+                        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (bar->priv->mute_button),
+                                                      FALSE);
+                }
+
+                gtk_widget_set_sensitive (bar->priv->mute_button, enable);
+                gtk_widget_show (bar->priv->mute_button);
+        } else
+                gtk_widget_hide (bar->priv->mute_button);
+}
+
+static gboolean
+on_scale_button_press_event (GtkWidget      *widget,
+                             GdkEventButton *event,
+                             GvcChannelBar  *bar)
+{
+        /* Muting the stream when volume is non-zero moves the slider to zero,
+         * but the volume remains the same. In this case delay unmuting and
+         * changing volume until user releases the mouse button. */
+        if (bar->priv->control_flags & MATE_MIXER_STREAM_CONTROL_MUTE_READABLE &&
+            bar->priv->control_flags & MATE_MIXER_STREAM_CONTROL_VOLUME_READABLE) {
+                if (mate_mixer_stream_control_get_mute (bar->priv->control) == TRUE) {
+                        guint minimum = (guint) gtk_adjustment_get_lower (bar->priv->adjustment);
+
+                        if (mate_mixer_stream_control_get_volume (bar->priv->control) > minimum)
+                                bar->priv->click_lock = TRUE;
+                }
+        }
+        return FALSE;
+}
+
+static gboolean
+on_scale_button_release_event (GtkWidget      *widget,
+                               GdkEventButton *event,
+                               GvcChannelBar  *bar)
+{
+        if (bar->priv->click_lock == TRUE) {
+                /* The volume change is not reflected while the lock is
+                 * held, propagate the change now that user has released
+                 * the mouse button */
+                bar->priv->click_lock = FALSE;
+                on_adjustment_value_changed (bar->priv->adjustment, bar);
+        }
+
+        /* Play a sound */
+        ca_gtk_play_for_widget (GTK_WIDGET (bar), 0,
+                                CA_PROP_EVENT_ID, "audio-volume-change",
+                                CA_PROP_EVENT_DESCRIPTION, "Volume change",
+                                CA_PROP_APPLICATION_ID, "org.mate.VolumeControl",
+                                CA_PROP_APPLICATION_NAME, _("Volume Control"),
+                                CA_PROP_APPLICATION_VERSION, VERSION,
+                                CA_PROP_APPLICATION_ICON_NAME, "multimedia-volume-control",
+                                NULL);
+        return FALSE;
+}
+
+static gboolean
+on_scale_scroll_event (GtkWidget      *widget,
+                       GdkEventScroll *event,
+                       GvcChannelBar  *bar)
+{
+        GdkScrollDirection direction = event->direction;
+
+        if (direction == GDK_SCROLL_SMOOTH) {
+                gdouble dx = 0.0;
+                gdouble dy = 0.0;
+
+                gdk_event_get_scroll_deltas ((const GdkEvent *) event, &dx, &dy);
+                if (dy > 0.0)
+                        direction = GDK_SCROLL_DOWN;
+                else if (dy < 0.0)
+                        direction = GDK_SCROLL_UP;
+                else
+                        return FALSE;
+        }
+
+        return gvc_channel_bar_scroll (bar, direction);
+}
+
+static void
+on_control_volume_notify (MateMixerStreamControl *control,
+                          GParamSpec             *pspec,
+                          GvcChannelBar          *bar)
+{
+        update_adjustment_value (bar);
+}
+
+static void
+on_control_mute_notify (MateMixerStreamControl *control,
+                        GParamSpec             *pspec,
+                        GvcChannelBar          *bar)
+{
+        if (bar->priv->show_mute == TRUE) {
+                gboolean mute = mate_mixer_stream_control_get_mute (control);
+
+                g_signal_handlers_block_by_func (G_OBJECT (bar->priv->mute_button),
+                                                 on_mute_button_toggled,
+                                                 bar);
+
+                gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (bar->priv->mute_button), mute);
+
+                g_signal_handlers_unblock_by_func (G_OBJECT (bar->priv->mute_button),
+                                                   on_mute_button_toggled,
+                                                   bar);
+        }
+        update_adjustment_value (bar);
+}
+
+MateMixerStreamControl *
+gvc_channel_bar_get_control (GvcChannelBar *bar)
+{
+        g_return_val_if_fail (GVC_IS_CHANNEL_BAR (bar), NULL);
+
+        return bar->priv->control;
+}
+
+void
+gvc_channel_bar_set_control (GvcChannelBar *bar, MateMixerStreamControl *control)
+{
+        g_return_if_fail (GVC_IS_CHANNEL_BAR (bar));
+
+        if (bar->priv->control == control)
+                return;
+
+        if (control != NULL)
+                g_object_ref (control);
+
+        if (bar->priv->control != NULL) {
+                g_signal_handlers_disconnect_by_func (G_OBJECT (bar->priv->control),
+                                                      G_CALLBACK (on_control_volume_notify),
+                                                      bar);
+                g_signal_handlers_disconnect_by_func (G_OBJECT (bar->priv->control),
+                                                      G_CALLBACK (on_control_mute_notify),
+                                                      bar);
+                g_object_unref (bar->priv->control);
+        }
+
+        bar->priv->control = control;
+
+        if (control != NULL)
+                bar->priv->control_flags = mate_mixer_stream_control_get_flags (control);
+        else
+                bar->priv->control_flags = MATE_MIXER_STREAM_CONTROL_NO_FLAGS;
+
+        if (bar->priv->control_flags & MATE_MIXER_STREAM_CONTROL_VOLUME_READABLE)
+                g_signal_connect (G_OBJECT (control),
+                                  "notify::volume",
+                                  G_CALLBACK (on_control_volume_notify),
+                                  bar);
+        if (bar->priv->control_flags & MATE_MIXER_STREAM_CONTROL_MUTE_READABLE)
+                g_signal_connect (G_OBJECT (control),
+                                  "notify::mute",
+                                  G_CALLBACK (on_control_mute_notify),
+                                  bar);
+
+        update_marks (bar);
+        update_mute_button (bar);
+        update_adjustment_limits (bar);
+        update_adjustment_value (bar);
+        update_scale_size (bar);
+}
+
+GtkOrientation
+gvc_channel_bar_get_orientation (GvcChannelBar *bar)
+{
+        g_return_val_if_fail (GVC_IS_CHANNEL_BAR (bar), 0);
+
+        return bar->priv->orientation;
+}
+
+void
+gvc_channel_bar_set_orientation (GvcChannelBar  *bar,
+                                 GtkOrientation  orientation)
+{
+        g_return_if_fail (GVC_IS_CHANNEL_BAR (bar));
+
+        if (orientation == bar->priv->orientation)
+                return;
+
+        bar->priv->orientation = orientation;
+        update_layout (bar);
+
+        g_object_notify_by_pspec (G_OBJECT (bar), properties[PROP_ORIENTATION]);
+}
+
+gboolean
+gvc_channel_bar_get_show_icons (GvcChannelBar *bar)
+{
+        g_return_val_if_fail (GVC_IS_CHANNEL_BAR (bar), FALSE);
+
+        return bar->priv->show_icons;
+}
+
+void
+gvc_channel_bar_set_show_icons (GvcChannelBar *bar, gboolean show_icons)
+{
+        g_return_if_fail (GVC_IS_CHANNEL_BAR (bar));
+
+        if (show_icons == bar->priv->show_icons)
+                return;
+
+        bar->priv->show_icons = show_icons;
+
+        if (bar->priv->show_icons == TRUE) {
+                gtk_widget_show (bar->priv->low_image);
+                gtk_widget_show (bar->priv->high_image);
+        } else {
+                gtk_widget_hide (bar->priv->low_image);
+                gtk_widget_hide (bar->priv->high_image);
+        }
+
+        g_object_notify_by_pspec (G_OBJECT (bar), properties[PROP_SHOW_ICONS]);
+}
+
+gboolean
+gvc_channel_bar_get_show_mute (GvcChannelBar *bar)
+{
+        g_return_val_if_fail (GVC_IS_CHANNEL_BAR (bar), FALSE);
+
+        return bar->priv->show_mute;
+}
+
+void
+gvc_channel_bar_set_show_mute (GvcChannelBar *bar, gboolean show_mute)
+{
+        g_return_if_fail (GVC_IS_CHANNEL_BAR (bar));
+
+        if (show_mute == bar->priv->show_mute)
+                return;
+
+        bar->priv->show_mute = show_mute;
+        update_mute_button (bar);
+
+        g_object_notify_by_pspec (G_OBJECT (bar), properties[PROP_SHOW_MUTE]);
+}
+
+gboolean
+gvc_channel_bar_get_show_marks (GvcChannelBar *bar)
+{
+        g_return_val_if_fail (GVC_IS_CHANNEL_BAR (bar), FALSE);
+
+        return bar->priv->show_marks;
+}
+
+void
+gvc_channel_bar_set_show_marks (GvcChannelBar *bar, gboolean show_marks)
+{
+        g_return_if_fail (GVC_IS_CHANNEL_BAR (bar));
+
+        if (show_marks == bar->priv->show_marks)
+                return;
+
+        bar->priv->show_marks = show_marks;
+        update_marks (bar);
+
+        g_object_notify_by_pspec (G_OBJECT (bar), properties[PROP_SHOW_MARKS]);
+}
+
+gboolean
+gvc_channel_bar_get_show_mark_text (GvcChannelBar *bar)
+{
+        g_return_val_if_fail (GVC_IS_CHANNEL_BAR (bar), FALSE);
+
+        return bar->priv->show_mark_text;
+}
+
+void
+gvc_channel_bar_set_show_mark_text (GvcChannelBar *bar, gboolean show_mark_text)
+{
+        g_return_if_fail (GVC_IS_CHANNEL_BAR (bar));
+
+        if (show_mark_text == bar->priv->show_mark_text)
+                return;
+
+        bar->priv->show_mark_text = show_mark_text;
+        update_marks (bar);
+
+        g_object_notify_by_pspec (G_OBJECT (bar), properties[PROP_SHOW_MARK_TEXT]);
+}
+
+gboolean
+gvc_channel_bar_get_extended (GvcChannelBar *bar)
+{
+        g_return_val_if_fail (GVC_IS_CHANNEL_BAR (bar), FALSE);
+
+        return bar->priv->extended;
+}
+
+void
+gvc_channel_bar_set_extended (GvcChannelBar *bar, gboolean extended)
+{
+        g_return_if_fail (GVC_IS_CHANNEL_BAR (bar));
+
+        if (extended == bar->priv->extended)
+                return;
+
+        bar->priv->extended = extended;
+
+        /* Update displayed marks as non-extended scales do not show the 100%
+         * limit at the end of the scale */
+        update_marks (bar);
+        update_adjustment_limits (bar);
+        update_scale_size (bar);
+
+        g_object_notify_by_pspec (G_OBJECT (bar), properties[PROP_EXTENDED]);
+}
+
+const gchar *
+gvc_channel_bar_get_name (GvcChannelBar *bar)
+{
+        g_return_val_if_fail (GVC_IS_CHANNEL_BAR (bar), NULL);
+
+        return gtk_label_get_text (GTK_LABEL (bar->priv->label));
+}
+
+void
+gvc_channel_bar_set_name (GvcChannelBar *bar, const gchar *name)
+{
+        g_return_if_fail (GVC_IS_CHANNEL_BAR (bar));
+
+        if (name != NULL) {
+                gtk_label_set_text_with_mnemonic (GTK_LABEL (bar->priv->label), name);
+                gtk_label_set_mnemonic_widget (GTK_LABEL (bar->priv->label),
+                                               bar->priv->scale);
+
+                gtk_widget_show (bar->priv->label);
+        } else {
+                gtk_label_set_text (GTK_LABEL (bar->priv->label), NULL);
+                gtk_widget_hide (bar->priv->label);
+        }
+
+        g_object_notify_by_pspec (G_OBJECT (bar), properties[PROP_NAME]);
+}
+
+const gchar *
+gvc_channel_bar_get_icon_name (GvcChannelBar *bar)
+{
+        const gchar *name = NULL;
+
+        g_return_val_if_fail (GVC_IS_CHANNEL_BAR (bar), NULL);
+
+        gtk_image_get_icon_name (GTK_IMAGE (bar->priv->image), &name, NULL);
+        return name;
+}
+
+void
+gvc_channel_bar_set_icon_name (GvcChannelBar *bar, const gchar *name)
+{
+        g_return_if_fail (GVC_IS_CHANNEL_BAR (bar));
+
+        if (name != NULL) {
+                GtkIconTheme *icon_theme;
+                GdkPixbuf *pixbuf;
+                gint width, height;
+                GError *error = NULL;
+
+                gtk_icon_size_lookup (GTK_ICON_SIZE_DIALOG, &width, &height);
+                icon_theme = gtk_icon_theme_get_default ();
+                pixbuf = gtk_icon_theme_load_icon (icon_theme,
+                                                   name,
+                                                   width,
+                                                   GTK_ICON_LOOKUP_GENERIC_FALLBACK | GTK_ICON_LOOKUP_FORCE_SIZE,
+                                                   &error);
+                if (error != NULL) {
+                        g_warning ("Couldn’t load icon: %s\n", error->message);
+                        g_clear_error (&error);
+                }
+
+                if (pixbuf == NULL) {
+                        pixbuf = gdk_pixbuf_new_from_file_at_scale (name, width, height, TRUE, &error);
+                        if (error != NULL)
+                        {
+                                g_warning ("Couldn’t load icon: %s\n", error->message);
+                                g_clear_error (&error);
+                        }
+                }
+
+                if (pixbuf) {
+                        gtk_image_set_from_pixbuf (GTK_IMAGE (bar->priv->image), pixbuf);
+                        gtk_widget_show (bar->priv->image);
+                        g_object_unref (pixbuf);
+                }
+        } else {
+                gtk_widget_hide (bar->priv->image);
+        }
+
+        g_object_notify_by_pspec (G_OBJECT (bar), properties[PROP_ICON_NAME]);
+}
+
+const gchar *
+gvc_channel_bar_get_low_icon_name (GvcChannelBar *bar)
+{
+        const gchar *name = NULL;
+
+        g_return_val_if_fail (GVC_IS_CHANNEL_BAR (bar), NULL);
+
+        gtk_image_get_icon_name (GTK_IMAGE (bar->priv->low_image), &name, NULL);
+        return name;
+}
+
+void
+gvc_channel_bar_set_low_icon_name (GvcChannelBar *bar, const gchar *name)
+{
+        g_return_if_fail (GVC_IS_CHANNEL_BAR (bar));
+
+        gtk_image_set_from_icon_name (GTK_IMAGE (bar->priv->low_image),
+                                      name,
+                                      GTK_ICON_SIZE_BUTTON);
+
+        g_object_notify_by_pspec (G_OBJECT (bar), properties[PROP_LOW_ICON_NAME]);
+}
+
+const gchar *
+gvc_channel_bar_get_high_icon_name (GvcChannelBar *bar)
+{
+        const gchar *name = NULL;
+
+        g_return_val_if_fail (GVC_IS_CHANNEL_BAR (bar), NULL);
+
+        gtk_image_get_icon_name (GTK_IMAGE (bar->priv->high_image), &name, NULL);
+        return name;
+}
+
+void
+gvc_channel_bar_set_high_icon_name (GvcChannelBar *bar, const gchar *name)
+{
+        g_return_if_fail (GVC_IS_CHANNEL_BAR (bar));
+
+        gtk_image_set_from_icon_name (GTK_IMAGE (bar->priv->high_image),
+                                      name,
+                                      GTK_ICON_SIZE_BUTTON);
+
+        g_object_notify_by_pspec (G_OBJECT (bar), properties[PROP_HIGH_ICON_NAME]);
+}
+
+gboolean
+gvc_channel_bar_scroll (GvcChannelBar *bar, GdkScrollDirection direction)
+{
+        gdouble value;
+        gdouble minimum;
+        gdouble maximum;
+        gdouble scrollstep;
+        GSettings *settings;
+
+        g_return_val_if_fail (GVC_IS_CHANNEL_BAR (bar), FALSE);
+
+        if (bar->priv->orientation == GTK_ORIENTATION_VERTICAL) {
+                if (direction != GDK_SCROLL_UP && direction != GDK_SCROLL_DOWN)
+                        return FALSE;
+        } else {
+                /* Switch direction for RTL */
+                if (gtk_widget_get_direction (GTK_WIDGET (bar)) == GTK_TEXT_DIR_RTL) {
+                        if (direction == GDK_SCROLL_RIGHT)
+                                direction = GDK_SCROLL_LEFT;
+                        else if (direction == GDK_SCROLL_LEFT)
+                                direction = GDK_SCROLL_RIGHT;
+                }
+
+                /* Switch side scroll to vertical */
+                if (direction == GDK_SCROLL_RIGHT)
+                        direction = GDK_SCROLL_UP;
+                else if (direction == GDK_SCROLL_LEFT)
+                        direction = GDK_SCROLL_DOWN;
+        }
+
+        value   = gtk_adjustment_get_value (bar->priv->adjustment);
+        minimum = gtk_adjustment_get_lower (bar->priv->adjustment);
+        maximum = gtk_adjustment_get_upper (bar->priv->adjustment);
+
+        /* Use the same setting for `scrollstep` as used by the media keys plugin */
+        settings = g_settings_new ("org.mate.SettingsDaemon.plugins.media-keys");
+        scrollstep = g_settings_get_int (settings, "volume-step");
+        if (scrollstep <= 0 || scrollstep > 100) {
+                GVariant *variant = g_settings_get_default_value (settings, "volume-step");
+                scrollstep = g_variant_get_int32 (variant);
+                g_variant_unref (variant);
+        }
+        g_object_unref (settings);
+
+        /* Scale the volume step size accordingly to the range used by the control */
+        scrollstep = (maximum - minimum) * scrollstep / 100;
+
+        if (direction == GDK_SCROLL_UP) {
+                value = MIN (value + scrollstep, maximum);
+        } else if (direction == GDK_SCROLL_DOWN) {
+                value = MAX (value - scrollstep, minimum);
+        }
+
+        gtk_adjustment_set_value (bar->priv->adjustment, value);
+
+        return TRUE;
+}
+
+void
+gvc_channel_bar_set_size_group (GvcChannelBar *bar,
+                                GtkSizeGroup  *group,
+                                gboolean       symmetric)
+{
+        g_return_if_fail (GVC_IS_CHANNEL_BAR (bar));
+        g_return_if_fail (GTK_IS_SIZE_GROUP (group));
+
+        bar->priv->size_group = group;
+        bar->priv->symmetric = symmetric;
+
+        if (bar->priv->size_group != NULL) {
+                gtk_size_group_add_widget (bar->priv->size_group,
+                                           bar->priv->start_box);
+
+                if (bar->priv->symmetric)
+                        gtk_size_group_add_widget (bar->priv->size_group,
+                                                   bar->priv->end_box);
+        }
+        gtk_widget_queue_draw (GTK_WIDGET (bar));
+}
+
+static void
+gvc_channel_bar_set_property (GObject       *object,
+                              guint          prop_id,
+                              const GValue  *value,
+                              GParamSpec    *pspec)
+{
+        GvcChannelBar *self = GVC_CHANNEL_BAR (object);
+
+        switch (prop_id) {
+        case PROP_CONTROL:
+                gvc_channel_bar_set_control (self, g_value_get_object (value));
+                break;
+        case PROP_ORIENTATION:
+                gvc_channel_bar_set_orientation (self, g_value_get_enum (value));
+                break;
+        case PROP_SHOW_MUTE:
+                gvc_channel_bar_set_show_mute (self, g_value_get_boolean (value));
+                break;
+        case PROP_SHOW_ICONS:
+                gvc_channel_bar_set_show_icons (self, g_value_get_boolean (value));
+                break;
+        case PROP_SHOW_MARKS:
+                gvc_channel_bar_set_show_marks (self, g_value_get_boolean (value));
+                break;
+        case PROP_SHOW_MARK_TEXT:
+                gvc_channel_bar_set_show_mark_text (self, g_value_get_boolean (value));
+                break;
+        case PROP_EXTENDED:
+                gvc_channel_bar_set_extended (self, g_value_get_boolean (value));
+                break;
+        case PROP_NAME:
+                gvc_channel_bar_set_name (self, g_value_get_string (value));
+                break;
+        case PROP_ICON_NAME:
+                gvc_channel_bar_set_icon_name (self, g_value_get_string (value));
+                break;
+        case PROP_LOW_ICON_NAME:
+                gvc_channel_bar_set_low_icon_name (self, g_value_get_string (value));
+                break;
+        case PROP_HIGH_ICON_NAME:
+                gvc_channel_bar_set_high_icon_name (self, g_value_get_string (value));
+                break;
+        default:
+                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+                break;
+        }
+}
+
+static void
+gvc_channel_bar_get_property (GObject     *object,
+                              guint        prop_id,
+                              GValue      *value,
+                              GParamSpec  *pspec)
+{
+        GvcChannelBar *self = GVC_CHANNEL_BAR (object);
+
+        switch (prop_id) {
+        case PROP_CONTROL:
+                g_value_set_object (value, self->priv->control);
+                break;
+        case PROP_ORIENTATION:
+                g_value_set_enum (value, self->priv->orientation);
+                break;
+        case PROP_SHOW_MUTE:
+                g_value_set_boolean (value, self->priv->show_mute);
+                break;
+        case PROP_SHOW_ICONS:
+                g_value_set_boolean (value, self->priv->show_icons);
+                break;
+        case PROP_SHOW_MARKS:
+                g_value_set_boolean (value, self->priv->show_marks);
+                break;
+        case PROP_SHOW_MARK_TEXT:
+                g_value_set_boolean (value, self->priv->show_mark_text);
+                break;
+        case PROP_EXTENDED:
+                g_value_set_boolean (value, self->priv->extended);
+                break;
+        case PROP_NAME:
+                g_value_set_string (value, gtk_label_get_text (GTK_LABEL (self->priv->label)));
+                break;
+        default:
+                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+                break;
+        }
+}
+
+static void
+gvc_channel_bar_class_init (GvcChannelBarClass *klass)
+{
+        GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+        object_class->set_property = gvc_channel_bar_set_property;
+        object_class->get_property = gvc_channel_bar_get_property;
+
+        properties[PROP_CONTROL] =
+                g_param_spec_object ("control",
+                                     "Control",
+                                     "MateMixer stream control",
+                                     MATE_MIXER_TYPE_STREAM_CONTROL,
+                                     G_PARAM_READWRITE |
+                                     G_PARAM_CONSTRUCT |
+                                     G_PARAM_STATIC_STRINGS);
+
+        properties[PROP_ORIENTATION] =
+                g_param_spec_enum ("orientation",
+                                   "Orientation",
+                                   "The orientation of the scale",
+                                   GTK_TYPE_ORIENTATION,
+                                   GTK_ORIENTATION_VERTICAL,
+                                   G_PARAM_READWRITE |
+                                   G_PARAM_STATIC_STRINGS);
+
+        properties[PROP_SHOW_MUTE] =
+                g_param_spec_boolean ("show-mute",
+                                      "show mute",
+                                      "Whether stream is muted",
+                                      FALSE,
+                                      G_PARAM_READWRITE |
+                                      G_PARAM_CONSTRUCT |
+                                      G_PARAM_STATIC_STRINGS);
+
+        properties[PROP_SHOW_ICONS] =
+                g_param_spec_boolean ("show-icons",
+                                      "show mute",
+                                      "Whether to show low and high icons",
+                                      FALSE,
+                                      G_PARAM_READWRITE |
+                                      G_PARAM_CONSTRUCT |
+                                      G_PARAM_STATIC_STRINGS);
+
+        properties[PROP_SHOW_MARKS] =
+                g_param_spec_boolean ("show-marks",
+                                      "Show marks",
+                                      "Whether to show scale marks",
+                                      FALSE,
+                                      G_PARAM_READWRITE |
+                                      G_PARAM_CONSTRUCT |
+                                      G_PARAM_STATIC_STRINGS);
+
+        properties[PROP_SHOW_MARK_TEXT] =
+                g_param_spec_boolean ("show-mark-text",
+                                      "Show mark-text",
+                                      "Whether to show a volume level label next to each scale mark",
+                                      TRUE,
+                                      G_PARAM_READWRITE |
+                                      G_PARAM_CONSTRUCT |
+                                      G_PARAM_STATIC_STRINGS);
+
+        properties[PROP_EXTENDED] =
+                g_param_spec_boolean ("extended",
+                                      "Extended",
+                                      "Allow the scale to be extended above normal volume",
+                                      FALSE,
+                                      G_PARAM_READWRITE |
+                                      G_PARAM_STATIC_STRINGS);
+
+        properties[PROP_NAME] =
+                g_param_spec_string ("name",
+                                     "Name",
+                                     "Name to display for this stream",
+                                     NULL,
+                                     G_PARAM_READWRITE |
+                                     G_PARAM_CONSTRUCT |
+                                     G_PARAM_STATIC_STRINGS);
+
+        properties[PROP_ICON_NAME] =
+                g_param_spec_string ("icon-name",
+                                     "Icon name",
+                                     "Name of icon to display for this stream",
+                                     NULL,
+                                     G_PARAM_WRITABLE |
+                                     G_PARAM_CONSTRUCT |
+                                     G_PARAM_STATIC_STRINGS);
+
+        properties[PROP_LOW_ICON_NAME] =
+                g_param_spec_string ("low-icon-name",
+                                     "Low icon name",
+                                     "Name of low volume icon to display for this stream",
+                                     "audio-volume-low",
+                                     G_PARAM_WRITABLE |
+                                     G_PARAM_CONSTRUCT |
+                                     G_PARAM_STATIC_STRINGS);
+
+        properties[PROP_HIGH_ICON_NAME] =
+                g_param_spec_string ("high-icon-name",
+                                     "High icon name",
+                                     "Name of high volume icon to display for this stream",
+                                     "audio-volume-high",
+                                     G_PARAM_WRITABLE |
+                                     G_PARAM_CONSTRUCT |
+                                     G_PARAM_STATIC_STRINGS);
+
+        g_object_class_install_properties (object_class, N_PROPERTIES, properties);
+}
+
+static void
+gvc_channel_bar_init (GvcChannelBar *bar)
+{
+        GtkWidget *frame;
+
+        bar->priv = gvc_channel_bar_get_instance_private (bar);
+
+        /* Mute button */
+        bar->priv->mute_button = gtk_check_button_new_with_label (_("Mute"));
+        gtk_widget_set_no_show_all (bar->priv->mute_button, TRUE);
+
+        g_signal_connect (bar->priv->mute_button,
+                          "toggled",
+                          G_CALLBACK (on_mute_button_toggled),
+                          bar);
+
+        bar->priv->image = gtk_image_new ();
+        gtk_widget_set_no_show_all (bar->priv->image, TRUE);
+
+        /* Low/high icons */
+        bar->priv->low_image = gtk_image_new ();
+        gtk_widget_set_no_show_all (bar->priv->low_image, TRUE);
+
+        bar->priv->high_image = gtk_image_new ();
+        gtk_widget_set_no_show_all (bar->priv->high_image, TRUE);
+
+        bar->priv->label = gtk_label_new (NULL);
+        gtk_label_set_xalign (GTK_LABEL (bar->priv->label), 0.0);
+        gtk_label_set_yalign (GTK_LABEL (bar->priv->label), 0.5);
+        gtk_widget_set_no_show_all (bar->priv->label, TRUE);
+
+        /* Frame */
+        frame = gtk_frame_new (NULL);
+        gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
+        gtk_box_pack_start (GTK_BOX (bar), frame, TRUE, TRUE, 0);
+
+        gtk_widget_show_all (frame);
+
+        /* Create a default adjustment */
+        bar->priv->adjustment = GTK_ADJUSTMENT (gtk_adjustment_new (0, 0, 0, 0, 0, 0));
+
+        g_object_ref_sink (bar->priv->adjustment);
+
+        g_signal_connect (bar->priv->adjustment,
+                          "value-changed",
+                          G_CALLBACK (on_adjustment_value_changed),
+                          bar);
+
+        /* Initially create a vertical scale box */
+        bar->priv->orientation = GTK_ORIENTATION_VERTICAL;
+
+        create_scale_box (bar);
+
+        gtk_container_add (GTK_CONTAINER (frame), bar->priv->scale_box);
+}
+
+GtkWidget *
+gvc_channel_bar_new (MateMixerStreamControl *control)
+{
+        return g_object_new (GVC_TYPE_CHANNEL_BAR,
+                             "control", control,
+                             "orientation", GTK_ORIENTATION_HORIZONTAL,
+                             NULL);
+}
+
+ +
+ +
+ + diff --git a/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/48.html b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/48.html new file mode 100644 index 0000000..ef9ff12 --- /dev/null +++ b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/48.html @@ -0,0 +1,467 @@ + + + + + + Cppcheck - HTML report - mate-media + + + + + +
+ + + +
+
  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
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 Red Hat, Inc.
+ * Copyright (C) 2014 Michal Ratajsky <michal.ratajsky@gmail.com>
+ * 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.
+ *
+ */
+
+#ifndef __GVC_CHANNEL_BAR_H
+#define __GVC_CHANNEL_BAR_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.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <libmatemixer/matemixer.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+G_BEGIN_DECLS
+
+#define GVC_TYPE_CHANNEL_BAR         (gvc_channel_bar_get_type ())
+#define GVC_CHANNEL_BAR(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), GVC_TYPE_CHANNEL_BAR, GvcChannelBar))
+#define GVC_CHANNEL_BAR_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST((k), GVC_TYPE_CHANNEL_BAR, GvcChannelBarClass))
+#define GVC_IS_CHANNEL_BAR(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), GVC_TYPE_CHANNEL_BAR))
+#define GVC_IS_CHANNEL_BAR_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), GVC_TYPE_CHANNEL_BAR))
+#define GVC_CHANNEL_BAR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GVC_TYPE_CHANNEL_BAR, GvcChannelBarClass))
+
+typedef struct _GvcChannelBar         GvcChannelBar;
+typedef struct _GvcChannelBarClass    GvcChannelBarClass;
+typedef struct _GvcChannelBarPrivate  GvcChannelBarPrivate;
+
+struct _GvcChannelBar
+{
+        GtkBox                parent;
+        GvcChannelBarPrivate *priv;
+};
+
+struct _GvcChannelBarClass
+{
+        GtkBoxClass           parent_class;
+
+        void (* changed) (GvcChannelBar *bar);
+};
+
+GType               gvc_channel_bar_get_type            (void);
+
+GtkWidget *         gvc_channel_bar_new                 (MateMixerStreamControl    *control);
+
+MateMixerStreamControl *gvc_channel_bar_get_control          (GvcChannelBar      *bar);
+void                gvc_channel_bar_set_control          (GvcChannelBar      *bar,
+                                                         MateMixerStreamControl    *control);
+
+const gchar *       gvc_channel_bar_get_name            (GvcChannelBar      *bar);
+void                gvc_channel_bar_set_name            (GvcChannelBar      *bar,
+                                                         const gchar        *name);
+
+const gchar *       gvc_channel_bar_get_icon_name       (GvcChannelBar      *bar);
+void                gvc_channel_bar_set_icon_name       (GvcChannelBar      *bar,
+                                                         const gchar        *icon_name);
+
+const gchar *       gvc_channel_bar_get_low_icon_name   (GvcChannelBar      *bar);
+void                gvc_channel_bar_set_low_icon_name   (GvcChannelBar      *bar,
+                                                         const gchar        *icon_name);
+
+const gchar *       gvc_channel_bar_get_high_icon_name  (GvcChannelBar      *bar);
+void                gvc_channel_bar_set_high_icon_name  (GvcChannelBar      *bar,
+                                                         const gchar        *icon_name);
+
+GtkOrientation      gvc_channel_bar_get_orientation     (GvcChannelBar      *bar);
+void                gvc_channel_bar_set_orientation     (GvcChannelBar      *bar,
+                                                         GtkOrientation      orientation);
+
+gboolean            gvc_channel_bar_get_show_icons      (GvcChannelBar      *bar);
+void                gvc_channel_bar_set_show_icons      (GvcChannelBar      *bar,
+                                                         gboolean            show_mute);
+
+gboolean            gvc_channel_bar_get_show_mute       (GvcChannelBar      *bar);
+void                gvc_channel_bar_set_show_mute       (GvcChannelBar      *bar,
+                                                         gboolean            show_mute);
+
+gboolean            gvc_channel_bar_get_show_marks      (GvcChannelBar      *bar);
+void                gvc_channel_bar_set_show_marks      (GvcChannelBar      *bar,
+                                                         gboolean            show_marks);
+
+gboolean            gvc_channel_bar_get_show_mark_text  (GvcChannelBar      *bar);
+void                gvc_channel_bar_set_show_mark_text  (GvcChannelBar      *bar,
+                                                         gboolean            show_mark_text);
+
+gboolean            gvc_channel_bar_get_extended        (GvcChannelBar      *bar);
+void                gvc_channel_bar_set_extended        (GvcChannelBar      *bar,
+                                                         gboolean            extended);
+
+void                gvc_channel_bar_set_size_group      (GvcChannelBar      *bar,
+                                                         GtkSizeGroup       *group,
+                                                         gboolean            symmetric);
+
+gboolean            gvc_channel_bar_scroll              (GvcChannelBar      *bar,
+                                                         GdkScrollDirection  direction);
+
+G_END_DECLS
+
+#endif /* __GVC_CHANNEL_BAR_H */
+
+ +
+ +
+ + diff --git a/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/49.html b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/49.html new file mode 100644 index 0000000..ab01774 --- /dev/null +++ b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/49.html @@ -0,0 +1,1123 @@ + + + + + + Cppcheck - HTML report - mate-media + + + + + +
+ + + +
+
  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
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2009 Bastien Nocera
+ * Copyright (C) 2014 Michal Ratajsky <michal.ratajsky@gmail.com>
+ * 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.
+ *
+ */
+
+#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-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 <libmatemixer/matemixer.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "gvc-combo-box.h"
+
+struct _GvcComboBoxPrivate
+{
+        GtkWidget       *drop_box;
+        GtkWidget       *start_box;
+        GtkWidget       *end_box;
+        GtkWidget       *label;
+        GtkWidget       *button;
+        GtkTreeModel    *model;
+        GtkWidget       *combobox;
+        MateMixerSwitch *swtch;
+};
+
+enum {
+        COL_NAME,
+        COL_HUMAN_NAME,
+        NUM_COLS
+};
+
+enum {
+        CHANGING,
+        BUTTON_CLICKED,
+        LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL] = { 0, };
+
+enum {
+        PROP_0,
+        PROP_SWITCH,
+        PROP_LABEL,
+        PROP_SHOW_BUTTON,
+        PROP_BUTTON_LABEL,
+        N_PROPERTIES
+};
+
+static GParamSpec *properties[N_PROPERTIES] = { NULL, };
+
+static void gvc_combo_box_dispose    (GObject          *object);
+
+G_DEFINE_TYPE_WITH_PRIVATE (GvcComboBox, gvc_combo_box, 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.
+
+MateMixerSwitch *
+gvc_combo_box_get_switch (GvcComboBox *combobox)
+{
+        g_return_val_if_fail (GVC_IS_COMBO_BOX (combobox), NULL);
+
+        return combobox->priv->swtch;
+}
+
+void
+gvc_combo_box_set_size_group (GvcComboBox  *combobox,
+                              GtkSizeGroup *group,
+                              gboolean      symmetric)
+{
+        g_return_if_fail (GVC_IS_COMBO_BOX (combobox));
+        g_return_if_fail (GTK_IS_SIZE_GROUP (group));
+
+        if (group != NULL) {
+                gtk_size_group_add_widget (group, combobox->priv->start_box);
+                if (symmetric == TRUE)
+                        gtk_size_group_add_widget (group, combobox->priv->end_box);
+        }
+        gtk_widget_queue_draw (GTK_WIDGET (combobox));
+}
+
+static void
+on_switch_active_option_notify (MateMixerSwitch *swtch,
+                                GParamSpec      *pspec,
+                                GvcComboBox     *combobox)
+{
+        GtkTreeIter            iter;
+        MateMixerSwitchOption *active;
+        gboolean               cont;
+        const gchar           *name;
+
+        active = mate_mixer_switch_get_active_option (swtch);
+        if (G_UNLIKELY (active == NULL)) {
+                g_warn_if_reached ();
+                return;
+        }
+
+        /* Select the newly activated switch option in the combo box */
+        name = mate_mixer_switch_option_get_name (active);
+        cont = gtk_tree_model_get_iter_first (combobox->priv->model, &iter);
+        while (cont == TRUE) {
+                gchar *current;
+
+                gtk_tree_model_get (combobox->priv->model, &iter,
+                                    COL_NAME, &current,
+                                    -1);
+                if (g_strcmp0 (name, current) == 0) {
+                        gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combobox->priv->combobox), &iter);
+                        g_free (current);
+                        return;
+                }
+                g_free (current);
+
+                cont = gtk_tree_model_iter_next (combobox->priv->model, &iter);
+        }
+        g_warning ("Could not find switch option '%s' in combo box", name);
+}
+
+static void
+gvc_combo_box_set_switch (GvcComboBox *combobox, MateMixerSwitch *swtch)
+{
+        MateMixerSwitchOption *active;
+        const GList           *options;
+
+        g_return_if_fail (GVC_IS_COMBO_BOX (combobox));
+        g_return_if_fail (MATE_MIXER_IS_SWITCH (swtch));
+
+        combobox->priv->swtch = g_object_ref (swtch);
+
+        active  = mate_mixer_switch_get_active_option (swtch);
+        options = mate_mixer_switch_list_options (swtch);
+        while (options != NULL) {
+                GtkTreeIter            iter;
+                MateMixerSwitchOption *option = MATE_MIXER_SWITCH_OPTION (options->data);
+
+                gtk_list_store_insert_with_values (GTK_LIST_STORE (combobox->priv->model),
+                                                   &iter,
+                                                   G_MAXINT,
+                                                   COL_NAME,
+                                                   mate_mixer_switch_option_get_name (option),
+                                                   COL_HUMAN_NAME,
+                                                   mate_mixer_switch_option_get_label (option),
+                                                   -1);
+
+                /* Select the currently active option of the switch */
+                if (option == active) {
+                        gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combobox->priv->combobox),
+                                                       &iter);
+                }
+                options = options->next;
+        }
+
+        g_signal_connect (G_OBJECT (swtch),
+                          "notify::active-option",
+                          G_CALLBACK (on_switch_active_option_notify),
+                          combobox);
+}
+
+static void
+gvc_combo_box_set_property (GObject       *object,
+                            guint          prop_id,
+                            const GValue  *value,
+                            GParamSpec    *pspec)
+{
+        GvcComboBox *self = GVC_COMBO_BOX (object);
+
+        switch (prop_id) {
+        case PROP_SWITCH:
+                gvc_combo_box_set_switch (self, g_value_get_object (value));
+                break;
+        case PROP_LABEL:
+                gtk_label_set_text_with_mnemonic (GTK_LABEL (self->priv->label), g_value_get_string (value));
+                break;
+        case PROP_BUTTON_LABEL:
+                gtk_button_set_label (GTK_BUTTON (self->priv->button), g_value_get_string (value));
+                break;
+        case PROP_SHOW_BUTTON:
+                gtk_widget_set_visible (self->priv->button, g_value_get_boolean (value));
+                break;
+        default:
+                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+                break;
+        }
+}
+
+static void
+gvc_combo_box_get_property (GObject     *object,
+                            guint        prop_id,
+                            GValue      *value,
+                            GParamSpec  *pspec)
+{
+        GvcComboBox *self = GVC_COMBO_BOX (object);
+
+        switch (prop_id) {
+        case PROP_SWITCH:
+                g_value_set_object (value, self->priv->swtch);
+                break;
+        case PROP_LABEL:
+                g_value_set_string (value, gtk_label_get_text (GTK_LABEL (self->priv->label)));
+                break;
+        case PROP_BUTTON_LABEL:
+                g_value_set_string (value, gtk_button_get_label (GTK_BUTTON (self->priv->button)));
+                break;
+        case PROP_SHOW_BUTTON:
+                g_value_set_boolean (value, gtk_widget_get_visible (self->priv->button));
+                break;
+        default:
+                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+                break;
+        }
+}
+
+static void
+gvc_combo_box_class_init (GvcComboBoxClass *klass)
+{
+        GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+        object_class->dispose = gvc_combo_box_dispose;
+        object_class->set_property = gvc_combo_box_set_property;
+        object_class->get_property = gvc_combo_box_get_property;
+
+        properties[PROP_SWITCH] =
+                g_param_spec_object ("switch",
+                                     "switch",
+                                     "The MateMixerSwitch",
+                                     MATE_MIXER_TYPE_SWITCH,
+                                     G_PARAM_READWRITE |
+                                     G_PARAM_CONSTRUCT_ONLY |
+                                     G_PARAM_STATIC_STRINGS);
+
+        properties[PROP_LABEL] =
+                g_param_spec_string ("label",
+                                     "label",
+                                     "The combo box label",
+                                     _("_Profile:"),
+                                     G_PARAM_READWRITE |
+                                     G_PARAM_CONSTRUCT |
+                                     G_PARAM_STATIC_STRINGS);
+
+        properties[PROP_SHOW_BUTTON] =
+                g_param_spec_boolean ("show-button",
+                                      "show-button",
+                                      "Whether to show the button",
+                                      FALSE,
+                                      G_PARAM_READWRITE |
+                                      G_PARAM_CONSTRUCT |
+                                      G_PARAM_STATIC_STRINGS);
+
+        properties[PROP_BUTTON_LABEL] =
+                g_param_spec_string ("button-label",
+                                     "button-label",
+                                     "The button's label",
+                                     "",
+                                     G_PARAM_READWRITE |
+                                     G_PARAM_CONSTRUCT |
+                                     G_PARAM_STATIC_STRINGS);
+
+        g_object_class_install_properties (object_class, N_PROPERTIES, properties);
+
+        signals[CHANGING] =
+                g_signal_new ("changing",
+                              G_TYPE_FROM_CLASS (klass),
+                              G_SIGNAL_RUN_LAST,
+                              G_STRUCT_OFFSET (GvcComboBoxClass, changing),
+                              NULL, NULL,
+                              g_cclosure_marshal_VOID__OBJECT,
+                              G_TYPE_NONE,
+                              1,
+                              MATE_MIXER_TYPE_SWITCH_OPTION);
+
+        signals[BUTTON_CLICKED] =
+                g_signal_new ("button-clicked",
+                              G_TYPE_FROM_CLASS (klass),
+                              G_SIGNAL_RUN_LAST,
+                              G_STRUCT_OFFSET (GvcComboBoxClass, button_clicked),
+                              NULL, NULL,
+                              g_cclosure_marshal_VOID__VOID,
+                              G_TYPE_NONE,
+                              0);
+}
+
+static void
+on_combo_box_changed (GtkComboBox *widget, GvcComboBox *combobox)
+{
+        GtkTreeIter            iter;
+        gchar                 *name;
+        MateMixerSwitchOption *option;
+
+        if (G_UNLIKELY (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter) == FALSE))
+                return;
+
+        gtk_tree_model_get (combobox->priv->model, &iter,
+                            COL_NAME, &name,
+                            -1);
+
+        option = mate_mixer_switch_get_option (combobox->priv->swtch, name);
+        if (G_UNLIKELY (option == NULL)) {
+                g_warn_if_reached ();
+                g_free (name);
+                return;
+        }
+
+        /* Inform that we are about to change the active option of the switch */
+        g_signal_emit (combobox, signals[CHANGING], 0, option);
+
+        mate_mixer_switch_set_active_option (combobox->priv->swtch, option);
+        g_free (name);
+}
+
+static void
+on_combo_box_button_clicked (GtkButton *button, GvcComboBox *combobox)
+{
+        /* The meaning of the button is defined by the owner, so only notify
+         * when it is clicked on */
+        g_signal_emit (combobox, signals[BUTTON_CLICKED], 0);
+}
+
+static void
+gvc_combo_box_init (GvcComboBox *combobox)
+{
+        GtkWidget       *frame;
+        GtkCellRenderer *renderer;
+
+        frame = gtk_frame_new (NULL);
+        gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
+
+        combobox->priv = gvc_combo_box_get_instance_private (combobox);
+
+        combobox->priv->model = GTK_TREE_MODEL (gtk_list_store_new (NUM_COLS,
+                                                                    G_TYPE_STRING,
+                                                                    G_TYPE_STRING));
+
+        combobox->priv->combobox = gtk_combo_box_new_with_model (combobox->priv->model);
+
+        combobox->priv->label = gtk_label_new (NULL);
+
+        gtk_label_set_xalign (GTK_LABEL (combobox->priv->label), 0.0);
+        gtk_label_set_yalign (GTK_LABEL (combobox->priv->label), 0.5);
+        gtk_label_set_mnemonic_widget (GTK_LABEL (combobox->priv->label),
+                                       combobox->priv->combobox);
+
+        renderer = gtk_cell_renderer_text_new ();
+        gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox->priv->combobox),
+                                    renderer,
+                                    FALSE);
+        gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (combobox->priv->combobox),
+                                       renderer,
+                                       "text",
+                                       COL_HUMAN_NAME);
+
+        combobox->priv->drop_box  = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
+        combobox->priv->start_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
+        combobox->priv->end_box   = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
+
+        /* Make sure the combo box does not get too long on long profile names */
+        g_object_set (G_OBJECT (renderer),
+                      "ellipsize",
+                      PANGO_ELLIPSIZE_END,
+                      NULL);
+
+        gtk_combo_box_set_popup_fixed_width (GTK_COMBO_BOX (combobox->priv->combobox), FALSE);
+
+        gtk_box_pack_start (GTK_BOX (combobox),
+                            frame,
+                            TRUE, TRUE, 0);
+
+        gtk_box_pack_start (GTK_BOX (combobox->priv->drop_box),
+                            combobox->priv->start_box,
+                            FALSE, FALSE, 0);
+        gtk_box_pack_start (GTK_BOX (combobox->priv->start_box),
+                            combobox->priv->label,
+                            FALSE, FALSE, 0);
+        gtk_box_pack_start (GTK_BOX (combobox->priv->drop_box),
+                            combobox->priv->combobox,
+                            TRUE, TRUE, 0);
+
+        combobox->priv->button = gtk_button_new_with_label ("");
+
+        gtk_box_pack_start (GTK_BOX (combobox->priv->drop_box),
+                            combobox->priv->button,
+                            FALSE, FALSE, 0);
+        gtk_box_pack_start (GTK_BOX (combobox->priv->drop_box),
+                            combobox->priv->end_box,
+                            FALSE, FALSE, 0);
+
+        gtk_container_add (GTK_CONTAINER (frame), combobox->priv->drop_box);
+
+        g_signal_connect (G_OBJECT (combobox->priv->combobox),
+                          "changed",
+                          G_CALLBACK (on_combo_box_changed),
+                          combobox);
+        g_signal_connect (G_OBJECT (combobox->priv->button),
+                          "clicked",
+                          G_CALLBACK (on_combo_box_button_clicked),
+                          combobox);
+
+        gtk_widget_set_no_show_all (combobox->priv->button, TRUE);
+        gtk_widget_show_all (frame);
+}
+
+static void
+gvc_combo_box_dispose (GObject *object)
+{
+        GvcComboBox *combobox;
+
+        combobox = GVC_COMBO_BOX (object);
+
+        if (G_LIKELY (combobox->priv->swtch != NULL)) {
+                g_signal_handlers_disconnect_by_func (G_OBJECT (combobox->priv->swtch),
+                                                      G_CALLBACK (on_switch_active_option_notify),
+                                                      combobox);
+                g_clear_object (&combobox->priv->swtch);
+        }
+
+        g_clear_object (&combobox->priv->model);
+
+        G_OBJECT_CLASS (gvc_combo_box_parent_class)->dispose (object);
+}
+
+GtkWidget *
+gvc_combo_box_new (MateMixerSwitch *swtch, const gchar *label)
+{
+        return g_object_new (GVC_TYPE_COMBO_BOX,
+                             "switch", swtch,
+                             "label", label,
+                             "orientation", GTK_ORIENTATION_HORIZONTAL,
+                             NULL);
+}
+
+ +
+ +
+ + diff --git a/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/5.html b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/5.html new file mode 100644 index 0000000..5788c4d --- /dev/null +++ b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/5.html @@ -0,0 +1,2025 @@ + + + + + + Cppcheck - HTML report - mate-media + + + + + +
+ + + +
+
  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/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/50.html b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/50.html new file mode 100644 index 0000000..bf9311e --- /dev/null +++ b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/50.html @@ -0,0 +1,383 @@ + + + + + + Cppcheck - HTML report - mate-media + + + + + +
+ + + +
+
 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
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2009 Red Hat, Inc.
+ * Copyright (C) 2014 Michal Ratajsky <michal.ratajsky@gmail.com>
+ * 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.
+ *
+ */
+
+#ifndef __GVC_COMBO_BOX_H
+#define __GVC_COMBO_BOX_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.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <libmatemixer/matemixer.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+G_BEGIN_DECLS
+
+#define GVC_TYPE_COMBO_BOX         (gvc_combo_box_get_type ())
+#define GVC_COMBO_BOX(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), GVC_TYPE_COMBO_BOX, GvcComboBox))
+#define GVC_COMBO_BOX_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST((k), GVC_TYPE_COMBO_BOX, GvcComboBoxClass))
+#define GVC_IS_COMBO_BOX(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), GVC_TYPE_COMBO_BOX))
+#define GVC_IS_COMBO_BOX_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), GVC_TYPE_COMBO_BOX))
+#define GVC_COMBO_BOX_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GVC_TYPE_COMBO_BOX, GvcComboBoxClass))
+
+typedef struct _GvcComboBox         GvcComboBox;
+typedef struct _GvcComboBoxClass    GvcComboBoxClass;
+typedef struct _GvcComboBoxPrivate  GvcComboBoxPrivate;
+
+struct _GvcComboBox
+{
+        GtkBox                  parent;
+        GvcComboBoxPrivate     *priv;
+};
+
+struct _GvcComboBoxClass
+{
+        GtkBoxClass             parent_class;
+
+        void (* changing)       (GvcComboBox           *combobox,
+                                 MateMixerSwitchOption *option);
+        void (* button_clicked) (GvcComboBox           *combobox);
+};
+
+GType               gvc_combo_box_get_type            (void) G_GNUC_CONST;
+
+GtkWidget *         gvc_combo_box_new                 (MateMixerSwitch *swtch,
+                                                       const gchar     *label);
+
+MateMixerSwitch *   gvc_combo_box_get_switch          (GvcComboBox     *combobox);
+
+void                gvc_combo_box_set_size_group      (GvcComboBox     *combobox,
+                                                       GtkSizeGroup    *group,
+                                                       gboolean         symmetric);
+
+G_END_DECLS
+
+#endif /* __GVC_COMBO_BOX_H */
+
+ +
+ +
+ + diff --git a/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/51.html b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/51.html new file mode 100644 index 0000000..59909a9 --- /dev/null +++ b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/51.html @@ -0,0 +1,1815 @@ + + + + + + Cppcheck - HTML report - mate-media + + + + + +
+ + + +
+
  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
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 William Jon McCann <william.jon.mccann@gmail.com>
+ * Copyright (C) 2014 Michal Ratajsky <michal.ratajsky@gmail.com>
+ * 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.
+ *
+ */
+
+#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 <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.
+
+#define MATE_DESKTOP_USE_UNSTABLE_API
+#include <libmate-desktop/mate-desktop-utils.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "gvc-level-bar.h"
+#include "gvc-utils.h"
+
+#define NUM_BOXES                  15
+#define MIN_HORIZONTAL_BAR_WIDTH   150
+#define HORIZONTAL_BAR_HEIGHT      6
+#define VERTICAL_BAR_WIDTH         6
+#define MIN_VERTICAL_BAR_HEIGHT    400
+
+typedef struct {
+        int            peak_num;
+        int            max_peak_num;
+        GdkRectangle   area;
+        int            delta;
+        int            box_width;
+        int            box_height;
+        int            box_radius;
+        GdkRGBA        color_bg;
+        GdkRGBA        color_fg;
+        GdkRGBA        color_dark;
+} LevelBarLayout;
+
+struct _GvcLevelBarPrivate
+{
+        GtkOrientation orientation;
+        GtkAdjustment *peak_adjustment;
+        GtkAdjustment *rms_adjustment;
+        GvcLevelScale  scale;
+        gdouble        peak_fraction;
+        gdouble        rms_fraction;
+        gdouble        max_peak;
+        guint          max_peak_id;
+        LevelBarLayout layout;
+};
+
+enum
+{
+        PROP_0,
+        PROP_PEAK_ADJUSTMENT,
+        PROP_RMS_ADJUSTMENT,
+        PROP_SCALE,
+        PROP_ORIENTATION,
+        N_PROPERTIES
+};
+
+static GParamSpec *properties[N_PROPERTIES] = { NULL, };
+
+static void gvc_level_bar_finalize   (GObject          *object);
+
+G_DEFINE_TYPE_WITH_PRIVATE (GvcLevelBar, gvc_level_bar, 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.
+
+static gboolean
+layout_changed (LevelBarLayout *layout1, LevelBarLayout *layout2)
+{
+        if (layout1->area.x != layout2->area.x)
+                return TRUE;
+        if (layout1->area.y != layout2->area.y)
+                return TRUE;
+        if (layout1->area.width != layout2->area.width)
+                return TRUE;
+        if (layout1->area.height != layout2->area.height)
+                return TRUE;
+
+        if (layout1->delta != layout2->delta)
+                return TRUE;
+        if (layout1->peak_num != layout2->peak_num)
+                return TRUE;
+        if (layout1->max_peak_num != layout2->max_peak_num)
+                return TRUE;
+
+        if (!gdk_rgba_equal (&layout1->color_fg, &layout2->color_fg))
+                return TRUE;
+        if (!gdk_rgba_equal (&layout1->color_bg, &layout2->color_bg))
+                return TRUE;
+        if (!gdk_rgba_equal (&layout1->color_dark, &layout2->color_dark))
+                return TRUE;
+
+        return FALSE;
+}
+
+static gdouble
+fraction_from_adjustment (GvcLevelBar   *bar,
+                          GtkAdjustment *adjustment)
+{
+        gdouble level;
+        gdouble fraction = 0.0;
+        gdouble min;
+        gdouble max;
+
+        level = gtk_adjustment_get_value (adjustment);
+        min   = gtk_adjustment_get_lower (adjustment);
+        max   = gtk_adjustment_get_upper (adjustment);
+
+        switch (bar->priv->scale) {
+        case GVC_LEVEL_SCALE_LINEAR:
+                fraction = (level - min) / (max - min);
+                break;
+        case GVC_LEVEL_SCALE_LOG:
+                fraction = log10 ((level - min + 1) / (max - min + 1));
+                break;
+        }
+
+        return fraction;
+}
+
+static gboolean
+reset_max_peak (GvcLevelBar *bar)
+{
+        bar->priv->max_peak = gtk_adjustment_get_lower (bar->priv->peak_adjustment);
+
+        bar->priv->layout.max_peak_num = 0;
+
+        gtk_widget_queue_draw (GTK_WIDGET (bar));
+
+        bar->priv->max_peak_id = 0;
+        return FALSE;
+}
+
+static void
+bar_calc_layout (GvcLevelBar *bar)
+{
+        gdouble       peak_level;
+        gdouble       max_peak_level;
+        GtkAllocation allocation;
+
+        GtkStyleContext *context;
+
+        context = gtk_widget_get_style_context (GTK_WIDGET (bar));
+
+        gtk_style_context_save (context);
+        gtk_style_context_set_state (context, GTK_STATE_FLAG_NORMAL);
+        gtk_style_context_get_background_color (context,
+                                                gtk_style_context_get_state (context),
+                                                &bar->priv->layout.color_bg);
+        mate_desktop_gtk_style_get_dark_color (context,
+                                               gtk_style_context_get_state (context),
+                                               &bar->priv->layout.color_dark);
+
+        gtk_style_context_set_state (context, GTK_STATE_FLAG_SELECTED);
+        gtk_style_context_get_background_color (context,
+                                                gtk_style_context_get_state (context),
+                                                &bar->priv->layout.color_fg);
+        gtk_style_context_restore (context);
+
+        gtk_widget_get_allocation (GTK_WIDGET (bar), &allocation);
+
+        bar->priv->layout.area.width = allocation.width - 2;
+        bar->priv->layout.area.height = allocation.height - 2;
+
+        if (bar->priv->orientation == GTK_ORIENTATION_VERTICAL) {
+                peak_level = bar->priv->peak_fraction * (gdouble) bar->priv->layout.area.height;
+                max_peak_level = bar->priv->max_peak * (gdouble) bar->priv->layout.area.height;
+
+                bar->priv->layout.delta = bar->priv->layout.area.height / NUM_BOXES;
+                bar->priv->layout.area.x = 0;
+                bar->priv->layout.area.y = 0;
+                bar->priv->layout.box_height = bar->priv->layout.delta / 2;
+                bar->priv->layout.box_width  = bar->priv->layout.area.width;
+                bar->priv->layout.box_radius = bar->priv->layout.box_width / 2;
+        } else {
+                peak_level = bar->priv->peak_fraction * (gdouble) bar->priv->layout.area.width;
+                max_peak_level = bar->priv->max_peak * (gdouble) bar->priv->layout.area.width;
+
+                bar->priv->layout.delta = bar->priv->layout.area.width / NUM_BOXES;
+                bar->priv->layout.area.x = 0;
+                bar->priv->layout.area.y = 0;
+                bar->priv->layout.box_width  = bar->priv->layout.delta / 2;
+                bar->priv->layout.box_height = bar->priv->layout.area.height;
+                bar->priv->layout.box_radius = bar->priv->layout.box_height / 2;
+        }
+
+        bar->priv->layout.peak_num = (int) (peak_level / (gdouble) bar->priv->layout.delta);
+        bar->priv->layout.max_peak_num = (int) (max_peak_level / (gdouble) bar->priv->layout.delta);
+}
+
+static void
+update_peak_value (GvcLevelBar *bar)
+{
+        gdouble        value;
+        LevelBarLayout layout;
+
+        value = fraction_from_adjustment (bar, bar->priv->peak_adjustment);
+
+        bar->priv->peak_fraction = value;
+
+        if (value > bar->priv->max_peak) {
+                AtkObject     *acc_obj;
+                char          *acc_string;
+                gdouble        peak_percentage;
+
+                if (bar->priv->max_peak_id > 0)
+                        g_source_remove (bar->priv->max_peak_id);
+
+                bar->priv->max_peak_id =
+                        g_timeout_add_seconds (1, (GSourceFunc) reset_max_peak, bar);
+                bar->priv->max_peak = value;
+                /* Providing an accessible based on peaks, so that
+                 * it doesn’t get updated too often. */
+                acc_obj = gtk_widget_get_accessible (GTK_WIDGET (bar));
+                peak_percentage = round (value * 100.0);
+                acc_string = g_strdup_printf (_("Peak: %.0lf"), peak_percentage);
+                atk_object_set_name (acc_obj, acc_string);
+                g_free (acc_string);
+        }
+
+        layout = bar->priv->layout;
+
+        bar_calc_layout (bar);
+
+        if (layout_changed (&bar->priv->layout, &layout))
+                gtk_widget_queue_draw (GTK_WIDGET (bar));
+}
+
+static void
+update_rms_value (GvcLevelBar *bar)
+{
+        bar->priv->rms_fraction = fraction_from_adjustment (bar, bar->priv->rms_adjustment);
+}
+
+GtkOrientation
+gvc_level_bar_get_orientation (GvcLevelBar *bar)
+{
+        g_return_val_if_fail (GVC_IS_LEVEL_BAR (bar), 0);
+
+        return bar->priv->orientation;
+}
+
+void
+gvc_level_bar_set_orientation (GvcLevelBar   *bar,
+                               GtkOrientation orientation)
+{
+        g_return_if_fail (GVC_IS_LEVEL_BAR (bar));
+
+        if (orientation != bar->priv->orientation) {
+                if (G_UNLIKELY (orientation != GTK_ORIENTATION_VERTICAL &&
+                                orientation != GTK_ORIENTATION_HORIZONTAL)) {
+                        g_warn_if_reached ();
+                        return;
+                }
+
+                bar->priv->orientation = orientation;
+
+                gtk_widget_queue_draw (GTK_WIDGET (bar));
+
+                g_object_notify_by_pspec (G_OBJECT (bar), properties[PROP_ORIENTATION]);
+        }
+}
+
+static void
+on_peak_adjustment_value_changed (GtkAdjustment *adjustment,
+                                  GvcLevelBar   *bar)
+{
+        update_peak_value (bar);
+}
+
+static void
+on_rms_adjustment_value_changed (GtkAdjustment *adjustment,
+                                 GvcLevelBar   *bar)
+{
+        update_rms_value (bar);
+}
+
+void
+gvc_level_bar_set_peak_adjustment (GvcLevelBar   *bar,
+                                   GtkAdjustment *adjustment)
+{
+        g_return_if_fail (GVC_LEVEL_BAR (bar));
+        g_return_if_fail (GTK_IS_ADJUSTMENT (adjustment));
+
+        if (bar->priv->peak_adjustment != NULL) {
+                g_signal_handlers_disconnect_by_func (G_OBJECT (bar->priv->peak_adjustment),
+                                                      G_CALLBACK (on_peak_adjustment_value_changed),
+                                                      bar);
+                g_object_unref (bar->priv->peak_adjustment);
+        }
+
+        bar->priv->peak_adjustment = g_object_ref_sink (adjustment);
+
+        g_signal_connect (G_OBJECT (bar->priv->peak_adjustment),
+                          "value-changed",
+                          G_CALLBACK (on_peak_adjustment_value_changed),
+                          bar);
+
+        update_peak_value (bar);
+
+        g_object_notify_by_pspec (G_OBJECT (bar), properties[PROP_PEAK_ADJUSTMENT]);
+}
+
+void
+gvc_level_bar_set_rms_adjustment (GvcLevelBar   *bar,
+                                  GtkAdjustment *adjustment)
+{
+        g_return_if_fail (GVC_LEVEL_BAR (bar));
+        g_return_if_fail (GTK_IS_ADJUSTMENT (adjustment));
+
+        if (bar->priv->rms_adjustment != NULL) {
+                g_signal_handlers_disconnect_by_func (G_OBJECT (bar->priv->rms_adjustment),
+                                                      G_CALLBACK (on_rms_adjustment_value_changed),
+                                                      bar);
+                g_object_unref (bar->priv->rms_adjustment);
+        }
+
+        bar->priv->rms_adjustment = g_object_ref_sink (adjustment);
+
+        g_signal_connect (G_OBJECT (bar->priv->rms_adjustment),
+                          "value-changed",
+                          G_CALLBACK (on_rms_adjustment_value_changed),
+                          bar);
+
+        update_rms_value (bar);
+
+        g_object_notify_by_pspec (G_OBJECT (bar), properties[PROP_RMS_ADJUSTMENT]);
+}
+
+GtkAdjustment *
+gvc_level_bar_get_peak_adjustment (GvcLevelBar *bar)
+{
+        g_return_val_if_fail (GVC_IS_LEVEL_BAR (bar), NULL);
+
+        return bar->priv->peak_adjustment;
+}
+
+GtkAdjustment *
+gvc_level_bar_get_rms_adjustment (GvcLevelBar *bar)
+{
+        g_return_val_if_fail (GVC_IS_LEVEL_BAR (bar), NULL);
+
+        return bar->priv->rms_adjustment;
+}
+
+void
+gvc_level_bar_set_scale (GvcLevelBar *bar, GvcLevelScale scale)
+{
+        g_return_if_fail (GVC_IS_LEVEL_BAR (bar));
+
+        if (scale != bar->priv->scale) {
+                if (G_UNLIKELY (scale != GVC_LEVEL_SCALE_LINEAR &&
+                                scale != GVC_LEVEL_SCALE_LOG)) {
+                        g_warn_if_reached ();
+                        return;
+                }
+                bar->priv->scale = scale;
+
+                update_peak_value (bar);
+                update_rms_value (bar);
+
+                g_object_notify_by_pspec (G_OBJECT (bar), properties[PROP_SCALE]);
+        }
+}
+
+static void
+gvc_level_bar_set_property (GObject       *object,
+                            guint          prop_id,
+                            const GValue  *value,
+                            GParamSpec    *pspec)
+{
+        GvcLevelBar *self = GVC_LEVEL_BAR (object);
+
+        switch (prop_id) {
+        case PROP_SCALE:
+                gvc_level_bar_set_scale (self, g_value_get_int (value));
+                break;
+        case PROP_ORIENTATION:
+                gvc_level_bar_set_orientation (self, g_value_get_enum (value));
+                break;
+        case PROP_PEAK_ADJUSTMENT:
+                gvc_level_bar_set_peak_adjustment (self, g_value_get_object (value));
+                break;
+        case PROP_RMS_ADJUSTMENT:
+                gvc_level_bar_set_rms_adjustment (self, g_value_get_object (value));
+                break;
+        default:
+                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+                break;
+        }
+}
+
+static void
+gvc_level_bar_get_property (GObject     *object,
+                            guint        prop_id,
+                            GValue      *value,
+                            GParamSpec  *pspec)
+{
+        GvcLevelBar *self = GVC_LEVEL_BAR (object);
+
+        switch (prop_id) {
+        case PROP_SCALE:
+                g_value_set_int (value, self->priv->scale);
+                break;
+        case PROP_ORIENTATION:
+                g_value_set_enum (value, self->priv->orientation);
+                break;
+        case PROP_PEAK_ADJUSTMENT:
+                g_value_set_object (value, self->priv->peak_adjustment);
+                break;
+        case PROP_RMS_ADJUSTMENT:
+                g_value_set_object (value, self->priv->rms_adjustment);
+                break;
+        default:
+                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+                break;
+        }
+}
+
+static void
+gvc_level_bar_size_request (GtkWidget      *widget,
+                            GtkRequisition *requisition)
+{
+        GvcLevelBar *bar;
+
+        g_return_if_fail (GVC_IS_LEVEL_BAR (widget));
+        g_return_if_fail (requisition != NULL);
+
+        bar = GVC_LEVEL_BAR (widget);
+
+        switch (bar->priv->orientation) {
+        case GTK_ORIENTATION_VERTICAL:
+                requisition->width  = VERTICAL_BAR_WIDTH;
+                requisition->height = MIN_VERTICAL_BAR_HEIGHT;
+                break;
+        case GTK_ORIENTATION_HORIZONTAL:
+                requisition->width  = MIN_HORIZONTAL_BAR_WIDTH;
+                requisition->height = HORIZONTAL_BAR_HEIGHT;
+                break;
+        }
+}
+
+static void
+gvc_level_bar_get_preferred_width (GtkWidget *widget,
+                                   gint      *minimum,
+                                   gint      *natural)
+{
+        GtkRequisition requisition;
+
+        gvc_level_bar_size_request (widget, &requisition);
+
+        if (minimum != NULL)
+                *minimum = requisition.width;
+        if (natural != NULL)
+                *natural = requisition.width;
+}
+
+static void
+gvc_level_bar_get_preferred_height (GtkWidget *widget,
+                                    gint      *minimum,
+                                    gint      *natural)
+{
+        GtkRequisition requisition;
+
+        gvc_level_bar_size_request (widget, &requisition);
+
+        if (minimum != NULL)
+                *minimum = requisition.height;
+        if (natural != NULL)
+                *natural = requisition.height;
+}
+
+static void
+gvc_level_bar_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
+{
+        GvcLevelBar *bar;
+
+        bar = GVC_LEVEL_BAR (widget);
+
+        /* FIXME: add height property, labels, etc */
+        GTK_WIDGET_CLASS (gvc_level_bar_parent_class)->size_allocate (widget, allocation);
+
+        gtk_widget_set_allocation (widget, allocation);
+        gtk_widget_get_allocation (widget, allocation);
+
+        if (bar->priv->orientation == GTK_ORIENTATION_VERTICAL) {
+                allocation->height = MIN (allocation->height, MIN_VERTICAL_BAR_HEIGHT);
+                allocation->width  = MAX (allocation->width, VERTICAL_BAR_WIDTH);
+        } else {
+                allocation->width  = MIN (allocation->width, MIN_HORIZONTAL_BAR_WIDTH);
+                allocation->height = MAX (allocation->height, HORIZONTAL_BAR_HEIGHT);
+        }
+
+        bar_calc_layout (bar);
+}
+
+static void
+curved_rectangle (cairo_t *cr,
+                  double   x0,
+                  double   y0,
+                  double   width,
+                  double   height,
+                  double   radius)
+{
+        double x1;
+        double y1;
+
+        x1 = x0 + width;
+        y1 = y0 + height;
+
+        if (width == 0.0 || height == 0.0)
+                return;
+
+        if (width / 2 < radius) {
+                if (height / 2 < radius) {
+                        cairo_move_to  (cr, x0, (y0 + y1) / 2);
+                        cairo_curve_to (cr, x0 ,y0, x0, y0, (x0 + x1) / 2, y0);
+                        cairo_curve_to (cr, x1, y0, x1, y0, x1, (y0 + y1) / 2);
+                        cairo_curve_to (cr, x1, y1, x1, y1, (x1 + x0) / 2, y1);
+                        cairo_curve_to (cr, x0, y1, x0, y1, x0, (y0 + y1) / 2);
+                } else {
+                        cairo_move_to  (cr, x0, y0 + radius);
+                        cairo_curve_to (cr, x0, y0, x0, y0, (x0 + x1) / 2, y0);
+                        cairo_curve_to (cr, x1, y0, x1, y0, x1, y0 + radius);
+                        cairo_line_to  (cr, x1, y1 - radius);
+                        cairo_curve_to (cr, x1, y1, x1, y1, (x1 + x0) / 2, y1);
+                        cairo_curve_to (cr, x0, y1, x0, y1, x0, y1 - radius);
+                }
+        } else {
+                if (height / 2 < radius) {
+                        cairo_move_to  (cr, x0, (y0 + y1) / 2);
+                        cairo_curve_to (cr, x0, y0, x0 , y0, x0 + radius, y0);
+                        cairo_line_to  (cr, x1 - radius, y0);
+                        cairo_curve_to (cr, x1, y0, x1, y0, x1, (y0 + y1) / 2);
+                        cairo_curve_to (cr, x1, y1, x1, y1, x1 - radius, y1);
+                        cairo_line_to  (cr, x0 + radius, y1);
+                        cairo_curve_to (cr, x0, y1, x0, y1, x0, (y0 + y1) / 2);
+                } else {
+                        cairo_move_to  (cr, x0, y0 + radius);
+                        cairo_curve_to (cr, x0 , y0, x0 , y0, x0 + radius, y0);
+                        cairo_line_to  (cr, x1 - radius, y0);
+                        cairo_curve_to (cr, x1, y0, x1, y0, x1, y0 + radius);
+                        cairo_line_to  (cr, x1, y1 - radius);
+                        cairo_curve_to (cr, x1, y1, x1, y1, x1 - radius, y1);
+                        cairo_line_to  (cr, x0 + radius, y1);
+                        cairo_curve_to (cr, x0, y1, x0, y1, x0, y1 - radius);
+                }
+        }
+
+        cairo_close_path (cr);
+}
+
+static int
+gvc_level_bar_draw (GtkWidget *widget, cairo_t *cr)
+{
+        GvcLevelBar *bar;
+
+        bar = GVC_LEVEL_BAR (widget);
+
+        cairo_save (cr);
+
+        if (bar->priv->orientation == GTK_ORIENTATION_VERTICAL) {
+                int i;
+
+                for (i = 0; i < NUM_BOXES; i++) {
+                        int by;
+
+                        by = i * bar->priv->layout.delta;
+                        curved_rectangle (cr,
+                                          bar->priv->layout.area.x + 0.5,
+                                          by + 0.5,
+                                          bar->priv->layout.box_width - 1,
+                                          bar->priv->layout.box_height - 1,
+                                          bar->priv->layout.box_radius);
+                        if ((bar->priv->layout.max_peak_num - 1) == i) {
+                                /* fill peak foreground */
+                                gdk_cairo_set_source_rgba (cr, &bar->priv->layout.color_fg);
+                                cairo_fill_preserve (cr);
+                        } else if ((bar->priv->layout.peak_num - 1) >= i) {
+                                /* fill background */
+                                gdk_cairo_set_source_rgba (cr, &bar->priv->layout.color_bg);
+                                cairo_fill_preserve (cr);
+
+                                /* fill foreground */
+                                cairo_set_source_rgba (cr,
+                                                       bar->priv->layout.color_fg.red,
+                                                       bar->priv->layout.color_fg.green,
+                                                       bar->priv->layout.color_fg.blue,
+                                                       0.5);
+                                cairo_fill_preserve (cr);
+                        } else {
+                                /* fill background */
+                                gdk_cairo_set_source_rgba (cr, &bar->priv->layout.color_bg);
+                                cairo_fill_preserve (cr);
+                        }
+
+                        /* stroke border */
+                        gdk_cairo_set_source_rgba (cr, &bar->priv->layout.color_dark);
+                        cairo_set_line_width (cr, 1);
+                        cairo_stroke (cr);
+                }
+        } else {
+                int i;
+
+                if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) {
+                        GtkAllocation allocation;
+
+                        gtk_widget_get_allocation (widget, &allocation);
+
+                        cairo_scale (cr, -1, 1);
+                        cairo_translate (cr, -allocation.width, 0);
+                }
+
+                for (i = 0; i < NUM_BOXES; i++) {
+                        int bx;
+
+                        bx = i * bar->priv->layout.delta;
+                        curved_rectangle (cr,
+                                          bx + 0.5,
+                                          bar->priv->layout.area.y + 0.5,
+                                          bar->priv->layout.box_width - 1,
+                                          bar->priv->layout.box_height - 1,
+                                          bar->priv->layout.box_radius);
+
+                        if ((bar->priv->layout.max_peak_num - 1) == i) {
+                                /* fill peak foreground */
+                                gdk_cairo_set_source_rgba (cr, &bar->priv->layout.color_fg);
+                                cairo_fill_preserve (cr);
+                        } else if ((bar->priv->layout.peak_num - 1) >= i) {
+                                /* fill background */
+                                gdk_cairo_set_source_rgba (cr, &bar->priv->layout.color_bg);
+                                cairo_fill_preserve (cr);
+
+                                /* fill foreground */
+                                cairo_set_source_rgba (cr,
+                                                       bar->priv->layout.color_fg.red,
+                                                       bar->priv->layout.color_fg.green,
+                                                       bar->priv->layout.color_fg.blue,
+                                                       0.5);
+                                cairo_fill_preserve (cr);
+                        } else {
+                                /* fill background */
+                                gdk_cairo_set_source_rgba (cr, &bar->priv->layout.color_bg);
+                                cairo_fill_preserve (cr);
+                        }
+
+                        /* stroke border */
+                        gdk_cairo_set_source_rgba (cr, &bar->priv->layout.color_dark);
+                        cairo_set_line_width (cr, 1);
+                        cairo_stroke (cr);
+                }
+        }
+
+        cairo_restore (cr);
+
+        return FALSE;
+}
+
+static void
+gvc_level_bar_class_init (GvcLevelBarClass *klass)
+{
+        GObjectClass   *object_class = G_OBJECT_CLASS (klass);
+        GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+        object_class->finalize = gvc_level_bar_finalize;
+        object_class->set_property = gvc_level_bar_set_property;
+        object_class->get_property = gvc_level_bar_get_property;
+
+        widget_class->draw = gvc_level_bar_draw;
+        widget_class->get_preferred_width = gvc_level_bar_get_preferred_width;
+        widget_class->get_preferred_height = gvc_level_bar_get_preferred_height;
+        widget_class->size_allocate = gvc_level_bar_size_allocate;
+
+        gtk_widget_class_set_css_name (widget_class, "gvc-level-bar");
+
+        properties[PROP_ORIENTATION] =
+                g_param_spec_enum ("orientation",
+                                   "Orientation",
+                                   "The orientation of the bar",
+                                   GTK_TYPE_ORIENTATION,
+                                   GTK_ORIENTATION_HORIZONTAL,
+                                   G_PARAM_READWRITE |
+                                   G_PARAM_STATIC_STRINGS);
+
+        properties[PROP_PEAK_ADJUSTMENT] =
+                g_param_spec_object ("peak-adjustment",
+                                     "Peak Adjustment",
+                                     "The GtkAdjustment that contains the current peak value",
+                                     GTK_TYPE_ADJUSTMENT,
+                                     G_PARAM_READWRITE |
+                                     G_PARAM_STATIC_STRINGS);
+
+        properties[PROP_RMS_ADJUSTMENT] =
+                g_param_spec_object ("rms-adjustment",
+                                     "RMS Adjustment",
+                                     "The GtkAdjustment that contains the current rms value",
+                                     GTK_TYPE_ADJUSTMENT,
+                                     G_PARAM_READWRITE |
+                                     G_PARAM_STATIC_STRINGS);
+
+        properties[PROP_SCALE] =
+                g_param_spec_int ("scale",
+                                  "Scale",
+                                  "Scale",
+                                  0,
+                                  G_MAXINT,
+                                  GVC_LEVEL_SCALE_LINEAR,
+                                  G_PARAM_READWRITE |
+                                  G_PARAM_CONSTRUCT |
+                                  G_PARAM_STATIC_STRINGS);
+
+        g_object_class_install_properties (object_class, N_PROPERTIES, properties);
+}
+
+static void
+gvc_level_bar_init (GvcLevelBar *bar)
+{
+        GtkStyleContext *context = gtk_widget_get_style_context (GTK_WIDGET (bar));
+
+        gtk_style_context_add_class (context, GTK_STYLE_CLASS_LIST_ROW);
+
+        bar->priv = gvc_level_bar_get_instance_private (bar);
+
+        bar->priv->peak_adjustment = GTK_ADJUSTMENT (gtk_adjustment_new (0.0,
+                                                                         0.0,
+                                                                         1.0,
+                                                                         0.05,
+                                                                         0.1,
+                                                                         0.1));
+        g_object_ref_sink (bar->priv->peak_adjustment);
+
+        g_signal_connect (bar->priv->peak_adjustment,
+                          "value-changed",
+                          G_CALLBACK (on_peak_adjustment_value_changed),
+                          bar);
+
+        bar->priv->rms_adjustment = GTK_ADJUSTMENT (gtk_adjustment_new (0.0,
+                                                                        0.0,
+                                                                        1.0,
+                                                                        0.05,
+                                                                        0.1,
+                                                                        0.1));
+        g_object_ref_sink (bar->priv->rms_adjustment);
+
+        g_signal_connect (bar->priv->rms_adjustment,
+                          "value-changed",
+                          G_CALLBACK (on_rms_adjustment_value_changed),
+                          bar);
+
+        gtk_widget_set_has_window (GTK_WIDGET (bar), FALSE);
+
+        atk_object_set_role (gtk_widget_get_accessible (GTK_WIDGET (bar)),
+                                                        ATK_ROLE_STATIC);
+}
+
+static void
+gvc_level_bar_finalize (GObject *object)
+{
+        GvcLevelBar *bar;
+
+        bar = GVC_LEVEL_BAR (object);
+
+        if (bar->priv->max_peak_id > 0)
+                g_source_remove (bar->priv->max_peak_id);
+
+        G_OBJECT_CLASS (gvc_level_bar_parent_class)->finalize (object);
+}
+
+GtkWidget *
+gvc_level_bar_new (void)
+{
+        return g_object_new (GVC_TYPE_LEVEL_BAR, NULL);
+}
+
+ +
+ +
+ + diff --git a/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/52.html b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/52.html new file mode 100644 index 0000000..26ad000 --- /dev/null +++ b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/52.html @@ -0,0 +1,397 @@ + + + + + + Cppcheck - HTML report - mate-media + + + + + +
+ + + +
+
 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: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 William Jon McCann <william.jon.mccann@gmail.com>
+ * Copyright (C) 2014 Michal Ratajsky <michal.ratajsky@gmail.com>
+ * 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.
+ *
+ */
+
+#ifndef __GVC_LEVEL_BAR_H
+#define __GVC_LEVEL_BAR_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.
+#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 GVC_TYPE_LEVEL_BAR         (gvc_level_bar_get_type ())
+#define GVC_LEVEL_BAR(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), GVC_TYPE_LEVEL_BAR, GvcLevelBar))
+#define GVC_LEVEL_BAR_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST((k), GVC_TYPE_LEVEL_BAR, GvcLevelBarClass))
+#define GVC_IS_LEVEL_BAR(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), GVC_TYPE_LEVEL_BAR))
+#define GVC_IS_LEVEL_BAR_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), GVC_TYPE_LEVEL_BAR))
+#define GVC_LEVEL_BAR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GVC_TYPE_LEVEL_BAR, GvcLevelBarClass))
+
+typedef struct _GvcLevelBar         GvcLevelBar;
+typedef struct _GvcLevelBarClass    GvcLevelBarClass;
+typedef struct _GvcLevelBarPrivate  GvcLevelBarPrivate;
+
+struct _GvcLevelBar
+{
+        GtkWidget              parent;
+        GvcLevelBarPrivate    *priv;
+};
+
+struct _GvcLevelBarClass
+{
+        GtkWidgetClass         parent_class;
+};
+
+typedef enum
+{
+    GVC_LEVEL_SCALE_LINEAR,
+    GVC_LEVEL_SCALE_LOG
+} GvcLevelScale;
+
+GType               gvc_level_bar_get_type            (void) G_GNUC_CONST;
+
+GtkWidget *         gvc_level_bar_new                 (void);
+void                gvc_level_bar_set_orientation     (GvcLevelBar   *bar,
+                                                       GtkOrientation orientation);
+GtkOrientation      gvc_level_bar_get_orientation     (GvcLevelBar   *bar);
+
+void                gvc_level_bar_set_peak_adjustment (GvcLevelBar   *bar,
+                                                       GtkAdjustment *adjustment);
+GtkAdjustment *     gvc_level_bar_get_peak_adjustment (GvcLevelBar   *bar);
+
+void                gvc_level_bar_set_rms_adjustment  (GvcLevelBar   *bar,
+                                                       GtkAdjustment *adjustment);
+GtkAdjustment *     gvc_level_bar_get_rms_adjustment  (GvcLevelBar   *bar);
+
+void                gvc_level_bar_set_scale           (GvcLevelBar   *bar,
+                                                       GvcLevelScale  scale);
+
+G_END_DECLS
+
+#endif /* __GVC_LEVEL_BAR_H */
+
+ +
+ +
+ + diff --git a/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/53.html b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/53.html new file mode 100644 index 0000000..a5f2432 --- /dev/null +++ b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/53.html @@ -0,0 +1,311 @@ + + + + + + Cppcheck - HTML report - mate-media + + + + + +
+ + + +
+
 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: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2014 Michal Ratajsky <michal.ratajsky@gmail.com>
+ * 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.
+ *
+ */
+
+#ifndef __GVC_HELPERS_H
+#define __GVC_HELPERS_H
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <libmatemixer/matemixer.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+G_BEGIN_DECLS
+
+const gchar *gvc_channel_position_to_pulse_string  (MateMixerChannelPosition position);
+const gchar *gvc_channel_position_to_pretty_string (MateMixerChannelPosition position);
+const gchar *gvc_channel_map_to_pretty_string      (MateMixerStreamControl  *control);
+
+G_END_DECLS
+
+#endif /* __GVC_HELPERS_H */
+
+ +
+ +
+ + diff --git a/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/54.html b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/54.html new file mode 100644 index 0000000..1560fc2 --- /dev/null +++ b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/54.html @@ -0,0 +1,5209 @@ + + + + + + Cppcheck - HTML report - mate-media + + + + + +
+ + + +
+
   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
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 William Jon McCann
+ * Copyright (C) 2014 Michal Ratajsky <michal.ratajsky@gmail.com>
+ * 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.
+ *
+ */
+
+#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-object.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/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 <libmatemixer/matemixer.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "gvc-channel-bar.h"
+#include "gvc-balance-bar.h"
+#include "gvc-combo-box.h"
+#include "gvc-mixer-dialog.h"
+#include "gvc-sound-theme-chooser.h"
+#include "gvc-level-bar.h"
+#include "gvc-speaker-test.h"
+#include "gvc-utils.h"
+
+struct _GvcMixerDialogPrivate
+{
+        GSettings        *sound_settings;
+        MateMixerContext *context;
+        MateMixerBackendFlags backend_flags;
+        GHashTable       *bars;
+        GtkWidget        *volume_overamplifiable_button;
+        GtkWidget        *notebook;
+        GtkWidget        *output_bar;
+        GtkWidget        *input_bar;
+        GtkWidget        *input_level_bar;
+        GtkWidget        *effects_bar;
+        GtkWidget        *output_stream_box;
+        GtkWidget        *hw_box;
+        GtkWidget        *hw_treeview;
+        GtkWidget        *hw_settings_box;
+        GtkWidget        *hw_profile_combo;
+        GtkWidget        *input_box;
+        GtkWidget        *output_box;
+        GtkWidget        *applications_box;
+        GtkWidget        *applications_window;
+        GtkWidget        *no_apps_label;
+        GtkWidget        *output_treeview;
+        GtkWidget        *output_settings_frame;
+        GtkWidget        *output_settings_box;
+        GtkWidget        *output_balance_bar;
+        GtkWidget        *output_fade_bar;
+        GtkWidget        *output_lfe_bar;
+        GtkWidget        *output_port_combo;
+        GtkWidget        *input_treeview;
+        GtkWidget        *input_port_combo;
+        GtkWidget        *input_settings_box;
+        GtkSizeGroup     *size_group;
+        gdouble           last_input_peak;
+        guint             num_apps;
+};
+
+enum {
+        ICON_COLUMN,
+        NAME_COLUMN,
+        LABEL_COLUMN,
+        ACTIVE_COLUMN,
+        SPEAKERS_COLUMN,
+        NUM_COLUMNS
+};
+
+enum {
+        HW_ICON_COLUMN,
+        HW_NAME_COLUMN,
+        HW_LABEL_COLUMN,
+        HW_STATUS_COLUMN,
+        HW_PROFILE_COLUMN,
+        HW_NUM_COLUMNS
+};
+
+enum {
+        PAGE_EFFECTS,
+        PAGE_HARDWARE,
+        PAGE_INPUT,
+        PAGE_OUTPUT,
+        PAGE_APPLICATIONS
+};
+
+enum {
+        PROP_0,
+        PROP_CONTEXT
+};
+
+static const guint tab_accel_keys[] = {
+        GDK_KEY_1, GDK_KEY_2, GDK_KEY_3, GDK_KEY_4, GDK_KEY_5
+};
+
+static void gvc_mixer_dialog_finalize   (GObject                *object);
+
+static void add_stream                  (GvcMixerDialog         *dialog,
+                                         MateMixerStream        *stream);
+static void add_application_control     (GvcMixerDialog         *dialog,
+                                         MateMixerStreamControl *control);
+
+static void remove_stream               (GvcMixerDialog         *dialog,
+                                         const gchar            *name);
+static void remove_application_control  (GvcMixerDialog         *dialog,
+                                         const gchar            *name);
+
+static void bar_set_stream              (GvcMixerDialog         *dialog,
+                                         GtkWidget              *bar,
+                                         MateMixerStream        *stream);
+static void bar_set_stream_control      (GvcMixerDialog         *dialog,
+                                         GtkWidget              *bar,
+                                         MateMixerStreamControl *control);
+
+G_DEFINE_TYPE_WITH_PRIVATE (GvcMixerDialog, gvc_mixer_dialog, GTK_TYPE_DIALOG)<--- There is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
+
+static MateMixerSwitch *
+find_stream_port_switch (MateMixerStream *stream)
+{
+        const GList *switches;
+
+        switches = mate_mixer_stream_list_switches (stream);
+        while (switches != NULL) {
+                MateMixerStreamSwitch *swtch = MATE_MIXER_STREAM_SWITCH (switches->data);
+
+                if (!MATE_MIXER_IS_STREAM_TOGGLE (swtch) &&
+                    mate_mixer_stream_switch_get_role (swtch) == MATE_MIXER_STREAM_SWITCH_ROLE_PORT)
+                    return MATE_MIXER_SWITCH (swtch);
+
+                switches = switches->next;
+        }
+        return NULL;
+}
+
+static MateMixerSwitch *
+find_device_profile_switch (MateMixerDevice *device)
+{
+        const GList *switches;
+
+        switches = mate_mixer_device_list_switches (device);
+        while (switches != NULL) {
+                MateMixerDeviceSwitch *swtch = MATE_MIXER_DEVICE_SWITCH (switches->data);
+
+                if (mate_mixer_device_switch_get_role (swtch) == MATE_MIXER_DEVICE_SWITCH_ROLE_PROFILE)
+                        return MATE_MIXER_SWITCH (swtch);
+
+                switches = switches->next;
+        }
+        return NULL;
+}
+
+static MateMixerStream *
+find_device_test_stream (GvcMixerDialog *dialog, MateMixerDevice *device)
+{
+        const GList *streams;
+
+        streams = mate_mixer_device_list_streams (device);
+        while (streams != NULL) {
+                MateMixerStream   *stream;
+                MateMixerDirection direction;
+
+                stream = MATE_MIXER_STREAM (streams->data);
+                direction = mate_mixer_stream_get_direction (stream);
+
+                if (direction == MATE_MIXER_DIRECTION_OUTPUT) {
+                    MateMixerStreamControl *control;
+
+                    control = mate_mixer_stream_get_default_control (stream);
+                    if (mate_mixer_stream_control_get_num_channels (control) > 0)
+                        return stream;
+                }
+                streams = streams->next;
+        }
+        return FALSE;
+}
+
+static gboolean
+find_tree_item_by_name (GtkTreeModel *model,
+                        const gchar  *name,
+                        guint         column,
+                        GtkTreeIter  *iter)
+{
+        gboolean found = FALSE;
+
+        if (!gtk_tree_model_get_iter_first (model, iter))
+                return FALSE;
+
+        do {
+                gchar *n;
+                gtk_tree_model_get (model, iter, column, &n, -1);
+
+                if (!g_strcmp0 (name, n))
+                        found = TRUE;
+
+                g_free (n);
+        } while (!found && gtk_tree_model_iter_next (model, iter));
+
+        return found;
+}
+
+static void
+update_default_tree_item (GvcMixerDialog  *dialog,
+                          GtkTreeModel    *model,
+                          MateMixerStream *stream)
+{
+        GtkTreeIter  iter;
+        const gchar *name = NULL;
+
+        if (gtk_tree_model_get_iter_first (model, &iter) == FALSE)
+                return;
+
+        /* The supplied stream is the default, or the selected item. Traverse
+         * the item list and mark each item as being selected or not. Also do not
+         * presume some known stream is selected and allow NULL here. */
+        if (stream != NULL)
+                name = mate_mixer_stream_get_name (stream);
+
+        do {
+                gchar *n;
+                gtk_tree_model_get (model, &iter,
+                                    NAME_COLUMN, &n,
+                                    -1);
+                gtk_list_store_set (GTK_LIST_STORE (model),
+                                    &iter,
+                                    ACTIVE_COLUMN, !g_strcmp0 (name, n),
+                                    -1);
+                g_free (n);
+        } while (gtk_tree_model_iter_next (model, &iter));
+}
+
+static void
+update_output_settings (GvcMixerDialog *dialog)
+{
+        MateMixerStream            *stream;
+        MateMixerStreamControl     *control;
+        MateMixerStreamControlFlags flags;
+        MateMixerSwitch            *port_switch;
+        gboolean                    has_settings = FALSE;
+
+        g_debug ("Updating output settings");
+
+        if (dialog->priv->output_balance_bar != NULL) {
+                gtk_container_remove (GTK_CONTAINER (dialog->priv->output_settings_box),
+                                      dialog->priv->output_balance_bar);
+
+                dialog->priv->output_balance_bar = NULL;
+        }
+        if (dialog->priv->output_fade_bar != NULL) {
+                gtk_container_remove (GTK_CONTAINER (dialog->priv->output_settings_box),
+                                      dialog->priv->output_fade_bar);
+
+                dialog->priv->output_fade_bar = NULL;
+        }
+        if (dialog->priv->output_lfe_bar != NULL) {
+                gtk_container_remove (GTK_CONTAINER (dialog->priv->output_settings_box),
+                                      dialog->priv->output_lfe_bar);
+
+                dialog->priv->output_lfe_bar = NULL;
+        }
+        if (dialog->priv->output_port_combo != NULL) {
+                gtk_container_remove (GTK_CONTAINER (dialog->priv->output_settings_box),
+                                      dialog->priv->output_port_combo);
+
+                dialog->priv->output_port_combo = NULL;
+        }
+
+        /* Get the control currently associated with the output slider */
+        control = gvc_channel_bar_get_control (GVC_CHANNEL_BAR (dialog->priv->output_bar));
+        if (control == NULL) {
+                g_debug ("There is no control for the default output stream");
+                gtk_widget_hide (dialog->priv->output_settings_frame);
+                return;
+        }
+        flags = mate_mixer_stream_control_get_flags (control);
+
+        /* Enable balance bar if it is available */
+        if (flags & MATE_MIXER_STREAM_CONTROL_CAN_BALANCE) {
+                dialog->priv->output_balance_bar =
+                        gvc_balance_bar_new (control, BALANCE_TYPE_RL);
+
+                gvc_balance_bar_set_size_group (GVC_BALANCE_BAR (dialog->priv->output_balance_bar),
+                                                dialog->priv->size_group,
+                                                TRUE);
+
+                gtk_box_pack_start (GTK_BOX (dialog->priv->output_settings_box),
+                                    dialog->priv->output_balance_bar,
+                                    FALSE, FALSE, 6);
+
+                gtk_widget_show (dialog->priv->output_balance_bar);
+                has_settings = TRUE;
+        }
+
+        /* Enable fade bar if it is available */
+        if (flags & MATE_MIXER_STREAM_CONTROL_CAN_FADE) {
+                dialog->priv->output_fade_bar =
+                        gvc_balance_bar_new (control, BALANCE_TYPE_FR);
+
+                gvc_balance_bar_set_size_group (GVC_BALANCE_BAR (dialog->priv->output_fade_bar),
+                                                dialog->priv->size_group,
+                                                TRUE);
+
+                gtk_box_pack_start (GTK_BOX (dialog->priv->output_settings_box),
+                                    dialog->priv->output_fade_bar,
+                                    FALSE, FALSE, 6);
+
+                gtk_widget_show (dialog->priv->output_fade_bar);
+                has_settings = TRUE;
+        }
+
+        /* Enable subwoofer volume bar if subwoofer is available */
+        if (mate_mixer_stream_control_has_channel_position (control, MATE_MIXER_CHANNEL_LFE)) {
+                dialog->priv->output_lfe_bar =
+                        gvc_balance_bar_new (control, BALANCE_TYPE_LFE);
+
+                gvc_balance_bar_set_size_group (GVC_BALANCE_BAR (dialog->priv->output_lfe_bar),
+                                                dialog->priv->size_group,
+                                                TRUE);
+
+                gtk_box_pack_start (GTK_BOX (dialog->priv->output_settings_box),
+                                    dialog->priv->output_lfe_bar,
+                                    FALSE, FALSE, 6);
+
+                gtk_widget_show (dialog->priv->output_lfe_bar);
+                has_settings = TRUE;
+        }
+
+        /* Get owning stream of the control */
+        stream = mate_mixer_stream_control_get_stream (control);
+        if (G_UNLIKELY (stream == NULL))
+                return;
+
+        /* Enable the port selector if the stream has one */
+        port_switch = find_stream_port_switch (stream);
+        if (port_switch != NULL) {
+                dialog->priv->output_port_combo =
+                        gvc_combo_box_new (port_switch, _("Co_nnector:"));
+
+                gvc_combo_box_set_size_group (GVC_COMBO_BOX (dialog->priv->output_port_combo),
+                                              dialog->priv->size_group,
+                                              FALSE);
+
+                gtk_box_pack_start (GTK_BOX (dialog->priv->output_settings_box),
+                                    dialog->priv->output_port_combo,
+                                    TRUE, FALSE, 6);
+
+                gtk_widget_show (dialog->priv->output_port_combo);
+                has_settings = TRUE;
+        }
+
+        if (has_settings == TRUE)
+                gtk_widget_show (dialog->priv->output_settings_frame);
+        else
+                gtk_widget_hide (dialog->priv->output_settings_frame);
+}
+
+/*
+ * Enable or disable the checkbox allowing the user to set the volume above
+ * 100%, depending on whether the maximum volume is greater than the
+ * "normal" volume.  If the maximum volume is greater than the normal
+ * volume, then enable the checkbox; otherwise, over-amplification is not
+ * possible with this control, so disable the checkbox.
+ */
+static void
+update_overamplify_sensitivity (GvcMixerDialog *dialog)
+{
+        MateMixerStreamControl *control;
+        guint                   normal_volume;
+        guint                   maximum_volume;
+
+        control = gvc_channel_bar_get_control (GVC_CHANNEL_BAR (dialog->priv->output_bar));
+        if (control == NULL)
+        {
+                gtk_widget_set_sensitive (dialog->priv->volume_overamplifiable_button,
+                                          FALSE);
+                return;
+        }
+
+        normal_volume = mate_mixer_stream_control_get_normal_volume (control);
+        maximum_volume = mate_mixer_stream_control_get_max_volume (control);
+
+        if (maximum_volume > normal_volume)
+                gtk_widget_set_sensitive (dialog->priv->volume_overamplifiable_button,
+                                          TRUE);
+        else
+                gtk_widget_set_sensitive (dialog->priv->volume_overamplifiable_button,
+                                          FALSE);
+}
+
+static void
+set_output_stream (GvcMixerDialog *dialog, MateMixerStream *stream)
+{
+        GtkTreeModel           *model;
+        MateMixerStreamControl *control;
+
+        control = gvc_channel_bar_get_control (GVC_CHANNEL_BAR (dialog->priv->output_bar));
+        if (control != NULL) {
+                /* Disconnect port switch of the previous stream */
+                if (dialog->priv->output_port_combo != NULL) {
+                        MateMixerSwitch        *swtch;
+
+                        swtch = g_object_get_data (G_OBJECT (dialog->priv->output_port_combo),
+                                                   "switch");
+                        if (swtch != NULL)
+                                g_signal_handlers_disconnect_by_data (G_OBJECT (swtch),
+                                                                      dialog);
+                }
+        }
+
+        bar_set_stream (dialog, dialog->priv->output_bar, stream);
+
+        if (stream != NULL) {
+                const GList *controls;
+
+                controls = mate_mixer_context_list_stored_controls (dialog->priv->context);
+
+                /* Move all stored controls to the newly selected default stream */
+                while (controls != NULL) {
+                        MateMixerStream        *parent;
+
+                        control = MATE_MIXER_STREAM_CONTROL (controls->data);
+                        parent  = mate_mixer_stream_control_get_stream (control);
+
+                        /* Prefer streamless controls to stay the way they are, forcing them to
+                         * a particular owning stream would be wrong for eg. event controls */
+                        if (parent != NULL && parent != stream) {
+                                MateMixerDirection direction =
+                                        mate_mixer_stream_get_direction (parent);
+
+                                if (direction == MATE_MIXER_DIRECTION_OUTPUT)
+                                        mate_mixer_stream_control_set_stream (control, stream);
+                        }
+                        controls = controls->next;
+                }
+        }
+
+        model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->priv->output_treeview));
+        update_default_tree_item (dialog, model, stream);
+
+        update_output_settings (dialog);
+        update_overamplify_sensitivity (dialog);
+}
+
+static void
+on_context_default_output_stream_notify (MateMixerContext *context,
+                                         GParamSpec       *pspec,
+                                         GvcMixerDialog   *dialog)
+{
+        MateMixerStream *stream;
+
+        stream = mate_mixer_context_get_default_output_stream (context);
+
+        set_output_stream (dialog, stream);
+}
+
+#define DECAY_STEP .15
+
+static void
+on_stream_control_monitor_value (MateMixerStream *stream,
+                                 gdouble          value,
+                                 GvcMixerDialog  *dialog)
+{
+        GtkAdjustment *adj;
+
+        if (dialog->priv->last_input_peak >= DECAY_STEP) {
+                if (value < dialog->priv->last_input_peak - DECAY_STEP) {
+                        value = dialog->priv->last_input_peak - DECAY_STEP;
+                }
+        }
+
+        dialog->priv->last_input_peak = value;
+
+        adj = gvc_level_bar_get_peak_adjustment (GVC_LEVEL_BAR (dialog->priv->input_level_bar));
+        if (value >= 0)
+                gtk_adjustment_set_value (adj, value);
+        else
+                gtk_adjustment_set_value (adj, 0.0);
+}
+
+static void
+update_input_settings (GvcMixerDialog *dialog)
+{
+        MateMixerStream            *stream;
+        MateMixerStreamControl     *control;
+        MateMixerStreamControlFlags flags;
+        MateMixerSwitch            *port_switch;
+
+        g_debug ("Updating input settings");
+
+        if (dialog->priv->input_port_combo != NULL) {
+                gtk_container_remove (GTK_CONTAINER (dialog->priv->input_settings_box),
+                                      dialog->priv->input_port_combo);
+
+                dialog->priv->input_port_combo = NULL;
+        }
+
+        /* Get the control currently associated with the input slider */
+        control = gvc_channel_bar_get_control (GVC_CHANNEL_BAR (dialog->priv->input_bar));
+        if (control == NULL)
+                return;
+
+        flags = mate_mixer_stream_control_get_flags (control);
+
+        /* Enable level bar only if supported by the control */
+        if (flags & MATE_MIXER_STREAM_CONTROL_HAS_MONITOR)
+                g_signal_connect (G_OBJECT (control),
+                                  "monitor-value",
+                                  G_CALLBACK (on_stream_control_monitor_value),
+                                  dialog);
+
+        /* Get owning stream of the control */
+        stream = mate_mixer_stream_control_get_stream (control);
+        if (G_UNLIKELY (stream == NULL))
+                return;
+
+        /* Enable the port selector if the stream has one */
+        port_switch = find_stream_port_switch (stream);
+        if (port_switch != NULL) {
+                dialog->priv->input_port_combo =
+                        gvc_combo_box_new (port_switch, _("Co_nnector:"));
+
+                gvc_combo_box_set_size_group (GVC_COMBO_BOX (dialog->priv->input_port_combo),
+                                              dialog->priv->size_group,
+                                              FALSE);
+
+                gtk_box_pack_start (GTK_BOX (dialog->priv->input_settings_box),
+                                    dialog->priv->input_port_combo,
+                                    TRUE, TRUE, 0);
+
+                gtk_widget_show (dialog->priv->input_port_combo);
+        }
+}
+
+static void
+on_stream_control_mute_notify (MateMixerStreamControl *control,
+                               GParamSpec             *pspec,
+                               GvcMixerDialog         *dialog)
+{
+        /* Stop monitoring the input stream when it gets muted */
+        if (mate_mixer_stream_control_get_mute (control) == TRUE)
+                mate_mixer_stream_control_set_monitor_enabled (control, FALSE);
+        else
+                mate_mixer_stream_control_set_monitor_enabled (control, TRUE);
+}
+
+static void
+set_input_stream (GvcMixerDialog *dialog, MateMixerStream *stream)
+{
+        GtkTreeModel           *model;
+        MateMixerStreamControl *control;
+
+        control = gvc_channel_bar_get_control (GVC_CHANNEL_BAR (dialog->priv->input_bar));
+        if (control != NULL) {
+                /* Disconnect port switch of the previous stream */
+                if (dialog->priv->input_port_combo != NULL) {
+                        MateMixerSwitch        *swtch;
+
+                        swtch = g_object_get_data (G_OBJECT (dialog->priv->input_port_combo),
+                                                   "switch");
+                        if (swtch != NULL)
+                                g_signal_handlers_disconnect_by_data (G_OBJECT (swtch),
+                                                                      dialog);
+                }
+
+                /* Disable monitoring of the previous control */
+                g_signal_handlers_disconnect_by_func (G_OBJECT (control),
+                                                      G_CALLBACK (on_stream_control_monitor_value),
+                                                      dialog);
+
+                mate_mixer_stream_control_set_monitor_enabled (control, FALSE);
+        }
+
+        bar_set_stream (dialog, dialog->priv->input_bar, stream);
+
+        if (stream != NULL) {
+                const GList *controls;
+                guint page = gtk_notebook_get_current_page (GTK_NOTEBOOK (dialog->priv->notebook));
+
+                controls = mate_mixer_context_list_stored_controls (dialog->priv->context);
+
+                /* Move all stored controls to the newly selected default stream */
+                while (controls != NULL) {
+                        MateMixerStream *parent;
+
+                        control = MATE_MIXER_STREAM_CONTROL (controls->data);
+                        parent  = mate_mixer_stream_control_get_stream (control);
+
+                        /* Prefer streamless controls to stay the way they are, forcing them to
+                         * a particular owning stream would be wrong for eg. event controls */
+                        if (parent != NULL && parent != stream) {
+                                MateMixerDirection direction =
+                                        mate_mixer_stream_get_direction (parent);
+
+                                if (direction == MATE_MIXER_DIRECTION_INPUT)
+                                        mate_mixer_stream_control_set_stream (control, stream);
+                        }
+                        controls = controls->next;
+                }
+
+                if (page == PAGE_INPUT) {
+                        control = gvc_channel_bar_get_control (GVC_CHANNEL_BAR (dialog->priv->input_bar));
+
+                        if (G_LIKELY (control != NULL))
+                                mate_mixer_stream_control_set_monitor_enabled (control, TRUE);
+                }
+
+                /* Enable/disable the peak level monitor according to mute state */
+                g_signal_connect (G_OBJECT (stream),
+                                  "notify::mute",
+                                  G_CALLBACK (on_stream_control_mute_notify),
+                                  dialog);
+        }
+
+        model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->priv->input_treeview));
+        update_default_tree_item (dialog, model, stream);
+
+        update_input_settings (dialog);
+}
+
+static void
+on_context_default_input_stream_notify (MateMixerContext *context,
+                                        GParamSpec       *pspec,
+                                        GvcMixerDialog   *dialog)
+{
+        MateMixerStream *stream;
+
+        g_debug ("Default input stream has changed");
+
+        stream = mate_mixer_context_get_default_input_stream (context);
+
+        set_input_stream (dialog, stream);
+}
+
+static GtkWidget *
+create_bar (GvcMixerDialog *dialog, gboolean use_size_group, gboolean symmetric)
+{
+        GtkWidget *bar;
+
+        bar = gvc_channel_bar_new (NULL);
+
+        if (use_size_group == TRUE)
+                gvc_channel_bar_set_size_group (GVC_CHANNEL_BAR (bar),
+                                                dialog->priv->size_group,
+                                                symmetric);
+
+        g_object_set (G_OBJECT (bar),
+                      "orientation", GTK_ORIENTATION_HORIZONTAL,
+                      "show-mute",   TRUE,
+                      "show-icons",  TRUE,
+                      "show-marks",  TRUE, NULL);
+        return bar;
+}
+
+static void
+bar_set_stream (GvcMixerDialog  *dialog,
+                GtkWidget       *bar,
+                MateMixerStream *stream)
+{
+        MateMixerStreamControl *control = NULL;
+
+        if (stream != NULL)
+                control = mate_mixer_stream_get_default_control (stream);
+
+        bar_set_stream_control (dialog, bar, control);
+}
+
+static void
+bar_set_stream_control (GvcMixerDialog         *dialog,
+                        GtkWidget              *bar,
+                        MateMixerStreamControl *control)
+{
+        const gchar            *name;
+        MateMixerStreamControl *previous;
+
+        previous = gvc_channel_bar_get_control (GVC_CHANNEL_BAR (bar));
+        if (previous == control)
+                return;
+
+        if (previous != NULL) {
+                name = mate_mixer_stream_control_get_name (previous);
+
+                g_debug ("Removing stream control %s from bar %s",
+                         name,
+                         gvc_channel_bar_get_name (GVC_CHANNEL_BAR (bar)));
+
+                g_signal_handlers_disconnect_by_data (G_OBJECT (previous), dialog);
+
+                /* This may not do anything because we no longer have the information
+                 * about the owning stream, in case it was an input stream, make
+                 * sure to disconnected from the peak level monitor */
+                mate_mixer_stream_control_set_monitor_enabled (previous, FALSE);
+
+                g_hash_table_remove (dialog->priv->bars, name);
+        }
+
+        gvc_channel_bar_set_control (GVC_CHANNEL_BAR (bar), control);
+
+        if (control != NULL) {
+                name = mate_mixer_stream_control_get_name (control);
+
+                g_debug ("Setting stream control %s for bar %s",
+                         name,
+                         gvc_channel_bar_get_name (GVC_CHANNEL_BAR (bar)));
+
+                g_hash_table_insert (dialog->priv->bars,
+                                     (gpointer) name,
+                                     bar);
+
+                gtk_widget_set_sensitive (GTK_WIDGET (bar), TRUE);
+        } else
+                gtk_widget_set_sensitive (GTK_WIDGET (bar), TRUE);
+}
+
+static void
+add_application_control (GvcMixerDialog *dialog, MateMixerStreamControl *control)
+{
+        MateMixerStream                *stream;
+        MateMixerStreamControlMediaRole media_role;
+        MateMixerAppInfo               *info;
+        MateMixerDirection              direction = MATE_MIXER_DIRECTION_UNKNOWN;
+        GtkWidget                      *bar;
+        const gchar                    *app_id;
+        const gchar                    *app_name;
+        const gchar                    *app_icon;
+
+        media_role = mate_mixer_stream_control_get_media_role (control);
+
+        /* Add stream to the applications page, but make sure the stream qualifies
+         * for the inclusion */
+        info = mate_mixer_stream_control_get_app_info (control);
+        if (info == NULL)
+                return;
+
+        /* Skip streams with roles we don't care about */
+        if (media_role == MATE_MIXER_STREAM_CONTROL_MEDIA_ROLE_EVENT ||
+            media_role == MATE_MIXER_STREAM_CONTROL_MEDIA_ROLE_TEST ||
+            media_role == MATE_MIXER_STREAM_CONTROL_MEDIA_ROLE_ABSTRACT ||
+            media_role == MATE_MIXER_STREAM_CONTROL_MEDIA_ROLE_FILTER)
+                return;
+
+        app_id = mate_mixer_app_info_get_id (info);
+
+        /* These applications may have associated streams because they do peak
+         * level monitoring, skip these too */
+        if (!g_strcmp0 (app_id, "org.mate.VolumeControl") ||
+            !g_strcmp0 (app_id, "org.gnome.VolumeControl") ||
+            !g_strcmp0 (app_id, "org.PulseAudio.pavucontrol"))
+                return;
+
+        app_name = mate_mixer_app_info_get_name (info);
+        if (app_name == NULL)
+                app_name = mate_mixer_stream_control_get_label (control);
+        if (app_name == NULL)
+                app_name = mate_mixer_stream_control_get_name (control);
+        if (G_UNLIKELY (app_name == NULL))
+                return;
+
+        bar = create_bar (dialog, FALSE, FALSE);
+
+        g_object_set (G_OBJECT (bar),
+                      "show-marks", FALSE,
+                      "extended", FALSE,
+                      NULL);
+
+        /* By default channel bars use speaker icons, use microphone icons
+         * instead for recording applications */
+        stream = mate_mixer_stream_control_get_stream (control);
+        if (stream != NULL)
+                direction = mate_mixer_stream_get_direction (stream);
+
+        if (direction == MATE_MIXER_DIRECTION_INPUT)
+                g_object_set (G_OBJECT (bar),
+                              "low-icon-name", "audio-input-microphone-low",
+                              "high-icon-name", "audio-input-microphone-high",
+                              NULL);
+
+        app_icon = mate_mixer_app_info_get_icon (info);
+        if (app_icon == NULL) {
+                if (direction == MATE_MIXER_DIRECTION_INPUT)
+                        app_icon = "audio-input-microphone";
+                else
+                        app_icon = "applications-multimedia";
+        }
+
+        gvc_channel_bar_set_name (GVC_CHANNEL_BAR (bar), app_name);
+        gvc_channel_bar_set_icon_name (GVC_CHANNEL_BAR (bar), app_icon);
+
+        gtk_box_pack_start (GTK_BOX (dialog->priv->applications_box),
+                            bar,
+                            FALSE, FALSE, 12);
+
+        bar_set_stream_control (dialog, bar, control);
+        dialog->priv->num_apps++;
+
+        gtk_widget_hide (dialog->priv->no_apps_label);
+        gtk_widget_show (bar);
+}
+
+static void
+on_stream_control_added (MateMixerStream *stream,
+                         const gchar     *name,
+                         GvcMixerDialog  *dialog)
+{
+        MateMixerStreamControl    *control;
+        MateMixerStreamControlRole role;
+
+        control = mate_mixer_stream_get_control (stream, name);
+        if (G_UNLIKELY (control == NULL))
+                return;
+
+        role = mate_mixer_stream_control_get_role (control);
+
+        if (role == MATE_MIXER_STREAM_CONTROL_ROLE_APPLICATION)
+                add_application_control (dialog, control);
+}
+
+static void
+on_stream_control_removed (MateMixerStream *stream,
+                           const gchar     *name,
+                           GvcMixerDialog  *dialog)
+{
+        MateMixerStreamControl *control;
+
+        control = gvc_channel_bar_get_control (GVC_CHANNEL_BAR (dialog->priv->input_bar));
+        if (control != NULL) {
+                const gchar *input_name = mate_mixer_stream_control_get_name (control);
+
+                if (strcmp (name, input_name) == 0) {
+                        // XXX probably can't even happen, but handle it somehow
+                        return;
+                }
+        }
+
+        control = gvc_channel_bar_get_control (GVC_CHANNEL_BAR (dialog->priv->output_bar));
+        if (control != NULL) {
+                const gchar *input_name = mate_mixer_stream_control_get_name (control);
+
+                if (strcmp (name, input_name) == 0) {
+                        // XXX probably can't even happen, but handle it somehow
+                        return;
+                }
+        }
+
+        /* No way to be sure that it is an application control, but we don't have
+         * any other than application bars that could match the name */
+        remove_application_control (dialog, name);
+}
+
+static void
+add_stream (GvcMixerDialog *dialog, MateMixerStream *stream)
+{
+        GtkTreeModel      *model = NULL;
+        GtkTreeIter        iter;
+        const gchar       *speakers = NULL;
+        const GList       *controls;
+        gboolean           is_default = FALSE;
+        MateMixerDirection direction;
+
+        direction = mate_mixer_stream_get_direction (stream);
+
+        if (direction == MATE_MIXER_DIRECTION_INPUT) {
+                MateMixerStream *input;
+
+                input = mate_mixer_context_get_default_input_stream (dialog->priv->context);
+                if (stream == input) {
+                        bar_set_stream (dialog, dialog->priv->input_bar, stream);
+
+                        update_input_settings (dialog);
+                        is_default = TRUE;
+                }
+                model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->priv->input_treeview));
+        }
+        else if (direction == MATE_MIXER_DIRECTION_OUTPUT) {
+                MateMixerStream        *output;
+                MateMixerStreamControl *control;
+
+                output = mate_mixer_context_get_default_output_stream (dialog->priv->context);
+                if (stream == output) {
+                        bar_set_stream (dialog, dialog->priv->output_bar, stream);
+
+                        update_output_settings (dialog);
+                        update_overamplify_sensitivity (dialog);
+                        is_default = TRUE;
+                }
+                model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->priv->output_treeview));
+
+                control = mate_mixer_stream_get_default_control (stream);
+                if (G_LIKELY (control != NULL))
+                        speakers = gvc_channel_map_to_pretty_string (control);
+        }
+
+        controls = mate_mixer_stream_list_controls (stream);
+        while (controls != NULL) {
+                MateMixerStreamControl    *control = MATE_MIXER_STREAM_CONTROL (controls->data);
+                MateMixerStreamControlRole role;
+
+                role = mate_mixer_stream_control_get_role (control);
+
+                if (role == MATE_MIXER_STREAM_CONTROL_ROLE_APPLICATION)
+                        add_application_control (dialog, control);
+
+                controls = controls->next;
+        }
+
+        if (model != NULL) {
+                const gchar *name;
+                const gchar *label;
+
+                name  = mate_mixer_stream_get_name (stream);
+                label = mate_mixer_stream_get_label (stream);
+
+                gtk_list_store_append (GTK_LIST_STORE (model), &iter);
+                gtk_list_store_set (GTK_LIST_STORE (model),
+                                    &iter,
+                                    NAME_COLUMN, name,
+                                    LABEL_COLUMN, label,
+                                    ACTIVE_COLUMN, is_default,
+                                    SPEAKERS_COLUMN, speakers,
+                                    -1);
+        }
+
+        // XXX find a way to disconnect when removed
+        g_signal_connect (G_OBJECT (stream),
+                          "control-added",
+                          G_CALLBACK (on_stream_control_added),
+                          dialog);
+        g_signal_connect (G_OBJECT (stream),
+                          "control-removed",
+                          G_CALLBACK (on_stream_control_removed),
+                          dialog);
+}
+
+static void
+update_device_test_visibility (GvcMixerDialog *dialog)
+{
+        MateMixerDevice *device;
+        MateMixerStream *stream;
+
+        device = g_object_get_data (G_OBJECT (dialog->priv->hw_profile_combo), "device");
+        if (G_UNLIKELY (device == NULL)) {
+                return;
+        }
+
+        stream = find_device_test_stream (dialog, device);
+
+        g_object_set (G_OBJECT (dialog->priv->hw_profile_combo),
+                      "show-button", (stream != NULL),
+                      NULL);
+}
+
+static void
+on_context_stream_added (MateMixerContext *context,
+                         const gchar      *name,
+                         GvcMixerDialog   *dialog)
+{
+        MateMixerStream   *stream;
+        MateMixerDirection direction;
+        GtkWidget         *bar;
+
+        stream = mate_mixer_context_get_stream (context, name);
+        if (G_UNLIKELY (stream == NULL))
+                return;
+
+        direction = mate_mixer_stream_get_direction (stream);
+
+        /* If the newly added stream belongs to the currently selected device and
+         * the test button is hidden, this stream may be the one to allow the
+         * sound test and therefore we may need to enable the button */
+        if (dialog->priv->hw_profile_combo != NULL && direction == MATE_MIXER_DIRECTION_OUTPUT) {
+                MateMixerDevice *device1;
+                MateMixerDevice *device2;
+
+                device1 = mate_mixer_stream_get_device (stream);
+                device2 = g_object_get_data (G_OBJECT (dialog->priv->hw_profile_combo),
+                                             "device");
+
+                if (device1 == device2) {
+                        gboolean show_button;
+
+                        g_object_get (G_OBJECT (dialog->priv->hw_profile_combo),
+                                      "show-button", &show_button,
+                                      NULL);
+
+                        if (show_button == FALSE)
+                                update_device_test_visibility (dialog);
+                }
+        }
+
+        bar = g_hash_table_lookup (dialog->priv->bars, name);
+        if (G_UNLIKELY (bar != NULL))
+                return;
+
+        add_stream (dialog, stream);
+}
+
+static void
+remove_stream (GvcMixerDialog *dialog, const gchar *name)
+{
+        GtkWidget    *bar;
+        GtkTreeIter   iter;
+        GtkTreeModel *model;
+
+        bar = g_hash_table_lookup (dialog->priv->bars, name);
+
+        if (bar != NULL) {
+                g_debug ("Removing stream %s from bar %s",
+                         name,
+                         gvc_channel_bar_get_name (GVC_CHANNEL_BAR (bar)));
+
+                bar_set_stream (dialog, bar, NULL);
+        }
+
+        /* Remove from any models */
+        model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->priv->output_treeview));
+        if (find_tree_item_by_name (GTK_TREE_MODEL (model),
+                                    name,
+                                    NAME_COLUMN,
+                                    &iter) == TRUE)
+                gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
+
+        model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->priv->input_treeview));
+        if (find_tree_item_by_name (GTK_TREE_MODEL (model),
+                                    name,
+                                    NAME_COLUMN,
+                                    &iter) == TRUE)
+                gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
+}
+
+static void
+remove_application_control (GvcMixerDialog *dialog, const gchar *name)
+{
+        GtkWidget *bar;
+
+        bar = g_hash_table_lookup (dialog->priv->bars, name);
+        if (G_UNLIKELY (bar == NULL))
+                return;
+
+        g_debug ("Removing application stream %s", name);
+
+        /* We could call bar_set_stream_control here, but that would pointlessly
+         * invalidate the channel bar, so just remove it ourselves */
+        g_hash_table_remove (dialog->priv->bars, name);
+
+        gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (bar)), bar);
+
+        if (G_UNLIKELY (dialog->priv->num_apps <= 0)) {
+                g_warn_if_reached ();
+                dialog->priv->num_apps = 1;
+        }
+
+        dialog->priv->num_apps--;
+
+        if (dialog->priv->num_apps == 0)
+                gtk_widget_show (dialog->priv->no_apps_label);
+}
+
+static void
+on_context_stream_removed (MateMixerContext *context,
+                           const gchar      *name,
+                           GvcMixerDialog   *dialog)
+{
+        if (dialog->priv->hw_profile_combo != NULL) {
+                gboolean show_button;
+
+                g_object_get (G_OBJECT (dialog->priv->hw_profile_combo),
+                              "show-button", &show_button,
+                              NULL);
+
+                if (show_button == TRUE)
+                        update_device_test_visibility (dialog);
+        }
+
+        remove_stream (dialog, name);
+}
+
+static void
+on_context_stored_control_added (MateMixerContext *context,
+                                 const gchar      *name,
+                                 GvcMixerDialog   *dialog)
+{
+        MateMixerStreamControl         *control;
+        MateMixerStreamControlMediaRole media_role;
+
+        control = MATE_MIXER_STREAM_CONTROL (mate_mixer_context_get_stored_control (context, name));
+        if (G_UNLIKELY (control == NULL))
+                return;
+
+        media_role = mate_mixer_stream_control_get_media_role (control);
+
+        if (media_role == MATE_MIXER_STREAM_CONTROL_MEDIA_ROLE_EVENT)
+                bar_set_stream_control (dialog, dialog->priv->effects_bar, control);
+}
+
+static void
+on_context_stored_control_removed (MateMixerContext *context,
+                                   const gchar      *name,
+                                   GvcMixerDialog   *dialog)
+{
+        GtkWidget *bar;
+
+        bar = g_hash_table_lookup (dialog->priv->bars, name);
+
+        if (bar != NULL) {
+                /* We only use a stored control in the effects bar */
+                if (G_UNLIKELY (bar != dialog->priv->effects_bar)) {
+                        g_warn_if_reached ();
+                        return;
+                }
+
+                bar_set_stream (dialog, bar, NULL);
+        }
+}
+
+static gchar *
+device_status (MateMixerDevice *device)
+{
+        guint        inputs = 0;
+        guint        outputs = 0;
+        gchar       *inputs_str = NULL;
+        gchar       *outputs_str = NULL;
+        const GList *streams;
+
+        /* Get number of input and output streams in the device */
+        streams = mate_mixer_device_list_streams (device);
+        while (streams != NULL) {
+                MateMixerStream   *stream = MATE_MIXER_STREAM (streams->data);
+                MateMixerDirection direction;
+
+                direction = mate_mixer_stream_get_direction (stream);
+
+                if (direction == MATE_MIXER_DIRECTION_INPUT)
+                        inputs++;
+                else if (direction == MATE_MIXER_DIRECTION_OUTPUT)
+                        outputs++;
+
+                streams = streams->next;
+        }
+
+        if (inputs == 0 && outputs == 0) {
+                /* translators:
+                 * The device has been disabled */
+                return g_strdup (_("Disabled"));
+        }
+
+        if (outputs > 0) {
+                /* translators:
+                 * The number of sound outputs on a particular device */
+                outputs_str = g_strdup_printf (ngettext ("%u Output",
+                                                         "%u Outputs",
+                                                          outputs),
+                                               outputs);
+        }
+
+        if (inputs > 0) {
+                /* translators:
+                 * The number of sound inputs on a particular device */
+                inputs_str = g_strdup_printf (ngettext ("%u Input",
+                                                        "%u Inputs",
+                                                        inputs),
+                                              inputs);
+        }
+
+        if (inputs_str != NULL && outputs_str != NULL) {
+                gchar *ret = g_strdup_printf ("%s / %s",
+                                              outputs_str,
+                                              inputs_str);
+                g_free (outputs_str);
+                g_free (inputs_str);
+                return ret;
+        }
+
+        if (inputs_str != NULL)
+                return inputs_str;
+
+        return outputs_str;
+}
+
+static void
+update_device_info (GvcMixerDialog *dialog, MateMixerDevice *device)
+{
+        GtkTreeModel    *model = NULL;
+        GtkTreeIter      iter;
+        const gchar     *label;
+        const gchar     *profile_label = NULL;
+        gchar           *status;
+        MateMixerSwitch *profile_switch;
+
+        model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->priv->hw_treeview));
+
+        if (find_tree_item_by_name (model,
+                                    mate_mixer_device_get_name (device),
+                                    HW_NAME_COLUMN,
+                                    &iter) == FALSE)
+                return;
+
+        label = mate_mixer_device_get_label (device);
+
+        profile_switch = find_device_profile_switch (device);
+        if (profile_switch != NULL) {
+                MateMixerSwitchOption *active;
+
+                active = mate_mixer_switch_get_active_option (profile_switch);
+                if (G_LIKELY (active != NULL))
+                        profile_label = mate_mixer_switch_option_get_label (active);
+        }
+
+        status = device_status (device);
+
+        gtk_list_store_set (GTK_LIST_STORE (model),
+                            &iter,
+                            HW_LABEL_COLUMN, label,
+                            HW_PROFILE_COLUMN, profile_label,
+                            HW_STATUS_COLUMN, status,
+                            -1);
+        g_free (status);
+}
+
+static void
+on_device_profile_active_option_notify (MateMixerDeviceSwitch *swtch,
+                                        GParamSpec            *pspec,
+                                        GvcMixerDialog        *dialog)
+{
+        MateMixerDevice *device;
+
+        device = mate_mixer_device_switch_get_device (swtch);
+
+        update_device_info (dialog, device);
+}
+
+static void
+add_device (GvcMixerDialog *dialog, MateMixerDevice *device)
+{
+        GtkTreeModel    *model;
+        GtkTreeIter      iter;
+        GIcon           *icon;
+        const gchar     *name;
+        const gchar     *label;
+        gchar           *status;
+        const gchar     *profile_label = NULL;
+        MateMixerSwitch *profile_switch;
+
+        model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->priv->hw_treeview));
+
+        name  = mate_mixer_device_get_name (device);
+        label = mate_mixer_device_get_label (device);
+
+        if (find_tree_item_by_name (GTK_TREE_MODEL (model),
+                                    name,
+                                    HW_NAME_COLUMN,
+                                    &iter) == FALSE)
+                gtk_list_store_append (GTK_LIST_STORE (model), &iter);
+
+        icon = g_themed_icon_new_with_default_fallbacks (mate_mixer_device_get_icon (device));
+
+        profile_switch = find_device_profile_switch (device);
+        if (profile_switch != NULL) {
+                MateMixerSwitchOption *active;
+
+                active = mate_mixer_switch_get_active_option (profile_switch);
+                if (G_LIKELY (active != NULL))
+                        profile_label = mate_mixer_switch_option_get_label (active);
+
+                g_signal_connect (G_OBJECT (profile_switch),
+                                  "notify::active-option",
+                                  G_CALLBACK (on_device_profile_active_option_notify),
+                                  dialog);
+        }
+
+        status = device_status (device);
+
+        gtk_list_store_set (GTK_LIST_STORE (model),
+                            &iter,
+                            HW_NAME_COLUMN, name,
+                            HW_LABEL_COLUMN, label,
+                            HW_ICON_COLUMN, icon,
+                            HW_PROFILE_COLUMN, profile_label,
+                            HW_STATUS_COLUMN, status,
+                            -1);
+        g_free (status);
+
+}
+
+static void
+on_context_device_added (MateMixerContext *context, const gchar *name, GvcMixerDialog *dialog)
+{
+        MateMixerDevice *device;
+
+        device = mate_mixer_context_get_device (context, name);
+        if (G_UNLIKELY (device == NULL))
+                return;
+
+        add_device (dialog, device);
+}
+
+static void
+on_context_device_removed (MateMixerContext *context,
+                           const gchar      *name,
+                           GvcMixerDialog   *dialog)
+{
+        GtkTreeIter   iter;
+        GtkTreeModel *model;
+
+        /* Remove from the device model */
+        model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->priv->hw_treeview));
+
+        if (find_tree_item_by_name (GTK_TREE_MODEL (model),
+                                    name,
+                                    HW_NAME_COLUMN,
+                                    &iter) == TRUE)
+                gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
+}
+
+static void
+make_label_bold (GtkLabel *label)
+{
+        PangoFontDescription *font_desc;
+
+        font_desc = pango_font_description_new ();
+
+        pango_font_description_set_weight (font_desc, PANGO_WEIGHT_BOLD);
+
+        /* This will only affect the weight of the font, the rest is
+         * from the current state of the widget, which comes from the
+         * theme or user prefs, since the font desc only has the
+         * weight flag turned on. */
+        PangoAttrList *attrs = pango_attr_list_new ();
+        PangoAttribute *font_desc_attr = pango_attr_font_desc_new (font_desc);
+        pango_attr_list_insert (attrs, font_desc_attr);
+        gtk_label_set_attributes (label, attrs);
+        pango_attr_list_unref (attrs);
+
+        pango_font_description_free (font_desc);
+}
+
+static void
+on_input_radio_toggled (GtkCellRendererToggle *renderer,
+                        gchar                 *path_str,
+                        GvcMixerDialog        *dialog)
+{
+        GtkTreeModel *model;
+        GtkTreeIter   iter;
+        GtkTreePath  *path;
+        gboolean      toggled = FALSE;
+        gchar        *name = NULL;
+
+        model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->priv->input_treeview));
+        path  = gtk_tree_path_new_from_string (path_str);
+
+        gtk_tree_model_get_iter (model, &iter, path);
+        gtk_tree_path_free (path);
+
+        gtk_tree_model_get (model, &iter,
+                            NAME_COLUMN, &name,
+                            ACTIVE_COLUMN, &toggled,
+                            -1);
+        if (toggled ^ 1) {
+                MateMixerStream      *stream;
+                MateMixerBackendFlags flags;
+
+                stream = mate_mixer_context_get_stream (dialog->priv->context, name);
+                if (G_UNLIKELY (stream == NULL)) {
+                        g_warn_if_reached ();
+                        g_free (name);
+                        return;
+                }
+
+                g_debug ("Default input stream selection changed to %s", name);
+
+                // XXX cache this
+                flags = mate_mixer_context_get_backend_flags (dialog->priv->context);
+
+                if (flags & MATE_MIXER_BACKEND_CAN_SET_DEFAULT_INPUT_STREAM)
+                        mate_mixer_context_set_default_input_stream (dialog->priv->context, stream);
+                else
+                        set_input_stream (dialog, stream);
+        }
+        g_free (name);
+}
+
+static void
+on_output_radio_toggled (GtkCellRendererToggle *renderer,
+                         gchar                 *path_str,
+                         GvcMixerDialog        *dialog)
+{
+        GtkTreeModel *model;
+        GtkTreeIter   iter;
+        GtkTreePath  *path;
+        gboolean      toggled = FALSE;
+        gchar        *name = NULL;
+
+        model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->priv->output_treeview));
+        path  = gtk_tree_path_new_from_string (path_str);
+
+        gtk_tree_model_get_iter (model, &iter, path);
+        gtk_tree_path_free (path);
+
+        gtk_tree_model_get (model, &iter,
+                            NAME_COLUMN, &name,
+                            ACTIVE_COLUMN, &toggled,
+                            -1);
+        if (toggled ^ 1) {
+                MateMixerStream      *stream;
+                MateMixerBackendFlags flags;
+
+                stream = mate_mixer_context_get_stream (dialog->priv->context, name);
+                if (G_UNLIKELY (stream == NULL)) {
+                        g_warn_if_reached ();
+                        g_free (name);
+                        return;
+                }
+
+                g_debug ("Default output stream selection changed to %s", name);
+
+                // XXX cache this
+                flags = mate_mixer_context_get_backend_flags (dialog->priv->context);
+
+                if (flags & MATE_MIXER_BACKEND_CAN_SET_DEFAULT_OUTPUT_STREAM)
+                        mate_mixer_context_set_default_output_stream (dialog->priv->context, stream);
+                else
+                        set_output_stream (dialog, stream);
+        }
+        g_free (name);
+}
+
+static void
+stream_name_to_text (GtkTreeViewColumn *column,
+                     GtkCellRenderer   *cell,
+                     GtkTreeModel      *model,
+                     GtkTreeIter       *iter,
+                     gpointer           user_data)
+{
+        gchar *label;
+        gchar *speakers;
+
+        gtk_tree_model_get (model, iter,
+                            LABEL_COLUMN, &label,
+                            SPEAKERS_COLUMN, &speakers,
+                            -1);
+
+        if (speakers != NULL) {
+                gchar *str = g_strdup_printf ("%s\n<i>%s</i>",
+                                              label,
+                                              speakers);
+
+                g_object_set (cell, "markup", str, NULL);
+                g_free (str);
+                g_free (speakers);
+        } else {
+                g_object_set (cell, "text", label, NULL);
+        }
+
+        g_free (label);
+}
+
+static gint
+compare_stream_treeview_items (GtkTreeModel *model,
+                               GtkTreeIter  *a,
+                               GtkTreeIter  *b,
+                               gpointer      user_data)
+{
+        gchar *desc_a = NULL;
+        gchar *desc_b = NULL;
+        gint   result;
+
+        gtk_tree_model_get (model, a,
+                            LABEL_COLUMN, &desc_a,
+                            -1);
+        gtk_tree_model_get (model, b,
+                            LABEL_COLUMN, &desc_b,
+                            -1);
+
+        if (desc_a == NULL) {
+                g_free (desc_b);
+                return -1;
+        }
+        if (desc_b == NULL) {
+                g_free (desc_a);
+                return 1;
+        }
+
+        result = g_ascii_strcasecmp (desc_a, desc_b);
+
+        g_free (desc_a);
+        g_free (desc_b);
+        return result;
+}
+
+static GtkWidget *
+create_stream_treeview (GvcMixerDialog *dialog, GCallback on_toggled)
+{
+        GtkWidget         *treeview;
+        GtkListStore      *store;
+        GtkCellRenderer   *renderer;
+        GtkTreeViewColumn *column;
+
+        treeview = gtk_tree_view_new ();
+        gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), FALSE);
+
+        store = gtk_list_store_new (NUM_COLUMNS,
+                                    G_TYPE_ICON,
+                                    G_TYPE_STRING,
+                                    G_TYPE_STRING,
+                                    G_TYPE_BOOLEAN,
+                                    G_TYPE_STRING);
+
+        gtk_tree_view_set_model (GTK_TREE_VIEW (treeview),
+                                 GTK_TREE_MODEL (store));
+
+        renderer = gtk_cell_renderer_toggle_new ();
+        gtk_cell_renderer_toggle_set_radio (GTK_CELL_RENDERER_TOGGLE (renderer), TRUE);
+
+        column = gtk_tree_view_column_new_with_attributes (NULL,
+                                                           renderer,
+                                                           "active", ACTIVE_COLUMN,
+                                                           NULL);
+
+        gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
+
+        g_signal_connect (G_OBJECT (renderer),
+                          "toggled",
+                          G_CALLBACK (on_toggled),
+                          dialog);
+
+        gtk_tree_view_insert_column_with_data_func (GTK_TREE_VIEW (treeview), -1,
+                                                    _("Name"),
+                                                    gtk_cell_renderer_text_new (),
+                                                    stream_name_to_text,
+                                                    NULL, NULL);
+
+        /* Keep the list of streams sorted by the name */
+        gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store),
+                                              LABEL_COLUMN,
+                                              GTK_SORT_ASCENDING);
+
+        gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (store),
+                                         LABEL_COLUMN,
+                                         compare_stream_treeview_items,
+                                         NULL, NULL);
+        return treeview;
+}
+
+static void
+on_device_profile_changing (GvcComboBox           *combobox,
+                            MateMixerSwitchOption *option,
+                            GvcMixerDialog        *dialog)
+{
+        g_debug ("Changing device profile");
+        // TODO
+}
+
+static void
+on_test_speakers_clicked (GvcComboBox *widget, GvcMixerDialog *dialog)
+{
+        GtkWidget       *d,
+                        *test,
+                        *container;
+        gchar           *title;
+        MateMixerDevice *device;
+        MateMixerStream *stream;
+
+        device = g_object_get_data (G_OBJECT (widget), "device");
+        if (G_UNLIKELY (device == NULL)) {
+                g_warn_if_reached ();
+                return;
+        }
+
+        stream = find_device_test_stream (dialog, device);
+        if (G_UNLIKELY (stream == NULL)) {
+                g_warn_if_reached ();
+                return;
+        }
+
+        title = g_strdup_printf (_("Speaker Testing for %s"),
+                                 mate_mixer_device_get_label (device));
+
+        d = gtk_dialog_new_with_buttons (title,
+                                         GTK_WINDOW (dialog),
+                                         GTK_DIALOG_MODAL |
+                                         GTK_DIALOG_DESTROY_WITH_PARENT,
+                                         "gtk-close",
+                                         GTK_RESPONSE_CLOSE,
+                                         NULL);
+        g_free (title);
+
+        gtk_window_set_resizable (GTK_WINDOW (d), FALSE);
+
+        test = gvc_speaker_test_new (stream);
+        gtk_widget_show (test);
+
+        container = gtk_dialog_get_content_area (GTK_DIALOG (d));
+        gtk_container_add (GTK_CONTAINER (container), test);
+
+        gtk_dialog_run (GTK_DIALOG (d));
+        gtk_widget_destroy (d);
+}
+
+static void
+on_device_selection_changed (GtkTreeSelection *selection, GvcMixerDialog *dialog)
+{
+        GtkTreeIter          iter;
+        gchar               *name;
+        MateMixerDevice     *device;
+        MateMixerSwitch     *profile_switch;
+
+        g_debug ("Device selection changed");
+
+        if (dialog->priv->hw_profile_combo != NULL) {
+                gtk_container_remove (GTK_CONTAINER (dialog->priv->hw_settings_box),
+                                      dialog->priv->hw_profile_combo);
+
+                dialog->priv->hw_profile_combo = NULL;
+        }
+
+        if (gtk_tree_selection_get_selected (selection, NULL, &iter) == FALSE)
+                return;
+
+        gtk_tree_model_get (gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->priv->hw_treeview)),
+                            &iter,
+                            HW_NAME_COLUMN, &name,
+                            -1);
+
+        device = mate_mixer_context_get_device (dialog->priv->context, name);
+        if (G_UNLIKELY (device == NULL)) {
+                g_warn_if_reached ();
+                g_free (name);
+                return;
+        }
+        g_free (name);
+
+        /* Profile/speaker test combo */
+        profile_switch = find_device_profile_switch (device);
+        if (profile_switch != NULL) {
+                dialog->priv->hw_profile_combo =
+                        gvc_combo_box_new (profile_switch, _("_Profile:"));
+
+                g_object_set (G_OBJECT (dialog->priv->hw_profile_combo),
+                              "button-label", _("Test Speakers"),
+                              NULL);
+
+                g_signal_connect (G_OBJECT (dialog->priv->hw_profile_combo),
+                                  "changing",
+                                  G_CALLBACK (on_device_profile_changing),
+                                  dialog);
+
+                g_signal_connect (G_OBJECT (dialog->priv->hw_profile_combo),
+                                  "button-clicked",
+                                  G_CALLBACK (on_test_speakers_clicked),
+                                  dialog);
+
+                g_object_set_data_full (G_OBJECT (dialog->priv->hw_profile_combo),
+                                        "device",
+                                        g_object_ref (device),
+                                        g_object_unref);
+
+                gtk_box_pack_start (GTK_BOX (dialog->priv->hw_settings_box),
+                                    dialog->priv->hw_profile_combo,
+                                    TRUE, TRUE, 6);
+
+                /* Enable the speaker test button if the selected device
+                 * is capable of sound output */
+                update_device_test_visibility (dialog);
+
+                gtk_widget_show (dialog->priv->hw_profile_combo);
+        }
+}
+
+static void
+on_notebook_switch_page (GtkNotebook    *notebook,
+                         GtkWidget      *page,
+                         guint           page_num,
+                         GvcMixerDialog *dialog)
+{
+        MateMixerStreamControl *control;
+
+        // XXX because this is called too early in constructor
+        if (G_UNLIKELY (dialog->priv->input_bar == NULL))
+                return;
+
+        control = gvc_channel_bar_get_control (GVC_CHANNEL_BAR (dialog->priv->input_bar));
+        if (control == NULL)
+                return;
+
+        if (page_num == PAGE_INPUT)
+                mate_mixer_stream_control_set_monitor_enabled (control, TRUE);
+        else
+                mate_mixer_stream_control_set_monitor_enabled (control, FALSE);
+}
+
+static void
+device_name_to_text (GtkTreeViewColumn *column,
+                     GtkCellRenderer   *cell,
+                     GtkTreeModel      *model,
+                     GtkTreeIter       *iter,
+                     gpointer           user_data)
+{
+        gchar *label = NULL;
+        gchar *profile = NULL;
+        gchar *status = NULL;
+
+        gtk_tree_model_get (model, iter,
+                            HW_LABEL_COLUMN, &label,
+                            HW_PROFILE_COLUMN, &profile,
+                            HW_STATUS_COLUMN, &status,
+                            -1);
+
+        if (G_LIKELY (status != NULL)) {
+                gchar *str;
+
+                if (profile != NULL)
+                        str = g_strdup_printf ("%s\n<i>%s</i>\n<i>%s</i>",
+                                               label,
+                                               status,
+                                               profile);
+                else
+                        str = g_strdup_printf ("%s\n<i>%s</i>",
+                                               label,
+                                               status);
+
+                g_object_set (cell, "markup", str, NULL);
+                g_free (str);
+                g_free (profile);
+                g_free (status);
+        } else
+                g_object_set (cell, "text", label, NULL);
+
+        g_free (label);
+}
+
+static gint
+compare_device_treeview_items (GtkTreeModel *model,
+                               GtkTreeIter  *a,
+                               GtkTreeIter  *b,
+                               gpointer      user_data)
+{
+        gchar *desc_a = NULL;
+        gchar *desc_b = NULL;
+        gint   result;
+
+        gtk_tree_model_get (model, a,
+                            HW_LABEL_COLUMN, &desc_a,
+                            -1);
+        gtk_tree_model_get (model, b,
+                            HW_LABEL_COLUMN, &desc_b,
+                            -1);
+
+        result = g_ascii_strcasecmp (desc_a, desc_b);
+
+        g_free (desc_a);
+        g_free (desc_b);
+        return result;
+}
+
+static GtkWidget *
+create_device_treeview (GvcMixerDialog *dialog, GCallback on_changed)
+{
+        GtkWidget         *treeview;
+        GtkListStore      *store;
+        GtkCellRenderer   *renderer;
+        GtkTreeViewColumn *column;
+        GtkTreeSelection  *selection;
+
+        treeview = gtk_tree_view_new ();
+        gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), FALSE);
+
+        selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
+        g_signal_connect (G_OBJECT (selection),
+                          "changed",
+                          on_changed,
+                          dialog);
+
+        store = gtk_list_store_new (HW_NUM_COLUMNS,
+                                    G_TYPE_ICON,
+                                    G_TYPE_STRING,
+                                    G_TYPE_STRING,
+                                    G_TYPE_STRING,
+                                    G_TYPE_STRING);
+
+        gtk_tree_view_set_model (GTK_TREE_VIEW (treeview),
+                                 GTK_TREE_MODEL (store));
+
+        renderer = gtk_cell_renderer_pixbuf_new ();
+        g_object_set (G_OBJECT (renderer),
+                      "stock-size",
+                      GTK_ICON_SIZE_DIALOG,
+                      NULL);
+
+        column = gtk_tree_view_column_new_with_attributes (NULL,
+                                                           renderer,
+                                                           "gicon", HW_ICON_COLUMN,
+                                                           NULL);
+
+        gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
+        gtk_tree_view_insert_column_with_data_func (GTK_TREE_VIEW (treeview), -1,
+                                                    _("Name"),
+                                                    gtk_cell_renderer_text_new (),
+                                                    device_name_to_text,
+                                                    NULL, NULL);
+
+        /* Keep the list of streams sorted by the name */
+        gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store),
+                                              HW_LABEL_COLUMN,
+                                              GTK_SORT_ASCENDING);
+
+        gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (store),
+                                         HW_LABEL_COLUMN,
+                                         compare_device_treeview_items,
+                                         NULL, NULL);
+        return treeview;
+}
+
+static void
+dialog_accel_cb (GtkAccelGroup    *accelgroup,
+                 GObject          *object,
+                 guint             key,
+                 GdkModifierType   mod,
+                 GvcMixerDialog   *self)
+{
+        gint  num = -1;
+        gsize i;
+
+        for (i = 0; i < G_N_ELEMENTS (tab_accel_keys); i++) {
+                if (tab_accel_keys[i] == key) {
+                        num = (gint) i;
+                        break;
+                }
+        }
+
+        if (num != -1)
+                gtk_notebook_set_current_page (GTK_NOTEBOOK (self->priv->notebook), num);
+}
+
+static void
+create_page_effects (GvcMixerDialog *self)
+{
+        GtkWidget *box;
+        GtkWidget *label;
+        GtkWidget *chooser;
+
+        box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
+        gtk_container_set_border_width (GTK_CONTAINER (box), 12);
+
+        label = gtk_label_new (_("Sound Effects"));
+        gtk_notebook_append_page (GTK_NOTEBOOK (self->priv->notebook),
+                                  box,
+                                  label);
+
+        /*
+         * Create a volume slider for the sound effect sounds.
+         *
+         * Only look for a stored control because regular controls only exist
+         * for short time periods when an event sound is played.
+         */
+        if (self->priv->backend_flags & MATE_MIXER_BACKEND_HAS_STORED_CONTROLS) {
+                GvcChannelBar *bar;
+                const GList   *list;
+
+                bar = GVC_CHANNEL_BAR (create_bar (self, TRUE, TRUE));
+
+                gtk_box_pack_start (GTK_BOX (box),
+                                    GTK_WIDGET (bar),
+                                    FALSE, FALSE, 0);
+
+                gvc_channel_bar_set_show_marks (bar, FALSE);
+                gvc_channel_bar_set_extended (bar, FALSE);
+                gvc_channel_bar_set_name (bar, _("_Alert volume: "));
+
+                /* Find an event role stored control */
+                list = mate_mixer_context_list_stored_controls (self->priv->context);
+                while (list != NULL) {
+                        MateMixerStreamControl *control = MATE_MIXER_STREAM_CONTROL (list->data);
+                        MateMixerStreamControlMediaRole media_role;
+
+                        media_role = mate_mixer_stream_control_get_media_role (control);
+
+                        if (media_role == MATE_MIXER_STREAM_CONTROL_MEDIA_ROLE_EVENT) {
+                                bar_set_stream_control (self, GTK_WIDGET (bar), control);
+                                break;
+                        }
+
+                        list = list->next;
+                }
+
+                self->priv->effects_bar = GTK_WIDGET (bar);
+        }
+
+        chooser = gvc_sound_theme_chooser_new ();
+        gtk_box_pack_start (GTK_BOX (box),
+                            chooser,
+                            TRUE, TRUE, 6);
+}
+
+static gboolean
+on_notebook_scroll_event (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;
+                        }
+                        break;
+        }
+
+        return TRUE;
+}
+
+static GObject *
+gvc_mixer_dialog_constructor (GType                  type,
+                              guint                  n_construct_properties,
+                              GObjectConstructParam *construct_params)
+{
+        GObject          *object;
+        GvcMixerDialog   *self;
+        GtkWidget        *main_vbox;
+        GtkWidget        *label;
+        GtkWidget        *box;
+        GtkWidget        *scroll_box;
+        GtkWidget        *sbox;
+        GtkWidget        *ebox;
+        GtkTreeSelection *selection;
+        GtkAccelGroup    *accel_group;
+        GtkTreeIter       iter;
+        gsize             i;
+        const GList      *list;
+        GClosure         *closure = NULL;
+
+        object = G_OBJECT_CLASS (gvc_mixer_dialog_parent_class)->constructor (type,
+                                                                              n_construct_properties,
+                                                                              construct_params);
+
+        self = GVC_MIXER_DIALOG (object);
+
+        self->priv->sound_settings = g_settings_new ("org.mate.sound");
+
+        gtk_dialog_add_button (GTK_DIALOG (self), "gtk-close", GTK_RESPONSE_OK);
+
+        main_vbox = gtk_dialog_get_content_area (GTK_DIALOG (self));
+        gtk_box_set_spacing (GTK_BOX (main_vbox), 2);
+
+        gtk_container_set_border_width (GTK_CONTAINER (self), 6);
+
+        self->priv->output_stream_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
+        gtk_container_set_border_width (GTK_CONTAINER (self->priv->output_stream_box), 12);
+
+        gtk_box_pack_start (GTK_BOX (main_vbox),
+                            self->priv->output_stream_box,
+                            FALSE, FALSE, 0);
+
+        self->priv->output_bar = create_bar (self, TRUE, TRUE);
+        gvc_channel_bar_set_name (GVC_CHANNEL_BAR (self->priv->output_bar),
+                                  _("_Output volume: "));
+
+        g_settings_bind (self->priv->sound_settings, "volume-overamplifiable",
+                         self->priv->output_bar,     "extended",
+                         G_SETTINGS_BIND_GET);
+
+        gtk_widget_show (self->priv->output_bar);
+        gtk_widget_set_sensitive (self->priv->output_bar, FALSE);
+
+        gtk_box_pack_start (GTK_BOX (self->priv->output_stream_box),
+                            self->priv->output_bar, TRUE, TRUE, 0);
+
+        self->priv->volume_overamplifiable_button =
+                gtk_check_button_new_with_mnemonic (_("Allow volume to e_xceed 100%"));
+
+        g_settings_bind (self->priv->sound_settings,                "volume-overamplifiable",
+                         self->priv->volume_overamplifiable_button, "active",
+                         G_SETTINGS_BIND_GET|G_SETTINGS_BIND_SET);
+
+        gtk_box_pack_start (GTK_BOX (self->priv->output_stream_box),
+                            self->priv->volume_overamplifiable_button,
+                            FALSE, FALSE, 0);
+
+        self->priv->notebook = gtk_notebook_new ();
+
+        gtk_widget_add_events (self->priv->notebook, GDK_SCROLL_MASK);
+        g_signal_connect (self->priv->notebook,
+                          "scroll-event",
+                          G_CALLBACK (on_notebook_scroll_event),
+                          NULL);
+
+        gtk_box_pack_start (GTK_BOX (main_vbox),
+                            self->priv->notebook,
+                            TRUE, TRUE, 0);
+
+        g_signal_connect (G_OBJECT (self->priv->notebook),
+                          "switch-page",
+                          G_CALLBACK (on_notebook_switch_page),
+                          self);
+
+        gtk_container_set_border_width (GTK_CONTAINER (self->priv->notebook), 5);
+
+        /* Set up accels (borrowed from Empathy) */
+        accel_group = gtk_accel_group_new ();
+        gtk_window_add_accel_group (GTK_WINDOW (self), accel_group);
+
+        for (i = 0; i < G_N_ELEMENTS (tab_accel_keys); i++) {
+                closure = g_cclosure_new (G_CALLBACK (dialog_accel_cb),
+                                          self,
+                                          NULL);
+                gtk_accel_group_connect (accel_group,
+                                         tab_accel_keys[i],
+                                         GDK_MOD1_MASK,
+                                         0,
+                                         closure);
+        }
+
+        g_object_unref (accel_group);
+
+        /* Create notebook pages */
+        create_page_effects (self);
+
+        self->priv->hw_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
+        gtk_container_set_border_width (GTK_CONTAINER (self->priv->hw_box), 12);
+
+        label = gtk_label_new (_("Hardware"));
+        gtk_notebook_append_page (GTK_NOTEBOOK (self->priv->notebook),
+                                  self->priv->hw_box,
+                                  label);
+
+        box = gtk_frame_new (_("C_hoose a device to configure:"));
+        label = gtk_frame_get_label_widget (GTK_FRAME (box));
+        make_label_bold (GTK_LABEL (label));
+        gtk_label_set_use_underline (GTK_LABEL (label), TRUE);
+        gtk_frame_set_shadow_type (GTK_FRAME (box), GTK_SHADOW_NONE);
+        gtk_box_pack_start (GTK_BOX (self->priv->hw_box), box, TRUE, TRUE, 0);
+
+        self->priv->hw_treeview = create_device_treeview (self,
+                                                         G_CALLBACK (on_device_selection_changed));
+        gtk_label_set_mnemonic_widget (GTK_LABEL (label), self->priv->hw_treeview);
+
+        scroll_box = gtk_scrolled_window_new (NULL, NULL);
+        gtk_widget_set_margin_top (scroll_box, 6);
+        gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll_box),
+                                        GTK_POLICY_NEVER,
+                                        GTK_POLICY_AUTOMATIC);
+        gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scroll_box),
+                                             GTK_SHADOW_IN);
+        gtk_container_add (GTK_CONTAINER (scroll_box), self->priv->hw_treeview);
+        gtk_container_add (GTK_CONTAINER (box), scroll_box);
+
+        selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (self->priv->hw_treeview));
+        gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
+
+        box = gtk_frame_new (_("Settings for the selected device:"));
+        label = gtk_frame_get_label_widget (GTK_FRAME (box));
+        make_label_bold (GTK_LABEL (label));
+        gtk_frame_set_shadow_type (GTK_FRAME (box), GTK_SHADOW_NONE);
+        gtk_box_pack_start (GTK_BOX (self->priv->hw_box), box, FALSE, TRUE, 12);
+
+        self->priv->hw_settings_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
+
+        gtk_container_add (GTK_CONTAINER (box), self->priv->hw_settings_box);
+
+        self->priv->input_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
+
+        gtk_container_set_border_width (GTK_CONTAINER (self->priv->input_box), 12);
+
+        label = gtk_label_new (_("Input"));
+        gtk_notebook_append_page (GTK_NOTEBOOK (self->priv->notebook),
+                                  self->priv->input_box,
+                                  label);
+
+        self->priv->input_bar = create_bar (self, TRUE, TRUE);
+        gtk_widget_set_margin_top (self->priv->input_bar, 6);
+
+        gvc_channel_bar_set_name (GVC_CHANNEL_BAR (self->priv->input_bar),
+                                  _("_Input volume: "));
+
+        gvc_channel_bar_set_low_icon_name (GVC_CHANNEL_BAR (self->priv->input_bar),
+                                           "audio-input-microphone-low");
+        gvc_channel_bar_set_high_icon_name (GVC_CHANNEL_BAR (self->priv->input_bar),
+                                            "audio-input-microphone-high");
+
+        gtk_widget_show (self->priv->input_bar);
+        gtk_widget_set_sensitive (self->priv->input_bar, FALSE);
+
+        gtk_box_pack_start (GTK_BOX (self->priv->input_box),
+                            self->priv->input_bar,
+                            FALSE, FALSE, 0);
+
+        box  = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
+        sbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
+        ebox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
+
+        gtk_box_pack_start (GTK_BOX (self->priv->input_box),
+                            box,
+                            FALSE, FALSE, 6);
+        gtk_box_pack_start (GTK_BOX (box),
+                            sbox,
+                            FALSE, FALSE, 0);
+
+        label = gtk_label_new (_("Input level:"));
+        gtk_box_pack_start (GTK_BOX (sbox),
+                            label,
+                            FALSE, FALSE, 0);
+        gtk_size_group_add_widget (self->priv->size_group, sbox);
+
+        self->priv->input_level_bar = gvc_level_bar_new ();
+        gvc_level_bar_set_orientation (GVC_LEVEL_BAR (self->priv->input_level_bar),
+                                       GTK_ORIENTATION_HORIZONTAL);
+        gvc_level_bar_set_scale (GVC_LEVEL_BAR (self->priv->input_level_bar),
+                                 GVC_LEVEL_SCALE_LINEAR);
+        gtk_label_set_mnemonic_widget (GTK_LABEL (label),
+                                       self->priv->input_level_bar);
+        gtk_widget_set_can_focus (self->priv->input_level_bar, TRUE);
+        gtk_box_pack_start (GTK_BOX (box),
+                            self->priv->input_level_bar,
+                            TRUE, TRUE, 6);
+
+        gtk_box_pack_start (GTK_BOX (box),
+                            ebox,
+                            FALSE, FALSE, 0);
+        gtk_size_group_add_widget (self->priv->size_group, ebox);
+
+        self->priv->input_settings_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
+        gtk_box_pack_start (GTK_BOX (self->priv->input_box),
+                            self->priv->input_settings_box,
+                            FALSE, FALSE, 0);
+
+        box = gtk_frame_new (_("C_hoose a device for sound input:"));
+        label = gtk_frame_get_label_widget (GTK_FRAME (box));
+        make_label_bold (GTK_LABEL (label));
+        gtk_label_set_use_underline (GTK_LABEL (label), TRUE);
+        gtk_frame_set_shadow_type (GTK_FRAME (box), GTK_SHADOW_NONE);
+        gtk_box_pack_start (GTK_BOX (self->priv->input_box), box, TRUE, TRUE, 0);
+
+        self->priv->input_treeview =
+                create_stream_treeview (self, G_CALLBACK (on_input_radio_toggled));
+
+        gtk_label_set_mnemonic_widget (GTK_LABEL (label), self->priv->input_treeview);
+
+        scroll_box = gtk_scrolled_window_new (NULL, NULL);
+        gtk_widget_set_margin_top (scroll_box, 6);
+        gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll_box),
+                                        GTK_POLICY_NEVER,
+                                        GTK_POLICY_AUTOMATIC);
+        gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scroll_box),
+                                             GTK_SHADOW_IN);
+        gtk_container_add (GTK_CONTAINER (scroll_box), self->priv->input_treeview);
+        gtk_container_add (GTK_CONTAINER (box), scroll_box);
+
+        selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (self->priv->input_treeview));
+        gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
+
+        /* Output page */
+        self->priv->output_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
+        gtk_container_set_border_width (GTK_CONTAINER (self->priv->output_box), 12);
+        label = gtk_label_new (_("Output"));
+        gtk_notebook_append_page (GTK_NOTEBOOK (self->priv->notebook),
+                                  self->priv->output_box,
+                                  label);
+
+        box = gtk_frame_new (_("C_hoose a device for sound output:"));
+        label = gtk_frame_get_label_widget (GTK_FRAME (box));
+        make_label_bold (GTK_LABEL (label));
+        gtk_label_set_use_underline (GTK_LABEL (label), TRUE);
+        gtk_frame_set_shadow_type (GTK_FRAME (box), GTK_SHADOW_NONE);
+        gtk_box_pack_start (GTK_BOX (self->priv->output_box), box, TRUE, TRUE, 0);
+
+        self->priv->output_treeview = create_stream_treeview (self,
+                                                              G_CALLBACK (on_output_radio_toggled));
+        gtk_label_set_mnemonic_widget (GTK_LABEL (label), self->priv->output_treeview);
+
+        scroll_box = gtk_scrolled_window_new (NULL, NULL);
+        gtk_widget_set_margin_top (scroll_box, 6);
+        gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll_box),
+                                        GTK_POLICY_NEVER,
+                                        GTK_POLICY_AUTOMATIC);
+        gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scroll_box),
+                                             GTK_SHADOW_IN);
+        gtk_container_add (GTK_CONTAINER (scroll_box), self->priv->output_treeview);
+        gtk_container_add (GTK_CONTAINER (box), scroll_box);
+
+        selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (self->priv->output_treeview));
+        gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
+
+        box = gtk_frame_new (_("Settings for the selected device:"));
+        label = gtk_frame_get_label_widget (GTK_FRAME (box));
+        make_label_bold (GTK_LABEL (label));
+        gtk_frame_set_shadow_type (GTK_FRAME (box), GTK_SHADOW_NONE);
+        gtk_box_pack_start (GTK_BOX (self->priv->output_box), box, FALSE, FALSE, 12);
+        self->priv->output_settings_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
+        gtk_container_add (GTK_CONTAINER (box), self->priv->output_settings_box);
+
+        self->priv->output_settings_frame = box;
+
+        /* Applications */
+        self->priv->applications_window = gtk_scrolled_window_new (NULL, NULL);
+        gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (self->priv->applications_window),
+                                        GTK_POLICY_NEVER,
+                                        GTK_POLICY_AUTOMATIC);
+
+        gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (self->priv->applications_window),
+                                             GTK_SHADOW_NONE);
+
+        self->priv->applications_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
+        gtk_container_set_border_width (GTK_CONTAINER (self->priv->applications_box), 12);
+
+        gtk_container_add (GTK_CONTAINER (self->priv->applications_window),
+                           self->priv->applications_box);
+
+        label = gtk_label_new (_("Applications"));
+        gtk_notebook_append_page (GTK_NOTEBOOK (self->priv->notebook),
+                                  self->priv->applications_window,
+                                  label);
+
+        self->priv->no_apps_label = gtk_label_new (_("No application is currently playing or recording audio."));
+        gtk_box_pack_start (GTK_BOX (self->priv->applications_box),
+                            self->priv->no_apps_label,
+                            TRUE, TRUE, 0);
+
+        gtk_widget_show_all (main_vbox);
+
+        list = mate_mixer_context_list_streams (self->priv->context);
+        while (list != NULL) {
+                add_stream (self, MATE_MIXER_STREAM (list->data));
+                list = list->next;
+        }
+
+        list = mate_mixer_context_list_devices (self->priv->context);
+        while (list != NULL) {
+                add_device (self, MATE_MIXER_DEVICE (list->data));
+                list = list->next;
+        }
+
+        selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (self->priv->hw_treeview));
+
+        /* Select the first device in the list */
+        // XXX handle no devices
+        if (gtk_tree_selection_get_selected (selection, NULL, NULL) == FALSE) {
+                GtkTreeModel *model =
+                        gtk_tree_view_get_model (GTK_TREE_VIEW (self->priv->hw_treeview));
+
+                if (gtk_tree_model_get_iter_first (model, &iter))
+                        gtk_tree_selection_select_iter (selection, &iter);
+        }
+
+        return object;
+}
+
+static MateMixerContext *
+gvc_mixer_dialog_get_context (GvcMixerDialog *dialog)
+{
+        return dialog->priv->context;
+}
+
+static void
+gvc_mixer_dialog_set_context (GvcMixerDialog *dialog, MateMixerContext *context)
+{
+        dialog->priv->context = g_object_ref (context);
+
+        g_signal_connect (G_OBJECT (dialog->priv->context),
+                          "stream-added",
+                          G_CALLBACK (on_context_stream_added),
+                          dialog);
+        g_signal_connect (G_OBJECT (dialog->priv->context),
+                          "stream-removed",
+                          G_CALLBACK (on_context_stream_removed),
+                          dialog);
+
+        g_signal_connect (G_OBJECT (dialog->priv->context),
+                          "device-added",
+                          G_CALLBACK (on_context_device_added),
+                          dialog);
+        g_signal_connect (G_OBJECT (dialog->priv->context),
+                          "device-removed",
+                          G_CALLBACK (on_context_device_removed),
+                          dialog);
+
+        g_signal_connect (G_OBJECT (dialog->priv->context),
+                          "notify::default-input-stream",
+                          G_CALLBACK (on_context_default_input_stream_notify),
+                          dialog);
+        g_signal_connect (G_OBJECT (dialog->priv->context),
+                          "notify::default-output-stream",
+                          G_CALLBACK (on_context_default_output_stream_notify),
+                          dialog);
+
+        g_signal_connect (G_OBJECT (dialog->priv->context),
+                          "stored-control-added",
+                          G_CALLBACK (on_context_stored_control_added),
+                          dialog);
+        g_signal_connect (G_OBJECT (dialog->priv->context),
+                          "stored-control-removed",
+                          G_CALLBACK (on_context_stored_control_removed),
+                          dialog);
+
+        dialog->priv->backend_flags = mate_mixer_context_get_backend_flags (context);
+
+        g_object_notify (G_OBJECT (dialog), "context");
+}
+
+static void
+gvc_mixer_dialog_set_property (GObject       *object,
+                               guint          prop_id,
+                               const GValue  *value,
+                               GParamSpec    *pspec)
+{
+        GvcMixerDialog *self = GVC_MIXER_DIALOG (object);
+
+        switch (prop_id) {
+        case PROP_CONTEXT:
+                gvc_mixer_dialog_set_context (self, g_value_get_object (value));
+                break;
+        default:
+                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+                break;
+        }
+}
+
+static void
+gvc_mixer_dialog_get_property (GObject     *object,
+                               guint        prop_id,
+                               GValue      *value,
+                               GParamSpec  *pspec)
+{
+        GvcMixerDialog *self = GVC_MIXER_DIALOG (object);
+
+        switch (prop_id) {
+        case PROP_CONTEXT:
+                g_value_set_object (value, gvc_mixer_dialog_get_context (self));
+                break;
+        default:
+                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+                break;
+        }
+}
+
+static void
+gvc_mixer_dialog_dispose (GObject *object)
+{
+        GvcMixerDialog *dialog = GVC_MIXER_DIALOG (object);
+
+        if (dialog->priv->context != NULL) {
+                g_signal_handlers_disconnect_by_data (G_OBJECT (dialog->priv->context),
+                                                      dialog);
+
+                g_clear_object (&dialog->priv->context);
+        }
+
+        g_clear_object (&dialog->priv->sound_settings);
+
+        G_OBJECT_CLASS (gvc_mixer_dialog_parent_class)->dispose (object);
+}
+
+static void
+gvc_mixer_dialog_class_init (GvcMixerDialogClass *klass)
+{
+        GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+        object_class->constructor = gvc_mixer_dialog_constructor;
+        object_class->dispose = gvc_mixer_dialog_dispose;
+        object_class->finalize = gvc_mixer_dialog_finalize;
+        object_class->set_property = gvc_mixer_dialog_set_property;
+        object_class->get_property = gvc_mixer_dialog_get_property;
+
+        g_object_class_install_property (object_class,
+                                         PROP_CONTEXT,
+                                         g_param_spec_object ("context",
+                                                              "Context",
+                                                              "MateMixer context",
+                                                              MATE_MIXER_TYPE_CONTEXT,
+                                                              G_PARAM_READWRITE |
+                                                              G_PARAM_CONSTRUCT_ONLY |
+                                                              G_PARAM_STATIC_STRINGS));
+
+        GtkWidgetClass *widget_class  = GTK_WIDGET_CLASS (klass);
+        gtk_widget_class_set_css_name (widget_class, "GvcMixerDialog");
+}
+
+static void
+gvc_mixer_dialog_init (GvcMixerDialog *dialog)
+{
+        dialog->priv = gvc_mixer_dialog_get_instance_private (dialog);
+
+        dialog->priv->bars = g_hash_table_new (g_str_hash, g_str_equal);
+        dialog->priv->size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
+}
+
+static void
+gvc_mixer_dialog_finalize (GObject *object)
+{
+        GvcMixerDialog *dialog;
+
+        dialog = GVC_MIXER_DIALOG (object);
+
+        g_hash_table_destroy (dialog->priv->bars);
+
+        G_OBJECT_CLASS (gvc_mixer_dialog_parent_class)->finalize (object);
+}
+
+GvcMixerDialog *
+gvc_mixer_dialog_new (MateMixerContext *context)
+{
+        return g_object_new (GVC_TYPE_MIXER_DIALOG,
+                             "icon-name", "multimedia-volume-control",
+                             "title", _("Sound Preferences"),
+                             "context", context,
+                             NULL);
+}
+
+gboolean
+gvc_mixer_dialog_set_page (GvcMixerDialog *self, const gchar *page)
+{
+        guint num = 0;
+
+        g_return_val_if_fail (GVC_IS_MIXER_DIALOG (self), FALSE);
+
+        if (page != NULL) {
+                if (g_str_equal (page, "effects"))
+                        num = PAGE_EFFECTS;
+                else if (g_str_equal (page, "hardware"))
+                        num = PAGE_HARDWARE;
+                else if (g_str_equal (page, "input"))
+                        num = PAGE_INPUT;
+                else if (g_str_equal (page, "output"))
+                        num = PAGE_OUTPUT;
+                else if (g_str_equal (page, "applications"))
+                        num = PAGE_APPLICATIONS;
+        }
+
+        gtk_notebook_set_current_page (GTK_NOTEBOOK (self->priv->notebook), num);
+
+        return TRUE;
+}
+
+ +
+ +
+ + diff --git a/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/55.html b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/55.html new file mode 100644 index 0000000..7261e95 --- /dev/null +++ b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/55.html @@ -0,0 +1,347 @@ + + + + + + Cppcheck - HTML report - mate-media + + + + + +
+ + + +
+
 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
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 Red Hat, Inc.
+ * 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.
+ *
+ */
+
+#ifndef __GVC_SOUND_THEME_CHOOSER_H
+#define __GVC_SOUND_THEME_CHOOSER_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 GVC_TYPE_SOUND_THEME_CHOOSER         (gvc_sound_theme_chooser_get_type ())
+#define GVC_SOUND_THEME_CHOOSER(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), GVC_TYPE_SOUND_THEME_CHOOSER, GvcSoundThemeChooser))
+#define GVC_SOUND_THEME_CHOOSER_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST((k), GVC_TYPE_SOUND_THEME_CHOOSER, GvcSoundThemeChooserClass))
+#define GVC_IS_SOUND_THEME_CHOOSER(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), GVC_TYPE_SOUND_THEME_CHOOSER))
+#define GVC_IS_SOUND_THEME_CHOOSER_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), GVC_TYPE_SOUND_THEME_CHOOSER))
+#define GVC_SOUND_THEME_CHOOSER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GVC_TYPE_SOUND_THEME_CHOOSER, GvcSoundThemeChooserClass))
+
+typedef struct GvcSoundThemeChooserPrivate GvcSoundThemeChooserPrivate;
+
+typedef struct
+{
+        GtkBox                       parent;
+        GvcSoundThemeChooserPrivate *priv;
+} GvcSoundThemeChooser;
+
+typedef struct
+{
+        GtkBoxClass           parent_class;
+} GvcSoundThemeChooserClass;
+
+GType               gvc_sound_theme_chooser_get_type            (void);
+
+GtkWidget *         gvc_sound_theme_chooser_new                 (void);
+
+G_END_DECLS
+
+#endif /* __GVC_SOUND_THEME_CHOOSER_H */
+
+ +
+ +
+ + diff --git a/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/56.html b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/56.html new file mode 100644 index 0000000..8900dcc --- /dev/null +++ b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/56.html @@ -0,0 +1,365 @@ + + + + + + Cppcheck - HTML report - mate-media + + + + + +
+ + + +
+
 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: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2009 Red Hat, Inc.
+ * Copyright (C) 2014 Michal Ratajsky <michal.ratajsky@gmail.com>
+ * 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.
+ *
+ */
+
+#ifndef __GVC_SPEAKER_TEST_H
+#define __GVC_SPEAKER_TEST_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.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <libmatemixer/matemixer.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+G_BEGIN_DECLS
+
+#define GVC_TYPE_SPEAKER_TEST         (gvc_speaker_test_get_type ())
+#define GVC_SPEAKER_TEST(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), GVC_TYPE_SPEAKER_TEST, GvcSpeakerTest))
+#define GVC_SPEAKER_TEST_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST((k), GVC_TYPE_SPEAKER_TEST, GvcSpeakerTestClass))
+#define GVC_IS_SPEAKER_TEST(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), GVC_TYPE_SPEAKER_TEST))
+#define GVC_IS_SPEAKER_TEST_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), GVC_TYPE_SPEAKER_TEST))
+#define GVC_SPEAKER_TEST_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GVC_TYPE_SPEAKER_TEST, GvcSpeakerTestClass))
+
+typedef struct _GvcSpeakerTest         GvcSpeakerTest;
+typedef struct _GvcSpeakerTestClass    GvcSpeakerTestClass;
+typedef struct _GvcSpeakerTestPrivate  GvcSpeakerTestPrivate;
+
+struct _GvcSpeakerTest
+{
+        GtkGrid                   parent;
+        GvcSpeakerTestPrivate    *priv;
+};
+
+struct _GvcSpeakerTestClass
+{
+        GtkGridClass              parent_class;
+};
+
+GType               gvc_speaker_test_get_type            (void) G_GNUC_CONST;
+
+GtkWidget *         gvc_speaker_test_new                 (MateMixerStream *stream);
+
+MateMixerStream *   gvc_speaker_test_get_stream          (GvcSpeakerTest  *test);
+
+G_END_DECLS
+
+#endif /* __GVC_SPEAKER_TEST_H */
+
+ +
+ +
+ + diff --git a/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/57.html b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/57.html new file mode 100644 index 0000000..aa18be7 --- /dev/null +++ b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/57.html @@ -0,0 +1,2451 @@ + + + + + + Cppcheck - HTML report - mate-media + + + + + +
+ + + +
+
   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
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 Bastien Nocera <hadess@hadess.net>
+ * Copyright (C) 2008 William Jon McCann
+ * 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.
+ *
+ */
+
+#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 <utime.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 <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-object.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 <gtk/gtk.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 <libxml/tree.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "gvc-sound-theme-chooser.h"
+#include "sound-theme-file-utils.h"
+
+struct GvcSoundThemeChooserPrivate
+{
+        GtkWidget *combo_box;
+        GtkWidget *treeview;
+        GtkWidget *theme_box;
+        GtkWidget *selection_box;
+        GtkWidget *click_feedback_button;
+        GSettings *sound_settings;
+};
+
+static void     gvc_sound_theme_chooser_dispose   (GObject            *object);
+
+G_DEFINE_TYPE_WITH_PRIVATE (GvcSoundThemeChooser, gvc_sound_theme_chooser, GTK_TYPE_BOX)
+
+#define KEY_SOUNDS_SCHEMA          "org.mate.sound"
+#define EVENT_SOUNDS_KEY           "event-sounds"
+#define INPUT_SOUNDS_KEY           "input-feedback-sounds"
+#define SOUND_THEME_KEY            "theme-name"
+
+#define DEFAULT_ALERT_ID        "__default"
+#define CUSTOM_THEME_NAME       "__custom"
+#define NO_SOUNDS_THEME_NAME    "__no_sounds"
+
+enum {
+        THEME_DISPLAY_COL,
+        THEME_IDENTIFIER_COL,
+        THEME_PARENT_ID_COL,
+        THEME_NUM_COLS
+};
+
+enum {
+        ALERT_DISPLAY_COL,
+        ALERT_IDENTIFIER_COL,
+        ALERT_SOUND_TYPE_COL,
+        ALERT_ACTIVE_COL,
+        ALERT_NUM_COLS
+};
+
+enum {
+        SOUND_TYPE_UNSET,
+        SOUND_TYPE_OFF,
+        SOUND_TYPE_DEFAULT_FROM_THEME,
+        SOUND_TYPE_BUILTIN,
+        SOUND_TYPE_CUSTOM
+};
+
+static void
+on_combobox_changed (GtkComboBox          *widget,
+                     GvcSoundThemeChooser *chooser)
+{
+        GtkTreeIter   iter;
+        GtkTreeModel *model;
+        char         *theme_name;
+
+        if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (chooser->priv->combo_box), &iter) == FALSE) {
+                return;
+        }
+
+        model = gtk_combo_box_get_model (GTK_COMBO_BOX (chooser->priv->combo_box));
+        gtk_tree_model_get (model, &iter, THEME_IDENTIFIER_COL, &theme_name, -1);
+
+        g_assert (theme_name != NULL);
+
+        /* It is necessary to update the theme name before any other setting as
+         * the "changed" notification will reload the contents of the widget */
+        g_settings_set_string (chooser->priv->sound_settings, SOUND_THEME_KEY, theme_name);
+
+        /* special case for no sounds */
+        if (strcmp (theme_name, NO_SOUNDS_THEME_NAME) == 0) {
+                g_settings_set_boolean (chooser->priv->sound_settings, EVENT_SOUNDS_KEY, FALSE);
+                return;
+        } else {
+                g_settings_set_boolean (chooser->priv->sound_settings, EVENT_SOUNDS_KEY, TRUE);
+        }
+
+        g_free (theme_name);
+
+        /* FIXME: reset alert model */
+}
+
+static char *
+load_index_theme_name (const char *index,
+                       char      **parent)
+{
+        GKeyFile *file;
+        char *indexname = NULL;
+        gboolean hidden;
+
+        file = g_key_file_new ();
+        if (g_key_file_load_from_file (file, index, G_KEY_FILE_KEEP_TRANSLATIONS, NULL) == FALSE) {
+                g_key_file_free (file);
+                return NULL;
+        }
+        /* Don't add hidden themes to the list */
+        hidden = g_key_file_get_boolean (file, "Sound Theme", "Hidden", NULL);
+        if (!hidden) {
+                indexname = g_key_file_get_locale_string (file,
+                                                          "Sound Theme",
+                                                          "Name",
+                                                          NULL,
+                                                          NULL);
+
+                /* Save the parent theme, if there's one */
+                if (parent != NULL) {
+                        *parent = g_key_file_get_string (file,
+                                                         "Sound Theme",
+                                                         "Inherits",
+                                                         NULL);
+                }
+        }
+
+        g_key_file_free (file);
+        return indexname;
+}
+
+static void
+sound_theme_in_dir (GHashTable *hash,
+                    const char *dir)
+{
+        GDir *d;
+        const char *name;
+
+        d = g_dir_open (dir, 0, NULL);
+        if (d == NULL) {
+                return;
+        }
+
+        while ((name = g_dir_read_name (d)) != NULL) {
+                char *dirname, *index, *indexname;
+
+                /* Look for directories */
+                dirname = g_build_filename (dir, name, NULL);
+                if (g_file_test (dirname, G_FILE_TEST_IS_DIR) == FALSE) {
+                        g_free (dirname);
+                        continue;
+                }
+
+                /* Look for index files */
+                index = g_build_filename (dirname, "index.theme", NULL);
+                g_free (dirname);
+
+                /* Check the name of the theme in the index.theme file */
+                indexname = load_index_theme_name (index, NULL);
+                g_free (index);
+                if (indexname == NULL) {
+                        continue;
+                }
+
+                g_hash_table_insert (hash, g_strdup (name), indexname);
+        }
+
+        g_dir_close (d);
+}
+
+static void
+add_theme_to_store (const char   *key,
+                    const char   *value,
+                    GtkListStore *store)
+{
+        char *parent;
+
+        parent = NULL;
+
+        /* Get the parent, if we're checking the custom theme */
+        if (strcmp (key, CUSTOM_THEME_NAME) == 0) {
+                char *name, *path;
+
+                path = custom_theme_dir_path ("index.theme");
+                name = load_index_theme_name (path, &parent);
+                g_free (name);
+                g_free (path);
+        }
+        gtk_list_store_insert_with_values (store, NULL, G_MAXINT,
+                                           THEME_DISPLAY_COL, value,
+                                           THEME_IDENTIFIER_COL, key,
+                                           THEME_PARENT_ID_COL, parent,
+                                           -1);
+        g_free (parent);
+}
+
+static void
+set_combox_for_theme_name (GvcSoundThemeChooser *chooser,
+                           const char           *name)
+{
+        GtkTreeIter   iter;
+        GtkTreeModel *model;
+        gboolean      found;
+
+        /* If the name is empty, use "freedesktop" */
+        if (name == NULL || *name == '\0') {
+                name = "freedesktop";
+        }
+
+        model = gtk_combo_box_get_model (GTK_COMBO_BOX (chooser->priv->combo_box));
+
+        if (gtk_tree_model_get_iter_first (model, &iter) == FALSE) {
+                return;
+        }
+
+        do {
+                char *value;
+
+                gtk_tree_model_get (model, &iter, THEME_IDENTIFIER_COL, &value, -1);
+                found = (value != NULL && strcmp (value, name) == 0);
+                g_free (value);
+
+        } while (!found && gtk_tree_model_iter_next (model, &iter));
+
+        /* When we can't find the theme we need to set, try to set the default
+         * one "freedesktop" */
+        if (found) {
+                gtk_combo_box_set_active_iter (GTK_COMBO_BOX (chooser->priv->combo_box), &iter);
+        } else if (strcmp (name, "freedesktop") != 0) {
+                g_debug ("not found, falling back to fdo");
+                set_combox_for_theme_name (chooser, "freedesktop");
+        }
+}
+
+static void
+set_input_feedback_enabled (GvcSoundThemeChooser *chooser,
+                            gboolean              enabled)
+{
+        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chooser->priv->click_feedback_button),
+                                      enabled);
+}
+
+static void
+setup_theme_selector (GvcSoundThemeChooser *chooser)
+{
+        GHashTable           *hash;
+        GtkListStore         *store;
+        GtkCellRenderer      *renderer;
+        const char * const   *data_dirs;
+        const char           *data_dir;
+        char                 *dir;
+        guint                 i;
+
+        /* Add the theme names and their display name to a hash table,
+         * makes it easy to avoid duplicate themes */
+        hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
+
+        data_dirs = g_get_system_data_dirs ();
+        for (i = 0; data_dirs[i] != NULL; i++) {
+                dir = g_build_filename (data_dirs[i], "sounds", NULL);
+                sound_theme_in_dir (hash, dir);
+                g_free (dir);
+        }
+
+        data_dir = g_get_user_data_dir ();
+        dir = g_build_filename (data_dir, "sounds", NULL);
+        sound_theme_in_dir (hash, dir);
+        g_free (dir);
+
+        /* If there isn't at least one theme, make everything
+         * insensitive, LAME! */
+        if (g_hash_table_size (hash) == 0) {
+                gtk_widget_set_sensitive (GTK_WIDGET (chooser), FALSE);
+                g_warning ("Bad setup, install the freedesktop sound theme");
+                g_hash_table_destroy (hash);
+                return;
+        }
+
+        /* Setup the tree model, 3 columns:
+         * - internal theme name/directory
+         * - display theme name
+         * - the internal id for the parent theme, used for the custom theme */
+        store = gtk_list_store_new (THEME_NUM_COLS,
+                                    G_TYPE_STRING,
+                                    G_TYPE_STRING,
+                                    G_TYPE_STRING);
+
+        /* Add the themes to a combobox */
+        gtk_list_store_insert_with_values (store,
+                                           NULL,
+                                           G_MAXINT,
+                                           THEME_DISPLAY_COL, _("No sounds"),
+                                           THEME_IDENTIFIER_COL, "__no_sounds",
+                                           THEME_PARENT_ID_COL, NULL,
+                                           -1);
+        g_hash_table_foreach (hash, (GHFunc) add_theme_to_store, store);
+        g_hash_table_destroy (hash);
+
+        /* Set the display */
+        gtk_combo_box_set_model (GTK_COMBO_BOX (chooser->priv->combo_box),
+                                 GTK_TREE_MODEL (store));
+
+        renderer = gtk_cell_renderer_text_new ();
+        gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (chooser->priv->combo_box),
+                                    renderer,
+                                    TRUE);
+        gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (chooser->priv->combo_box),
+                                        renderer,
+                                        "text", THEME_DISPLAY_COL,
+                                        NULL);
+
+        g_signal_connect (G_OBJECT (chooser->priv->combo_box),
+                          "changed",
+                          G_CALLBACK (on_combobox_changed),
+                          chooser);
+}
+
+#define GVC_SOUND_SOUND    (xmlChar *) "sound"
+#define GVC_SOUND_NAME     (xmlChar *) "name"
+#define GVC_SOUND_FILENAME (xmlChar *) "filename"
+
+/* Adapted from yelp-toc-pager.c */
+static xmlChar *
+xml_get_and_trim_names (xmlNodePtr node)
+{
+        xmlNodePtr cur;
+        xmlChar *keep_lang = NULL;
+        xmlChar *value;
+        int j, keep_pri = INT_MAX;
+
+        const gchar * const * langs = g_get_language_names ();
+
+        value = NULL;
+
+        for (cur = node->children; cur; cur = cur->next) {
+                if (! xmlStrcmp (cur->name, GVC_SOUND_NAME)) {
+                        xmlChar *cur_lang = NULL;
+                        int cur_pri = INT_MAX;
+
+                        cur_lang = xmlNodeGetLang (cur);
+
+                        if (cur_lang) {
+                                for (j = 0; langs[j]; j++) {
+                                        if (g_str_equal (cur_lang, langs[j])) {
+                                                cur_pri = j;
+                                                break;
+                                        }
+                                }
+                        } else {
+                                cur_pri = INT_MAX - 1;
+                        }
+
+                        if (cur_pri <= keep_pri) {
+                                if (keep_lang)
+                                        xmlFree (keep_lang);
+                                if (value)
+                                        xmlFree (value);
+
+                                value = xmlNodeGetContent (cur);
+
+                                keep_lang = cur_lang;
+                                keep_pri = cur_pri;
+                        } else {
+                                if (cur_lang)
+                                        xmlFree (cur_lang);
+                        }
+                }
+        }
+
+        /* Delete all GVC_SOUND_NAME nodes */
+        cur = node->children;
+        while (cur) {
+                xmlNodePtr this = cur;
+                cur = cur->next;
+                if (! xmlStrcmp (this->name, GVC_SOUND_NAME)) {
+                        xmlUnlinkNode (this);
+                        xmlFreeNode (this);
+                }
+        }
+
+        return value;
+}
+
+static void
+populate_model_from_node (GvcSoundThemeChooser *chooser,
+                          GtkTreeModel         *model,
+                          xmlNodePtr            node)
+{
+        xmlNodePtr child;
+        xmlChar   *filename;
+        xmlChar   *name;
+
+        filename = NULL;
+        name = xml_get_and_trim_names (node);
+        for (child = node->children; child; child = child->next) {
+                if (xmlNodeIsText (child)) {
+                        continue;
+                }
+
+                if (xmlStrcmp (child->name, GVC_SOUND_FILENAME) == 0) {
+                        filename = xmlNodeGetContent (child);
+                } else if (xmlStrcmp (child->name, GVC_SOUND_NAME) == 0) {
+                        /* EH? should have been trimmed */
+                }
+        }
+
+        if (filename != NULL && name != NULL) {
+                gtk_list_store_insert_with_values (GTK_LIST_STORE (model),
+                                                   NULL,
+                                                   G_MAXINT,
+                                                   ALERT_IDENTIFIER_COL, filename,
+                                                   ALERT_DISPLAY_COL, name,
+                                                   ALERT_SOUND_TYPE_COL, _("Built-in"),
+                                                   ALERT_ACTIVE_COL, FALSE,
+                                                   -1);
+        }
+
+        xmlFree (filename);
+        xmlFree (name);
+}
+
+static void
+populate_model_from_file (GvcSoundThemeChooser *chooser,
+                          GtkTreeModel         *model,
+                          const char           *filename)
+{
+        xmlDocPtr  doc;
+        xmlNodePtr root;
+        xmlNodePtr child;
+        gboolean   exists;
+
+        exists = g_file_test (filename, G_FILE_TEST_EXISTS);
+        if (! exists) {
+                return;
+        }
+
+        doc = xmlParseFile (filename);
+        if (doc == NULL) {
+                return;
+        }
+
+        root = xmlDocGetRootElement (doc);
+
+        for (child = root->children; child; child = child->next) {
+                if (xmlNodeIsText (child)) {
+                        continue;
+                }
+                if (xmlStrcmp (child->name, GVC_SOUND_SOUND) != 0) {
+                        continue;
+                }
+
+                populate_model_from_node (chooser, model, child);
+        }
+
+        xmlFreeDoc (doc);
+}
+
+static void
+populate_model_from_dir (GvcSoundThemeChooser *chooser,
+                         GtkTreeModel         *model,
+                         const char           *dirname)
+{
+        GDir       *d;
+        const char *name;
+
+        d = g_dir_open (dirname, 0, NULL);
+        if (d == NULL) {
+                return;
+        }
+
+        while ((name = g_dir_read_name (d)) != NULL) {
+                char *path;
+
+                if (! g_str_has_suffix (name, ".xml")) {
+                        continue;
+                }
+
+                path = g_build_filename (dirname, name, NULL);
+                populate_model_from_file (chooser, model, path);
+                g_free (path);
+        }
+
+        g_dir_close (d);
+}
+
+static gboolean
+save_alert_sounds (GvcSoundThemeChooser  *chooser,
+                   const char            *id)
+{
+        const char *sounds[3] = { "bell-terminal", "bell-window-system", NULL };
+        char *path;
+
+        if (strcmp (id, DEFAULT_ALERT_ID) == 0) {
+                delete_old_files (sounds);
+                delete_disabled_files (sounds);
+        } else {
+                delete_old_files (sounds);
+                delete_disabled_files (sounds);
+                add_custom_file (sounds, id);
+        }
+
+        /* And poke the directory so the theme gets updated */
+        path = custom_theme_dir_path (NULL);
+        if (utime (path, NULL) != 0) {
+                g_warning ("Failed to update mtime for directory '%s': %s",
+                           path, g_strerror (errno));
+        }
+        g_free (path);
+
+        return FALSE;
+}
+
+static void
+update_alert_model (GvcSoundThemeChooser  *chooser,
+                    const char            *id)
+{
+        GtkTreeModel *model;
+        GtkTreeIter   iter;
+
+        model = gtk_tree_view_get_model (GTK_TREE_VIEW (chooser->priv->treeview));
+        gtk_tree_model_get_iter_first (model, &iter);
+        do {
+                gboolean toggled;
+                char    *this_id;
+
+                gtk_tree_model_get (model, &iter,
+                                    ALERT_IDENTIFIER_COL, &this_id,
+                                    -1);
+
+                if (strcmp (this_id, id) == 0) {
+                        toggled = TRUE;
+                } else {
+                        toggled = FALSE;
+                }
+                g_free (this_id);
+
+                gtk_list_store_set (GTK_LIST_STORE (model),
+                                    &iter,
+                                    ALERT_ACTIVE_COL, toggled,
+                                    -1);
+        } while (gtk_tree_model_iter_next (model, &iter));
+}
+
+static void
+update_alert (GvcSoundThemeChooser *chooser,
+              const char           *alert_id)
+{
+        GtkTreeModel *theme_model;
+        GtkTreeIter   iter;
+        char         *theme;
+        char         *parent;
+        gboolean      is_custom;
+        gboolean      is_default;
+        gboolean      add_custom;
+        gboolean      remove_custom;
+
+        theme_model = gtk_combo_box_get_model (GTK_COMBO_BOX (chooser->priv->combo_box));
+        /* Get the current theme's name, and set the parent */
+        if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (chooser->priv->combo_box), &iter) == FALSE) {
+                return;
+        }
+
+        gtk_tree_model_get (theme_model, &iter,
+                            THEME_IDENTIFIER_COL, &theme,
+                            THEME_IDENTIFIER_COL, &parent,
+                            -1);
+        is_custom = strcmp (theme, CUSTOM_THEME_NAME) == 0;
+        is_default = strcmp (alert_id, DEFAULT_ALERT_ID) == 0;
+
+        /* So a few possibilities:
+         * 1. Named theme, default alert selected: noop
+         * 2. Named theme, alternate alert selected: create new custom with sound
+         * 3. Custom theme, default alert selected: remove sound and possibly custom
+         * 4. Custom theme, alternate alert selected: update custom sound
+         */
+        add_custom = FALSE;
+        remove_custom = FALSE;
+        if (! is_custom && is_default) {
+                /* remove custom just in case */
+                remove_custom = TRUE;
+        } else if (! is_custom && ! is_default) {
+                create_custom_theme (parent);
+                save_alert_sounds (chooser, alert_id);
+                add_custom = TRUE;
+        } else if (is_custom && is_default) {
+                save_alert_sounds (chooser, alert_id);
+                /* after removing files check if it is empty */
+                if (custom_theme_dir_is_empty ()) {
+                        remove_custom = TRUE;
+                }
+        } else if (is_custom && ! is_default) {
+                save_alert_sounds (chooser, alert_id);
+        }
+
+        if (add_custom) {
+                gtk_list_store_insert_with_values (GTK_LIST_STORE (theme_model),
+                                                   NULL,
+                                                   G_MAXINT,
+                                                   THEME_DISPLAY_COL, _("Custom"),
+                                                   THEME_IDENTIFIER_COL, CUSTOM_THEME_NAME,
+                                                   THEME_PARENT_ID_COL, theme,
+                                                   -1);
+                set_combox_for_theme_name (chooser, CUSTOM_THEME_NAME);
+        } else if (remove_custom) {
+                gtk_tree_model_get_iter_first (theme_model, &iter);
+                do {
+                        char *this_parent;
+
+                        gtk_tree_model_get (theme_model, &iter,
+                                            THEME_PARENT_ID_COL, &this_parent,
+                                            -1);
+                        if (this_parent != NULL && strcmp (this_parent, CUSTOM_THEME_NAME) != 0) {
+                                g_free (this_parent);
+                                gtk_list_store_remove (GTK_LIST_STORE (theme_model), &iter);
+                                break;
+                        }
+                        g_free (this_parent);
+                } while (gtk_tree_model_iter_next (theme_model, &iter));
+
+                delete_custom_theme_dir ();
+
+                set_combox_for_theme_name (chooser, parent);
+        }
+
+        update_alert_model (chooser, alert_id);
+
+        g_free (theme);
+        g_free (parent);
+}
+
+static void
+on_alert_toggled (GtkCellRendererToggle *renderer,
+                  char                  *path_str,
+                  GvcSoundThemeChooser  *chooser)
+{
+        GtkTreeModel *model;
+        GtkTreeIter   iter;
+        GtkTreePath  *path;
+        gboolean      toggled;
+        char         *id;
+
+        model = gtk_tree_view_get_model (GTK_TREE_VIEW (chooser->priv->treeview));
+
+        path = gtk_tree_path_new_from_string (path_str);
+        gtk_tree_model_get_iter (model, &iter, path);
+        gtk_tree_path_free (path);
+
+        id = NULL;
+        gtk_tree_model_get (model, &iter,
+                            ALERT_IDENTIFIER_COL, &id,
+                            ALERT_ACTIVE_COL, &toggled,
+                            -1);
+
+        toggled ^= 1;
+        if (toggled) {
+                update_alert (chooser, id);
+        }
+
+        g_free (id);
+}
+
+static void
+play_preview_for_path (GvcSoundThemeChooser *chooser, GtkTreePath *path)
+{
+        GtkTreeModel *model;
+        GtkTreeIter   iter;
+        GtkTreeIter   theme_iter;
+        gchar        *id = NULL;
+        gchar        *parent_theme = NULL;
+
+        model = gtk_tree_view_get_model (GTK_TREE_VIEW (chooser->priv->treeview));
+        if (gtk_tree_model_get_iter (model, &iter, path) == FALSE)
+                return;
+
+        gtk_tree_model_get (model, &iter,
+                            ALERT_IDENTIFIER_COL, &id,
+                            -1);
+        if (id == NULL)
+                return;
+
+        if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (chooser->priv->combo_box), &theme_iter)) {
+                GtkTreeModel *theme_model;
+                gchar        *theme_id = NULL;
+                gchar        *parent_id = NULL;
+
+                theme_model = gtk_combo_box_get_model (GTK_COMBO_BOX (chooser->priv->combo_box));
+
+                gtk_tree_model_get (theme_model, &theme_iter,
+                                    THEME_IDENTIFIER_COL, &theme_id,
+                                    THEME_PARENT_ID_COL, &parent_id, -1);
+                if (theme_id && strcmp (theme_id, CUSTOM_THEME_NAME) == 0)
+                        parent_theme = g_strdup (parent_id);
+
+                g_free (theme_id);
+                g_free (parent_id);
+        }
+
+        /* special case: for the default item on custom themes
+         * play the alert for the parent theme */
+        if (strcmp (id, DEFAULT_ALERT_ID) == 0) {
+                if (parent_theme != NULL) {
+                        ca_gtk_play_for_widget (GTK_WIDGET (chooser), 0,
+                                                CA_PROP_APPLICATION_NAME, _("Sound Preferences"),
+                                                CA_PROP_EVENT_ID, "bell-window-system",
+                                                CA_PROP_CANBERRA_XDG_THEME_NAME, parent_theme,
+                                                CA_PROP_EVENT_DESCRIPTION, _("Testing event sound"),
+                                                CA_PROP_CANBERRA_CACHE_CONTROL, "never",
+                                                CA_PROP_APPLICATION_ID, "org.mate.VolumeControl",
+#ifdef CA_PROP_CANBERRA_ENABLE
+                                                CA_PROP_CANBERRA_ENABLE, "1",
+#endif
+                                                NULL);
+                } else {
+                        ca_gtk_play_for_widget (GTK_WIDGET (chooser), 0,
+                                                CA_PROP_APPLICATION_NAME, _("Sound Preferences"),
+                                                CA_PROP_EVENT_ID, "bell-window-system",
+                                                CA_PROP_EVENT_DESCRIPTION, _("Testing event sound"),
+                                                CA_PROP_CANBERRA_CACHE_CONTROL, "never",
+                                                CA_PROP_APPLICATION_ID, "org.mate.VolumeControl",
+#ifdef CA_PROP_CANBERRA_ENABLE
+                                                CA_PROP_CANBERRA_ENABLE, "1",
+#endif
+                                                NULL);
+                }
+        } else {
+                ca_gtk_play_for_widget (GTK_WIDGET (chooser), 0,
+                                        CA_PROP_APPLICATION_NAME, _("Sound Preferences"),
+                                        CA_PROP_MEDIA_FILENAME, id,
+                                        CA_PROP_EVENT_DESCRIPTION, _("Testing event sound"),
+                                        CA_PROP_CANBERRA_CACHE_CONTROL, "never",
+                                        CA_PROP_APPLICATION_ID, "org.mate.VolumeControl",
+#ifdef CA_PROP_CANBERRA_ENABLE
+                                        CA_PROP_CANBERRA_ENABLE, "1",
+#endif
+                                        NULL);
+
+        }
+        g_free (parent_theme);
+        g_free (id);
+}
+
+static void
+on_treeview_row_activated (GtkTreeView          *treeview,
+                           GtkTreePath          *path,
+                           GtkTreeViewColumn    *column,
+                           GvcSoundThemeChooser *chooser)
+{
+        play_preview_for_path (chooser, path);
+}
+
+static void
+on_treeview_selection_changed (GtkTreeSelection     *selection,
+                               GvcSoundThemeChooser *chooser)
+{
+        GList        *paths;
+        GtkTreeModel *model;
+        GtkTreePath  *path;
+
+        if (chooser->priv->treeview == NULL)
+                return;
+
+        model = gtk_tree_view_get_model (GTK_TREE_VIEW (chooser->priv->treeview));
+
+        paths = gtk_tree_selection_get_selected_rows (selection, &model);
+        if (paths == NULL)
+                return;
+
+        path = paths->data;
+        play_preview_for_path (chooser, path);
+
+        g_list_foreach (paths, (GFunc)gtk_tree_path_free, NULL);
+        g_list_free (paths);
+}
+
+static GtkWidget *
+create_alert_treeview (GvcSoundThemeChooser *chooser)
+{
+        GtkListStore         *store;
+        GtkWidget            *treeview;
+        GtkCellRenderer      *renderer;
+        GtkTreeViewColumn    *column;
+        GtkTreeSelection     *selection;
+
+        treeview = gtk_tree_view_new ();
+
+        gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), FALSE);
+        g_signal_connect (G_OBJECT (treeview),
+                          "row-activated",
+                          G_CALLBACK (on_treeview_row_activated),
+                          chooser);
+
+        selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
+
+        gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
+        g_signal_connect (G_OBJECT (selection),
+                          "changed",
+                          G_CALLBACK (on_treeview_selection_changed),
+                          chooser);
+
+        /* Setup the tree model, 3 columns:
+         * - display name
+         * - sound id
+         * - sound type
+         */
+        store = gtk_list_store_new (ALERT_NUM_COLS,
+                                    G_TYPE_STRING,
+                                    G_TYPE_STRING,
+                                    G_TYPE_STRING,
+                                    G_TYPE_BOOLEAN);
+
+        gtk_list_store_insert_with_values (store,
+                                           NULL,
+                                           G_MAXINT,
+                                           ALERT_IDENTIFIER_COL, DEFAULT_ALERT_ID,
+                                           ALERT_DISPLAY_COL, _("Default"),
+                                           ALERT_SOUND_TYPE_COL, _("From theme"),
+                                           ALERT_ACTIVE_COL, TRUE,
+                                           -1);
+
+        populate_model_from_dir (chooser, GTK_TREE_MODEL (store), SOUND_SET_DIR);
+
+        gtk_tree_view_set_model (GTK_TREE_VIEW (treeview),
+                                 GTK_TREE_MODEL (store));
+
+        renderer = gtk_cell_renderer_toggle_new ();
+        gtk_cell_renderer_toggle_set_radio (GTK_CELL_RENDERER_TOGGLE (renderer), TRUE);
+
+        column = gtk_tree_view_column_new_with_attributes (NULL,
+                                                           renderer,
+                                                           "active", ALERT_ACTIVE_COL,
+                                                           NULL);
+        gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
+        g_signal_connect (renderer,
+                          "toggled",
+                          G_CALLBACK (on_alert_toggled),
+                          chooser);
+
+        renderer = gtk_cell_renderer_text_new ();
+        column = gtk_tree_view_column_new_with_attributes (_("Name"),
+                                                           renderer,
+                                                           "text", ALERT_DISPLAY_COL,
+                                                           NULL);
+        gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
+
+        renderer = gtk_cell_renderer_text_new ();
+        column = gtk_tree_view_column_new_with_attributes (_("Type"),
+                                                           renderer,
+                                                           "text", ALERT_SOUND_TYPE_COL,
+                                                           NULL);
+
+        gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
+
+        return treeview;
+}
+
+static int
+get_file_type (const char *sound_name,
+               char      **linked_name)
+{
+        char *name, *filename;
+
+        *linked_name = NULL;
+
+        name = g_strdup_printf ("%s.disabled", sound_name);
+        filename = custom_theme_dir_path (name);
+        g_free (name);
+
+        if (g_file_test (filename, G_FILE_TEST_IS_REGULAR) != FALSE) {
+                g_free (filename);
+                return SOUND_TYPE_OFF;
+        }
+        g_free (filename);
+
+        /* We only check for .ogg files because those are the
+         * only ones we create */
+        name = g_strdup_printf ("%s.ogg", sound_name);
+        filename = custom_theme_dir_path (name);
+        g_free (name);
+
+        if (g_file_test (filename, G_FILE_TEST_IS_SYMLINK) != FALSE) {
+                *linked_name = g_file_read_link (filename, NULL);
+                g_free (filename);
+                return SOUND_TYPE_CUSTOM;
+        }
+        g_free (filename);
+
+        return SOUND_TYPE_BUILTIN;
+}
+
+static void
+update_alerts_from_theme_name (GvcSoundThemeChooser *chooser,
+                               const gchar          *name)
+{
+        if (strcmp (name, CUSTOM_THEME_NAME) != 0) {
+                /* reset alert to default */
+                update_alert (chooser, DEFAULT_ALERT_ID);
+        } else {
+                int   sound_type;
+                char *linkname;
+
+                linkname = NULL;
+                sound_type = get_file_type ("bell-terminal", &linkname);
+                g_debug ("Found link: %s", linkname);
+                if (sound_type == SOUND_TYPE_CUSTOM) {
+                        update_alert (chooser, linkname);
+                }
+        }
+}
+
+static void
+update_theme (GvcSoundThemeChooser *chooser)
+{
+        char        *theme_name;
+        gboolean     events_enabled;
+        gboolean     feedback_enabled;
+
+        feedback_enabled = g_settings_get_boolean (chooser->priv->sound_settings, INPUT_SOUNDS_KEY);
+        set_input_feedback_enabled (chooser, feedback_enabled);
+
+        events_enabled = g_settings_get_boolean (chooser->priv->sound_settings, EVENT_SOUNDS_KEY);
+        if (events_enabled) {
+                theme_name = g_settings_get_string (chooser->priv->sound_settings, SOUND_THEME_KEY);
+        } else {
+                theme_name = g_strdup (NO_SOUNDS_THEME_NAME);
+        }
+
+        gtk_widget_set_sensitive (chooser->priv->selection_box, events_enabled);
+        gtk_widget_set_sensitive (chooser->priv->click_feedback_button, events_enabled);
+
+        set_combox_for_theme_name (chooser, theme_name);
+
+        update_alerts_from_theme_name (chooser, theme_name);
+
+        g_free (theme_name);
+}
+
+static void
+gvc_sound_theme_chooser_class_init (GvcSoundThemeChooserClass *klass)
+{
+        GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+        object_class->dispose = gvc_sound_theme_chooser_dispose;
+}
+
+static void
+on_click_feedback_toggled (GtkToggleButton      *button,
+                           GvcSoundThemeChooser *chooser)
+{
+        gboolean enabled;
+
+        enabled = gtk_toggle_button_get_active (button);
+
+        g_settings_set_boolean (chooser->priv->sound_settings, INPUT_SOUNDS_KEY, enabled);
+}
+
+static void
+on_key_changed (GSettings            *settings,
+                gchar                *key,<--- Parameter 'key' can be declared as pointer to const
+                GvcSoundThemeChooser *chooser)
+{
+        if (!strcmp (key, EVENT_SOUNDS_KEY) ||
+            !strcmp (key, SOUND_THEME_KEY) ||
+            !strcmp (key, INPUT_SOUNDS_KEY))
+                update_theme (chooser);
+}
+
+static void
+setup_list_size_constraint (GtkWidget *widget,
+                            GtkWidget *to_size)
+{
+        GtkRequisition req;
+        gint           sc_height;
+        int            max_height;
+
+        /* Constrain height to be the tree height up to a max */
+        gdk_window_get_geometry (gdk_screen_get_root_window (gtk_widget_get_screen (widget)),
+                                 NULL, NULL, NULL, &sc_height);
+
+        max_height = sc_height / 4;
+
+        // XXX this doesn't work
+        gtk_widget_get_preferred_size (to_size, NULL, &req);
+
+        gtk_scrolled_window_set_min_content_height (GTK_SCROLLED_WINDOW (widget),
+                                                    MIN (req.height, max_height));
+}
+
+static void
+gvc_sound_theme_chooser_init (GvcSoundThemeChooser *chooser)
+{
+        GtkWidget   *box;
+        GtkWidget   *label;
+        GtkWidget   *scrolled_window;
+        gchar       *str;
+
+        chooser->priv = gvc_sound_theme_chooser_get_instance_private (chooser);
+
+        chooser->priv->theme_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+
+        gtk_box_pack_start (GTK_BOX (chooser),
+                            chooser->priv->theme_box, FALSE, FALSE, 0);
+
+        label = gtk_label_new_with_mnemonic (_("Sound _theme:"));
+        gtk_box_pack_start (GTK_BOX (chooser->priv->theme_box), label, FALSE, FALSE, 0);
+        chooser->priv->combo_box = gtk_combo_box_new ();
+        gtk_box_pack_start (GTK_BOX (chooser->priv->theme_box), chooser->priv->combo_box, FALSE, FALSE, 6);
+        gtk_label_set_mnemonic_widget (GTK_LABEL (label), chooser->priv->combo_box);
+
+        chooser->priv->sound_settings = g_settings_new (KEY_SOUNDS_SCHEMA);
+
+        g_signal_connect (G_OBJECT (chooser->priv->sound_settings),
+                          "changed",
+                          G_CALLBACK (on_key_changed),<--- You might need to cast the function pointer here
+                          chooser);
+
+        str = g_strdup_printf ("<b>%s</b>", _("C_hoose an alert sound:"));
+        chooser->priv->selection_box = box = gtk_frame_new (str);
+        g_free (str);
+
+        label = gtk_frame_get_label_widget (GTK_FRAME (box));
+        gtk_label_set_use_underline (GTK_LABEL (label), TRUE);
+        gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+        gtk_frame_set_shadow_type (GTK_FRAME (box), GTK_SHADOW_NONE);
+
+        gtk_box_pack_start (GTK_BOX (chooser), box, TRUE, TRUE, 6);
+
+        chooser->priv->treeview = create_alert_treeview (chooser);
+        gtk_label_set_mnemonic_widget (GTK_LABEL (label), chooser->priv->treeview);
+
+        scrolled_window = gtk_scrolled_window_new (NULL, NULL);
+        gtk_widget_set_hexpand (scrolled_window, TRUE);
+        gtk_widget_set_vexpand (scrolled_window, TRUE);
+        gtk_widget_set_margin_top (scrolled_window, 6);
+
+        gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
+                                        GTK_POLICY_NEVER,
+                                        GTK_POLICY_AUTOMATIC);
+        gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window),
+                                             GTK_SHADOW_IN);
+
+        gtk_container_add (GTK_CONTAINER (scrolled_window), chooser->priv->treeview);
+        gtk_container_add (GTK_CONTAINER (box), scrolled_window);
+
+        chooser->priv->click_feedback_button = gtk_check_button_new_with_mnemonic (_("Enable _window and button sounds"));
+        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chooser->priv->click_feedback_button),
+                                      g_settings_get_boolean (chooser->priv->sound_settings, INPUT_SOUNDS_KEY));
+
+        gtk_box_pack_start (GTK_BOX (chooser),
+                            chooser->priv->click_feedback_button,
+                            FALSE, FALSE, 0);
+
+        g_signal_connect (G_OBJECT (chooser->priv->click_feedback_button),
+                          "toggled",
+                          G_CALLBACK (on_click_feedback_toggled),
+                          chooser);
+
+        setup_theme_selector (chooser);
+        update_theme (chooser);
+
+        setup_list_size_constraint (scrolled_window, chooser->priv->treeview);
+}
+
+static void
+gvc_sound_theme_chooser_dispose (GObject *object)
+{
+        GvcSoundThemeChooser *chooser;
+
+        chooser = GVC_SOUND_THEME_CHOOSER (object);
+
+        g_clear_object (&chooser->priv->sound_settings);
+
+        G_OBJECT_CLASS (gvc_sound_theme_chooser_parent_class)->dispose (object);
+}
+
+GtkWidget *
+gvc_sound_theme_chooser_new (void)
+{
+        return g_object_new (GVC_TYPE_SOUND_THEME_CHOOSER,
+                                "spacing", 6,
+                                "orientation", GTK_ORIENTATION_VERTICAL,
+                                NULL);
+}
+
+ +
+ +
+ + diff --git a/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/58.html b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/58.html new file mode 100644 index 0000000..7db2f64 --- /dev/null +++ b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/58.html @@ -0,0 +1,313 @@ + + + + + + Cppcheck - HTML report - mate-media + + + + + +
+ + + +
+
 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
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ * Copyright (C) 2008 Bastien Nocera <hadess@hadess.net>
+ * 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, 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 __SOUND_THEME_FILE_UTILS_HH__
+#define __SOUND_THEME_FILE_UTILS_HH__
+
+#include <gio/gio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+char *custom_theme_dir_path (const char *child);
+gboolean custom_theme_dir_is_empty (void);
+void create_custom_theme (const char *parent);
+
+void delete_custom_theme_dir (void);
+void delete_old_files (const char **sounds);
+void delete_disabled_files (const char **sounds);
+
+void add_disabled_file (const char **sounds);
+void add_custom_file (const char **sounds, const char *filename);
+
+void custom_theme_update_time (void);
+
+#endif /* __SOUND_THEME_FILE_UTILS_HH__ */
+
+ +
+ +
+ + diff --git a/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/59.html b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/59.html new file mode 100644 index 0000000..88e7e67 --- /dev/null +++ b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/59.html @@ -0,0 +1,1195 @@ + + + + + + Cppcheck - HTML report - mate-media + + + + + +
+ + + +
+
  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
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2009 Bastien Nocera
+ * Copyright (C) 2014 Michal Ratajsky <michal.ratajsky@gmail.com>
+ * 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.
+ *
+ */
+
+#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-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 <canberra.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <libmatemixer/matemixer.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "gvc-speaker-test.h"
+#include "gvc-utils.h"
+
+struct _GvcSpeakerTestPrivate
+{
+        GArray           *controls;
+        ca_context       *canberra;
+        MateMixerStream  *stream;
+};
+
+enum {
+        PROP_0,
+        PROP_STREAM,
+        N_PROPERTIES
+};
+
+static GParamSpec *properties[N_PROPERTIES] = { NULL, };
+
+static void gvc_speaker_test_dispose    (GObject             *object);
+static void gvc_speaker_test_finalize   (GObject             *object);
+
+G_DEFINE_TYPE_WITH_PRIVATE (GvcSpeakerTest, gvc_speaker_test, GTK_TYPE_GRID)<--- 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 {
+        MateMixerChannelPosition position;
+        guint left;
+        guint top;
+} TablePosition;
+
+static const TablePosition positions[] = {
+        /* Position, X, Y */
+        { MATE_MIXER_CHANNEL_FRONT_LEFT, 0, 0, },
+        { MATE_MIXER_CHANNEL_FRONT_LEFT_CENTER, 1, 0, },
+        { MATE_MIXER_CHANNEL_FRONT_CENTER, 2, 0, },
+        { MATE_MIXER_CHANNEL_MONO, 2, 0, },
+        { MATE_MIXER_CHANNEL_FRONT_RIGHT_CENTER, 3, 0, },
+        { MATE_MIXER_CHANNEL_FRONT_RIGHT, 4, 0, },
+        { MATE_MIXER_CHANNEL_SIDE_LEFT, 0, 1, },
+        { MATE_MIXER_CHANNEL_SIDE_RIGHT, 4, 1, },
+        { MATE_MIXER_CHANNEL_BACK_LEFT, 0, 2, },
+        { MATE_MIXER_CHANNEL_BACK_CENTER, 2, 2, },
+        { MATE_MIXER_CHANNEL_BACK_RIGHT, 4, 2, },
+        { MATE_MIXER_CHANNEL_LFE, 3, 2 }
+};
+
+MateMixerStream *
+gvc_speaker_test_get_stream (GvcSpeakerTest *test)
+{
+        g_return_val_if_fail (GVC_IS_SPEAKER_TEST (test), NULL);
+
+        return test->priv->stream;
+}
+
+static void
+gvc_speaker_test_set_stream (GvcSpeakerTest *test, MateMixerStream *stream)
+{
+        MateMixerStreamControl *control;
+        const gchar            *name;
+        guint                   i;
+
+        name = mate_mixer_stream_get_name (stream);
+        control = mate_mixer_stream_get_default_control (stream);
+
+        ca_context_change_device (test->priv->canberra, name);
+
+        for (i = 0; i < G_N_ELEMENTS (positions); i++) {
+                gboolean has_position =
+                        mate_mixer_stream_control_has_channel_position (control, positions[i].position);
+
+                gtk_widget_set_visible (g_array_index (test->priv->controls, GtkWidget *, i),
+                                        has_position);
+        }
+
+        test->priv->stream = g_object_ref (stream);
+}
+
+static void
+gvc_speaker_test_set_property (GObject       *object,
+                               guint          prop_id,
+                               const GValue  *value,
+                               GParamSpec    *pspec)
+{
+        GvcSpeakerTest *self = GVC_SPEAKER_TEST (object);
+
+        switch (prop_id) {
+        case PROP_STREAM:
+                gvc_speaker_test_set_stream (self, g_value_get_object (value));
+                break;
+        default:
+                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+                break;
+        }
+}
+
+static void
+gvc_speaker_test_get_property (GObject     *object,
+                               guint        prop_id,
+                               GValue      *value,
+                               GParamSpec  *pspec)
+{
+        GvcSpeakerTest *self = GVC_SPEAKER_TEST (object);
+
+        switch (prop_id) {
+        case PROP_STREAM:
+                g_value_set_object (value, self->priv->stream);
+                break;
+        default:
+                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+                break;
+        }
+}
+
+static void
+gvc_speaker_test_class_init (GvcSpeakerTestClass *klass)
+{
+        GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+        object_class->dispose  = gvc_speaker_test_dispose;
+        object_class->finalize = gvc_speaker_test_finalize;
+        object_class->set_property = gvc_speaker_test_set_property;
+        object_class->get_property = gvc_speaker_test_get_property;
+
+        properties[PROP_STREAM] =
+                g_param_spec_object ("stream",
+                                     "Stream",
+                                     "MateMixer stream",
+                                     MATE_MIXER_TYPE_STREAM,
+                                     G_PARAM_READWRITE |
+                                     G_PARAM_CONSTRUCT_ONLY |
+                                     G_PARAM_STATIC_STRINGS);
+
+        g_object_class_install_properties (object_class, N_PROPERTIES, properties);
+}
+
+static const gchar *
+sound_name (MateMixerChannelPosition position)
+{
+        switch (position) {
+        case MATE_MIXER_CHANNEL_FRONT_LEFT:
+                return "audio-channel-front-left";
+        case MATE_MIXER_CHANNEL_FRONT_RIGHT:
+                return "audio-channel-front-right";
+        case MATE_MIXER_CHANNEL_FRONT_CENTER:
+                return "audio-channel-front-center";
+        case MATE_MIXER_CHANNEL_BACK_LEFT:
+                return "audio-channel-rear-left";
+        case MATE_MIXER_CHANNEL_BACK_RIGHT:
+                return "audio-channel-rear-right";
+        case MATE_MIXER_CHANNEL_BACK_CENTER:
+                return "audio-channel-rear-center";
+        case MATE_MIXER_CHANNEL_LFE:
+                return "audio-channel-lfe";
+        case MATE_MIXER_CHANNEL_SIDE_LEFT:
+                return "audio-channel-side-left";
+        case MATE_MIXER_CHANNEL_SIDE_RIGHT:
+                return "audio-channel-side-right";
+        default:
+                return NULL;
+        }
+}
+
+static const gchar *
+icon_name (MateMixerChannelPosition position, gboolean playing)
+{
+        switch (position) {
+        case MATE_MIXER_CHANNEL_FRONT_LEFT:
+                return playing
+                        ? "audio-speaker-left-testing"
+                        : "audio-speaker-left";
+        case MATE_MIXER_CHANNEL_FRONT_RIGHT:
+                return playing
+                        ? "audio-speaker-right-testing"
+                        : "audio-speaker-right";
+        case MATE_MIXER_CHANNEL_FRONT_CENTER:
+                return playing
+                        ? "audio-speaker-center-testing"
+                        : "audio-speaker-center";
+        case MATE_MIXER_CHANNEL_BACK_LEFT:
+                return playing
+                        ? "audio-speaker-left-back-testing"
+                        : "audio-speaker-left-back";
+        case MATE_MIXER_CHANNEL_BACK_RIGHT:
+                return playing
+                        ? "audio-speaker-right-back-testing"
+                        : "audio-speaker-right-back";
+        case MATE_MIXER_CHANNEL_BACK_CENTER:
+                return playing
+                        ? "audio-speaker-center-back-testing"
+                        : "audio-speaker-center-back";
+        case MATE_MIXER_CHANNEL_LFE:
+                return playing
+                        ? "audio-subwoofer-testing"
+                        : "audio-subwoofer";
+        case MATE_MIXER_CHANNEL_SIDE_LEFT:
+                return playing
+                        ? "audio-speaker-left-side-testing"
+                        : "audio-speaker-left-side";
+        case MATE_MIXER_CHANNEL_SIDE_RIGHT:
+                return playing
+                        ? "audio-speaker-right-side-testing"
+                        : "audio-speaker-right-side";
+        default:
+                return NULL;
+        }
+}
+
+static void
+update_button (GtkWidget *control)
+{
+        GtkWidget *button;
+        GtkWidget *image;
+        gboolean   playing;
+        MateMixerChannelPosition position;
+
+        button = g_object_get_data (G_OBJECT (control), "button");
+        image  = g_object_get_data (G_OBJECT (control), "image");
+
+        position = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (control), "position"));
+        playing  = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (control), "playing"));
+
+        gtk_button_set_label (GTK_BUTTON (button), playing ? _("Stop") : _("Test"));
+
+        gtk_image_set_from_icon_name (GTK_IMAGE (image),
+                                      icon_name (position, playing),
+                                      GTK_ICON_SIZE_DIALOG);
+}
+
+static gboolean
+idle_cb (GtkWidget *control)
+{
+        if (control != NULL) {
+                /* This is called in the background thread, hence forward to main thread
+                 * via idle callback */
+                g_object_set_data (G_OBJECT (control), "playing", GINT_TO_POINTER (FALSE));
+
+                update_button (control);
+        }
+        return FALSE;
+}
+
+static void
+finish_cb (ca_context *c, uint32_t id, int error_code, void *userdata)
+{
+        GtkWidget *control = (GtkWidget *) userdata;
+
+        if (error_code == CA_ERROR_DESTROYED || control == NULL)
+                return;
+
+        g_idle_add ((GSourceFunc) idle_cb, control);
+}
+
+static void
+on_test_button_clicked (GtkButton *button, GtkWidget *control)
+{
+        gboolean    playing;
+        ca_context *canberra;
+
+        canberra = g_object_get_data (G_OBJECT (control), "canberra");
+
+        ca_context_cancel (canberra, 1);
+
+        playing = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (control), "playing"));
+
+        if (playing) {
+                g_object_set_data (G_OBJECT (control), "playing", GINT_TO_POINTER (FALSE));
+        } else {
+                MateMixerChannelPosition position;
+                const gchar *name;
+                ca_proplist *proplist;
+
+                position = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (control), "position"));
+
+                ca_proplist_create (&proplist);
+                ca_proplist_sets (proplist,
+                                  CA_PROP_MEDIA_ROLE, "test");
+                ca_proplist_sets (proplist,
+                                  CA_PROP_MEDIA_NAME,
+                                  gvc_channel_position_to_pretty_string (position));
+                ca_proplist_sets (proplist,
+                                  CA_PROP_CANBERRA_FORCE_CHANNEL,
+                                  gvc_channel_position_to_pulse_string (position));
+
+                ca_proplist_sets (proplist, CA_PROP_CANBERRA_ENABLE, "1");
+
+                name = sound_name (position);
+                if (name != NULL) {
+                        ca_proplist_sets (proplist, CA_PROP_EVENT_ID, name);
+                        playing = ca_context_play_full (canberra, 1, proplist, finish_cb, control) >= 0;
+                }
+
+                if (!playing) {
+                        ca_proplist_sets (proplist, CA_PROP_EVENT_ID, "audio-test-signal");
+                        playing = ca_context_play_full (canberra, 1, proplist, finish_cb, control) >= 0;
+                }
+
+                if (!playing) {
+                        ca_proplist_sets(proplist, CA_PROP_EVENT_ID, "bell-window-system");
+                        playing = ca_context_play_full (canberra, 1, proplist, finish_cb, control) >= 0;
+                }
+
+                g_object_set_data (G_OBJECT (control), "playing", GINT_TO_POINTER (playing));
+        }
+
+        update_button (control);
+}
+
+static GtkWidget *
+create_control (ca_context *canberra, MateMixerChannelPosition position)
+{
+        GtkWidget   *control;
+        GtkWidget   *box;
+        GtkWidget   *label;
+        GtkWidget   *image;
+        GtkWidget   *test_button;
+        const gchar *name;
+
+        control = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
+        box     = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+
+        g_object_set_data (G_OBJECT (control), "playing", GINT_TO_POINTER (FALSE));
+        g_object_set_data (G_OBJECT (control), "position", GINT_TO_POINTER (position));
+        g_object_set_data (G_OBJECT (control), "canberra", canberra);
+
+        name = icon_name (position, FALSE);
+        if (name == NULL)
+                name = "audio-volume-medium";
+
+        image = gtk_image_new_from_icon_name (name, GTK_ICON_SIZE_DIALOG);
+        g_object_set_data (G_OBJECT (control), "image", image);
+        gtk_box_pack_start (GTK_BOX (control), image, FALSE, FALSE, 0);
+
+        label = gtk_label_new (gvc_channel_position_to_pretty_string (position));
+        gtk_box_pack_start (GTK_BOX (control), label, FALSE, FALSE, 0);
+
+        test_button = gtk_button_new_with_label (_("Test"));
+        gtk_label_set_mnemonic_widget (GTK_LABEL (label), test_button);
+        g_signal_connect (G_OBJECT (test_button),
+                          "clicked",
+                          G_CALLBACK (on_test_button_clicked),
+                          control);
+
+        g_object_set_data (G_OBJECT (control), "button", test_button);
+
+        gtk_box_pack_start (GTK_BOX (box), test_button, TRUE, FALSE, 0);
+        gtk_box_pack_start (GTK_BOX (control), box, FALSE, FALSE, 0);
+
+        gtk_widget_show_all (control);
+
+        return control;
+}
+
+static void
+create_controls (GvcSpeakerTest *test)
+{
+        guint i;
+
+        for (i = 0; i < G_N_ELEMENTS (positions); i++) {
+                GtkWidget *control = create_control (test->priv->canberra, positions[i].position);
+
+                gtk_grid_attach (GTK_GRID (test),
+                                 control,
+                                 positions[i].left,
+                                 positions[i].top,
+                                 1, 1);
+                g_array_insert_val (test->priv->controls, i, control);
+        }
+}
+
+static void
+gvc_speaker_test_init (GvcSpeakerTest *test)
+{
+        GtkWidget *face;
+
+        test->priv = gvc_speaker_test_get_instance_private (test);
+
+        gtk_container_set_border_width (GTK_CONTAINER (test), 12);
+
+        face = gtk_image_new_from_icon_name ("face-smile", GTK_ICON_SIZE_DIALOG);
+
+        gtk_grid_attach (GTK_GRID (test),
+                         face,
+                         1, 1,
+                         3, 1);
+
+        gtk_grid_set_baseline_row (GTK_GRID (test), 1);
+        gtk_widget_show (face);
+
+        ca_context_create (&test->priv->canberra);
+
+        /* The test sounds are played for a single channel, set up using the
+         * FORCE_CHANNEL property of libcanberra; this property is only supported
+         * in the PulseAudio backend, so avoid other backends completely */
+        ca_context_set_driver (test->priv->canberra, "pulse");
+
+        ca_context_change_props (test->priv->canberra,
+                                 CA_PROP_APPLICATION_ID, "org.mate.VolumeControl",
+                                 CA_PROP_APPLICATION_NAME, _("Volume Control"),
+                                 CA_PROP_APPLICATION_VERSION, VERSION,
+                                 CA_PROP_APPLICATION_ICON_NAME, "multimedia-volume-control",
+                                 NULL);
+
+        test->priv->controls = g_array_new (FALSE, FALSE, sizeof (GtkWidget *));
+
+        create_controls (test);
+}
+
+static void
+gvc_speaker_test_dispose (GObject *object)
+{
+        GvcSpeakerTest *test;
+
+        test = GVC_SPEAKER_TEST (object);
+
+        g_clear_object (&test->priv->stream);
+
+        G_OBJECT_CLASS (gvc_speaker_test_parent_class)->dispose (object);
+}
+
+static void
+gvc_speaker_test_finalize (GObject *object)
+{
+        GvcSpeakerTest *test;
+
+        test = GVC_SPEAKER_TEST (object);
+
+        ca_context_destroy (test->priv->canberra);
+
+        G_OBJECT_CLASS (gvc_speaker_test_parent_class)->finalize (object);
+}
+
+GtkWidget *
+gvc_speaker_test_new (MateMixerStream *stream)
+{
+        GObject *test;
+
+        g_return_val_if_fail (MATE_MIXER_IS_STREAM (stream), NULL);
+
+        test = g_object_new (GVC_TYPE_SPEAKER_TEST,
+                             "row-spacing", 6,
+                             "column-spacing", 6,
+                             "row-homogeneous", TRUE,
+                             "column-homogeneous", TRUE,
+                             "stream", stream,
+                             NULL);
+
+        return GTK_WIDGET (test);
+}
+
+ +
+ +
+ + diff --git a/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/6.html b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/6.html new file mode 100644 index 0000000..3f8f876 --- /dev/null +++ b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/6.html @@ -0,0 +1,309 @@ + + + + + + Cppcheck - HTML report - mate-media + + + + + +
+ + + +
+
 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/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/60.html b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/60.html new file mode 100644 index 0000000..086c2d6 --- /dev/null +++ b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/60.html @@ -0,0 +1,955 @@ + + + + + + Cppcheck - HTML report - mate-media + + + + + +
+ + + +
+
  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
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 Red Hat, Inc.
+ * Copyright (C) 2014 Michal Ratajsky <michal.ratajsky@gmail.com>
+ * 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.
+ *
+ */
+
+#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 <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 <libmatemixer/matemixer.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "gvc-status-icon.h"
+#include "gvc-stream-status-icon.h"
+
+static const gchar *icon_names_output[] = {
+        "audio-volume-muted",
+        "audio-volume-low",
+        "audio-volume-medium",
+        "audio-volume-high",
+        NULL
+};
+
+static const gchar *icon_names_input[] = {
+        "audio-input-microphone-muted",
+        "audio-input-microphone-low",
+        "audio-input-microphone-medium",
+        "audio-input-microphone-high",
+        NULL
+};
+
+struct _GvcStatusIconPrivate
+{
+        GvcStreamStatusIcon *icon_input;
+        GvcStreamStatusIcon *icon_output;
+        gboolean             running;
+        MateMixerContext    *context;
+        MateMixerStream     *input;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (GvcStatusIcon, gvc_status_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.
+
+static void
+update_icon_input (GvcStatusIcon *status_icon)
+{
+        MateMixerStreamControl *control = NULL;
+        gboolean                show = FALSE;
+
+        /* Enable the input icon in case there is an input stream present and there
+         * is a non-mixer application using the input */
+        if (status_icon->priv->input != NULL) {
+                const gchar *app_id;
+                const GList *inputs =
+                        mate_mixer_stream_list_controls (status_icon->priv->input);
+
+                control = mate_mixer_stream_get_default_control (status_icon->priv->input);
+
+                const gchar *stream_name =
+                        mate_mixer_stream_get_name (status_icon->priv->input);
+                g_debug ("Got stream name %s", stream_name);
+                if (g_str_has_suffix (stream_name, ".monitor")) {
+                        inputs = NULL;
+                        g_debug ("Stream is a monitor, ignoring");
+                }
+
+                while (inputs != NULL) {
+                        MateMixerStreamControl    *input =
+                                MATE_MIXER_STREAM_CONTROL (inputs->data);
+                        MateMixerStreamControlRole role =
+                                mate_mixer_stream_control_get_role (input);
+
+                        if (role == MATE_MIXER_STREAM_CONTROL_ROLE_APPLICATION) {
+                                MateMixerAppInfo *app_info =
+                                        mate_mixer_stream_control_get_app_info (input);
+
+                                app_id = mate_mixer_app_info_get_id (app_info);
+                                if (app_id == NULL) {
+                                        /* A recording application which has no
+                                         * identifier set */
+                                        g_debug ("Found a recording application control %s",
+                                                 mate_mixer_stream_control_get_label (input));
+
+                                        if (G_UNLIKELY (control == NULL)) {
+                                                /* In the unlikely case when there is no
+                                                 * default input control, use the application
+                                                 * control for the icon */
+                                                control = input;
+                                        }
+                                        show = TRUE;
+                                        break;
+                                }
+
+                                if (strcmp (app_id, "org.mate.VolumeControl") != 0 &&
+                                    strcmp (app_id, "org.gnome.VolumeControl") != 0 &&
+                                    strcmp (app_id, "org.PulseAudio.pavucontrol") != 0) {
+                                        g_debug ("Found a recording application %s", app_id);
+
+                                        if (G_UNLIKELY (control == NULL))
+                                                control = input;
+
+                                        show = TRUE;
+                                        break;
+                                }
+                        }
+                        inputs = inputs->next;
+                }
+
+                if (show == TRUE)
+                        g_debug ("Input icon enabled");
+                else
+                        g_debug ("There is no recording application, input icon disabled");
+        }
+
+        gvc_stream_status_icon_set_control (status_icon->priv->icon_input, control);
+
+        gtk_status_icon_set_visible (GTK_STATUS_ICON (status_icon->priv->icon_input), show);
+}
+
+static void
+update_icon_output (GvcStatusIcon *status_icon)
+{
+        MateMixerStream        *stream;
+        MateMixerStreamControl *control = NULL;
+
+        stream = mate_mixer_context_get_default_output_stream (status_icon->priv->context);
+        if (stream != NULL)
+                control = mate_mixer_stream_get_default_control (stream);
+
+        gvc_stream_status_icon_set_control (status_icon->priv->icon_output, control);
+
+        if (control != NULL) {
+                g_debug ("Output icon enabled");
+                gtk_status_icon_set_visible (GTK_STATUS_ICON (status_icon->priv->icon_output),
+                                             TRUE);
+        }
+        else {
+                g_debug ("There is no output stream/control, output icon disabled");
+                gtk_status_icon_set_visible (GTK_STATUS_ICON (status_icon->priv->icon_output),
+                                             FALSE);
+        }
+}
+
+static void
+on_input_stream_control_added (MateMixerStream *stream,
+                               const gchar     *name,
+                               GvcStatusIcon       *status_icon)
+{
+        MateMixerStreamControl *control;
+
+        control = mate_mixer_stream_get_control (stream, name);
+        if (G_LIKELY (control != NULL)) {
+                MateMixerStreamControlRole role =
+                        mate_mixer_stream_control_get_role (control);
+
+                /* Non-application input control doesn't affect the icon */
+                if (role != MATE_MIXER_STREAM_CONTROL_ROLE_APPLICATION)
+                        return;
+        }
+
+        /* Either an application control has been added or we couldn't
+         * read the control, this shouldn't happen but let's revalidate the
+         * icon to be sure if it does */
+        update_icon_input (status_icon);
+}
+
+static void
+on_input_stream_control_removed (MateMixerStream *stream,
+                                 const gchar     *name,
+                                 GvcStatusIcon       *status_icon)
+{
+        /* The removed stream could be an application input, which may cause
+         * the input status icon to disappear */
+        update_icon_input (status_icon);
+}
+
+static gboolean
+update_default_input_stream (GvcStatusIcon *status_icon)
+{
+        MateMixerStream *stream;
+
+        stream = mate_mixer_context_get_default_input_stream (status_icon->priv->context);
+        if (stream == status_icon->priv->input)
+                return FALSE;
+
+        /* The input stream has changed */
+        if (status_icon->priv->input != NULL) {
+                g_signal_handlers_disconnect_by_data (G_OBJECT (status_icon->priv->input),
+                                                      status_icon);
+                g_object_unref (status_icon->priv->input);
+        }
+
+        status_icon->priv->input = (stream == NULL) ? NULL : g_object_ref (stream);
+        if (status_icon->priv->input != NULL) {
+                g_signal_connect (G_OBJECT (status_icon->priv->input),
+                                  "control-added",
+                                  G_CALLBACK (on_input_stream_control_added),
+                                  status_icon);
+                g_signal_connect (G_OBJECT (status_icon->priv->input),
+                                  "control-removed",
+                                  G_CALLBACK (on_input_stream_control_removed),
+                                  status_icon);
+        }
+
+        /* Return TRUE if the default input stream has changed */
+        return TRUE;
+}
+
+static void
+on_context_state_notify (MateMixerContext *context,
+                         GParamSpec       *pspec,
+                         GvcStatusIcon        *status_icon)
+{
+        MateMixerState state = mate_mixer_context_get_state (context);
+
+        switch (state) {
+        case MATE_MIXER_STATE_FAILED:
+                g_warning ("Failed to connect to a sound system");
+                break;
+
+        case MATE_MIXER_STATE_READY:
+                update_default_input_stream (status_icon);
+
+                /* Each status change may affect the visibility of the icons */
+                update_icon_output (status_icon);
+                update_icon_input (status_icon);
+                break;
+        default:
+                break;
+        }
+}
+
+static void
+on_context_default_input_stream_notify (MateMixerContext *context,
+                                        GParamSpec       *pspec,
+                                        GvcStatusIcon        *status_icon)
+{
+        if (update_default_input_stream (status_icon) == FALSE)
+                return;
+
+        update_icon_input (status_icon);
+}
+
+static void
+on_context_default_output_stream_notify (MateMixerContext *control,
+                                         GParamSpec       *pspec,
+                                         GvcStatusIcon        *status_icon)
+{
+        update_icon_output (status_icon);
+}
+
+void
+gvc_status_icon_start (GvcStatusIcon *status_icon)
+{
+        g_return_if_fail (GVC_IS_STATUS_ICON (status_icon));
+
+        if (G_UNLIKELY (status_icon->priv->running == TRUE))
+                return;
+
+        if (G_UNLIKELY (mate_mixer_context_open (status_icon->priv->context) == FALSE)) {
+                /* Normally this should never happen, in the worst case we
+                 * should end up with the Null module */
+                g_warning ("Failed to connect to a sound system");
+        }
+
+        g_debug ("StatusIcon has been started");
+
+        status_icon->priv->running = TRUE;
+}
+
+static void
+gvc_status_icon_dispose (GObject *object)
+{
+        GvcStatusIcon *status_icon = GVC_STATUS_ICON (object);
+
+        if (status_icon->priv->input != NULL) {
+                g_signal_handlers_disconnect_by_data (G_OBJECT (status_icon->priv->input),
+                                                      status_icon);
+                g_clear_object (&status_icon->priv->input);
+        }
+
+        g_clear_object (&status_icon->priv->context);
+        g_clear_object (&status_icon->priv->icon_input);
+        g_clear_object (&status_icon->priv->icon_output);
+
+        G_OBJECT_CLASS (gvc_status_icon_parent_class)->dispose (object);
+}
+
+static void
+gvc_status_icon_class_init (GvcStatusIconClass *klass)
+{
+        GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+        object_class->dispose = gvc_status_icon_dispose;
+}
+
+static void
+gvc_status_icon_init (GvcStatusIcon *status_icon)
+{
+        status_icon->priv = gvc_status_icon_get_instance_private (status_icon);
+
+        status_icon->priv->icon_input  = gvc_stream_status_icon_new (NULL, icon_names_input);
+        status_icon->priv->icon_output = gvc_stream_status_icon_new (NULL, icon_names_output);
+
+        gvc_stream_status_icon_set_display_name (status_icon->priv->icon_input,  _("Input"));
+        gvc_stream_status_icon_set_display_name (status_icon->priv->icon_output, _("Output"));
+
+        gtk_status_icon_set_title (GTK_STATUS_ICON (status_icon->priv->icon_input),
+                                   _("Microphone Volume"));
+        gtk_status_icon_set_title (GTK_STATUS_ICON (status_icon->priv->icon_output),
+                                   _("Sound Output Volume"));
+
+        status_icon->priv->context = mate_mixer_context_new ();
+
+        mate_mixer_context_set_app_name (status_icon->priv->context,
+                                         _("MATE Volume Control StatusIcon"));
+
+        mate_mixer_context_set_app_id (status_icon->priv->context, GVC_STATUS_ICON_DBUS_NAME);
+        mate_mixer_context_set_app_version (status_icon->priv->context, VERSION);
+        mate_mixer_context_set_app_icon (status_icon->priv->context, "multimedia-volume-control");
+
+        g_signal_connect (G_OBJECT (status_icon->priv->context),
+                          "notify::state",
+                          G_CALLBACK (on_context_state_notify),
+                          status_icon);
+        g_signal_connect (G_OBJECT (status_icon->priv->context),
+                          "notify::default-input-stream",
+                          G_CALLBACK (on_context_default_input_stream_notify),
+                          status_icon);
+        g_signal_connect (G_OBJECT (status_icon->priv->context),
+                          "notify::default-output-stream",
+                          G_CALLBACK (on_context_default_output_stream_notify),
+                          status_icon);
+}
+
+GvcStatusIcon *
+gvc_status_icon_new (void)
+{
+        return g_object_new (GVC_TYPE_STATUS_ICON, NULL);
+}
+
+ +
+ +
+ + diff --git a/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/61.html b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/61.html new file mode 100644 index 0000000..99a5f43 --- /dev/null +++ b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/61.html @@ -0,0 +1,361 @@ + + + + + + Cppcheck - HTML report - mate-media + + + + + +
+ + + +
+
 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
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 Red Hat, Inc.
+ * Copyright (C) 2014 Michal Ratajsky <michal.ratajsky@gmail.com>
+ * 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.
+ *
+ */
+
+#ifndef __GVC_STATUS_ICON_H
+#define __GVC_STATUS_ICON_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.
+
+G_BEGIN_DECLS
+
+#define GVC_STATUS_ICON_DBUS_NAME    "org.mate.VolumeControlStatusIcon"
+
+#define GVC_TYPE_STATUS_ICON         (gvc_status_icon_get_type ())
+#define GVC_STATUS_ICON(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), GVC_TYPE_STATUS_ICON, GvcStatusIcon))
+#define GVC_STATUS_ICON_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST ((k), GVC_TYPE_STATUS_ICON, GvcStatusIconClass))
+#define GVC_IS_STATUS_ICON(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), GVC_TYPE_STATUS_ICON))
+#define GVC_IS_STATUS_ICON_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), GVC_TYPE_STATUS_ICON))
+#define GVC_STATUS_ICON_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GVC_TYPE_STATUS_ICON, GvcStatusIconClass))
+
+typedef struct _GvcStatusIcon         GvcStatusIcon;
+typedef struct _GvcStatusIconClass    GvcStatusIconClass;
+typedef struct _GvcStatusIconPrivate  GvcStatusIconPrivate;
+
+struct _GvcStatusIcon
+{
+        GObject               parent;
+        GvcStatusIconPrivate *priv;
+};
+
+struct _GvcStatusIconClass
+{
+        GObjectClass          parent_class;
+};
+
+GType               gvc_status_icon_get_type            (void) G_GNUC_CONST;
+
+GvcStatusIcon *     gvc_status_icon_new                 (void);
+void                gvc_status_icon_start               (GvcStatusIcon *status_icon);
+
+G_END_DECLS
+
+#endif /* __GVC_STATUS_ICON_H */
+
+ +
+ +
+ + diff --git a/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/62.html b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/62.html new file mode 100644 index 0000000..b0554ed --- /dev/null +++ b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/62.html @@ -0,0 +1,375 @@ + + + + + + Cppcheck - HTML report - mate-media + + + + + +
+ + + +
+
 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: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 Red Hat, Inc.
+ * Copyright (C) 2014 Michal Ratajsky <michal.ratajsky@gmail.com>
+ * 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.
+ *
+ */
+
+#ifndef __GVC_STREAM_STATUS_ICON_H
+#define __GVC_STREAM_STATUS_ICON_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.
+#include <libmatemixer/matemixer.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+G_BEGIN_DECLS
+
+#define GVC_TYPE_STREAM_STATUS_ICON         (gvc_stream_status_icon_get_type ())
+#define GVC_STREAM_STATUS_ICON(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), GVC_TYPE_STREAM_STATUS_ICON, GvcStreamStatusIcon))
+#define GVC_STREAM_STATUS_ICON_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST ((k), GVC_TYPE_STREAM_STATUS_ICON, GvcStreamStatusIconClass))
+#define GVC_IS_STREAM_STATUS_ICON(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), GVC_TYPE_STREAM_STATUS_ICON))
+#define GVC_IS_STREAM_STATUS_ICON_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), GVC_TYPE_STREAM_STATUS_ICON))
+#define GVC_STREAM_STATUS_ICON_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GVC_TYPE_STREAM_STATUS_ICON, GvcStreamStatusIconClass))
+
+typedef struct _GvcStreamStatusIcon         GvcStreamStatusIcon;
+typedef struct _GvcStreamStatusIconClass    GvcStreamStatusIconClass;
+typedef struct _GvcStreamStatusIconPrivate  GvcStreamStatusIconPrivate;
+
+struct _GvcStreamStatusIcon
+{
+        GtkStatusIcon               parent;
+        GvcStreamStatusIconPrivate *priv;
+};
+
+struct _GvcStreamStatusIconClass
+{
+        GtkStatusIconClass          parent_class;
+};
+
+GType                 gvc_stream_status_icon_get_type         (void) G_GNUC_CONST;
+
+GvcStreamStatusIcon * gvc_stream_status_icon_new              (MateMixerStreamControl *control,
+                                                               const gchar           **icon_names);
+
+void                  gvc_stream_status_icon_set_icon_names   (GvcStreamStatusIcon    *icon,
+                                                               const gchar           **icon_names);
+void                  gvc_stream_status_icon_set_display_name (GvcStreamStatusIcon    *icon,
+                                                                  const gchar         *display_name);
+
+void                  gvc_stream_status_icon_set_control      (GvcStreamStatusIcon    *icon,
+                                                               MateMixerStreamControl *control);
+
+G_END_DECLS
+
+#endif /* __GVC_STREAM_STATUS_ICON_H */
+
+ +
+ +
+ + diff --git a/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/63.html b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/63.html new file mode 100644 index 0000000..9b9f0fa --- /dev/null +++ b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/63.html @@ -0,0 +1,1989 @@ + + + + + + Cppcheck - HTML report - mate-media + + + + + +
+ + + +
+
  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
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 William Jon McCann
+ * Copyright (C) 2014 Michal Ratajsky <michal.ratajsky@gmail.com>
+ * Copyright (C) 2019 Victor Kareh <vkareh@vkareh.net>
+ * 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.
+ *
+ */
+#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/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 <gdk/gdkkeysyms.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#if defined(ENABLE_WAYLAND) && defined(GDK_WINDOWING_WAYLAND)
+#include <gdk/gdkwayland.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk-layer-shell/gtk-layer-shell.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+
+#include <libmatemixer/matemixer.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.
+
+#define MATE_DESKTOP_USE_UNSTABLE_API
+#include <libmate-desktop/mate-desktop-utils.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "gvc-channel-bar.h"
+#include "gvc-stream-applet-icon.h"
+
+struct _GvcStreamAppletIconPrivate
+{
+        GSettings              *sound_settings;
+        gchar                 **icon_names;
+        GtkImage               *image;
+        GtkWidget              *dock;
+        GtkWidget              *bar;
+        guint                   current_icon;
+        gchar                  *display_name;
+        MateMixerStreamControl *control;
+        MatePanelAppletOrient   orient;
+        guint                   size;
+};
+
+enum
+{
+        PROP_0,
+        PROP_CONTROL,
+        PROP_DISPLAY_NAME,
+        PROP_ICON_NAMES,
+        N_PROPERTIES
+};
+
+static GParamSpec *properties[N_PROPERTIES] = { NULL, };
+
+static void gvc_stream_applet_icon_finalize   (GObject *object);
+
+G_DEFINE_TYPE_WITH_PRIVATE (GvcStreamAppletIcon, gvc_stream_applet_icon, GTK_TYPE_EVENT_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 gboolean
+popup_dock (GvcStreamAppletIcon *icon, guint time)
+{
+        GtkAllocation  allocation;
+        GdkDisplay    *display;
+        GdkScreen     *screen;
+        int            x, y;
+        GdkMonitor    *monitor_num;
+        GdkRectangle   monitor;
+        GtkRequisition dock_req;
+
+        screen = gtk_widget_get_screen (GTK_WIDGET (icon));
+        gtk_widget_get_allocation (GTK_WIDGET (icon), &allocation);
+        gdk_window_get_origin (gtk_widget_get_window (GTK_WIDGET (icon)), &allocation.x, &allocation.y);
+
+        /* position roughly */
+        gtk_window_set_screen (GTK_WINDOW (icon->priv->dock), screen);
+        switch (icon->priv->orient) {
+            case MATE_PANEL_APPLET_ORIENT_LEFT:
+            case MATE_PANEL_APPLET_ORIENT_RIGHT:
+                gvc_channel_bar_set_orientation (GVC_CHANNEL_BAR (icon->priv->bar), GTK_ORIENTATION_HORIZONTAL);
+                break;
+            case MATE_PANEL_APPLET_ORIENT_UP:
+            case MATE_PANEL_APPLET_ORIENT_DOWN:
+            default:
+                gvc_channel_bar_set_orientation (GVC_CHANNEL_BAR (icon->priv->bar), GTK_ORIENTATION_VERTICAL);
+        }
+
+        display = gdk_screen_get_display (screen);
+        monitor_num = gdk_display_get_monitor_at_point (display, allocation.x, allocation.y);
+        gdk_monitor_get_geometry (monitor_num, &monitor);
+
+        gtk_container_foreach (GTK_CONTAINER (icon->priv->dock), (GtkCallback) gtk_widget_show_all, NULL);
+        gtk_widget_get_preferred_size (icon->priv->dock, &dock_req, NULL);
+
+#if defined(ENABLE_WAYLAND) && defined(GDK_WINDOWING_WAYLAND)
+        if (GDK_IS_WAYLAND_DISPLAY (display))
+        {
+            gboolean top, bottom, left, right;
+            GtkWidget *toplevel;
+            toplevel = gtk_widget_get_toplevel (GTK_WIDGET (icon));
+
+            if (!gtk_layer_is_layer_window (GTK_WINDOW (icon->priv->dock)))
+            {
+                gtk_layer_init_for_window (GTK_WINDOW (icon->priv->dock));
+                gtk_layer_set_layer (GTK_WINDOW (icon->priv->dock), GTK_LAYER_SHELL_LAYER_TOP);
+                gtk_layer_set_keyboard_mode (GTK_WINDOW (icon->priv->dock), GTK_LAYER_SHELL_KEYBOARD_MODE_ON_DEMAND);
+            }
+
+            top = gtk_layer_get_anchor (GTK_WINDOW (toplevel), GTK_LAYER_SHELL_EDGE_TOP);
+            bottom = gtk_layer_get_anchor (GTK_WINDOW (toplevel), GTK_LAYER_SHELL_EDGE_BOTTOM);
+            left = gtk_layer_get_anchor (GTK_WINDOW (toplevel), GTK_LAYER_SHELL_EDGE_LEFT);
+            right = gtk_layer_get_anchor (GTK_WINDOW (toplevel), GTK_LAYER_SHELL_EDGE_RIGHT);
+
+            /*Set anchors to the edges (will hold to panel edge) and position along the panel
+             *Unset margins and anchors from any other position so as to avoid rendering issues
+             *when orientation changes as when the panel is moved
+             */
+
+            if (top && left && right)
+            {
+                gtk_layer_set_anchor (GTK_WINDOW (icon->priv->dock), GTK_LAYER_SHELL_EDGE_TOP, TRUE);
+                gtk_layer_set_anchor (GTK_WINDOW (icon->priv->dock), GTK_LAYER_SHELL_EDGE_LEFT, TRUE);
+                gtk_layer_set_anchor (GTK_WINDOW (icon->priv->dock), GTK_LAYER_SHELL_EDGE_BOTTOM, FALSE);
+                gtk_layer_set_anchor (GTK_WINDOW (icon->priv->dock), GTK_LAYER_SHELL_EDGE_RIGHT, FALSE);
+                gtk_layer_set_margin (GTK_WINDOW (icon->priv->dock), GTK_LAYER_SHELL_EDGE_LEFT, allocation.x);
+                gtk_layer_set_margin (GTK_WINDOW (icon->priv->dock), GTK_LAYER_SHELL_EDGE_TOP, 0);
+            }
+            if (bottom && left && right)
+            {
+                gtk_layer_set_anchor (GTK_WINDOW (icon->priv->dock), GTK_LAYER_SHELL_EDGE_BOTTOM, TRUE);
+                gtk_layer_set_anchor (GTK_WINDOW (icon->priv->dock), GTK_LAYER_SHELL_EDGE_LEFT, TRUE);
+                gtk_layer_set_anchor (GTK_WINDOW (icon->priv->dock), GTK_LAYER_SHELL_EDGE_TOP, FALSE);
+                gtk_layer_set_anchor (GTK_WINDOW (icon->priv->dock), GTK_LAYER_SHELL_EDGE_RIGHT, FALSE);
+                gtk_layer_set_margin (GTK_WINDOW (icon->priv->dock), GTK_LAYER_SHELL_EDGE_LEFT, allocation.x);
+                gtk_layer_set_margin (GTK_WINDOW (icon->priv->dock), GTK_LAYER_SHELL_EDGE_TOP, 0);
+            }
+            if (left && bottom && top && !right)
+            {
+                gtk_layer_set_anchor (GTK_WINDOW (icon->priv->dock), GTK_LAYER_SHELL_EDGE_LEFT, TRUE);
+                gtk_layer_set_anchor (GTK_WINDOW (icon->priv->dock), GTK_LAYER_SHELL_EDGE_TOP, TRUE);
+                gtk_layer_set_anchor (GTK_WINDOW (icon->priv->dock), GTK_LAYER_SHELL_EDGE_RIGHT, FALSE);
+                gtk_layer_set_anchor (GTK_WINDOW (icon->priv->dock), GTK_LAYER_SHELL_EDGE_BOTTOM, FALSE);
+                gtk_layer_set_margin (GTK_WINDOW (icon->priv->dock), GTK_LAYER_SHELL_EDGE_TOP, allocation.y);
+                gtk_layer_set_margin (GTK_WINDOW (icon->priv->dock), GTK_LAYER_SHELL_EDGE_LEFT, 0);
+            }
+            if (right && bottom && top && !left)
+            {
+                gtk_layer_set_anchor (GTK_WINDOW (icon->priv->dock), GTK_LAYER_SHELL_EDGE_RIGHT, TRUE);
+                gtk_layer_set_anchor (GTK_WINDOW (icon->priv->dock), GTK_LAYER_SHELL_EDGE_TOP, TRUE);
+                gtk_layer_set_anchor (GTK_WINDOW (icon->priv->dock), GTK_LAYER_SHELL_EDGE_LEFT, FALSE);
+                gtk_layer_set_anchor (GTK_WINDOW (icon->priv->dock), GTK_LAYER_SHELL_EDGE_BOTTOM, FALSE);
+                gtk_layer_set_margin (GTK_WINDOW (icon->priv->dock), GTK_LAYER_SHELL_EDGE_TOP, allocation.y);
+                gtk_layer_set_margin (GTK_WINDOW (icon->priv->dock), GTK_LAYER_SHELL_EDGE_LEFT, 0);
+            }
+            gtk_widget_show_all (icon->priv->dock);
+
+            /* Grab focus */
+            gtk_grab_add (icon->priv->dock);
+            gtk_widget_grab_focus (icon->priv->dock);
+
+            return TRUE;
+        }
+#endif /* wayland support */
+
+        if (icon->priv->orient == MATE_PANEL_APPLET_ORIENT_LEFT || icon->priv->orient == MATE_PANEL_APPLET_ORIENT_RIGHT) {
+                if (allocation.x + allocation.width + dock_req.width <= monitor.x + monitor.width)
+                        x = allocation.x + allocation.width;
+                else
+                        x = allocation.x - dock_req.width;
+
+                if (allocation.y + dock_req.height <= monitor.y + monitor.height)
+                        y = allocation.y;
+                else
+                        y = monitor.y + monitor.height - dock_req.height;
+        } else {
+                if (allocation.y + allocation.height + dock_req.height <= monitor.y + monitor.height)
+                        y = allocation.y + allocation.height;
+                else
+                        y = allocation.y - dock_req.height;
+
+                if (allocation.x + dock_req.width <= monitor.x + monitor.width)
+                        x = allocation.x;
+                else
+                        x = monitor.x + monitor.width - dock_req.width;
+        }
+
+        gtk_window_move (GTK_WINDOW (icon->priv->dock), x, y);
+
+        /* Without this, the popup window appears as a square after changing
+         * the orientation */
+        gtk_window_resize (GTK_WINDOW (icon->priv->dock), 1, 1);
+
+        gtk_widget_show_all (icon->priv->dock);
+
+        /* Grab focus */
+        gtk_grab_add (icon->priv->dock);
+
+        display = gtk_widget_get_display (icon->priv->dock);
+
+        do {
+                GdkSeat *seat = gdk_display_get_default_seat (display);
+                GdkWindow *window = gtk_widget_get_window (icon->priv->dock);
+
+                if (gdk_seat_grab (seat,
+                                   window,
+                                   GDK_SEAT_CAPABILITY_ALL,
+                                   TRUE,
+                                   NULL,
+                                   NULL,
+                                   NULL,
+                                   NULL) != GDK_GRAB_SUCCESS) {
+                        gtk_grab_remove (icon->priv->dock);
+                        gtk_widget_hide (icon->priv->dock);
+                        break;
+                }
+        } while (0);
+
+        gtk_widget_grab_focus (icon->priv->dock);
+
+        return TRUE;
+}
+
+static gboolean
+on_applet_icon_button_press (GtkWidget           *applet_icon,
+                             GdkEventButton      *event,
+                             GvcStreamAppletIcon *icon)
+{
+        if (event->button == 1) {
+                popup_dock (icon, GDK_CURRENT_TIME);
+                return TRUE;
+        }
+
+        /* Middle click acts as mute/unmute */
+        if (event->button == 2) {
+                gboolean is_muted = mate_mixer_stream_control_get_mute (icon->priv->control);
+
+                mate_mixer_stream_control_set_mute (icon->priv->control, !is_muted);
+                return TRUE;
+        }
+        return FALSE;
+}
+
+void
+gvc_stream_applet_icon_set_mute (GvcStreamAppletIcon *icon, gboolean mute)
+{
+        mate_mixer_stream_control_set_mute (icon->priv->control, mute);
+}
+
+gboolean
+gvc_stream_applet_icon_get_mute (GvcStreamAppletIcon *icon)
+{
+        return mate_mixer_stream_control_get_mute (icon->priv->control);
+}
+
+void
+gvc_stream_applet_icon_volume_control (GvcStreamAppletIcon *icon)
+{
+        GError *error = NULL;
+
+        mate_gdk_spawn_command_line_on_screen (gtk_widget_get_screen (icon->priv->dock),
+                                               "mate-volume-control",
+                                               &error);
+
+        if (error != NULL) {
+                GtkWidget *dialog;
+
+                dialog = gtk_message_dialog_new (NULL,
+                                                 0,
+                                                 GTK_MESSAGE_ERROR,
+                                                 GTK_BUTTONS_CLOSE,
+                                                 _("Failed to start Sound Preferences: %s"),
+                                                 error->message);
+                g_signal_connect (G_OBJECT (dialog),
+                                  "response",
+                                  G_CALLBACK (gtk_widget_destroy),
+                                  NULL);
+                gtk_widget_show (dialog);
+                g_error_free (error);
+        }
+}
+
+static gboolean
+on_applet_icon_scroll_event (GtkWidget           *event_box,
+                             GdkEventScroll      *event,
+                             GvcStreamAppletIcon *icon)
+{
+        return gvc_channel_bar_scroll (GVC_CHANNEL_BAR (icon->priv->bar), event->direction);
+}
+
+static void
+gvc_icon_release_grab (GvcStreamAppletIcon *icon, GdkEventButton *event)
+{
+        GdkDisplay *display = gtk_widget_get_display (icon->priv->dock);
+        GdkSeat *seat = gdk_display_get_default_seat (display);
+        gdk_seat_ungrab (seat);
+        gtk_grab_remove (icon->priv->dock);
+
+        /* Hide again */
+        gtk_widget_hide (icon->priv->dock);
+}
+
+static gboolean
+on_dock_button_press (GtkWidget           *widget,
+                      GdkEventButton      *event,
+                      GvcStreamAppletIcon *icon)
+{
+        if (event->type == GDK_BUTTON_PRESS) {
+                gvc_icon_release_grab (icon, event);
+                return TRUE;
+        }
+
+        return FALSE;
+}
+
+static void
+popdown_dock (GvcStreamAppletIcon *icon)
+{
+        GdkDisplay *display;
+
+        display = gtk_widget_get_display (icon->priv->dock);
+
+        GdkSeat *seat = gdk_display_get_default_seat (display);
+        gdk_seat_ungrab (seat);
+
+        /* Hide again */
+        gtk_widget_hide (icon->priv->dock);
+}
+
+/* This is called when the grab is broken for either the dock, or the scale */
+static void
+gvc_icon_grab_notify (GvcStreamAppletIcon *icon, gboolean was_grabbed)
+{
+        if (was_grabbed != FALSE)
+                return;
+
+        if (gtk_widget_has_grab (icon->priv->dock) == FALSE)
+                return;
+
+        if (gtk_widget_is_ancestor (gtk_grab_get_current (), icon->priv->dock))
+                return;
+
+        popdown_dock (icon);
+}
+
+static void
+on_dock_grab_notify (GtkWidget           *widget,
+                     gboolean             was_grabbed,
+                     GvcStreamAppletIcon *icon)
+{
+        gvc_icon_grab_notify (icon, was_grabbed);
+}
+
+static gboolean
+on_dock_grab_broken_event (GtkWidget           *widget,
+                           gboolean             was_grabbed,
+                           GvcStreamAppletIcon *icon)
+{
+        gvc_icon_grab_notify (icon, FALSE);
+        return FALSE;
+}
+
+static gboolean
+on_dock_key_release (GtkWidget           *widget,
+                     GdkEventKey         *event,
+                     GvcStreamAppletIcon *icon)
+{
+        if (event->keyval == GDK_KEY_Escape) {
+                popdown_dock (icon);
+                return TRUE;
+        }
+        return TRUE;
+}
+
+static gboolean
+on_dock_scroll_event (GtkWidget           *widget,
+                      GdkEventScroll      *event,
+                      GvcStreamAppletIcon *icon)
+{
+        /* Forward event to the applet icon */
+        on_applet_icon_scroll_event (NULL, event, icon);
+        return TRUE;
+}
+
+static void
+gvc_stream_applet_icon_set_icon_from_name (GvcStreamAppletIcon *icon,
+                                           const gchar *icon_name)
+{
+        GtkIconTheme *icon_theme = gtk_icon_theme_get_default ();
+        gint icon_scale = gtk_widget_get_scale_factor (GTK_WIDGET (icon));
+
+        cairo_surface_t* surface = gtk_icon_theme_load_surface (icon_theme, icon_name,
+                                                                icon->priv->size,
+                                                                icon_scale, NULL,
+                                                                GTK_ICON_LOOKUP_FORCE_SIZE,
+                                                                NULL);
+
+        gtk_image_set_from_surface (GTK_IMAGE (icon->priv->image), surface);
+        cairo_surface_destroy (surface);
+}
+
+static void
+update_icon (GvcStreamAppletIcon *icon)
+{
+        guint                       volume = 0;
+        gdouble                     decibel = 0;
+        guint                       normal = 0;
+        gboolean                    muted = FALSE;
+        guint                       n = 0;
+        gchar                      *markup;
+        const gchar                *description;
+        MateMixerStreamControlFlags flags;
+
+        if (icon->priv->control == NULL) {
+                /* Do not bother creating a tooltip for an unusable icon as it
+                 * has no practical use */
+                gtk_widget_set_has_tooltip (GTK_WIDGET (icon), FALSE);
+                return;
+        } else
+                gtk_widget_set_has_tooltip (GTK_WIDGET (icon), TRUE);
+
+        flags = mate_mixer_stream_control_get_flags (icon->priv->control);
+
+        if (flags & MATE_MIXER_STREAM_CONTROL_MUTE_READABLE)
+                muted = mate_mixer_stream_control_get_mute (icon->priv->control);
+
+        if (flags & MATE_MIXER_STREAM_CONTROL_VOLUME_READABLE) {
+                volume = mate_mixer_stream_control_get_volume (icon->priv->control);
+                normal = mate_mixer_stream_control_get_normal_volume (icon->priv->control);
+
+                /* Select an icon, they are expected to be sorted, the lowest index being
+                 * the mute icon and the rest being volume increments */
+                if (volume <= 0 || muted)
+                        n = 0;
+                else
+                        n = CLAMP (3 * volume / normal + 1, 1, 3);
+        }
+        if (flags & MATE_MIXER_STREAM_CONTROL_HAS_DECIBEL)
+                decibel = mate_mixer_stream_control_get_decibel (icon->priv->control);
+
+        /* Apparently applet icon will reset icon even if it doesn't change */
+        if (icon->priv->current_icon != n) {
+                gvc_stream_applet_icon_set_icon_from_name (icon, icon->priv->icon_names[n]);
+                icon->priv->current_icon = n;
+        }
+
+        description = mate_mixer_stream_control_get_label (icon->priv->control);
+
+        guint volume_percent = (guint) round (100.0 * volume / normal);
+        if (muted) {
+                markup = g_strdup_printf ("<b>%s: %s %u%%</b>\n<small>%s</small>",
+                                          icon->priv->display_name,
+                                          _("Muted at"),
+                                          volume_percent,
+                                          description);
+        } else if (flags & MATE_MIXER_STREAM_CONTROL_VOLUME_READABLE) {
+                if (flags & MATE_MIXER_STREAM_CONTROL_HAS_DECIBEL) {
+                        if (decibel > -MATE_MIXER_INFINITY) {
+                                markup = g_strdup_printf ("<b>%s: %u%%</b>\n"
+                                                          "<small>%0.2f dB\n%s</small>",
+                                                          icon->priv->display_name,
+                                                          volume_percent,
+                                                          decibel,
+                                                          description);
+                        } else {
+                                markup = g_strdup_printf ("<b>%s: %u%%</b>\n"
+                                                          "<small>-&#8734; dB\n%s</small>",
+                                                          icon->priv->display_name,
+                                                          volume_percent,
+                                                          description);
+                        }
+                } else {
+                        markup = g_strdup_printf ("<b>%s: %u%%</b>\n<small>%s</small>",
+                                                  icon->priv->display_name,
+                                                  volume_percent,
+                                                  description);
+                }
+        } else {
+                markup = g_strdup_printf ("<b>%s</b>\n<small>%s</small>",
+                                          icon->priv->display_name,
+                                          description);
+        }
+
+        gtk_widget_set_tooltip_markup (GTK_WIDGET (icon), markup);
+
+        g_free (markup);
+}
+
+void
+gvc_stream_applet_icon_set_size (GvcStreamAppletIcon *icon,
+                                 guint                size)
+{
+
+        /*Iterate through the icon sizes so they can be kept sharp*/
+        if (size < 22)
+                size = 16;
+        else if (size < 24)
+                size = 22;
+        else if (size < 32)
+                size = 24;
+        else if (size < 48)
+                size = 32;
+
+        icon->priv->size = size;
+        gvc_stream_applet_icon_set_icon_from_name (icon, icon->priv->icon_names[icon->priv->current_icon]);
+}
+
+void
+gvc_stream_applet_icon_set_orient (GvcStreamAppletIcon  *icon,
+                                   MatePanelAppletOrient orient)
+{
+        /* Sometimes orient does not get properly defined especially on a bottom panel.
+         * Use the applet orientation if it is valid, otherwise set a vertical slider,
+         * otherwise bottom panels get a horizontal slider.
+         */
+        if (orient)
+                icon->priv->orient = orient;
+        else
+                icon->priv->orient = MATE_PANEL_APPLET_ORIENT_DOWN;
+}
+
+void
+gvc_stream_applet_icon_set_icon_names (GvcStreamAppletIcon  *icon,
+                                       const gchar         **names)
+{
+        g_return_if_fail (GVC_IS_STREAM_APPLET_ICON (icon));
+        g_return_if_fail (names != NULL && *names != NULL);
+
+        if (G_UNLIKELY (g_strv_length ((gchar **) names) != 4)) {
+                g_warn_if_reached ();
+                return;
+        }
+
+        g_strfreev (icon->priv->icon_names);
+
+        icon->priv->icon_names = g_strdupv ((gchar **) names);
+
+        /* Set the first icon as the initial one, the icon may be immediately
+         * updated or not depending on whether a stream is available */
+        gvc_stream_applet_icon_set_icon_from_name (icon, names[0]);
+        update_icon (icon);
+
+        g_object_notify_by_pspec (G_OBJECT (icon), properties[PROP_ICON_NAMES]);
+}
+
+static void
+on_stream_control_volume_notify (MateMixerStreamControl *control,
+                                 GParamSpec             *pspec,
+                                 GvcStreamAppletIcon    *icon)
+{
+        update_icon (icon);
+}
+
+static void
+on_stream_control_mute_notify (MateMixerStreamControl *control,
+                               GParamSpec             *pspec,
+                               GvcStreamAppletIcon    *icon)
+{
+        update_icon (icon);
+}
+
+void
+gvc_stream_applet_icon_set_display_name (GvcStreamAppletIcon *icon,
+                                         const gchar         *name)
+{
+        g_return_if_fail (GVC_STREAM_APPLET_ICON (icon));
+
+        g_free (icon->priv->display_name);
+
+        icon->priv->display_name = g_strdup (name);
+        update_icon (icon);
+
+        g_object_notify_by_pspec (G_OBJECT (icon), properties[PROP_DISPLAY_NAME]);
+}
+
+void
+gvc_stream_applet_icon_set_control (GvcStreamAppletIcon    *icon,
+                                    MateMixerStreamControl *control)
+{
+        g_return_if_fail (GVC_STREAM_APPLET_ICON (icon));
+
+        if (icon->priv->control == control)
+                return;
+
+        if (control != NULL)
+                g_object_ref (control);
+
+        if (icon->priv->control != NULL) {
+                g_signal_handlers_disconnect_by_func (G_OBJECT (icon->priv->control),
+                                                      G_CALLBACK (on_stream_control_volume_notify),
+                                                      icon);
+                g_signal_handlers_disconnect_by_func (G_OBJECT (icon->priv->control),
+                                                      G_CALLBACK (on_stream_control_mute_notify),
+                                                      icon);
+
+                g_object_unref (icon->priv->control);
+        }
+
+        icon->priv->control = control;
+
+        if (icon->priv->control != NULL) {
+                g_signal_connect (G_OBJECT (icon->priv->control),
+                                  "notify::volume",
+                                  G_CALLBACK (on_stream_control_volume_notify),
+                                  icon);
+                g_signal_connect (G_OBJECT (icon->priv->control),
+                                  "notify::mute",
+                                  G_CALLBACK (on_stream_control_mute_notify),
+                                  icon);
+
+                // XXX when no stream set some default icon and "unset" dock
+                update_icon (icon);
+        }
+
+        gvc_channel_bar_set_control (GVC_CHANNEL_BAR (icon->priv->bar), icon->priv->control);
+
+        g_object_notify_by_pspec (G_OBJECT (icon), properties[PROP_CONTROL]);
+}
+
+static void
+gvc_stream_applet_icon_set_property (GObject      *object,
+                                     guint         prop_id,
+                                     const GValue *value,
+                                     GParamSpec   *pspec)
+{
+        GvcStreamAppletIcon *self = GVC_STREAM_APPLET_ICON (object);
+
+        switch (prop_id) {
+        case PROP_CONTROL:
+                gvc_stream_applet_icon_set_control (self, g_value_get_object (value));
+                break;
+        case PROP_DISPLAY_NAME:
+                gvc_stream_applet_icon_set_display_name (self, g_value_get_string (value));
+                break;
+        case PROP_ICON_NAMES:
+                gvc_stream_applet_icon_set_icon_names (self, g_value_get_boxed (value));
+                break;
+        default:
+                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+                break;
+        }
+}
+
+static void
+gvc_stream_applet_icon_get_property (GObject    *object,
+                                     guint       prop_id,
+                                     GValue     *value,
+                                     GParamSpec *pspec)
+{
+        GvcStreamAppletIcon *self = GVC_STREAM_APPLET_ICON (object);
+
+        switch (prop_id) {
+        case PROP_CONTROL:
+                g_value_set_object (value, self->priv->control);
+                break;
+        case PROP_DISPLAY_NAME:
+                g_value_set_string (value, self->priv->display_name);
+                break;
+        case PROP_ICON_NAMES:
+                g_value_set_boxed (value, self->priv->icon_names);
+                break;
+        default:
+                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+                break;
+        }
+}
+
+static void
+gvc_stream_applet_icon_dispose (GObject *object)
+{
+        GvcStreamAppletIcon *icon = GVC_STREAM_APPLET_ICON (object);
+
+        if (icon->priv->dock != NULL) {
+                gtk_widget_destroy (icon->priv->dock);
+                icon->priv->dock = NULL;
+        }
+
+        g_clear_object (&icon->priv->control);
+
+        G_OBJECT_CLASS (gvc_stream_applet_icon_parent_class)->dispose (object);
+}
+
+static void
+gvc_stream_applet_icon_class_init (GvcStreamAppletIconClass *klass)
+{
+        GObjectClass *object_class = G_OBJECT_CLASS (klass);
+        GtkWidgetClass *widget_class = (GtkWidgetClass *) klass;
+
+        object_class->finalize     = gvc_stream_applet_icon_finalize;
+        object_class->dispose      = gvc_stream_applet_icon_dispose;
+        object_class->set_property = gvc_stream_applet_icon_set_property;
+        object_class->get_property = gvc_stream_applet_icon_get_property;
+
+        properties[PROP_CONTROL] =
+                g_param_spec_object ("control",
+                                     "Control",
+                                     "MateMixer stream control",
+                                     MATE_MIXER_TYPE_STREAM_CONTROL,
+                                     G_PARAM_READWRITE |
+                                     G_PARAM_CONSTRUCT |
+                                     G_PARAM_STATIC_STRINGS);
+
+        properties[PROP_DISPLAY_NAME] =
+                g_param_spec_string ("display-name",
+                                     "Display name",
+                                     "Name to display for this stream",
+                                     NULL,
+                                     G_PARAM_READWRITE |
+                                     G_PARAM_CONSTRUCT |
+                                     G_PARAM_STATIC_STRINGS);
+
+        properties[PROP_ICON_NAMES] =
+                g_param_spec_boxed ("icon-names",
+                                    "Icon names",
+                                    "Name of icon to display for this stream",
+                                    G_TYPE_STRV,
+                                    G_PARAM_READWRITE |
+                                    G_PARAM_CONSTRUCT |
+                                    G_PARAM_STATIC_STRINGS);
+
+        gtk_widget_class_set_css_name (widget_class, "volume-applet");
+
+        g_object_class_install_properties (object_class, N_PROPERTIES, properties);
+}
+
+static void
+on_applet_icon_visible_notify (GvcStreamAppletIcon *icon)
+{
+        if (gtk_widget_get_visible (GTK_WIDGET (icon)) == FALSE)
+                gtk_widget_hide (icon->priv->dock);
+}
+
+static void
+on_icon_theme_change (GtkSettings         *settings,
+                      GParamSpec          *pspec,
+                      GvcStreamAppletIcon *icon)
+{
+        gvc_stream_applet_icon_set_icon_from_name (icon, icon->priv->icon_names[icon->priv->current_icon]);
+}
+
+static void
+gvc_stream_applet_icon_init (GvcStreamAppletIcon *icon)
+{
+        GtkWidget *frame;
+        GtkWidget *box;
+
+        icon->priv = gvc_stream_applet_icon_get_instance_private (icon);
+
+        icon->priv->sound_settings = g_settings_new ("org.mate.sound");
+
+        icon->priv->image = GTK_IMAGE (gtk_image_new ());
+        gtk_container_add (GTK_CONTAINER (icon), GTK_WIDGET (icon->priv->image));
+
+        g_signal_connect (GTK_WIDGET (icon),
+                          "button-press-event",
+                          G_CALLBACK (on_applet_icon_button_press),
+                          icon);
+        g_signal_connect (GTK_WIDGET (icon),
+                          "scroll-event",
+                          G_CALLBACK (on_applet_icon_scroll_event),
+                          icon);
+        g_signal_connect (GTK_WIDGET (icon),
+                          "notify::visible",
+                          G_CALLBACK (on_applet_icon_visible_notify),
+                          NULL);
+
+        /* Create the dock window */
+        icon->priv->dock = gtk_window_new (GTK_WINDOW_POPUP);
+
+        gtk_window_set_decorated (GTK_WINDOW (icon->priv->dock), FALSE);
+
+        g_signal_connect (G_OBJECT (icon->priv->dock),
+                          "button-press-event",
+                          G_CALLBACK (on_dock_button_press),
+                          icon);
+        g_signal_connect (G_OBJECT (icon->priv->dock),
+                          "key-release-event",
+                          G_CALLBACK (on_dock_key_release),
+                          icon);
+        g_signal_connect (G_OBJECT (icon->priv->dock),
+                          "scroll-event",
+                          G_CALLBACK (on_dock_scroll_event),
+                          icon);
+        g_signal_connect (G_OBJECT (icon->priv->dock),
+                          "grab-notify",
+                          G_CALLBACK (on_dock_grab_notify),
+                          icon);
+        g_signal_connect (G_OBJECT (icon->priv->dock),
+                          "grab-broken-event",
+                          G_CALLBACK (on_dock_grab_broken_event),
+                          icon);
+
+        frame = gtk_frame_new (NULL);
+        gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
+        gtk_container_add (GTK_CONTAINER (icon->priv->dock), frame);
+
+        icon->priv->bar = gvc_channel_bar_new (NULL);
+
+        gvc_channel_bar_set_orientation (GVC_CHANNEL_BAR (icon->priv->bar),
+                                         GTK_ORIENTATION_VERTICAL);
+
+        gvc_channel_bar_set_show_mark_text (GVC_CHANNEL_BAR (icon->priv->bar),
+                                            FALSE);
+
+        g_settings_bind (icon->priv->sound_settings, "volume-overamplifiable",
+                         icon->priv->bar,            "show-marks",
+                         G_SETTINGS_BIND_GET);
+
+        g_settings_bind (icon->priv->sound_settings, "volume-overamplifiable",
+                         icon->priv->bar,            "extended",
+                         G_SETTINGS_BIND_GET);
+
+        /* Set volume control frame, slider and toplevel window to follow panel theme */
+        GtkWidget *toplevel = gtk_widget_get_toplevel (icon->priv->dock);
+        GtkStyleContext *context;
+        context = gtk_widget_get_style_context (GTK_WIDGET(toplevel));
+        gtk_style_context_add_class(context,"mate-panel-applet-slider");
+
+        /* Make transparency possible in gtk3 theme */
+        GdkScreen *screen = gtk_widget_get_screen(GTK_WIDGET(toplevel));
+        GdkVisual *visual = gdk_screen_get_rgba_visual(screen);
+        gtk_widget_set_visual(GTK_WIDGET(toplevel), visual);
+
+        box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
+
+        gtk_container_set_border_width (GTK_CONTAINER (box), 2);
+        gtk_container_add (GTK_CONTAINER (frame), box);
+
+        gtk_box_pack_start (GTK_BOX (box), icon->priv->bar, TRUE, FALSE, 0);
+
+        g_signal_connect (gtk_settings_get_default (),
+                          "notify::gtk-icon-theme-name",
+                          G_CALLBACK (on_icon_theme_change),
+                          icon);
+}
+
+static void
+gvc_stream_applet_icon_finalize (GObject *object)
+{
+        GvcStreamAppletIcon *icon;
+
+        icon = GVC_STREAM_APPLET_ICON (object);
+
+        g_strfreev (icon->priv->icon_names);
+        g_clear_pointer (&icon->priv->display_name, g_free);
+
+        g_signal_handlers_disconnect_by_func (gtk_settings_get_default (),
+                                              on_icon_theme_change,
+                                              icon);
+
+        g_clear_object (&icon->priv->sound_settings);
+
+        G_OBJECT_CLASS (gvc_stream_applet_icon_parent_class)->finalize (object);
+}
+
+GvcStreamAppletIcon *
+gvc_stream_applet_icon_new (MateMixerStreamControl *control,
+                            const gchar           **icon_names)
+{
+        return g_object_new (GVC_TYPE_STREAM_APPLET_ICON,
+                             "control", control,
+                             "icon-names", icon_names,
+                             NULL);
+}
+
+ +
+ +
+ + diff --git a/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/64.html b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/64.html new file mode 100644 index 0000000..2ffdefd --- /dev/null +++ b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/64.html @@ -0,0 +1,1867 @@ + + + + + + Cppcheck - HTML report - mate-media + + + + + +
+ + + +
+
  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
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 William Jon McCann
+ * Copyright (C) 2014 Michal Ratajsky <michal.ratajsky@gmail.com>
+ * 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.
+ *
+ */
+
+#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/gdkkeysyms.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <libmatemixer/matemixer.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 <libmate-desktop/mate-desktop-utils.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 "gvc-channel-bar.h"
+#include "gvc-stream-status-icon.h"
+
+struct _GvcStreamStatusIconPrivate
+{
+        GSettings       *sound_settings;
+        gchar          **icon_names;
+        GtkWidget       *dock;
+        GtkWidget       *bar;
+        guint            current_icon;
+        gchar           *display_name;
+        MateMixerStreamControl *control;
+};
+
+enum
+{
+        PROP_0,
+        PROP_CONTROL,
+        PROP_DISPLAY_NAME,
+        PROP_ICON_NAMES,
+        N_PROPERTIES
+};
+
+static GParamSpec *properties[N_PROPERTIES] = { NULL, };
+
+static void gvc_stream_status_icon_finalize   (GObject                  *object);
+
+G_DEFINE_TYPE_WITH_PRIVATE (GvcStreamStatusIcon, gvc_stream_status_icon, GTK_TYPE_STATUS_ICON)<--- 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
+popup_dock (GvcStreamStatusIcon *icon, guint time)
+{
+        GdkRectangle   area;
+        GtkOrientation orientation;
+        GdkDisplay    *display;
+        GdkScreen     *screen;
+        int            x;
+        int            y;
+        GdkMonitor    *monitor_num;
+        GdkRectangle   monitor;
+        GtkRequisition dock_req;
+
+        screen = gtk_status_icon_get_screen (GTK_STATUS_ICON (icon));
+
+        if (gtk_status_icon_get_geometry (GTK_STATUS_ICON (icon),
+                                          &screen,
+                                          &area,
+                                          &orientation) == FALSE) {
+                g_warning ("Unable to determine geometry of status icon");
+                return FALSE;
+        }
+
+        /* position roughly */
+        gtk_window_set_screen (GTK_WINDOW (icon->priv->dock), screen);
+        gvc_channel_bar_set_orientation (GVC_CHANNEL_BAR (icon->priv->bar),
+                                         1 - orientation);
+
+        monitor_num = gdk_display_get_monitor_at_point (gdk_screen_get_display (screen), area.x, area.y);
+        gdk_monitor_get_geometry (monitor_num, &monitor);
+
+        gtk_container_foreach (GTK_CONTAINER (icon->priv->dock),
+                               (GtkCallback) gtk_widget_show_all, NULL);
+        gtk_widget_get_preferred_size (icon->priv->dock, &dock_req, NULL);
+
+        if (orientation == GTK_ORIENTATION_VERTICAL) {
+                if (area.x + area.width + dock_req.width <= monitor.x + monitor.width)
+                        x = area.x + area.width;
+                else
+                        x = area.x - dock_req.width;
+
+                if (area.y + dock_req.height <= monitor.y + monitor.height)
+                        y = area.y;
+                else
+                        y = monitor.y + monitor.height - dock_req.height;
+        } else {
+                if (area.y + area.height + dock_req.height <= monitor.y + monitor.height)
+                        y = area.y + area.height;
+                else
+                        y = area.y - dock_req.height;
+
+                if (area.x + dock_req.width <= monitor.x + monitor.width)
+                        x = area.x;
+                else
+                        x = monitor.x + monitor.width - dock_req.width;
+        }
+
+        gtk_window_move (GTK_WINDOW (icon->priv->dock), x, y);
+
+        /* Without this, the popup window appears as a square after changing
+         * the orientation */
+        gtk_window_resize (GTK_WINDOW (icon->priv->dock), 1, 1);
+
+        gtk_widget_show_all (icon->priv->dock);
+
+        /* Grab focus */
+        gtk_grab_add (icon->priv->dock);
+
+        display = gtk_widget_get_display (icon->priv->dock);
+
+        do {
+                GdkSeat *seat = gdk_display_get_default_seat (display);
+                GdkWindow *window = gtk_widget_get_window (icon->priv->dock);
+
+                if (gdk_seat_grab (seat,
+                                   window,
+                                   GDK_SEAT_CAPABILITY_ALL,
+                                   TRUE,
+                                   NULL,
+                                   NULL,
+                                   NULL,
+                                   NULL) != GDK_GRAB_SUCCESS) {
+                        gtk_grab_remove (icon->priv->dock);
+                        gtk_widget_hide (icon->priv->dock);
+                        break;
+                }
+        } while (0);
+
+        gtk_widget_grab_focus (icon->priv->dock);
+
+        return TRUE;
+}
+
+static void
+on_status_icon_activate (GtkStatusIcon *status_icon, GvcStreamStatusIcon *icon)
+{
+        popup_dock (icon, GDK_CURRENT_TIME);
+}
+
+static gboolean
+on_status_icon_button_press (GtkStatusIcon       *status_icon,
+                             GdkEventButton      *event,
+                             GvcStreamStatusIcon *icon)
+{
+        /* Middle click acts as mute/unmute */
+        if (event->button == 2) {
+                gboolean is_muted = mate_mixer_stream_control_get_mute (icon->priv->control);
+
+                mate_mixer_stream_control_set_mute (icon->priv->control, !is_muted);
+                return TRUE;
+        }
+        return FALSE;
+}
+
+static void
+on_menu_mute_toggled (GtkMenuItem *item, GvcStreamStatusIcon *icon)
+{
+        mate_mixer_stream_control_set_mute (icon->priv->control, !mate_mixer_stream_control_get_mute (icon->priv->control));
+}
+
+static void
+on_menu_activate_open_volume_control (GtkMenuItem         *item,
+                                      GvcStreamStatusIcon *icon)
+{
+        GError *error = NULL;
+
+        mate_gdk_spawn_command_line_on_screen (gtk_widget_get_screen (icon->priv->dock),
+                                               "mate-volume-control",
+                                               &error);
+
+        if (error != NULL) {
+                GtkWidget *dialog;
+
+                dialog = gtk_message_dialog_new (NULL,
+                                                 0,
+                                                 GTK_MESSAGE_ERROR,
+                                                 GTK_BUTTONS_CLOSE,
+                                                 _("Failed to start Sound Preferences: %s"),
+                                                 error->message);
+                g_signal_connect (G_OBJECT (dialog),
+                                  "response",
+                                  G_CALLBACK (gtk_widget_destroy),
+                                  NULL);
+                gtk_widget_show (dialog);
+                g_error_free (error);
+        }
+}
+
+static void
+on_status_icon_popup_menu (GtkStatusIcon       *status_icon,
+                           guint                button,
+                           guint                activate_time,
+                           GvcStreamStatusIcon *icon)
+{
+        GtkWidget *menu;
+        GtkWidget *item;
+        GtkWidget *image;
+        g_autofree char *label = NULL;
+
+        menu = gtk_menu_new ();
+
+        /* Set up theme and transparency support */
+        GtkWidget *toplevel = gtk_widget_get_toplevel (menu);
+        /* Fix any failures of compiz/other wm's to communicate with gtk for transparency */
+        GdkScreen *screen = gtk_widget_get_screen(GTK_WIDGET(toplevel));
+        GdkVisual *visual = gdk_screen_get_rgba_visual(screen);
+        gtk_widget_set_visual(GTK_WIDGET(toplevel), visual);
+        /* Set menu and it's toplevel window to follow panel theme */
+        GtkStyleContext *context;
+        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");
+
+        if (mate_mixer_stream_control_get_mute (icon->priv->control))
+        {
+                label = g_strdup_printf ("%s %s", _("Unmute"), icon->priv->display_name);
+                /* Set icon to medium*/
+                image = gtk_image_new_from_icon_name(icon->priv->icon_names[2], GTK_ICON_SIZE_MENU);
+        }
+        else
+        {
+                label = g_strdup_printf ("%s %s", _("Mute"), icon->priv->display_name);
+                /* Set icon to muted*/
+                image = gtk_image_new_from_icon_name(icon->priv->icon_names[0], GTK_ICON_SIZE_MENU);
+        }
+        item = mate_image_menu_item_new_with_mnemonic(label);
+        mate_image_menu_item_set_image (MATE_IMAGE_MENU_ITEM (item), image);
+        g_signal_connect (G_OBJECT (item),
+                          "activate",
+                          G_CALLBACK (on_menu_mute_toggled),
+                          icon);
+
+        gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+
+        item = mate_image_menu_item_new_with_mnemonic (_("_Sound Preferences"));
+        image = gtk_image_new_from_icon_name ("multimedia-volume-control",
+                                              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 (on_menu_activate_open_volume_control),
+                          icon);
+
+        gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+
+        gtk_widget_show_all (menu);
+        gtk_menu_popup (GTK_MENU (menu),
+                        NULL,
+                        NULL,
+                        gtk_status_icon_position_menu,
+                        status_icon,
+                        button,
+                        activate_time);
+}
+
+static gboolean
+on_status_icon_scroll_event (GtkStatusIcon       *status_icon,
+                             GdkEventScroll      *event,
+                             GvcStreamStatusIcon *icon)
+{
+        return gvc_channel_bar_scroll (GVC_CHANNEL_BAR (icon->priv->bar), event->direction);
+}
+
+static void
+gvc_icon_release_grab (GvcStreamStatusIcon *icon, GdkEventButton *event)
+{
+        GdkDisplay *display = gtk_widget_get_display (icon->priv->dock);
+        GdkSeat *seat = gdk_display_get_default_seat (display);
+        gdk_seat_ungrab (seat);
+        gtk_grab_remove (icon->priv->dock);
+
+        /* Hide again */
+        gtk_widget_hide (icon->priv->dock);
+}
+
+static gboolean
+on_dock_button_press (GtkWidget           *widget,
+                      GdkEventButton      *event,
+                      GvcStreamStatusIcon *icon)
+{
+        if (event->type == GDK_BUTTON_PRESS) {
+                gvc_icon_release_grab (icon, event);
+                return TRUE;
+        }
+
+        return FALSE;
+}
+
+static void
+popdown_dock (GvcStreamStatusIcon *icon)
+{
+        GdkDisplay *display;
+
+        display = gtk_widget_get_display (icon->priv->dock);
+
+        GdkSeat *seat = gdk_display_get_default_seat (display);
+        gdk_seat_ungrab (seat);
+
+        /* Hide again */
+        gtk_widget_hide (icon->priv->dock);
+}
+
+/* This is called when the grab is broken for either the dock, or the scale */
+static void
+gvc_icon_grab_notify (GvcStreamStatusIcon *icon, gboolean was_grabbed)
+{
+        if (was_grabbed != FALSE)
+                return;
+
+        if (gtk_widget_has_grab (icon->priv->dock) == FALSE)
+                return;
+
+        if (gtk_widget_is_ancestor (gtk_grab_get_current (), icon->priv->dock))
+                return;
+
+        popdown_dock (icon);
+}
+
+static void
+on_dock_grab_notify (GtkWidget           *widget,
+                     gboolean             was_grabbed,
+                     GvcStreamStatusIcon *icon)
+{
+        gvc_icon_grab_notify (icon, was_grabbed);
+}
+
+static gboolean
+on_dock_grab_broken_event (GtkWidget           *widget,
+                           gboolean             was_grabbed,
+                           GvcStreamStatusIcon *icon)
+{
+        gvc_icon_grab_notify (icon, FALSE);
+        return FALSE;
+}
+
+static gboolean
+on_dock_key_release (GtkWidget           *widget,
+                     GdkEventKey         *event,
+                     GvcStreamStatusIcon *icon)
+{
+        if (event->keyval == GDK_KEY_Escape) {
+                popdown_dock (icon);
+                return TRUE;
+        }
+        return TRUE;
+}
+
+static gboolean
+on_dock_scroll_event (GtkWidget           *widget,
+                      GdkEventScroll      *event,
+                      GvcStreamStatusIcon *icon)
+{
+        /* Forward event to the status icon */
+        on_status_icon_scroll_event (NULL, event, icon);
+        return TRUE;
+}
+
+static void
+update_icon (GvcStreamStatusIcon *icon)
+{
+        guint                volume = 0;
+        guint                volume_percent = 0;
+        gdouble              decibel = 0;
+        guint                normal = 0;
+        gboolean             muted = FALSE;
+        guint                n = 0;
+        gchar               *markup;
+        const gchar         *description;
+        MateMixerStreamControlFlags flags;
+
+        if (icon->priv->control == NULL) {
+                /* Do not bother creating a tooltip for an unusable icon as it
+                 * has no practical use */
+                gtk_status_icon_set_has_tooltip (GTK_STATUS_ICON (icon), FALSE);
+                return;
+        } else
+                gtk_status_icon_set_has_tooltip (GTK_STATUS_ICON (icon), TRUE);
+
+        flags = mate_mixer_stream_control_get_flags (icon->priv->control);
+
+        if (flags & MATE_MIXER_STREAM_CONTROL_MUTE_READABLE)
+                muted = mate_mixer_stream_control_get_mute (icon->priv->control);
+
+        if (flags & MATE_MIXER_STREAM_CONTROL_VOLUME_READABLE) {
+                volume = mate_mixer_stream_control_get_volume (icon->priv->control);
+                normal = mate_mixer_stream_control_get_normal_volume (icon->priv->control);
+
+                /* Select an icon, they are expected to be sorted, the lowest index being
+                 * the mute icon and the rest being volume increments */
+                if (volume == 0 || muted)
+                        n = 0;
+                else
+                        n = CLAMP (3 * volume / normal + 1, 1, 3);
+        }
+        if (flags & MATE_MIXER_STREAM_CONTROL_HAS_DECIBEL)
+                decibel = mate_mixer_stream_control_get_decibel (icon->priv->control);
+
+        /* Apparently status icon will reset icon even if it doesn't change */
+        if (icon->priv->current_icon != n) {
+                gtk_status_icon_set_from_icon_name (GTK_STATUS_ICON (icon),
+                                                    icon->priv->icon_names[n]);
+                icon->priv->current_icon = n;
+        }
+
+        description = mate_mixer_stream_control_get_label (icon->priv->control);
+
+        if (normal != 0)
+                volume_percent = (guint) (100.0 * ((double) volume) / ((double) normal));
+
+        if (muted) {
+                markup = g_strdup_printf ("<b>%s: %s %u%%</b>\n<small>%s</small>",
+                                          icon->priv->display_name,
+                                          _("Muted at"),
+                                          volume_percent,
+                                          description);
+        } else if (flags & MATE_MIXER_STREAM_CONTROL_VOLUME_READABLE) {
+                if (flags & MATE_MIXER_STREAM_CONTROL_HAS_DECIBEL) {
+                        if (decibel > -MATE_MIXER_INFINITY) {
+                                markup = g_strdup_printf ("<b>%s: %u%%</b>\n"
+                                                          "<small>%0.2f dB\n%s</small>",
+                                                          icon->priv->display_name,
+                                                          volume_percent,
+                                                          decibel,
+                                                          description);
+                        } else {
+                                markup = g_strdup_printf ("<b>%s: %u%%</b>\n"
+                                                          "<small>-&#8734; dB\n%s</small>",
+                                                          icon->priv->display_name,
+                                                          volume_percent,
+                                                          description);
+                        }
+                } else {
+                        markup = g_strdup_printf ("<b>%s: %u%%</b>\n<small>%s</small>",
+                                                  icon->priv->display_name,
+                                                  volume_percent,
+                                                  description);
+                }
+        } else {
+                markup = g_strdup_printf ("<b>%s</b>\n<small>%s</small>",
+                                          icon->priv->display_name,
+                                          description);
+        }
+
+        gtk_status_icon_set_tooltip_markup (GTK_STATUS_ICON (icon), markup);
+
+        g_free (markup);
+}
+
+void
+gvc_stream_status_icon_set_icon_names (GvcStreamStatusIcon  *icon,
+                                       const gchar         **names)
+{
+        g_return_if_fail (GVC_IS_STREAM_STATUS_ICON (icon));
+        g_return_if_fail (names != NULL && *names != NULL);
+
+        if (G_UNLIKELY (g_strv_length ((gchar **) names) != 4)) {
+                g_warn_if_reached ();
+                return;
+        }
+
+        g_strfreev (icon->priv->icon_names);
+
+        icon->priv->icon_names = g_strdupv ((gchar **) names);
+
+        /* Set the first icon as the initial one, the icon may be immediately
+         * updated or not depending on whether a stream is available */
+        gtk_status_icon_set_from_icon_name (GTK_STATUS_ICON (icon), names[0]);
+        update_icon (icon);
+
+        g_object_notify_by_pspec (G_OBJECT (icon), properties[PROP_ICON_NAMES]);
+}
+
+static void
+on_stream_control_volume_notify (MateMixerStreamControl     *control,
+                         GParamSpec          *pspec,
+                         GvcStreamStatusIcon *icon)
+{
+        update_icon (icon);
+}
+
+static void
+on_stream_control_mute_notify (MateMixerStreamControl     *control,
+                       GParamSpec          *pspec,
+                       GvcStreamStatusIcon *icon)
+{
+        update_icon (icon);
+}
+
+void
+gvc_stream_status_icon_set_display_name (GvcStreamStatusIcon *icon,
+                                         const gchar         *name)
+{
+        g_return_if_fail (GVC_STREAM_STATUS_ICON (icon));
+
+        g_free (icon->priv->display_name);
+
+        icon->priv->display_name = g_strdup (name);
+        update_icon (icon);
+
+        g_object_notify_by_pspec (G_OBJECT (icon), properties[PROP_DISPLAY_NAME]);
+}
+
+void
+gvc_stream_status_icon_set_control (GvcStreamStatusIcon    *icon,
+                                    MateMixerStreamControl *control)
+{
+        g_return_if_fail (GVC_STREAM_STATUS_ICON (icon));
+
+        if (icon->priv->control == control)
+                return;
+
+        if (control != NULL)
+                g_object_ref (control);
+
+        if (icon->priv->control != NULL) {
+                g_signal_handlers_disconnect_by_func (G_OBJECT (icon->priv->control),
+                                                      G_CALLBACK (on_stream_control_volume_notify),
+                                                      icon);
+                g_signal_handlers_disconnect_by_func (G_OBJECT (icon->priv->control),
+                                                      G_CALLBACK (on_stream_control_mute_notify),
+                                                      icon);
+
+                g_object_unref (icon->priv->control);
+        }
+
+        icon->priv->control = control;
+
+        if (icon->priv->control != NULL) {
+                g_signal_connect (G_OBJECT (icon->priv->control),
+                                  "notify::volume",
+                                  G_CALLBACK (on_stream_control_volume_notify),
+                                  icon);
+                g_signal_connect (G_OBJECT (icon->priv->control),
+                                  "notify::mute",
+                                  G_CALLBACK (on_stream_control_mute_notify),
+                                  icon);
+
+                // XXX when no stream set some default icon and "unset" dock
+                update_icon (icon);
+        }
+
+        gvc_channel_bar_set_control (GVC_CHANNEL_BAR (icon->priv->bar), icon->priv->control);
+
+        g_object_notify_by_pspec (G_OBJECT (icon), properties[PROP_CONTROL]);
+}
+
+static void
+gvc_stream_status_icon_set_property (GObject       *object,
+                                     guint          prop_id,
+                                     const GValue  *value,
+                                     GParamSpec    *pspec)
+{
+        GvcStreamStatusIcon *self = GVC_STREAM_STATUS_ICON (object);
+
+        switch (prop_id) {
+        case PROP_CONTROL:
+                gvc_stream_status_icon_set_control (self, g_value_get_object (value));
+                break;
+        case PROP_DISPLAY_NAME:
+                gvc_stream_status_icon_set_display_name (self, g_value_get_string (value));
+                break;
+        case PROP_ICON_NAMES:
+                gvc_stream_status_icon_set_icon_names (self, g_value_get_boxed (value));
+                break;
+        default:
+                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+                break;
+        }
+}
+
+static void
+gvc_stream_status_icon_get_property (GObject     *object,
+                                     guint        prop_id,
+                                     GValue      *value,
+                                     GParamSpec  *pspec)
+{
+        GvcStreamStatusIcon *self = GVC_STREAM_STATUS_ICON (object);
+
+        switch (prop_id) {
+        case PROP_CONTROL:
+                g_value_set_object (value, self->priv->control);
+                break;
+        case PROP_DISPLAY_NAME:
+                g_value_set_string (value, self->priv->display_name);
+                break;
+        case PROP_ICON_NAMES:
+                g_value_set_boxed (value, self->priv->icon_names);
+                break;
+        default:
+                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+                break;
+        }
+}
+
+static void
+gvc_stream_status_icon_dispose (GObject *object)
+{
+        GvcStreamStatusIcon *icon = GVC_STREAM_STATUS_ICON (object);
+
+        if (icon->priv->dock != NULL) {
+                gtk_widget_destroy (icon->priv->dock);
+                icon->priv->dock = NULL;
+        }
+
+        g_clear_object (&icon->priv->control);
+
+        G_OBJECT_CLASS (gvc_stream_status_icon_parent_class)->dispose (object);
+}
+
+static void
+gvc_stream_status_icon_class_init (GvcStreamStatusIconClass *klass)
+{
+        GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+        object_class->finalize = gvc_stream_status_icon_finalize;
+        object_class->dispose  = gvc_stream_status_icon_dispose;
+        object_class->set_property = gvc_stream_status_icon_set_property;
+        object_class->get_property = gvc_stream_status_icon_get_property;
+
+        properties[PROP_CONTROL] =
+                g_param_spec_object ("control",
+                                     "Control",
+                                     "MateMixer stream control",
+                                     MATE_MIXER_TYPE_STREAM_CONTROL,
+                                     G_PARAM_READWRITE |
+                                     G_PARAM_CONSTRUCT |
+                                     G_PARAM_STATIC_STRINGS);
+
+        properties[PROP_DISPLAY_NAME] =
+                g_param_spec_string ("display-name",
+                                     "Display name",
+                                     "Name to display for this stream",
+                                     NULL,
+                                     G_PARAM_READWRITE |
+                                     G_PARAM_CONSTRUCT |
+                                     G_PARAM_STATIC_STRINGS);
+
+        properties[PROP_ICON_NAMES] =
+                g_param_spec_boxed ("icon-names",
+                                    "Icon names",
+                                    "Name of icon to display for this stream",
+                                    G_TYPE_STRV,
+                                    G_PARAM_READWRITE |
+                                    G_PARAM_CONSTRUCT |
+                                    G_PARAM_STATIC_STRINGS);
+
+        g_object_class_install_properties (object_class, N_PROPERTIES, properties);
+}
+
+static void
+on_status_icon_visible_notify (GvcStreamStatusIcon *icon)
+{
+        if (gtk_status_icon_get_visible (GTK_STATUS_ICON (icon)) == FALSE)
+                gtk_widget_hide (icon->priv->dock);
+}
+
+static void
+on_icon_theme_change (GtkSettings         *settings,
+                      GParamSpec          *pspec,
+                      GvcStreamStatusIcon *icon)
+{
+        gtk_status_icon_set_from_icon_name (GTK_STATUS_ICON (icon),
+                                            icon->priv->icon_names[icon->priv->current_icon]);
+}
+
+static void
+gvc_stream_status_icon_init (GvcStreamStatusIcon *icon)
+{
+        GtkWidget *frame;
+        GtkWidget *box;
+
+        icon->priv = gvc_stream_status_icon_get_instance_private (icon);
+
+        icon->priv->sound_settings = g_settings_new ("org.mate.sound");
+
+        g_signal_connect (G_OBJECT (icon),
+                          "activate",
+                          G_CALLBACK (on_status_icon_activate),
+                          icon);
+        g_signal_connect (G_OBJECT (icon),
+                          "button-press-event",
+                          G_CALLBACK (on_status_icon_button_press),
+                          icon);
+        g_signal_connect (G_OBJECT (icon),
+                          "popup-menu",
+                          G_CALLBACK (on_status_icon_popup_menu),
+                          icon);
+        g_signal_connect (G_OBJECT (icon),
+                          "scroll-event",
+                          G_CALLBACK (on_status_icon_scroll_event),
+                          icon);
+        g_signal_connect (G_OBJECT (icon),
+                          "notify::visible",
+                          G_CALLBACK (on_status_icon_visible_notify),
+                          NULL);
+
+        /* Create the dock window */
+        icon->priv->dock = gtk_window_new (GTK_WINDOW_POPUP);
+
+        gtk_window_set_decorated (GTK_WINDOW (icon->priv->dock), FALSE);
+
+        g_signal_connect (G_OBJECT (icon->priv->dock),
+                          "button-press-event",
+                          G_CALLBACK (on_dock_button_press),
+                          icon);
+        g_signal_connect (G_OBJECT (icon->priv->dock),
+                          "key-release-event",
+                          G_CALLBACK (on_dock_key_release),
+                          icon);
+        g_signal_connect (G_OBJECT (icon->priv->dock),
+                          "scroll-event",
+                          G_CALLBACK (on_dock_scroll_event),
+                          icon);
+        g_signal_connect (G_OBJECT (icon->priv->dock),
+                          "grab-notify",
+                          G_CALLBACK (on_dock_grab_notify),
+                          icon);
+        g_signal_connect (G_OBJECT (icon->priv->dock),
+                          "grab-broken-event",
+                          G_CALLBACK (on_dock_grab_broken_event),
+                          icon);
+
+        frame = gtk_frame_new (NULL);
+        gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
+        gtk_container_add (GTK_CONTAINER (icon->priv->dock), frame);
+
+        icon->priv->bar = gvc_channel_bar_new (NULL);
+
+        gvc_channel_bar_set_orientation (GVC_CHANNEL_BAR (icon->priv->bar),
+                                         GTK_ORIENTATION_VERTICAL);
+
+        gvc_channel_bar_set_show_mark_text (GVC_CHANNEL_BAR (icon->priv->bar),
+                                            FALSE);
+
+        g_settings_bind (icon->priv->sound_settings, "volume-overamplifiable",
+                         icon->priv->bar,            "show-marks",
+                         G_SETTINGS_BIND_GET);
+
+        g_settings_bind (icon->priv->sound_settings, "volume-overamplifiable",
+                         icon->priv->bar,            "extended",
+                         G_SETTINGS_BIND_GET);
+
+        /* Set volume control frame, slider and toplevel window to follow panel theme */
+        GtkWidget *toplevel = gtk_widget_get_toplevel (icon->priv->dock);
+        GtkStyleContext *context;
+        context = gtk_widget_get_style_context (GTK_WIDGET(toplevel));
+        gtk_style_context_add_class(context,"mate-panel-applet-slider");
+        /* Make transparency possible in gtk3 theme */
+        GdkScreen *screen = gtk_widget_get_screen(GTK_WIDGET(toplevel));
+        GdkVisual *visual = gdk_screen_get_rgba_visual(screen);
+        gtk_widget_set_visual(GTK_WIDGET(toplevel), visual);
+
+        box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
+
+        gtk_container_set_border_width (GTK_CONTAINER (box), 2);
+        gtk_container_add (GTK_CONTAINER (frame), box);
+
+        gtk_box_pack_start (GTK_BOX (box), icon->priv->bar, TRUE, FALSE, 0);
+
+        g_signal_connect (gtk_settings_get_default (),
+                          "notify::gtk-icon-theme-name",
+                          G_CALLBACK (on_icon_theme_change),
+                          icon);
+}
+
+static void
+gvc_stream_status_icon_finalize (GObject *object)
+{
+        GvcStreamStatusIcon *icon;
+
+        icon = GVC_STREAM_STATUS_ICON (object);
+
+        g_strfreev (icon->priv->icon_names);
+
+        g_signal_handlers_disconnect_by_func (gtk_settings_get_default (),
+                                              on_icon_theme_change,
+                                              icon);
+
+        g_clear_object (&icon->priv->sound_settings);
+
+        G_OBJECT_CLASS (gvc_stream_status_icon_parent_class)->finalize (object);
+}
+
+GvcStreamStatusIcon *
+gvc_stream_status_icon_new (MateMixerStreamControl *control,
+                            const gchar           **icon_names)
+{
+        return g_object_new (GVC_TYPE_STREAM_STATUS_ICON,
+                             "control", control,
+                             "icon-names", icon_names,
+                             NULL);
+}
+
+ +
+ +
+ + diff --git a/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/65.html b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/65.html new file mode 100644 index 0000000..2d02859 --- /dev/null +++ b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/65.html @@ -0,0 +1,555 @@ + + + + + + Cppcheck - HTML report - mate-media + + + + + +
+ + + +
+
  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
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2014 Michal Ratajsky <michal.ratajsky@gmail.com>
+ * 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.
+ *
+ */
+
+#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 <libmatemixer/matemixer.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "gvc-utils.h"
+
+/* libcanberra requires a PulseAudio channel name to be given to its
+ * CA_PROP_CANBERRA_FORCE_CHANNEL property.
+ *
+ * The strings here are copied from PulseAudio source code to avoid depending
+ * on libpulse. */
+static const gchar *pulse_position[MATE_MIXER_CHANNEL_MAX] = {
+        [MATE_MIXER_CHANNEL_MONO] = "mono",
+        [MATE_MIXER_CHANNEL_FRONT_LEFT] = "front-left",
+        [MATE_MIXER_CHANNEL_FRONT_RIGHT] = "front-right",
+        [MATE_MIXER_CHANNEL_FRONT_CENTER] = "front-center",
+        [MATE_MIXER_CHANNEL_LFE] = "lfe",
+        [MATE_MIXER_CHANNEL_BACK_LEFT] = "rear-left",
+        [MATE_MIXER_CHANNEL_BACK_RIGHT] = "rear-right",
+        [MATE_MIXER_CHANNEL_BACK_CENTER] = "rear-center",
+        [MATE_MIXER_CHANNEL_FRONT_LEFT_CENTER] = "front-left-of-center",
+        [MATE_MIXER_CHANNEL_FRONT_RIGHT_CENTER] = "front-right-of-center",
+        [MATE_MIXER_CHANNEL_SIDE_LEFT] = "side-left",
+        [MATE_MIXER_CHANNEL_SIDE_RIGHT] = "side-right",
+        [MATE_MIXER_CHANNEL_TOP_FRONT_LEFT] = "top-front-left",
+        [MATE_MIXER_CHANNEL_TOP_FRONT_RIGHT] = "top-front-right",
+        [MATE_MIXER_CHANNEL_TOP_FRONT_CENTER] = "top-front-center",
+        [MATE_MIXER_CHANNEL_TOP_CENTER] = "top-center",
+        [MATE_MIXER_CHANNEL_TOP_BACK_LEFT] = "top-rear-left",
+        [MATE_MIXER_CHANNEL_TOP_BACK_RIGHT] = "top-rear-right",
+        [MATE_MIXER_CHANNEL_TOP_BACK_CENTER] = "top-rear-center"
+};
+
+static const gchar *pretty_position[MATE_MIXER_CHANNEL_MAX] = {
+        [MATE_MIXER_CHANNEL_UNKNOWN] = N_("Unknown"),
+        /* Speaker channel names */
+        [MATE_MIXER_CHANNEL_MONO] = N_("Mono"),
+        [MATE_MIXER_CHANNEL_FRONT_LEFT] = N_("Front Left"),
+        [MATE_MIXER_CHANNEL_FRONT_RIGHT] = N_("Front Right"),
+        [MATE_MIXER_CHANNEL_FRONT_CENTER] = N_("Front Center"),
+        [MATE_MIXER_CHANNEL_LFE] = N_("LFE"),
+        [MATE_MIXER_CHANNEL_BACK_LEFT] = N_("Rear Left"),
+        [MATE_MIXER_CHANNEL_BACK_RIGHT] = N_("Rear Right"),
+        [MATE_MIXER_CHANNEL_BACK_CENTER] = N_("Rear Center"),
+        [MATE_MIXER_CHANNEL_FRONT_LEFT_CENTER] = N_("Front Left of Center"),
+        [MATE_MIXER_CHANNEL_FRONT_RIGHT_CENTER] = N_("Front Right of Center"),
+        [MATE_MIXER_CHANNEL_SIDE_LEFT] = N_("Side Left"),
+        [MATE_MIXER_CHANNEL_SIDE_RIGHT] = N_("Side Right"),
+        [MATE_MIXER_CHANNEL_TOP_FRONT_LEFT] = N_("Top Front Left"),
+        [MATE_MIXER_CHANNEL_TOP_FRONT_RIGHT] = N_("Top Front Right"),
+        [MATE_MIXER_CHANNEL_TOP_FRONT_CENTER] = N_("Top Front Center"),
+        [MATE_MIXER_CHANNEL_TOP_CENTER] = N_("Top Center"),
+        [MATE_MIXER_CHANNEL_TOP_BACK_LEFT] = N_("Top Rear Left"),
+        [MATE_MIXER_CHANNEL_TOP_BACK_RIGHT] = N_("Top Rear Right"),
+        [MATE_MIXER_CHANNEL_TOP_BACK_CENTER] = N_("Top Rear Center")
+};
+
+const gchar *
+gvc_channel_position_to_pulse_string (MateMixerChannelPosition position)
+{
+        g_return_val_if_fail (position >= 0 && position < MATE_MIXER_CHANNEL_MAX, NULL);
+
+        return pulse_position[position];
+}
+
+const gchar *
+gvc_channel_position_to_pretty_string (MateMixerChannelPosition position)
+{
+        g_return_val_if_fail (position >= 0 && position < MATE_MIXER_CHANNEL_MAX, NULL);
+
+        return pretty_position[position];
+}
+
+const gchar *
+gvc_channel_map_to_pretty_string (MateMixerStreamControl *control)
+{
+        g_return_val_if_fail (MATE_MIXER_IS_STREAM_CONTROL (control), NULL);
+
+#define HAS_POSITION(p) (mate_mixer_stream_control_has_channel_position (control, (p)))
+
+        /* Modeled after PulseAudio 5.0, probably could be extended with other combinations */
+        switch (mate_mixer_stream_control_get_num_channels (control)) {
+        case 1:
+                if (HAS_POSITION (MATE_MIXER_CHANNEL_MONO))
+                        return _("Mono");
+                break;
+        case 2:
+                if (HAS_POSITION (MATE_MIXER_CHANNEL_FRONT_LEFT) &&
+                    HAS_POSITION (MATE_MIXER_CHANNEL_FRONT_RIGHT))
+                        return _("Stereo");
+                break;
+        case 4:
+                if (HAS_POSITION (MATE_MIXER_CHANNEL_FRONT_LEFT) &&
+                    HAS_POSITION (MATE_MIXER_CHANNEL_FRONT_RIGHT) &&
+                    HAS_POSITION (MATE_MIXER_CHANNEL_BACK_LEFT) &&
+                    HAS_POSITION (MATE_MIXER_CHANNEL_BACK_RIGHT))
+                        return _("Surround 4.0");
+                break;
+        case 5:
+                if (HAS_POSITION (MATE_MIXER_CHANNEL_FRONT_LEFT) &&
+                    HAS_POSITION (MATE_MIXER_CHANNEL_FRONT_RIGHT) &&
+                    HAS_POSITION (MATE_MIXER_CHANNEL_BACK_LEFT) &&
+                    HAS_POSITION (MATE_MIXER_CHANNEL_BACK_RIGHT)) {
+                        if (HAS_POSITION (MATE_MIXER_CHANNEL_LFE))
+                                return _("Surround 4.1");
+                        if (HAS_POSITION (MATE_MIXER_CHANNEL_FRONT_CENTER))
+                                return _("Surround 5.0");
+                }
+                break;
+        case 6:
+                if (HAS_POSITION (MATE_MIXER_CHANNEL_FRONT_LEFT) &&
+                    HAS_POSITION (MATE_MIXER_CHANNEL_FRONT_RIGHT) &&
+                    HAS_POSITION (MATE_MIXER_CHANNEL_FRONT_CENTER) &&
+                    HAS_POSITION (MATE_MIXER_CHANNEL_BACK_LEFT) &&
+                    HAS_POSITION (MATE_MIXER_CHANNEL_BACK_RIGHT) &&
+                    HAS_POSITION (MATE_MIXER_CHANNEL_LFE))
+                        return _("Surround 5.1");
+                break;
+        case 8:
+                if (HAS_POSITION (MATE_MIXER_CHANNEL_FRONT_LEFT) &&
+                    HAS_POSITION (MATE_MIXER_CHANNEL_FRONT_RIGHT) &&
+                    HAS_POSITION (MATE_MIXER_CHANNEL_FRONT_CENTER) &&
+                    HAS_POSITION (MATE_MIXER_CHANNEL_BACK_LEFT) &&
+                    HAS_POSITION (MATE_MIXER_CHANNEL_BACK_RIGHT) &&
+                    HAS_POSITION (MATE_MIXER_CHANNEL_SIDE_LEFT) &&
+                    HAS_POSITION (MATE_MIXER_CHANNEL_SIDE_RIGHT) &&
+                    HAS_POSITION (MATE_MIXER_CHANNEL_LFE))
+                        return _("Surround 7.1");
+                break;
+        }
+
+#undef HAS_POSITION
+
+        return NULL;
+}
+
+ +
+ +
+ + diff --git a/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/66.html b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/66.html new file mode 100644 index 0000000..404be7d --- /dev/null +++ b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/66.html @@ -0,0 +1,851 @@ + + + + + + Cppcheck - HTML report - mate-media + + + + + +
+ + + +
+
  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
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ * Copyright (C) 2008 Bastien Nocera <hadess@hadess.net>
+ * 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, 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 <glib/gstdio.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 <utime.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <strings.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "sound-theme-file-utils.h"
+
+#define CUSTOM_THEME_NAME       "__custom"
+
+/* This function needs to be called after each individual
+ * changeset to the theme */
+void
+custom_theme_update_time (void)
+{
+        char *path;
+
+        path = custom_theme_dir_path (NULL);
+        utime (path, NULL);
+        g_free (path);
+}
+
+char *
+custom_theme_dir_path (const char *child)
+{
+        static char *dir = NULL;
+
+        if (dir == NULL) {
+                const char *data_dir;
+
+                data_dir = g_get_user_data_dir ();
+                dir = g_build_filename (data_dir, "sounds", CUSTOM_THEME_NAME, NULL);
+        }
+        if (child == NULL)
+                return g_strdup (dir);
+
+        return g_build_filename (dir, child, NULL);
+}
+
+static gboolean
+directory_delete_recursive (GFile *directory, GError **error)
+{
+        GFileEnumerator *enumerator;
+        GFileInfo *info;
+        gboolean success = TRUE;
+
+        enumerator = g_file_enumerate_children (directory,
+                                                G_FILE_ATTRIBUTE_STANDARD_NAME ","
+                                                G_FILE_ATTRIBUTE_STANDARD_TYPE,
+                                                G_FILE_QUERY_INFO_NONE,
+                                                NULL, error);
+        if (enumerator == NULL)
+                return FALSE;
+
+        while (success &&
+               (info = g_file_enumerator_next_file (enumerator, NULL, NULL))) {
+                GFile *child;
+
+                child = g_file_get_child (directory, g_file_info_get_name (info));
+
+                if (g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY) {
+                        success = directory_delete_recursive (child, error);
+                }
+                g_object_unref (info);
+
+                if (success)
+                        success = g_file_delete (child, NULL, error);
+        }
+        g_file_enumerator_close (enumerator, NULL, NULL);
+
+        if (success)
+                success = g_file_delete (directory, NULL, error);
+
+        return success;
+}
+
+/**
+ * capplet_file_delete_recursive :
+ * @file :
+ * @error  :
+ *
+ * A utility routine to delete files and/or directories,
+ * including non-empty directories.
+ **/
+static gboolean
+capplet_file_delete_recursive (GFile *file, GError **error)
+{
+        GFileInfo *info;
+        GFileType type;
+
+        g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+
+        info = g_file_query_info (file,
+                                  G_FILE_ATTRIBUTE_STANDARD_TYPE,
+                                  G_FILE_QUERY_INFO_NONE,
+                                  NULL, error);
+        if (info == NULL)
+                return FALSE;
+
+        type = g_file_info_get_file_type (info);
+        g_object_unref (info);
+
+        if (type == G_FILE_TYPE_DIRECTORY)
+                return directory_delete_recursive (file, error);
+        else
+                return g_file_delete (file, NULL, error);
+}
+
+void
+delete_custom_theme_dir (void)
+{
+        char *dir;
+        GFile *file;
+
+        dir = custom_theme_dir_path (NULL);
+        file = g_file_new_for_path (dir);
+        g_free (dir);
+        capplet_file_delete_recursive (file, NULL);
+        g_object_unref (file);
+
+        g_debug ("deleted the custom theme dir");
+}
+
+gboolean
+custom_theme_dir_is_empty (void)
+{
+        char            *dir;
+        GFile           *file;
+        gboolean         is_empty;
+        GFileEnumerator *enumerator;
+        GFileInfo       *info;
+        GError          *error = NULL;
+
+        dir = custom_theme_dir_path (NULL);
+        file = g_file_new_for_path (dir);
+        g_free (dir);
+
+        is_empty = TRUE;
+
+        enumerator = g_file_enumerate_children (file,
+                                                G_FILE_ATTRIBUTE_STANDARD_NAME ","
+                                                G_FILE_ATTRIBUTE_STANDARD_TYPE,
+                                                G_FILE_QUERY_INFO_NONE,
+                                                NULL, &error);
+        if (enumerator == NULL) {
+                g_warning ("Unable to enumerate files: %s", error->message);
+                g_error_free (error);
+                goto out;
+        }
+
+        while (is_empty &&
+               (info = g_file_enumerator_next_file (enumerator, NULL, NULL))) {
+
+                if (strcmp ("index.theme", g_file_info_get_name (info)) != 0) {
+                        is_empty = FALSE;
+                }
+
+                g_object_unref (info);
+        }
+        g_file_enumerator_close (enumerator, NULL, NULL);
+
+ out:
+        g_object_unref (file);
+
+        return is_empty;
+}
+
+static void
+delete_one_file (const char *sound_name, const char *file_extension)
+{
+        GFile *file;
+        char *name, *filename;
+
+        name = g_strconcat (sound_name, file_extension, NULL);
+        filename = custom_theme_dir_path (name);
+        g_free (name);
+        file = g_file_new_for_path (filename);
+        g_free (filename);
+        capplet_file_delete_recursive (file, NULL);
+        g_object_unref (file);
+}
+
+void
+delete_old_files (const char **sounds)
+{
+        guint i;
+
+        for (i = 0; sounds[i] != NULL; i++) {
+                delete_one_file (sounds[i], ".ogg");
+        }
+}
+
+void
+delete_disabled_files (const char **sounds)
+{
+        guint i;
+
+        for (i = 0; sounds[i] != NULL; i++)
+                delete_one_file (sounds[i], ".disabled");
+}
+
+static void
+create_one_file (GFile *file)
+{
+        GFileOutputStream* stream;
+
+        stream = g_file_create (file, G_FILE_CREATE_NONE, NULL, NULL);
+        if (stream != NULL) {
+                g_output_stream_close (G_OUTPUT_STREAM (stream), NULL, NULL);
+                g_object_unref (stream);
+        }
+}
+
+void
+add_disabled_file (const char **sounds)
+{
+        guint i;
+
+        for (i = 0; sounds[i] != NULL; i++) {
+                GFile *file;
+                char *name, *filename;
+
+                name = g_strdup_printf ("%s.disabled", sounds[i]);
+                filename = custom_theme_dir_path (name);
+                g_free (name);
+                file = g_file_new_for_path (filename);
+                g_free (filename);
+
+                create_one_file (file);
+                g_object_unref (file);
+        }
+}
+
+void
+add_custom_file (const char **sounds, const char *filename)
+{
+        guint i;
+
+        for (i = 0; sounds[i] != NULL; i++) {
+                GFile *file;
+                char *name, *path;
+
+                /* We use *.ogg because it's the first type of file that
+                 * libcanberra looks at */
+                name = g_strdup_printf ("%s.ogg", sounds[i]);
+                path = custom_theme_dir_path (name);
+                g_free (name);
+                /* In case there's already a link there, delete it */
+                g_unlink (path);
+                file = g_file_new_for_path (path);
+                g_free (path);
+
+                /* Create the link */
+                g_file_make_symbolic_link (file, filename, NULL, NULL);
+                g_object_unref (file);
+        }
+}
+
+void
+create_custom_theme (const char *parent)
+{
+        GKeyFile *keyfile;
+        char     *data;
+        char     *path;
+
+        /* Create the custom directory */
+        path = custom_theme_dir_path (NULL);
+        g_mkdir_with_parents (path, 0755);
+        g_free (path);
+
+        /* Set the data for index.theme */
+        keyfile = g_key_file_new ();
+        g_key_file_set_string (keyfile, "Sound Theme", "Name", _("Custom"));
+        g_key_file_set_string (keyfile, "Sound Theme", "Inherits", parent);
+        g_key_file_set_string (keyfile, "Sound Theme", "Directories", ".");
+        data = g_key_file_to_data (keyfile, NULL, NULL);
+        g_key_file_free (keyfile);
+
+        /* Save the index.theme */
+        path = custom_theme_dir_path ("index.theme");
+        g_file_set_contents (path, data, -1, NULL);
+        g_free (path);
+        g_free (data);
+
+        custom_theme_update_time ();
+}
+
+ +
+ +
+ + diff --git a/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/67.html b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/67.html new file mode 100644 index 0000000..5dc7ba6 --- /dev/null +++ b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/67.html @@ -0,0 +1,439 @@ + + + + + + Cppcheck - HTML report - mate-media + + + + + +
+ + + +
+
  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
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 Red Hat, Inc.
+ * Copyright (C) 2014 Michal Ratajsky <michal.ratajsky@gmail.com>
+ * 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
+ * Lesser 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: "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-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 <libintl.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 <libmatemixer/matemixer.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "gvc-status-icon.h"
+
+static gboolean show_version = FALSE;
+static gboolean debug = FALSE;
+
+int
+main (int argc, char **argv)
+{
+        GError        *error = NULL;
+        GvcStatusIcon *status_icon;
+        GApplication  *app = NULL;
+        GOptionEntry   entries[] = {
+                { "version", 'v', 0, G_OPTION_ARG_NONE, &show_version, N_("Version of this application"), NULL },
+                { "debug", 'd', 0, G_OPTION_ARG_NONE, &debug, N_("Enable debug"), NULL },
+                { NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL }
+        };
+
+        bindtextdomain (GETTEXT_PACKAGE, LOCALE_DIR);
+        bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+        textdomain (GETTEXT_PACKAGE);
+
+        gtk_init_with_args (&argc, &argv,
+                            _(" — MATE Volume Control Status Icon"),
+                            entries, GETTEXT_PACKAGE,
+                            &error);
+
+        if (error != NULL) {
+                g_warning ("%s", error->message);
+                g_error_free (error);
+                return 1;
+        }
+        if (show_version == TRUE) {
+                g_print ("%s %s\n", argv[0], VERSION);
+                return 0;
+        }
+        if (debug == TRUE) {
+                g_setenv ("G_MESSAGES_DEBUG", "all", FALSE);
+        }
+
+        app = g_application_new (GVC_STATUS_ICON_DBUS_NAME, G_APPLICATION_FLAGS_NONE);
+
+        if (!g_application_register (app, NULL, &error)) {
+                g_warning ("%s", error->message);
+                g_error_free (error);
+                return 1;
+        }
+        if (g_application_get_is_remote (app)) {
+                g_warning ("Status icon is already running, exiting");
+                return 0;
+        }
+        if (mate_mixer_init () == FALSE) {
+                g_warning ("libmatemixer initialization failed, exiting");
+                return 1;
+        }
+
+        gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (),
+                                           ICON_DATA_DIR);
+
+        status_icon = gvc_status_icon_new ();
+
+        gvc_status_icon_start (status_icon);
+        gtk_main ();
+
+        g_object_unref (status_icon);
+        g_object_unref (app);
+
+        return 0;
+}
+
+ +
+ +
+ + diff --git a/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/7.html b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/7.html new file mode 100644 index 0000000..94cdfe8 --- /dev/null +++ b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/7.html @@ -0,0 +1,437 @@ + + + + + + Cppcheck - HTML report - mate-media + + + + + +
+ + + +
+
  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/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/8.html b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/8.html new file mode 100644 index 0000000..efc157f --- /dev/null +++ b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/8.html @@ -0,0 +1,489 @@ + + + + + + Cppcheck - HTML report - mate-media + + + + + +
+ + + +
+
  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/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/9.html b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/9.html new file mode 100644 index 0000000..d2df3eb --- /dev/null +++ b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/9.html @@ -0,0 +1,383 @@ + + + + + + Cppcheck - HTML report - mate-media + + + + + +
+ + + +
+
 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/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/index.html b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/index.html new file mode 100644 index 0000000..3a06819 --- /dev/null +++ b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/index.html @@ -0,0 +1,728 @@ + + + + + + Cppcheck - HTML report - mate-media + + + + + +
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
LineIdCWESeverityMessage
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.
220constVariable398styleVariable 'color_type' can be declared as const array
424constVariable398styleVariable 'stereo' can be declared as const array
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.
2328variableScope398styleThe scope of the variable 'exec' can be reduced.
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.
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.
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.
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.
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.
mate-volume-control/applet-main.c
24missingIncludeinformationInclude file: "config.h" not found.
26missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <glib/gi18n-lib.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.
29missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <libintl.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <gio/gio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
33missingIncludeSysteminformationInclude file: <libmatemixer/matemixer.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
34missingIncludeSysteminformationInclude file: <mate-panel-applet.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-volume-control/dialog-main.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/gi18n.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: <libintl.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.
31missingIncludeSysteminformationInclude file: <libmatemixer/matemixer.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-volume-control/gvc-applet.c
24missingIncludeinformationInclude file: "config.h" not found.
26missingIncludeSysteminformationInclude file: <string.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-lib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <glib-object.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.
32missingIncludeSysteminformationInclude file: <libmatemixer/matemixer.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
33missingIncludeSysteminformationInclude file: <mate-panel-applet.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
78unknownMacroerrorThere is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
mate-volume-control/gvc-applet.h
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.
mate-volume-control/gvc-balance-bar.c
23missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
24missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <glib-object.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.
28missingIncludeSysteminformationInclude file: <canberra-gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <libmatemixer/matemixer.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-volume-control/gvc-balance-bar.h
26missingIncludeSysteminformationInclude file: <glib.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: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <libmatemixer/matemixer.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-volume-control/gvc-channel-bar.c
23missingIncludeinformationInclude file: "config.h" not found.
25missingIncludeSysteminformationInclude file: <sys/param.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-lib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <glib-object.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.
32missingIncludeSysteminformationInclude file: <canberra-gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
33missingIncludeSysteminformationInclude file: <libmatemixer/matemixer.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
92unknownMacroerrorThere is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
mate-volume-control/gvc-channel-bar.h
26missingIncludeSysteminformationInclude file: <glib.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: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <libmatemixer/matemixer.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-volume-control/gvc-combo-box.c
23missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
24missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <glib-object.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.
28missingIncludeSysteminformationInclude file: <libmatemixer/matemixer.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.
mate-volume-control/gvc-combo-box.h
26missingIncludeSysteminformationInclude file: <glib.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: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <libmatemixer/matemixer.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-volume-control/gvc-level-bar.c
23missingIncludeSysteminformationInclude file: <math.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: <glib/gi18n.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.
30missingIncludeSysteminformationInclude file: <libmate-desktop/mate-desktop-utils.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
81unknownMacroerrorThere is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
mate-volume-control/gvc-level-bar.h
26missingIncludeSysteminformationInclude file: <glib.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: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-volume-control/gvc-mixer-dialog.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/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: <gdk/gdk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <gdk/gdkkeysyms.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: <libmatemixer/matemixer.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
133unknownMacroerrorThere is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
mate-volume-control/gvc-mixer-dialog.h
26missingIncludeSysteminformationInclude file: <glib.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.
29missingIncludeSysteminformationInclude file: <libmatemixer/matemixer.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-volume-control/gvc-sound-theme-chooser.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: <utime.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: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
33missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
34missingIncludeSysteminformationInclude file: <gio/gio.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: <canberra-gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
37missingIncludeSysteminformationInclude file: <libxml/tree.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
983constParameterCallback398styleParameter 'key' can be declared as pointer to const. However it seems that 'on_key_changed' is a callback function, if 'key' is declared with const you might also need to cast function pointer(s).
mate-volume-control/gvc-sound-theme-chooser.h
25missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-volume-control/gvc-speaker-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/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: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <canberra.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <libmatemixer/matemixer.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
54unknownMacroerrorThere is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
mate-volume-control/gvc-speaker-test.h
26missingIncludeSysteminformationInclude file: <glib.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: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <libmatemixer/matemixer.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-volume-control/gvc-status-icon.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: <glib-object.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.
31missingIncludeSysteminformationInclude file: <libmatemixer/matemixer.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.
mate-volume-control/gvc-status-icon.h
26missingIncludeSysteminformationInclude file: <glib.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.
mate-volume-control/gvc-stream-applet-icon.c
23missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <glib.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: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <gdk/gdkkeysyms.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <gdk/gdkwayland.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <gtk-layer-shell/gtk-layer-shell.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
35missingIncludeSysteminformationInclude file: <libmatemixer/matemixer.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
36missingIncludeSysteminformationInclude file: <mate-panel-applet.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
39missingIncludeSysteminformationInclude file: <libmate-desktop/mate-desktop-utils.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.
mate-volume-control/gvc-stream-applet-icon.h
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.
29missingIncludeSysteminformationInclude file: <libmatemixer/matemixer.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-volume-control/gvc-stream-status-icon.c
23missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
24missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <gdk/gdkkeysyms.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <libmatemixer/matemixer.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <libmate-desktop/mate-desktop-utils.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <libmate-desktop/mate-image-menu-item.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.
mate-volume-control/gvc-stream-status-icon.h
26missingIncludeSysteminformationInclude file: <glib.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: <libmatemixer/matemixer.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-volume-control/gvc-utils.c
22missingIncludeinformationInclude file: "config.h" not found.
24missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <libmatemixer/matemixer.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-volume-control/gvc-utils.h
25missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <libmatemixer/matemixer.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-volume-control/sound-theme-file-utils.c
21missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
22missingIncludeSysteminformationInclude file: <glib/gstdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
23missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
24missingIncludeSysteminformationInclude file: <gio/gio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <utime.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <strings.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-volume-control/sound-theme-file-utils.h
23missingIncludeSysteminformationInclude file: <gio/gio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-volume-control/status-icon-main.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/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: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <libintl.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <gio/gio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <libmatemixer/matemixer.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+ +
+ + diff --git a/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/stats.html b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/stats.html new file mode 100644 index 0000000..32563db --- /dev/null +++ b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/stats.html @@ -0,0 +1,199 @@ + + + + + + Cppcheck - HTML report - mate-media + + + + + +
+ + + +
+

Top 10 files for error severity, total findings: 21
+   1  mate-volume-control/gvc-stream-status-icon.c
+   1  mate-volume-control/gvc-stream-applet-icon.c
+   1  mate-volume-control/gvc-status-icon.c
+   1  mate-volume-control/gvc-speaker-test.c
+   1  mate-volume-control/gvc-mixer-dialog.c
+   1  mate-volume-control/gvc-level-bar.c
+   1  mate-volume-control/gvc-combo-box.c
+   1  mate-volume-control/gvc-channel-bar.c
+   1  mate-volume-control/gvc-balance-bar.c
+   1  mate-volume-control/gvc-applet.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: 12
+   3  mate-desktop-1.27.1/libmate-desktop/mate-desktop-item.c
+   2  mate-desktop-1.27.1/libmate-desktop/mate-languages.c
+   2  mate-desktop-1.27.1/libmate-desktop/mate-desktop-utils.c
+   2  mate-desktop-1.27.1/libmate-desktop/edid-parse.c
+   2  mate-desktop-1.27.1/libmate-desktop/display-name.c
+   1  mate-volume-control/gvc-sound-theme-chooser.c
+

+

Top 10 files for information severity, total findings: 337
+   20  mate-desktop-1.27.1/libmate-desktop/mate-desktop-item.c
+   14  mate-desktop-1.27.1/libmate-desktop/mate-languages.c
+   13  mate-volume-control/gvc-sound-theme-chooser.c
+   13  mate-desktop-1.27.1/libmate-desktop/mate-bg.c
+   12  mate-desktop-1.27.1/libmate-desktop/mate-bg-crossfade.c
+   10  mate-volume-control/gvc-stream-applet-icon.c
+   9   mate-volume-control/applet-main.c
+   8   mate-volume-control/status-icon-main.c
+   8   mate-volume-control/gvc-mixer-dialog.c
+   8   mate-volume-control/gvc-channel-bar.c
+

+ +
+ +
+ + diff --git a/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/style.css b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/style.css new file mode 100644 index 0000000..3897bfa --- /dev/null +++ b/2023-10-27-054818-5056-cppcheck@1c37a25c7384_meson/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