From 6a4038c69cc60abfcb284c8af0cf4ca2760406dd Mon Sep 17 00:00:00 2001 From: "raveit65 (via Travis CI)" Date: Fri, 7 Jun 2024 05:35:47 +0000 Subject: Deploy mate-desktop/mate-control-center to github.com/mate-desktop/mate-control-center.git:gh-pages --- .../index.html | 194 ++ .../report-0a8553.html | 1880 +++++++++++ .../report-0f29bf.html | 1029 ++++++ .../report-1a3269.html | 1978 ++++++++++++ .../report-409fe3.html | 1796 +++++++++++ .../report-434006.html | 1132 +++++++ .../report-465fc6.html | 1452 +++++++++ .../report-549b25.html | 2678 ++++++++++++++++ .../report-56f85a.html | 1455 +++++++++ .../report-5941f9.html | 816 +++++ .../report-5c0604.html | 1105 +++++++ .../report-6203f7.html | 1229 +++++++ .../report-6370cb.html | 1289 ++++++++ .../report-72d530.html | 1115 +++++++ .../report-77ae30.html | 1455 +++++++++ .../report-7c28e5.html | 949 ++++++ .../report-83aba4.html | 1070 +++++++ .../report-850291.html | 3339 ++++++++++++++++++++ .../report-894cd0.html | 1029 ++++++ .../report-8c7773.html | 1995 ++++++++++++ .../report-8e9a5f.html | 816 +++++ .../report-a6bd27.html | 816 +++++ .../report-b1744c.html | 1289 ++++++++ .../report-b47749.html | 1462 +++++++++ .../report-c9434f.html | 1115 +++++++ .../report-d85912.html | 2735 ++++++++++++++++ .../report-db9c1a.html | 2678 ++++++++++++++++ .../report-dbd148.html | 1115 +++++++ .../report-df0d78.html | 1555 +++++++++ .../report-dfa6cb.html | 2678 ++++++++++++++++ .../report-e4a995.html | 2000 ++++++++++++ .../report-e8a3a6.html | 1049 ++++++ .../scanview.css | 62 + .../sorttable.js | 492 +++ 34 files changed, 48847 insertions(+) create mode 100644 2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/index.html create mode 100644 2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-0a8553.html create mode 100644 2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-0f29bf.html create mode 100644 2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-1a3269.html create mode 100644 2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-409fe3.html create mode 100644 2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-434006.html create mode 100644 2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-465fc6.html create mode 100644 2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-549b25.html create mode 100644 2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-56f85a.html create mode 100644 2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-5941f9.html create mode 100644 2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-5c0604.html create mode 100644 2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-6203f7.html create mode 100644 2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-6370cb.html create mode 100644 2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-72d530.html create mode 100644 2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-77ae30.html create mode 100644 2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-7c28e5.html create mode 100644 2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-83aba4.html create mode 100644 2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-850291.html create mode 100644 2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-894cd0.html create mode 100644 2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-8c7773.html create mode 100644 2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-8e9a5f.html create mode 100644 2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-a6bd27.html create mode 100644 2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-b1744c.html create mode 100644 2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-b47749.html create mode 100644 2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-c9434f.html create mode 100644 2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-d85912.html create mode 100644 2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-db9c1a.html create mode 100644 2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-dbd148.html create mode 100644 2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-df0d78.html create mode 100644 2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-dfa6cb.html create mode 100644 2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-e4a995.html create mode 100644 2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-e8a3a6.html create mode 100644 2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/scanview.css create mode 100644 2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/sorttable.js (limited to '2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize') diff --git a/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/index.html b/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/index.html new file mode 100644 index 00000000..900e63fc --- /dev/null +++ b/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/index.html @@ -0,0 +1,194 @@ + + +rootdir - scan-build results + + + + + + +

rootdir - scan-build results

+ + + + + + + +
User:root@4541dfc273c2
Working Directory:/rootdir
Command Line:make -j 3
Clang Version:clang version 18.1.6 (Fedora 18.1.6-3.fc40) +
Date:Fri Jun 7 04:43:35 2024
+

Bug Summary

+ + + + + + + + + + + + + + +
Bug TypeQuantityDisplay?
All Bugs31
API
Argument with 'nonnull' attribute passed null3
Logic error
Cast from non-struct type to struct type3
Dereference of null pointer2
Garbage return value1
Out-of-bound access8
Uninitialized argument value2
Unused code
Dead assignment1
Dead nested assignment2
Unreachable code9
+

Reports

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Bug GroupBug Type ▾FileFunction/MethodLinePath Length
APIArgument with 'nonnull' attribute passed nullcapplets/appearance/appearance-themes.ctheme_message_area_update60021View Report
APIArgument with 'nonnull' attribute passed nullcapplets/time-admin/src/time-zone.cload_backward_tz14517View Report
APIArgument with 'nonnull' attribute passed nullcapplets/about-me/mate-about-me-fingerprint.cget_reason_for_error12213View Report
Logic errorCast from non-struct type to struct typecapplets/keybindings/mate-keybinding-properties.cappend_keys_to_tree_from_gsettings10141View Report
Logic errorCast from non-struct type to struct typecapplets/keybindings/mate-keybinding-properties.cappend_keys_to_tree_from_file9181View Report
Logic errorCast from non-struct type to struct typecapplets/keybindings/mate-keybinding-properties.cappend_keys_to_tree_from_file9521View Report
Unused codeDead assignmentcapplets/keyboard/mate-keyboard-properties-xkbltadd.cxkl_layout_chooser_add_default_switcher_if_necessary3641View Report
Unused codeDead nested assignmentcapplets/keyboard/mate-keyboard-properties-xkbpv.cxkb_layout_preview_set_drawing_layout961View Report
Unused codeDead nested assignmentcapplets/keyboard/mate-keyboard-properties-xkbpv.cxkb_layout_preview_set_drawing_layout931View Report
Logic errorDereference of null pointercapplets/keybindings/mate-keybinding-properties.cshow_error120621View Report
Logic errorDereference of null pointercapplets/common/gtkrc-utils.cgtkrc_get_details16524View Report
Logic errorGarbage return valuefont-viewer/font-thumbnailer.ccheck_font_contain_text9619View Report
Logic errorOut-of-bound accessshell/bookmark-agent.cupdate_items68617View Report
Logic errorOut-of-bound accesscapplets/appearance/theme-save.cescape_string_and_dup6323View Report
Logic errorOut-of-bound accesscapplets/appearance/theme-save.cescape_string_and_dup7914View Report
Logic errorOut-of-bound accesscapplets/appearance/theme-save.cescape_string_and_dup7217View Report
Logic errorOut-of-bound accessshell/bookmark-agent.cupdate_items70727View Report
Logic errorOut-of-bound accesscapplets/appearance/theme-save.cescape_string_and_dup6817View Report
Logic errorOut-of-bound accesscapplets/appearance/theme-save.cescape_string_and_dup6417View Report
Logic errorOut-of-bound accessshell/bookmark-agent.cupdate_items73526View Report
Logic errorUninitialized argument valuecapplets/display/xrandr-capplet.con_clone_changed109813View Report
Logic errorUninitialized argument valuefont-viewer/sushi-font-widget.csushi_font_widget_draw50713View Report
Unused codeUnreachable codecapplets/appearance/mate-wp-item.cwp_item_option_to_string351View Report
Unused codeUnreachable codecapplets/common/theme-thumbnail.cgenerate_gtk_theme_thumbnail9281View Report
Unused codeUnreachable codecapplets/system-info/mate-system-info.cget_graphics_hardware_string3691View Report
Unused codeUnreachable codetyping-break/main.cmain1161View Report
Unused codeUnreachable codetyping-break/drw-break-window.cpostpone_clicked_cb4971View Report
Unused codeUnreachable codecapplets/system-info/mate-system-info.cget_graphics_hardware_string3711View Report
Unused codeUnreachable codecapplets/appearance/appearance-main.cmain1881View Report
Unused codeUnreachable codecapplets/appearance/mate-wp-item.cwp_item_shading_to_string601View Report
Unused codeUnreachable codetyping-break/drw-break-window.cpostpone_clicked_cb5031View Report
+ + diff --git a/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-0a8553.html b/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-0a8553.html new file mode 100644 index 00000000..57fd7c08 --- /dev/null +++ b/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-0a8553.html @@ -0,0 +1,1880 @@ + + + +appearance-themes.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:capplets/appearance/appearance-themes.c
Warning:line 600, column 21
Null pointer passed to 1st parameter expecting 'nonnull'
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name appearance-themes.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/capplets/appearance -fcoverage-compilation-dir=/rootdir/capplets/appearance -resource-dir /usr/bin/../lib/clang/18 -D HAVE_CONFIG_H -I . -I ../.. -I /usr/include/marco-1 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/gio-unix-2.0 -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I ../../capplets/common -I /usr/include/udisks2 -I /usr/include/libgtop-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/libxml2 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/gio-unix-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/dconf -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I ../../ -D G_LOG_DOMAIN="appearance-properties" -I /usr/include/polkit-1 -I /usr/include/gio-unix-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I /usr/include/udisks2 -I /usr/include/libgtop-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/gio-unix-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/libxml2 -I /usr/include/harfbuzz -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/freetype2 -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/dconf -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libpng16 -D WITH_GZFILEOP -I /usr/include/sysprof-6 -I /usr/include/pixman-1 -D MATECC_DATA_DIR="/usr/local/share/mate-control-center" -D MATECC_PIXMAP_DIR="/usr/local/share/mate-control-center/pixmaps" -D WALLPAPER_DATADIR="/usr/local/share/mate-background-properties" -D BACKGROUND_DATADIR="/usr/local/share/backgrounds" -D MATE_DESKTOP_USE_UNSTABLE_API -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-06-07-044335-13427-1 -x c appearance-themes.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 * Copyright (C) 2007, 2010 The GNOME Foundation
3 * Written by Thomas Wood <thos@gnome.org>
4 * Jens Granseuer <jensgr@gmx.net>
5 * All Rights Reserved
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 */
21
22#include "appearance.h"
23#include "theme-thumbnail.h"
24#include "mate-theme-apply.h"
25#include "theme-installer.h"
26#include "theme-save.h"
27#include "theme-util.h"
28#include "gtkrc-utils.h"
29#include "appearance-themes.h"
30
31#include <glib/gi18n.h>
32#include <string.h>
33#include <libmate-desktop/mate-desktop-thumbnail.h>
34#include <libmate-desktop/mate-gsettings.h>
35
36#define CUSTOM_THEME_NAME"__custom__" "__custom__"
37
38enum {
39 RESPONSE_APPLY_BG,
40 RESPONSE_REVERT_FONT,
41 RESPONSE_APPLY_FONT,
42 RESPONSE_INSTALL_ENGINE
43};
44
45enum {
46 TARGET_URI_LIST,
47 TARGET_NS_URL
48};
49
50static const GtkTargetEntry drop_types[] =
51{
52 {"text/uri-list", 0, TARGET_URI_LIST},
53 {"_NETSCAPE_URL", 0, TARGET_NS_URL}
54};
55
56static void theme_message_area_update(AppearanceData* data);
57
58static time_t theme_get_mtime(const char* name)
59{
60 MateThemeMetaInfo* theme;
61 time_t mtime = -1;
62
63 theme = mate_theme_meta_info_find(name);
64 if (theme != NULL((void*)0))
65 {
66 GFile* file;
67 GFileInfo* file_info;
68
69 file = g_file_new_for_path(theme->path);
70 file_info = g_file_query_info(file, G_FILE_ATTRIBUTE_TIME_MODIFIED"time::modified", G_FILE_QUERY_INFO_NONE, NULL((void*)0), NULL((void*)0));
71 g_object_unref(file);
72
73 if (file_info != NULL((void*)0))
74 {
75 mtime = g_file_info_get_attribute_uint64(file_info, G_FILE_ATTRIBUTE_TIME_MODIFIED"time::modified");
76 g_object_unref(file_info);
77 }
78 }
79
80 return mtime;
81}
82
83static void theme_thumbnail_update(GdkPixbuf* pixbuf, gchar* theme_name, AppearanceData* data, gboolean cache)
84{
85 GtkTreeIter iter;
86 GtkTreeModel* model = GTK_TREE_MODEL(data->theme_store)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data->theme_store)), ((gtk_tree_model_get_type ()))))
))
;
87
88 /* find item in model and update thumbnail */
89 if (!pixbuf)
90 return;
91
92 if (theme_find_in_model(model, theme_name, &iter))
93 {
94 time_t mtime;
95
96 gtk_list_store_set(data->theme_store, &iter, COL_THUMBNAIL, pixbuf, -1);
97
98 /* cache thumbnail */
99 if (cache && (mtime = theme_get_mtime(theme_name)) != -1)
100 {
101 gchar* path;
102
103 /* try to share thumbs with caja, use themes:/// */
104 path = g_strconcat("themes:///", theme_name, NULL((void*)0));
105
106 mate_desktop_thumbnail_factory_save_thumbnail(data->thumb_factory, pixbuf, path, mtime);
107
108 g_free(path);
109 }
110 }
111}
112
113static GdkPixbuf* theme_get_thumbnail_from_cache(MateThemeMetaInfo* info, AppearanceData* data)
114{
115 GdkPixbuf* thumb = NULL((void*)0);
116 gchar* path, *thumb_filename;
117 time_t mtime;
118
119 if (info == data->theme_custom)
120 return NULL((void*)0);
121
122 mtime = theme_get_mtime(info->name);
123
124 if (mtime == -1)
125 return NULL((void*)0);
126
127 /* try to share thumbs with caja, use themes:/// */
128 path = g_strconcat ("themes:///", info->name, NULL((void*)0));
129 thumb_filename = mate_desktop_thumbnail_factory_lookup(data->thumb_factory, path, mtime);
130 g_free(path);
131
132 if (thumb_filename != NULL((void*)0))
133 {
134 thumb = gdk_pixbuf_new_from_file(thumb_filename, NULL((void*)0));
135 g_free(thumb_filename);
136 }
137
138 return thumb;
139}
140
141static void
142theme_thumbnail_done_cb (GdkPixbuf *pixbuf, gchar *theme_name, AppearanceData *data)
143{
144 theme_thumbnail_update (pixbuf, theme_name, data, TRUE(!(0)));
145}
146
147static void theme_thumbnail_generate(MateThemeMetaInfo* info, AppearanceData* data)
148{
149 GdkPixbuf* thumb = theme_get_thumbnail_from_cache(info, data);
150
151 if (thumb != NULL((void*)0))
152 {
153 theme_thumbnail_update(thumb, info->name, data, FALSE(0));
154 g_object_unref(thumb);
155 }
156 else
157 {
158 generate_meta_theme_thumbnail_async(info, (ThemeThumbnailFunc) theme_thumbnail_done_cb, data, NULL((void*)0));
159 }
160}
161
162static void theme_changed_on_disk_cb(MateThemeCommonInfo* theme, MateThemeChangeType change_type, MateThemeElement element_type, AppearanceData* data)
163{
164 if (theme->type == MATE_THEME_TYPE_METATHEME)
165 {
166 MateThemeMetaInfo* meta = (MateThemeMetaInfo*) theme;
167
168 if (change_type == MATE_THEME_CHANGE_CREATED)
169 {
170 gtk_list_store_insert_with_values (data->theme_store, NULL((void*)0), 0, COL_LABEL, meta->readable_name, COL_NAME, meta->name, COL_THUMBNAIL, data->theme_icon, -1);
171 theme_thumbnail_generate(meta, data);
172 }
173 else if (change_type == MATE_THEME_CHANGE_DELETED)
174 {
175 GtkTreeIter iter;
176
177 if (theme_find_in_model(GTK_TREE_MODEL(data->theme_store)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data->theme_store)), ((gtk_tree_model_get_type ()))))
))
, meta->name, &iter))
178 {
179 gtk_list_store_remove(data->theme_store, &iter);
180 }
181 }
182 else if (change_type == MATE_THEME_CHANGE_CHANGED)
183 {
184 theme_thumbnail_generate(meta, data);
185 }
186 }
187}
188
189/* Find out if the lockdown key has been set. */
190static gboolean is_locked_down(void)
191{
192 gboolean is_locked;
193 GSettings *settings;
194 settings = g_settings_new (LOCKDOWN_SCHEMA"org.mate.lockdown");
195 is_locked = g_settings_get_boolean (settings, DISABLE_THEMES_SETTINGS_KEY"disable-theme-settings");
196 g_object_unref (settings);
197 return is_locked;
198}
199
200static MateThemeMetaInfo *
201theme_load_from_gsettings (AppearanceData *data)
202{
203 MateThemeMetaInfo *theme;
204 gchar *scheme;
205
206 theme = mate_theme_meta_info_new ();
207
208 theme->gtk_theme_name = g_settings_get_string (data->interface_settings, GTK_THEME_KEY"gtk-theme");
209 if (theme->gtk_theme_name == NULL((void*)0))
210 theme->gtk_theme_name = g_strdup ("Menta")g_strdup_inline ("Menta");
211
212 scheme = g_settings_get_string (data->interface_settings, COLOR_SCHEME_KEY"gtk-color-scheme");
213 if (scheme == NULL((void*)0) || !strcmp (scheme, "")) {
214 g_free (scheme);
215 scheme = gtkrc_get_color_scheme_for_theme (theme->gtk_theme_name);
216 }
217 theme->gtk_color_scheme = scheme;
218
219 theme->marco_theme_name = g_settings_get_string (data->marco_settings, MARCO_THEME_KEY"theme");
220 if (theme->marco_theme_name == NULL((void*)0))
221 theme->marco_theme_name = g_strdup ("Menta")g_strdup_inline ("Menta");
222
223 theme->icon_theme_name = g_settings_get_string (data->interface_settings, ICON_THEME_KEY"icon-theme");
224 if (theme->icon_theme_name == NULL((void*)0))
225 theme->icon_theme_name = g_strdup ("menta")g_strdup_inline ("menta");
226
227 if (mate_gsettings_schema_exists (NOTIFICATION_SCHEMA"org.mate.NotificationDaemon")) {
228 GSettings *notification_settings;
229 notification_settings = g_settings_new (NOTIFICATION_SCHEMA"org.mate.NotificationDaemon");
230 theme->notification_theme_name = g_settings_get_string (notification_settings, NOTIFICATION_THEME_KEY"theme");
231 g_object_unref (notification_settings);
232 }
233 else
234 theme->notification_theme_name = NULL((void*)0);
235
236 theme->cursor_theme_name = g_settings_get_string (data->mouse_settings, CURSOR_THEME_KEY"cursor-theme");
237 theme->cursor_size = g_settings_get_int (data->mouse_settings, CURSOR_SIZE_KEY"cursor-size");
238
239 if (theme->cursor_theme_name == NULL((void*)0))
240 theme->cursor_theme_name = g_strdup ("default")g_strdup_inline ("default");
241
242 theme->application_font = g_settings_get_string (data->interface_settings, GTK_FONT_KEY"font-name");
243
244 return theme;
245}
246
247static gchar *
248theme_get_selected_name (GtkIconView *icon_view, AppearanceData *data)
249{
250 gchar *name = NULL((void*)0);
251 GList *selected = gtk_icon_view_get_selected_items (icon_view);
252
253 if (selected) {
254 GtkTreePath *path = selected->data;
255 GtkTreeModel *model = gtk_icon_view_get_model (icon_view);
256 GtkTreeIter iter;
257
258 if (gtk_tree_model_get_iter (model, &iter, path))
259 gtk_tree_model_get (model, &iter, COL_NAME, &name, -1);
260
261 g_list_foreach (selected, (GFunc) gtk_tree_path_free, NULL((void*)0));
262 g_list_free (selected);
263 }
264
265 return name;
266}
267
268static const MateThemeMetaInfo *
269theme_get_selected (GtkIconView *icon_view, AppearanceData *data)
270{
271 MateThemeMetaInfo *theme = NULL((void*)0);
272 gchar *name = theme_get_selected_name (icon_view, data);
273
274 if (name != NULL((void*)0)) {
3
Assuming 'name' is not equal to NULL
4
Taking true branch
275 if (!strcmp (name, data->theme_custom->name)) {
5
Taking true branch
276 theme = data->theme_custom;
277 } else {
278 theme = mate_theme_meta_info_find (name);
279 }
280
281 g_free (name);
282 }
283
284 return theme;
6
Returning pointer (loaded from 'theme'), which participates in a condition later
285}
286
287static void
288theme_select_iter (GtkIconView *icon_view, GtkTreeIter *iter)
289{
290 GtkTreePath *path;
291
292 path = gtk_tree_model_get_path (gtk_icon_view_get_model (icon_view), iter);
293 gtk_icon_view_select_path (icon_view, path);
294 gtk_icon_view_scroll_to_path (icon_view, path, FALSE(0), 0.5, 0.0);
295 gtk_tree_path_free (path);
296}
297
298static void
299theme_select_name (GtkIconView *icon_view, const gchar *theme)
300{
301 GtkTreeIter iter;
302 GtkTreeModel *model = gtk_icon_view_get_model (icon_view);
303
304 if (theme_find_in_model (model, theme, &iter))
305 theme_select_iter (icon_view, &iter);
306}
307
308static gboolean
309theme_is_equal (const MateThemeMetaInfo *a, const MateThemeMetaInfo *b)
310{
311 gboolean a_set, b_set;
312
313 if (!(a->gtk_theme_name && b->gtk_theme_name) ||
314 strcmp (a->gtk_theme_name, b->gtk_theme_name))
315 return FALSE(0);
316
317 if (!(a->icon_theme_name && b->icon_theme_name) ||
318 strcmp (a->icon_theme_name, b->icon_theme_name))
319 return FALSE(0);
320
321 if (!(a->marco_theme_name && b->marco_theme_name) ||
322 strcmp (a->marco_theme_name, b->marco_theme_name))
323 return FALSE(0);
324
325 if (!(a->cursor_theme_name && b->cursor_theme_name) ||
326 strcmp (a->cursor_theme_name, b->cursor_theme_name))
327 return FALSE(0);
328
329 if (a->cursor_size != b->cursor_size)
330 return FALSE(0);
331
332 a_set = a->gtk_color_scheme && strcmp (a->gtk_color_scheme, "");
333 b_set = b->gtk_color_scheme && strcmp (b->gtk_color_scheme, "");
334 if ((a_set != b_set) ||
335 (a_set && !mate_theme_color_scheme_equal (a->gtk_color_scheme, b->gtk_color_scheme)))
336 return FALSE(0);
337
338 return TRUE(!(0));
339}
340
341static void
342theme_set_custom_from_theme (const MateThemeMetaInfo *info, AppearanceData *data)
343{
344 MateThemeMetaInfo *custom = data->theme_custom;
345 GtkIconView *icon_view = GTK_ICON_VIEW (appearance_capplet_get_widget (data, "theme_list"))((((GtkIconView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (((GtkWidget*) gtk_builder_get_object(data->ui, "theme_list"
))), ((gtk_icon_view_get_type ()))))))
;
346 GtkTreeModel *model;
347 GtkTreeIter iter;
348 GtkTreePath *path;
349
350 if (info == custom)
351 return;
352
353 /* if info is not NULL, we'll copy those theme settings over */
354 if (info != NULL((void*)0)) {
355 g_free (custom->gtk_theme_name);
356 g_free (custom->icon_theme_name);
357 g_free (custom->marco_theme_name);
358 g_free (custom->gtk_color_scheme);
359 g_free (custom->cursor_theme_name);
360 g_free (custom->application_font);
361 custom->gtk_color_scheme = NULL((void*)0);
362 custom->application_font = NULL((void*)0);
363
364 /* these settings are guaranteed to be non-NULL */
365 custom->gtk_theme_name = g_strdup (info->gtk_theme_name)g_strdup_inline (info->gtk_theme_name);
366 custom->icon_theme_name = g_strdup (info->icon_theme_name)g_strdup_inline (info->icon_theme_name);
367 custom->marco_theme_name = g_strdup (info->marco_theme_name)g_strdup_inline (info->marco_theme_name);
368 custom->cursor_theme_name = g_strdup (info->cursor_theme_name)g_strdup_inline (info->cursor_theme_name);
369 custom->cursor_size = info->cursor_size;
370
371 /* these can be NULL */
372 if (info->gtk_color_scheme)
373 custom->gtk_color_scheme = g_strdup (info->gtk_color_scheme)g_strdup_inline (info->gtk_color_scheme);
374 else
375 custom->gtk_color_scheme = g_strdup ("")g_strdup_inline ("");
376
377 if (info->application_font)
378 custom->application_font = g_strdup (info->application_font)g_strdup_inline (info->application_font);
379 else
380 custom->application_font = g_strdup (GTK_FONT_DEFAULT_VALUE)g_strdup_inline ("Sans 10");
381 }
382
383 /* select the custom theme */
384 model = gtk_icon_view_get_model (icon_view);
385 if (!theme_find_in_model (model, custom->name, &iter)) {
386 GtkTreeIter child;
387
388 gtk_list_store_insert_with_values (data->theme_store, &child, 0,
389 COL_LABEL, custom->readable_name,
390 COL_NAME, custom->name,
391 COL_THUMBNAIL, data->theme_icon,
392 -1);
393 gtk_tree_model_sort_convert_child_iter_to_iter (
394 GTK_TREE_MODEL_SORT (model)((((GtkTreeModelSort*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((model)), ((gtk_tree_model_sort_get_type ())
)))))
, &iter, &child);
395 }
396
397 path = gtk_tree_model_get_path (model, &iter);
398 gtk_icon_view_select_path (icon_view, path);
399 gtk_icon_view_scroll_to_path (icon_view, path, FALSE(0), 0.5, 0.0);
400 gtk_tree_path_free (path);
401
402 /* update the theme thumbnail */
403 theme_thumbnail_generate (custom, data);
404}
405
406/** GUI Callbacks **/
407
408static void custom_font_cb(GtkWidget* button, AppearanceData* data)
409{
410 g_free(data->revert_application_font);
411 g_free(data->revert_documents_font);
412 g_free(data->revert_desktop_font);
413 g_free(data->revert_windowtitle_font);
414 g_free(data->revert_monospace_font);
415 data->revert_application_font = NULL((void*)0);
416 data->revert_documents_font = NULL((void*)0);
417 data->revert_desktop_font = NULL((void*)0);
418 data->revert_windowtitle_font = NULL((void*)0);
419 data->revert_monospace_font = NULL((void*)0);
420}
421
422static void
423theme_message_area_response_cb (GtkWidget *w,
424 gint response_id,
425 AppearanceData *data)
426{
427 const MateThemeMetaInfo *theme;
428 gchar *tmpfont;
429 gchar *engine_path;
430
431 theme = theme_get_selected (GTK_ICON_VIEW (appearance_capplet_get_widget (data, "theme_list"))((((GtkIconView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (((GtkWidget*) gtk_builder_get_object(data->ui, "theme_list"
))), ((gtk_icon_view_get_type ()))))))
, data);
432 if (!theme)
433 return;
434
435 switch (response_id)
436 {
437 case RESPONSE_APPLY_BG:
438 g_settings_set_string (data->wp_settings, WP_FILE_KEY"picture-filename", theme->background_image);
439 break;
440
441 case RESPONSE_REVERT_FONT:
442 if (data->revert_application_font != NULL((void*)0)) {
443 g_settings_set_string (data->interface_settings, GTK_FONT_KEY"font-name", data->revert_application_font);
444 g_free (data->revert_application_font);
445 data->revert_application_font = NULL((void*)0);
446 }
447
448 if (data->revert_documents_font != NULL((void*)0)) {
449 g_settings_set_string (data->interface_settings, DOCUMENT_FONT_KEY"document-font-name", data->revert_documents_font);
450 g_free (data->revert_documents_font);
451 data->revert_documents_font = NULL((void*)0);
452 }
453
454 if (data->caja_settings && data->revert_desktop_font != NULL((void*)0)) {
455 g_settings_set_string (data->caja_settings, DESKTOP_FONT_KEY"font", data->revert_desktop_font);
456 g_free (data->revert_desktop_font);
457 data->revert_desktop_font = NULL((void*)0);
458 }
459
460 if (data->revert_windowtitle_font != NULL((void*)0)) {
461 g_settings_set_string (data->marco_settings, WINDOW_TITLE_FONT_KEY"titlebar-font", data->revert_windowtitle_font);
462 g_free (data->revert_windowtitle_font);
463 data->revert_windowtitle_font = NULL((void*)0);
464 }
465
466 if (data->revert_monospace_font != NULL((void*)0)) {
467 g_settings_set_string (data->interface_settings, MONOSPACE_FONT_KEY"monospace-font-name", data->revert_monospace_font);
468 g_free (data->revert_monospace_font);
469 data->revert_monospace_font = NULL((void*)0);
470 }
471 break;
472
473 case RESPONSE_APPLY_FONT:
474 if (theme->application_font) {
475 tmpfont = g_settings_get_string (data->interface_settings, GTK_FONT_KEY"font-name");
476 if (tmpfont != NULL((void*)0)) {
477 g_free (data->revert_application_font);
478
479 if (strcmp (theme->application_font, tmpfont) == 0) {
480 g_free (tmpfont);
481 data->revert_application_font = NULL((void*)0);
482 } else
483 data->revert_application_font = tmpfont;
484 }
485 g_settings_set_string (data->interface_settings, GTK_FONT_KEY"font-name", theme->application_font);
486 }
487
488 if (theme->documents_font) {
489 tmpfont = g_settings_get_string (data->interface_settings, DOCUMENT_FONT_KEY"document-font-name");
490 if (tmpfont != NULL((void*)0)) {
491 g_free (data->revert_documents_font);
492
493 if (strcmp (theme->documents_font, tmpfont) == 0) {
494 g_free (tmpfont);
495 data->revert_documents_font = NULL((void*)0);
496 } else
497 data->revert_documents_font = tmpfont;
498 }
499 g_settings_set_string (data->interface_settings, DOCUMENT_FONT_KEY"document-font-name", theme->documents_font);
500 }
501
502 if (data->caja_settings && theme->desktop_font) {
503 tmpfont = g_settings_get_string (data->caja_settings, DESKTOP_FONT_KEY"font");
504 if (tmpfont != NULL((void*)0)) {
505 g_free (data->revert_desktop_font);
506
507 if (strcmp (theme->desktop_font, tmpfont) == 0) {
508 g_free (tmpfont);
509 data->revert_desktop_font = NULL((void*)0);
510 } else
511 data->revert_desktop_font = tmpfont;
512 }
513 g_settings_set_string (data->caja_settings, DESKTOP_FONT_KEY"font", theme->desktop_font);
514 }
515
516 if (theme->windowtitle_font) {
517 tmpfont = g_settings_get_string (data->marco_settings, WINDOW_TITLE_FONT_KEY"titlebar-font");
518 if (tmpfont != NULL((void*)0)) {
519 g_free (data->revert_windowtitle_font);
520
521 if (strcmp (theme->windowtitle_font, tmpfont) == 0) {
522 g_free (tmpfont);
523 data->revert_windowtitle_font = NULL((void*)0);
524 } else
525 data->revert_windowtitle_font = tmpfont;
526 }
527 g_settings_set_string (data->marco_settings, WINDOW_TITLE_FONT_KEY"titlebar-font", theme->windowtitle_font);
528 }
529
530 if (theme->monospace_font) {
531 tmpfont = g_settings_get_string (data->interface_settings, MONOSPACE_FONT_KEY"monospace-font-name");
532 if (tmpfont != NULL((void*)0)) {
533 g_free (data->revert_monospace_font);
534
535 if (strcmp (theme->monospace_font, tmpfont) == 0) {
536 g_free (tmpfont);
537 data->revert_monospace_font = NULL((void*)0);
538 } else
539 data->revert_monospace_font = tmpfont;
540 }
541 g_settings_set_string (data->interface_settings, MONOSPACE_FONT_KEY"monospace-font-name", theme->monospace_font);
542 }
543 break;
544
545 case RESPONSE_INSTALL_ENGINE:
546 engine_path = gtk_theme_info_missing_engine(theme->gtk_theme_name, FALSE(0));
547
548 if (engine_path != NULL((void*)0)) {
549 theme_install_file(GTK_WINDOW(gtk_widget_get_toplevel(data->install_button))((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_widget_get_toplevel(data->install_button))), ((gtk_window_get_type
()))))))
, engine_path);
550 g_free (engine_path);
551 }
552
553 theme_message_area_update(data);
554 break;
555 }
556}
557
558static void
559theme_message_area_update (AppearanceData *data)
560{
561 const MateThemeMetaInfo *theme;
562 gboolean show_apply_background = FALSE(0);
563 gboolean show_apply_font = FALSE(0);
564 gboolean show_revert_font = FALSE(0);
565 gboolean show_error;
566 const gchar *message;
567 gchar *font;
568 GError *error = NULL((void*)0);
569
570 theme = theme_get_selected (GTK_ICON_VIEW (appearance_capplet_get_widget (data, "theme_list"))((((GtkIconView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (((GtkWidget*) gtk_builder_get_object(data->ui, "theme_list"
))), ((gtk_icon_view_get_type ()))))))
, data)
;
2
Calling 'theme_get_selected'
7
Returning from 'theme_get_selected'
571
572 if (!theme
7.1
'theme' is non-null
) {
8
Taking false branch
573 if (data->theme_message_area != NULL((void*)0))
574 gtk_widget_hide (data->theme_message_area);
575 return;
576 }
577
578 show_error = !mate_theme_meta_info_validate (theme, &error);
9
Assuming the condition is false
579
580 if (!show_error
9.1
'show_error' is 0
) {
10
Taking true branch
581 if (theme->background_image != NULL((void*)0)) {
11
Assuming field 'background_image' is equal to NULL
12
Taking false branch
582 gchar *background;
583
584 background = g_settings_get_string (data->wp_settings, WP_FILE_KEY"picture-filename");
585 show_apply_background =
586 (!background || strcmp (theme->background_image, background) != 0);
587 g_free (background);
588 }
589
590 if (theme->application_font) {
13
Assuming field 'application_font' is null
14
Assuming pointer value is null
591 font = g_settings_get_string (data->interface_settings, GTK_FONT_KEY"font-name");
592 show_apply_font =
593 (!font || strcmp (theme->application_font, font) != 0);
594 g_free (font);
595 }
596
597 if (!show_apply_font
14.1
'show_apply_font' is 0
&& theme->documents_font) {
15
Assuming field 'documents_font' is non-null
16
Taking true branch
598 font = g_settings_get_string (data->interface_settings, DOCUMENT_FONT_KEY"document-font-name");
599 show_apply_font =
600 (!font || strcmp (theme->application_font, font) != 0);
17
Assuming 'font' is non-null
18
Null pointer passed to 1st parameter expecting 'nonnull'
601 g_free (font);
602 }
603
604 if (data->caja_settings && !show_apply_font && theme->desktop_font) {
605 font = g_settings_get_string (data->caja_settings, DESKTOP_FONT_KEY"font");
606 show_apply_font =
607 (!font || strcmp (theme->application_font, font) != 0);
608 g_free (font);
609 }
610
611 if (!show_apply_font && theme->windowtitle_font) {
612 font = g_settings_get_string (data->marco_settings, WINDOW_TITLE_FONT_KEY"titlebar-font");
613 show_apply_font =
614 (!font || strcmp (theme->application_font, font) != 0);
615 g_free (font);
616 }
617
618 if (!show_apply_font && theme->monospace_font) {
619 font = g_settings_get_string (data->interface_settings, MONOSPACE_FONT_KEY"monospace-font-name");
620 show_apply_font =
621 (!font || strcmp (theme->application_font, font) != 0);
622 g_free (font);
623 }
624
625 show_revert_font = (data->revert_application_font != NULL((void*)0) ||
626 data->revert_documents_font != NULL((void*)0) || data->revert_desktop_font != NULL((void*)0) ||
627 data->revert_windowtitle_font != NULL((void*)0) || data->revert_monospace_font != NULL((void*)0));
628 }
629
630 if (data->theme_message_area == NULL((void*)0)) {
631 GtkWidget *hbox;
632 GtkWidget *parent;
633 GtkWidget *content;
634
635 if (!show_apply_background && !show_revert_font && !show_apply_font && !show_error)
636 return;
637
638 data->theme_message_area = gtk_info_bar_new ();
639 gtk_widget_set_no_show_all (data->theme_message_area, TRUE(!(0)));
640
641 g_signal_connect (data->theme_message_area, "response",g_signal_connect_data ((data->theme_message_area), ("response"
), ((GCallback) theme_message_area_response_cb), (data), ((void
*)0), (GConnectFlags) 0)
642 (GCallback) theme_message_area_response_cb, data)g_signal_connect_data ((data->theme_message_area), ("response"
), ((GCallback) theme_message_area_response_cb), (data), ((void
*)0), (GConnectFlags) 0)
;
643
644 data->apply_background_button = gtk_info_bar_add_button (
645 GTK_INFO_BAR (data->theme_message_area)((((GtkInfoBar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data->theme_message_area)), ((gtk_info_bar_get_type()
))))))
,
646 _("Apply Background")gettext ("Apply Background"),
647 RESPONSE_APPLY_BG);
648 data->apply_font_button = gtk_info_bar_add_button (
649 GTK_INFO_BAR (data->theme_message_area)((((GtkInfoBar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data->theme_message_area)), ((gtk_info_bar_get_type()
))))))
,
650 _("Apply Font")gettext ("Apply Font"),
651 RESPONSE_APPLY_FONT);
652 data->revert_font_button = gtk_info_bar_add_button (
653 GTK_INFO_BAR (data->theme_message_area)((((GtkInfoBar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data->theme_message_area)), ((gtk_info_bar_get_type()
))))))
,
654 _("Revert Font")gettext ("Revert Font"),
655 RESPONSE_REVERT_FONT);
656 data->install_button = gtk_info_bar_add_button (
657 GTK_INFO_BAR (data->theme_message_area)((((GtkInfoBar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data->theme_message_area)), ((gtk_info_bar_get_type()
))))))
,
658 _("Install")gettext ("Install"),
659 RESPONSE_INSTALL_ENGINE);
660
661 data->theme_message_label = gtk_label_new (NULL((void*)0));
662 gtk_widget_show (data->theme_message_label);
663 gtk_label_set_line_wrap (GTK_LABEL (data->theme_message_label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data->theme_message_label)), ((gtk_label_get_type ())
)))))
, TRUE(!(0)));
664 gtk_label_set_xalign (GTK_LABEL (data->theme_message_label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data->theme_message_label)), ((gtk_label_get_type ())
)))))
, 0.0);
665
666 hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 9);
667 gtk_widget_show (hbox);
668 data->theme_info_icon = gtk_image_new_from_icon_name ("dialog-information", GTK_ICON_SIZE_DIALOG);
669 data->theme_error_icon = gtk_image_new_from_icon_name ("dialog-warning", GTK_ICON_SIZE_DIALOG);
670 gtk_widget_set_halign (data->theme_info_icon, GTK_ALIGN_CENTER);
671 gtk_widget_set_valign (data->theme_info_icon, GTK_ALIGN_START);
672 gtk_widget_set_halign (data->theme_error_icon, GTK_ALIGN_CENTER);
673 gtk_widget_set_valign (data->theme_error_icon, GTK_ALIGN_START);
674 gtk_box_pack_start (GTK_BOX (hbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((hbox)), ((gtk_box_get_type ()))))))
, data->theme_info_icon, FALSE(0), FALSE(0), 0);
675 gtk_box_pack_start (GTK_BOX (hbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((hbox)), ((gtk_box_get_type ()))))))
, data->theme_error_icon, FALSE(0), FALSE(0), 0);
676 gtk_box_pack_start (GTK_BOX (hbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((hbox)), ((gtk_box_get_type ()))))))
, data->theme_message_label, TRUE(!(0)), TRUE(!(0)), 0);
677 content = gtk_info_bar_get_content_area (GTK_INFO_BAR (data->theme_message_area)((((GtkInfoBar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data->theme_message_area)), ((gtk_info_bar_get_type()
))))))
);
678 gtk_container_add (GTK_CONTAINER (content)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((content)), ((gtk_container_get_type ()))))))
, hbox);
679
680 parent = appearance_capplet_get_widget (data, "theme_list_vbox")(GtkWidget*) gtk_builder_get_object(data->ui, "theme_list_vbox"
)
;
681 gtk_box_pack_start (GTK_BOX (parent)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((parent)), ((gtk_box_get_type ()))))))
, data->theme_message_area, FALSE(0), FALSE(0), 0);
682 }
683
684 if (show_error)
685 message = error->message;
686 else if (show_apply_background && show_apply_font && show_revert_font)
687 message = _("The current theme suggests a background and a font. Also, the last applied font suggestion can be reverted.")gettext ("The current theme suggests a background and a font. Also, the last applied font suggestion can be reverted."
)
;
688 else if (show_apply_background && show_revert_font)
689 message = _("The current theme suggests a background. Also, the last applied font suggestion can be reverted.")gettext ("The current theme suggests a background. Also, the last applied font suggestion can be reverted."
)
;
690 else if (show_apply_background && show_apply_font)
691 message = _("The current theme suggests a background and a font.")gettext ("The current theme suggests a background and a font."
)
;
692 else if (show_apply_font && show_revert_font)
693 message = _("The current theme suggests a font. Also, the last applied font suggestion can be reverted.")gettext ("The current theme suggests a font. Also, the last applied font suggestion can be reverted."
)
;
694 else if (show_apply_background)
695 message = _("The current theme suggests a background.")gettext ("The current theme suggests a background.");
696 else if (show_revert_font)
697 message = _("The last applied font suggestion can be reverted.")gettext ("The last applied font suggestion can be reverted.");
698 else if (show_apply_font)
699 message = _("The current theme suggests a font.")gettext ("The current theme suggests a font.");
700 else
701 message = NULL((void*)0);
702
703 if (show_apply_background)
704 gtk_widget_show (data->apply_background_button);
705 else
706 gtk_widget_hide (data->apply_background_button);
707
708 if (show_apply_font)
709 gtk_widget_show (data->apply_font_button);
710 else
711 gtk_widget_hide (data->apply_font_button);
712
713 if (show_revert_font)
714 gtk_widget_show (data->revert_font_button);
715 else
716 gtk_widget_hide (data->revert_font_button);
717
718 if (show_error
719 && g_error_matches (error, MATE_THEME_ERRORmate_theme_info_error_quark(), MATE_THEME_ERROR_GTK_ENGINE_NOT_AVAILABLE)
720 && packagekit_available ())
721 gtk_widget_show (data->install_button);
722 else
723 gtk_widget_hide (data->install_button);
724
725 if (show_error || show_apply_background || show_apply_font || show_revert_font) {
726 gtk_widget_show (data->theme_message_area);
727 gtk_widget_queue_draw (data->theme_message_area);
728
729 if (show_error) {
730 gtk_widget_show (data->theme_error_icon);
731 gtk_widget_hide (data->theme_info_icon);
732 } else {
733 gtk_widget_show (data->theme_info_icon);
734 gtk_widget_hide (data->theme_error_icon);
735 }
736 } else {
737 gtk_widget_hide (data->theme_message_area);
738 }
739
740 gtk_label_set_text (GTK_LABEL (data->theme_message_label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data->theme_message_label)), ((gtk_label_get_type ())
)))))
, message);
741 g_clear_error (&error);
742}
743
744static void
745theme_selection_changed_cb (GtkWidget *icon_view, AppearanceData *data)
746{
747 GList *selection;
748 MateThemeMetaInfo *theme = NULL((void*)0);
749 gboolean is_custom = FALSE(0);
750
751 selection = gtk_icon_view_get_selected_items (GTK_ICON_VIEW (icon_view)((((GtkIconView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((icon_view)), ((gtk_icon_view_get_type ()))))))
);
752
753 if (selection) {
754 GtkTreeModel *model;
755 GtkTreeIter iter;
756 gchar *name;
757
758 model = gtk_icon_view_get_model (GTK_ICON_VIEW (icon_view)((((GtkIconView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((icon_view)), ((gtk_icon_view_get_type ()))))))
);
759 gtk_tree_model_get_iter (model, &iter, selection->data);
760 gtk_tree_model_get (model, &iter, COL_NAME, &name, -1);
761
762 is_custom = !strcmp (name, CUSTOM_THEME_NAME"__custom__");
763
764 if (is_custom)
765 theme = data->theme_custom;
766 else
767 theme = mate_theme_meta_info_find (name);
768
769 if (theme) {
770 mate_meta_theme_set (theme);
771 theme_message_area_update (data);
772 }
773
774 g_free (name);
775 g_list_foreach (selection, (GFunc) gtk_tree_path_free, NULL((void*)0));
776 g_list_free (selection);
777
778 gtk_widget_set_sensitive (appearance_capplet_get_widget (data, "theme_delete")(GtkWidget*) gtk_builder_get_object(data->ui, "theme_delete"
)
,
779 theme_is_writable (theme));
780 gtk_widget_set_sensitive (appearance_capplet_get_widget (data, "theme_save")(GtkWidget*) gtk_builder_get_object(data->ui, "theme_save"
)
, is_custom);
781 }
782}
783
784static void
785theme_custom_cb (GtkWidget *button, AppearanceData *data)
786{
787 GtkWidget *w;
788
789 w = appearance_capplet_get_widget (data, "theme_details")(GtkWidget*) gtk_builder_get_object(data->ui, "theme_details"
)
;
790 gtk_window_set_transient_for (GTK_WINDOW (w)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((w)), ((gtk_window_get_type ()))))))
, GET_WINDOW ("appearance_window")(((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (data->ui, ("appearance_window"
)))), ((gtk_window_get_type ())))))))
);
791 gtk_widget_show_all (w);
792}
793
794static void
795theme_save_cb (GtkWidget *button, AppearanceData *data)
796{
797 theme_save_dialog_run (data->theme_custom, data);
798}
799
800static void
801theme_install_cb (GtkWidget *button, AppearanceData *data)
802{
803 mate_theme_installer_run (GET_WINDOW ("appearance_window")(((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (data->ui, ("appearance_window"
)))), ((gtk_window_get_type ())))))))
);
804}
805
806static void
807theme_delete_cb (GtkWidget *button, AppearanceData *data)
808{
809 GtkIconView *icon_view = GTK_ICON_VIEW (appearance_capplet_get_widget (data, "theme_list"))((((GtkIconView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (((GtkWidget*) gtk_builder_get_object(data->ui, "theme_list"
))), ((gtk_icon_view_get_type ()))))))
;
810 GList *selected = gtk_icon_view_get_selected_items (icon_view);
811
812 if (selected) {
813 GtkTreePath *path = selected->data;
814 GtkTreeModel *model = gtk_icon_view_get_model (icon_view);
815 GtkTreeIter iter;
816 gchar *name = NULL((void*)0);
817
818 if (gtk_tree_model_get_iter (model, &iter, path))
819 gtk_tree_model_get (model, &iter, COL_NAME, &name, -1);
820
821 if (name != NULL((void*)0) &&
822 strcmp (name, data->theme_custom->name) &&
823 theme_delete (name, THEME_TYPE_META)) {
824 /* remove theme from the model, too */
825 GtkTreeIter child;
826
827 if (gtk_tree_model_iter_next (model, &iter) ||
828 theme_model_iter_last (model, &iter))
829 theme_select_iter (icon_view, &iter);
830
831 gtk_tree_model_get_iter (model, &iter, path);
832 gtk_tree_model_sort_convert_iter_to_child_iter (
833 GTK_TREE_MODEL_SORT (model)((((GtkTreeModelSort*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((model)), ((gtk_tree_model_sort_get_type ())
)))))
, &child, &iter);
834 gtk_list_store_remove (data->theme_store, &child);
835 }
836
837 g_list_foreach (selected, (GFunc) gtk_tree_path_free, NULL((void*)0));
838 g_list_free (selected);
839 g_free (name);
840 }
841}
842
843static void
844theme_details_changed_cb (AppearanceData *data)
845{
846 MateThemeMetaInfo *gsettings_theme;
847 const MateThemeMetaInfo *selected;
848 GtkIconView *icon_view;
849 gboolean done = FALSE(0);
850
851 /* load new state from gsettings */
852 gsettings_theme = theme_load_from_gsettings (data);
853
854 /* check if it's our currently selected theme */
855 icon_view = GTK_ICON_VIEW (appearance_capplet_get_widget (data, "theme_list"))((((GtkIconView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (((GtkWidget*) gtk_builder_get_object(data->ui, "theme_list"
))), ((gtk_icon_view_get_type ()))))))
;
856 selected = theme_get_selected (icon_view, data);
857
858 if (!selected || !(done = theme_is_equal (selected, gsettings_theme))) {
859 /* look for a matching metatheme */
860 GList *theme_list, *l;
861
862 theme_list = mate_theme_meta_info_find_all ();
863
864 for (l = theme_list; l; l = l->next) {
865 MateThemeMetaInfo *info = l->data;
866
867 if (theme_is_equal (gsettings_theme, info)) {
868 theme_select_name (icon_view, info->name);
869 done = TRUE(!(0));
870 break;
871 }
872 }
873 g_list_free (theme_list);
874 }
875
876 if (!done)
877 /* didn't find a match, set or update custom */
878 theme_set_custom_from_theme (gsettings_theme, data);
879
880 mate_theme_meta_info_free (gsettings_theme);
881}
882
883static void
884theme_setting_changed_cb (GObject *settings,
885 GParamSpec *pspec,
886 AppearanceData *data)
887{
888 theme_details_changed_cb (data);
889}
890
891static void
892theme_gsettings_changed (GSettings *settings,
893 gchar *key,
894 AppearanceData *data)
895{
896 theme_details_changed_cb (data);
897}
898
899static gint
900theme_list_sort_func (MateThemeMetaInfo *a,
901 MateThemeMetaInfo *b)
902{
903 return strcmp (a->readable_name, b->readable_name);
904}
905
906static gint
907theme_store_sort_func (GtkTreeModel *model,
908 GtkTreeIter *a,
909 GtkTreeIter *b,
910 gpointer user_data)
911{
912 gchar *a_name, *a_label;
913 gint rc;
914
915 gtk_tree_model_get (model, a, COL_NAME, &a_name, COL_LABEL, &a_label, -1);
916
917 if (!strcmp (a_name, CUSTOM_THEME_NAME"__custom__")) {
918 rc = -1;
919 } else {
920 gchar *b_name, *b_label;
921
922 gtk_tree_model_get (model, b, COL_NAME, &b_name, COL_LABEL, &b_label, -1);
923
924 if (!strcmp (b_name, CUSTOM_THEME_NAME"__custom__")) {
925 rc = 1;
926 } else {
927 gchar *a_case, *b_case;
928
929 a_case = g_utf8_casefold (a_label, -1);
930 b_case = g_utf8_casefold (b_label, -1);
931 rc = g_utf8_collate (a_case, b_case);
932 g_free (a_case);
933 g_free (b_case);
934 }
935
936 g_free (b_name);
937 g_free (b_label);
938 }
939
940 g_free (a_name);
941 g_free (a_label);
942
943 return rc;
944}
945
946static void
947theme_drag_data_received_cb (GtkWidget *widget,
948 GdkDragContext *context,
949 gint x, gint y,
950 GtkSelectionData *selection_data,
951 guint info, guint time,
952 AppearanceData *data)
953{
954 gchar **uris;
955
956 if (!(info == TARGET_URI_LIST || info == TARGET_NS_URL))
957 return;
958
959 uris = g_uri_list_extract_uris ((gchar *) gtk_selection_data_get_data (selection_data));
960
961 if (uris != NULL((void*)0) && uris[0] != NULL((void*)0)) {
962 GFile *f = g_file_new_for_uri (uris[0]);
963
964 mate_theme_install (f, GET_WINDOW ("appearance_window")(((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (data->ui, ("appearance_window"
)))), ((gtk_window_get_type ())))))))
);
965 g_object_unref (f);
966 }
967
968 g_strfreev (uris);
969}
970
971static void background_or_font_changed(GSettings *settings, gchar *key, AppearanceData* data)
972{
973 theme_message_area_update(data);
1
Calling 'theme_message_area_update'
974}
975
976void themes_init(AppearanceData* data)
977{
978 GtkWidget *w, *del_button;
979 GList *theme_list, *l;
980 GtkListStore *theme_store;
981 GtkTreeModel *sort_model;
982 MateThemeMetaInfo *meta_theme = NULL((void*)0);
983 GtkIconView *icon_view;
984 GtkCellRenderer *renderer;
985 GtkSettings *settings;
986 char *url;
987
988 /* initialise some stuff */
989 mate_theme_init ();
990
991 data->revert_application_font = NULL((void*)0);
992 data->revert_documents_font = NULL((void*)0);
993 data->revert_desktop_font = NULL((void*)0);
994 data->revert_windowtitle_font = NULL((void*)0);
995 data->revert_monospace_font = NULL((void*)0);
996 data->theme_save_dialog = NULL((void*)0);
997 data->theme_message_area = NULL((void*)0);
998 data->theme_info_icon = NULL((void*)0);
999 data->theme_error_icon = NULL((void*)0);
1000 data->theme_icon = gdk_pixbuf_new_from_file (MATECC_PIXMAP_DIR"/usr/local/share/mate-control-center/pixmaps" "/theme-thumbnailing.png", NULL((void*)0));
1001 data->theme_store = theme_store =
1002 gtk_list_store_new (NUM_COLS, GDK_TYPE_PIXBUF(gdk_pixbuf_get_type ()), G_TYPE_STRING((GType) ((16) << (2))), G_TYPE_STRING((GType) ((16) << (2))));
1003
1004 /* set up theme list */
1005 theme_list = mate_theme_meta_info_find_all ();
1006 mate_theme_info_register_theme_change ((ThemeChangedCallback) theme_changed_on_disk_cb, data);
1007
1008 data->theme_custom = theme_load_from_gsettings (data);
1009 data->theme_custom->name = g_strdup (CUSTOM_THEME_NAME)g_strdup_inline ("__custom__");
1010 data->theme_custom->readable_name = g_strdup_printf ("<i>%s</i>", _("Custom")gettext ("Custom"));
1011
1012 for (l = theme_list; l; l = l->next) {
1013 MateThemeMetaInfo *info = l->data;
1014
1015 gtk_list_store_insert_with_values (theme_store, NULL((void*)0), 0,
1016 COL_LABEL, info->readable_name,
1017 COL_NAME, info->name,
1018 COL_THUMBNAIL, data->theme_icon,
1019 -1);
1020
1021 if (!meta_theme && theme_is_equal (data->theme_custom, info))
1022 meta_theme = info;
1023 }
1024
1025 if (!meta_theme) {
1026 /* add custom theme */
1027 meta_theme = data->theme_custom;
1028
1029 gtk_list_store_insert_with_values (theme_store, NULL((void*)0), 0,
1030 COL_LABEL, meta_theme->readable_name,
1031 COL_NAME, meta_theme->name,
1032 COL_THUMBNAIL, data->theme_icon,
1033 -1);
1034
1035 theme_thumbnail_generate (meta_theme, data);
1036 }
1037
1038 theme_list = g_list_sort (theme_list, (GCompareFunc) theme_list_sort_func);
1039
1040 g_list_foreach (theme_list, (GFunc) theme_thumbnail_generate, data);
1041 g_list_free (theme_list);
1042
1043 icon_view = GTK_ICON_VIEW (appearance_capplet_get_widget (data, "theme_list"))((((GtkIconView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (((GtkWidget*) gtk_builder_get_object(data->ui, "theme_list"
))), ((gtk_icon_view_get_type ()))))))
;
1044
1045 renderer = gtk_cell_renderer_pixbuf_new ();
1046 g_object_set (renderer, "xpad", 5, "ypad", 5,
1047 "xalign", 0.5, "yalign", 1.0, NULL((void*)0));
1048 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (icon_view)((((GtkCellLayout*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((icon_view)), ((gtk_cell_layout_get_type ()))))))
, renderer, FALSE(0));
1049 gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (icon_view)((((GtkCellLayout*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((icon_view)), ((gtk_cell_layout_get_type ()))))))
, renderer,
1050 "pixbuf", COL_THUMBNAIL, NULL((void*)0));
1051
1052 renderer = gtk_cell_renderer_text_new ();
1053 g_object_set (renderer, "alignment", PANGO_ALIGN_CENTER,
1054 "wrap-mode", PANGO_WRAP_WORD_CHAR,
1055 "wrap-width", gtk_icon_view_get_item_width (icon_view),
1056 "width", gtk_icon_view_get_item_width (icon_view),
1057 "xalign", 0.5, "yalign", 0.0, NULL((void*)0));
1058
1059 gtk_cell_layout_pack_end (GTK_CELL_LAYOUT (icon_view)((((GtkCellLayout*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((icon_view)), ((gtk_cell_layout_get_type ()))))))
, renderer, FALSE(0));
1060 gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (icon_view)((((GtkCellLayout*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((icon_view)), ((gtk_cell_layout_get_type ()))))))
, renderer,
1061 "markup", COL_LABEL, NULL((void*)0));
1062
1063 sort_model = gtk_tree_model_sort_new_with_model (GTK_TREE_MODEL (theme_store)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((theme_store)), ((gtk_tree_model_get_type ()))))))
);
1064 gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (sort_model)((((GtkTreeSortable*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((sort_model)), ((gtk_tree_sortable_get_type ()))))))
, COL_LABEL, theme_store_sort_func, NULL((void*)0), NULL((void*)0));
1065 gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (sort_model)((((GtkTreeSortable*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((sort_model)), ((gtk_tree_sortable_get_type ()))))))
, COL_LABEL, GTK_SORT_ASCENDING);
1066 gtk_icon_view_set_model (icon_view, GTK_TREE_MODEL (sort_model)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((sort_model)), ((gtk_tree_model_get_type ()))))))
);
1067
1068 g_signal_connect (icon_view, "selection-changed", (GCallback) theme_selection_changed_cb, data)g_signal_connect_data ((icon_view), ("selection-changed"), ((
GCallback) theme_selection_changed_cb), (data), ((void*)0), (
GConnectFlags) 0)
;
1069 g_signal_connect_after (icon_view, "realize", (GCallback) theme_select_name, meta_theme->name)g_signal_connect_data ((icon_view), ("realize"), ((GCallback)
theme_select_name), (meta_theme->name), ((void*)0), G_CONNECT_AFTER
)
;
1070
1071 w = appearance_capplet_get_widget (data, "theme_install")(GtkWidget*) gtk_builder_get_object(data->ui, "theme_install"
)
;
1072 g_signal_connect (w, "clicked", (GCallback) theme_install_cb, data)g_signal_connect_data ((w), ("clicked"), ((GCallback) theme_install_cb
), (data), ((void*)0), (GConnectFlags) 0)
;
1073
1074 w = appearance_capplet_get_widget (data, "theme_save")(GtkWidget*) gtk_builder_get_object(data->ui, "theme_save"
)
;
1075 g_signal_connect (w, "clicked", (GCallback) theme_save_cb, data)g_signal_connect_data ((w), ("clicked"), ((GCallback) theme_save_cb
), (data), ((void*)0), (GConnectFlags) 0)
;
1076
1077 w = appearance_capplet_get_widget (data, "theme_custom")(GtkWidget*) gtk_builder_get_object(data->ui, "theme_custom"
)
;
1078 g_signal_connect (w, "clicked", (GCallback) theme_custom_cb, data)g_signal_connect_data ((w), ("clicked"), ((GCallback) theme_custom_cb
), (data), ((void*)0), (GConnectFlags) 0)
;
1079
1080 del_button = appearance_capplet_get_widget (data, "theme_delete")(GtkWidget*) gtk_builder_get_object(data->ui, "theme_delete"
)
;
1081 g_signal_connect (del_button, "clicked", (GCallback) theme_delete_cb, data)g_signal_connect_data ((del_button), ("clicked"), ((GCallback
) theme_delete_cb), (data), ((void*)0), (GConnectFlags) 0)
;
1082
1083 w = appearance_capplet_get_widget (data, "theme_vbox")(GtkWidget*) gtk_builder_get_object(data->ui, "theme_vbox"
)
;
1084 gtk_drag_dest_set (w, GTK_DEST_DEFAULT_ALL,
1085 drop_types, G_N_ELEMENTS (drop_types)(sizeof (drop_types) / sizeof ((drop_types)[0])),
1086 GDK_ACTION_COPY | GDK_ACTION_LINK | GDK_ACTION_MOVE);
1087 g_signal_connect (w, "drag-data-received", (GCallback) theme_drag_data_received_cb, data)g_signal_connect_data ((w), ("drag-data-received"), ((GCallback
) theme_drag_data_received_cb), (data), ((void*)0), (GConnectFlags
) 0)
;
1088 if (is_locked_down ())
1089 gtk_widget_set_sensitive (w, FALSE(0));
1090
1091 w = appearance_capplet_get_widget (data, "more_themes_linkbutton")(GtkWidget*) gtk_builder_get_object(data->ui, "more_themes_linkbutton"
)
;
1092 url = g_settings_get_string (data->settings, MORE_THEMES_URL_KEY"more-themes-url");
1093 if (url != NULL((void*)0) && url[0] != '\0') {
1094 gtk_link_button_set_uri (GTK_LINK_BUTTON (w)((((GtkLinkButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((w)), ((gtk_link_button_get_type ()))))))
, url);
1095 gtk_widget_show (w);
1096 } else {
1097 gtk_widget_hide (w);
1098 }
1099 g_free (url);
1100
1101 /* listen to gsettings changes, too */
1102 g_signal_connect (data->marco_settings, "changed::" MARCO_THEME_KEY, G_CALLBACK (theme_gsettings_changed), data)g_signal_connect_data ((data->marco_settings), ("changed::"
"theme"), (((GCallback) (theme_gsettings_changed))), (data),
((void*)0), (GConnectFlags) 0)
;
1103 g_signal_connect (data->mouse_settings, "changed::" CURSOR_THEME_KEY, G_CALLBACK (theme_gsettings_changed), data)g_signal_connect_data ((data->mouse_settings), ("changed::"
"cursor-theme"), (((GCallback) (theme_gsettings_changed))), (
data), ((void*)0), (GConnectFlags) 0)
;
1104 g_signal_connect (data->mouse_settings, "changed::" CURSOR_SIZE_KEY, G_CALLBACK (theme_gsettings_changed), data)g_signal_connect_data ((data->mouse_settings), ("changed::"
"cursor-size"), (((GCallback) (theme_gsettings_changed))), (
data), ((void*)0), (GConnectFlags) 0)
;
1105 g_signal_connect (data->wp_settings, "changed::" WP_FILE_KEY, G_CALLBACK (background_or_font_changed), data)g_signal_connect_data ((data->wp_settings), ("changed::" "picture-filename"
), (((GCallback) (background_or_font_changed))), (data), ((void
*)0), (GConnectFlags) 0)
;
1106 g_signal_connect (data->interface_settings, "changed::" GTK_FONT_KEY, G_CALLBACK (background_or_font_changed), data)g_signal_connect_data ((data->interface_settings), ("changed::"
"font-name"), (((GCallback) (background_or_font_changed))), (
data), ((void*)0), (GConnectFlags) 0)
;
1107 g_signal_connect (data->interface_settings, "changed::" DOCUMENT_FONT_KEY, G_CALLBACK (background_or_font_changed), data)g_signal_connect_data ((data->interface_settings), ("changed::"
"document-font-name"), (((GCallback) (background_or_font_changed
))), (data), ((void*)0), (GConnectFlags) 0)
;
1108
1109 if (data->caja_settings)
1110 g_signal_connect (data->caja_settings, "changed::" DESKTOP_FONT_KEY, G_CALLBACK (background_or_font_changed), data)g_signal_connect_data ((data->caja_settings), ("changed::"
"font"), (((GCallback) (background_or_font_changed))), (data
), ((void*)0), (GConnectFlags) 0)
;
1111
1112 g_signal_connect (data->marco_settings, "changed::" WINDOW_TITLE_FONT_KEY, G_CALLBACK (background_or_font_changed), data)g_signal_connect_data ((data->marco_settings), ("changed::"
"titlebar-font"), (((GCallback) (background_or_font_changed)
)), (data), ((void*)0), (GConnectFlags) 0)
;
1113 g_signal_connect (data->interface_settings, "changed::" MONOSPACE_FONT_KEY, G_CALLBACK (background_or_font_changed), data)g_signal_connect_data ((data->interface_settings), ("changed::"
"monospace-font-name"), (((GCallback) (background_or_font_changed
))), (data), ((void*)0), (GConnectFlags) 0)
;
1114
1115 settings = gtk_settings_get_default ();
1116 g_signal_connect (settings, "notify::gtk-color-scheme", (GCallback) theme_setting_changed_cb, data)g_signal_connect_data ((settings), ("notify::gtk-color-scheme"
), ((GCallback) theme_setting_changed_cb), (data), ((void*)0)
, (GConnectFlags) 0)
;
1117 g_signal_connect (settings, "notify::gtk-theme-name", (GCallback) theme_setting_changed_cb, data)g_signal_connect_data ((settings), ("notify::gtk-theme-name")
, ((GCallback) theme_setting_changed_cb), (data), ((void*)0),
(GConnectFlags) 0)
;
1118 g_signal_connect (settings, "notify::gtk-icon-theme-name", (GCallback) theme_setting_changed_cb, data)g_signal_connect_data ((settings), ("notify::gtk-icon-theme-name"
), ((GCallback) theme_setting_changed_cb), (data), ((void*)0)
, (GConnectFlags) 0)
;
1119
1120 /* monitor individual font choice buttons, so
1121 "revert font" option (if any) can be cleared */
1122 w = appearance_capplet_get_widget (data, "application_font")(GtkWidget*) gtk_builder_get_object(data->ui, "application_font"
)
;
1123 g_signal_connect (w, "font_set", (GCallback) custom_font_cb, data)g_signal_connect_data ((w), ("font_set"), ((GCallback) custom_font_cb
), (data), ((void*)0), (GConnectFlags) 0)
;
1124 w = appearance_capplet_get_widget (data, "document_font")(GtkWidget*) gtk_builder_get_object(data->ui, "document_font"
)
;
1125 g_signal_connect (w, "font_set", (GCallback) custom_font_cb, data)g_signal_connect_data ((w), ("font_set"), ((GCallback) custom_font_cb
), (data), ((void*)0), (GConnectFlags) 0)
;
1126 w = appearance_capplet_get_widget (data, "desktop_font")(GtkWidget*) gtk_builder_get_object(data->ui, "desktop_font"
)
;
1127 g_signal_connect (w, "font_set", (GCallback) custom_font_cb, data)g_signal_connect_data ((w), ("font_set"), ((GCallback) custom_font_cb
), (data), ((void*)0), (GConnectFlags) 0)
;
1128 w = appearance_capplet_get_widget (data, "window_title_font")(GtkWidget*) gtk_builder_get_object(data->ui, "window_title_font"
)
;
1129 g_signal_connect (w, "font_set", (GCallback) custom_font_cb, data)g_signal_connect_data ((w), ("font_set"), ((GCallback) custom_font_cb
), (data), ((void*)0), (GConnectFlags) 0)
;
1130 w = appearance_capplet_get_widget (data, "monospace_font")(GtkWidget*) gtk_builder_get_object(data->ui, "monospace_font"
)
;
1131 g_signal_connect (w, "font_set", (GCallback) custom_font_cb, data)g_signal_connect_data ((w), ("font_set"), ((GCallback) custom_font_cb
), (data), ((void*)0), (GConnectFlags) 0)
;
1132}
1133
1134void
1135themes_shutdown (AppearanceData *data)
1136{
1137 mate_theme_meta_info_free (data->theme_custom);
1138
1139 if (data->theme_icon)
1140 g_object_unref (data->theme_icon);
1141 if (data->theme_save_dialog)
1142 gtk_widget_destroy (data->theme_save_dialog);
1143 g_free (data->revert_application_font);
1144 g_free (data->revert_documents_font);
1145 g_free (data->revert_desktop_font);
1146 g_free (data->revert_windowtitle_font);
1147 g_free (data->revert_monospace_font);
1148}
diff --git a/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-0f29bf.html b/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-0f29bf.html new file mode 100644 index 00000000..8dabe7d0 --- /dev/null +++ b/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-0f29bf.html @@ -0,0 +1,1029 @@ + + + +mate-wp-item.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:capplets/appearance/mate-wp-item.c
Warning:line 35, column 7
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name mate-wp-item.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/capplets/appearance -fcoverage-compilation-dir=/rootdir/capplets/appearance -resource-dir /usr/bin/../lib/clang/18 -D HAVE_CONFIG_H -I . -I ../.. -I /usr/include/marco-1 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/gio-unix-2.0 -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I ../../capplets/common -I /usr/include/udisks2 -I /usr/include/libgtop-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/libxml2 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/gio-unix-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/dconf -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I ../../ -D G_LOG_DOMAIN="appearance-properties" -I /usr/include/polkit-1 -I /usr/include/gio-unix-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I /usr/include/udisks2 -I /usr/include/libgtop-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/gio-unix-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/libxml2 -I /usr/include/harfbuzz -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/freetype2 -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/dconf -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libpng16 -D WITH_GZFILEOP -I /usr/include/sysprof-6 -I /usr/include/pixman-1 -D MATECC_DATA_DIR="/usr/local/share/mate-control-center" -D MATECC_PIXMAP_DIR="/usr/local/share/mate-control-center/pixmaps" -D WALLPAPER_DATADIR="/usr/local/share/mate-background-properties" -D BACKGROUND_DATADIR="/usr/local/share/backgrounds" -D MATE_DESKTOP_USE_UNSTABLE_API -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-06-07-044335-13427-1 -x c mate-wp-item.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 * Authors: Rodney Dawes <dobey@ximian.com>
3 *
4 * Copyright 2003-2006 Novell, Inc. (www.novell.com)
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of version 2 of the GNU General Public License
8 * as published by the Free Software Foundation
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Street #330, Boston, MA 02110-1301, USA.
18 *
19 */
20
21#include <config.h>
22
23#include <glib/gi18n.h>
24#include <gio/gio.h>
25#include <string.h>
26#include "appearance.h"
27#include "mate-wp-item.h"
28
29const gchar *wp_item_option_to_string (MateBGPlacement type)
30{
31 switch (type)
32 {
33 case MATE_BG_PLACEMENT_CENTERED:
34 return "centered";
35 break;
This statement is never executed
36 case MATE_BG_PLACEMENT_FILL_SCREEN:
37 return "stretched";
38 break;
39 case MATE_BG_PLACEMENT_SCALED:
40 return "scaled";
41 break;
42 case MATE_BG_PLACEMENT_ZOOMED:
43 return "zoom";
44 break;
45 case MATE_BG_PLACEMENT_TILED:
46 return "wallpaper";
47 break;
48 case MATE_BG_PLACEMENT_SPANNED:
49 return "spanned";
50 break;
51 }
52 return "";
53}
54
55const gchar *wp_item_shading_to_string (MateBGColorType type)
56{
57 switch (type) {
58 case MATE_BG_COLOR_SOLID:
59 return "solid";
60 break;
61 case MATE_BG_COLOR_H_GRADIENT:
62 return "horizontal-gradient";
63 break;
64 case MATE_BG_COLOR_V_GRADIENT:
65 return "vertical-gradient";
66 break;
67 }
68 return "";
69}
70
71MateBGPlacement wp_item_string_to_option (const gchar *option)
72{
73 if (!g_strcmp0(option, "centered"))
74 return MATE_BG_PLACEMENT_CENTERED;
75 else if (!g_strcmp0(option, "stretched"))
76 return MATE_BG_PLACEMENT_FILL_SCREEN;
77 else if (!g_strcmp0(option, "scaled"))
78 return MATE_BG_PLACEMENT_SCALED;
79 else if (!g_strcmp0(option, "zoom"))
80 return MATE_BG_PLACEMENT_ZOOMED;
81 else if (!g_strcmp0(option, "wallpaper"))
82 return MATE_BG_PLACEMENT_TILED;
83 else if (!g_strcmp0(option, "spanned"))
84 return MATE_BG_PLACEMENT_SPANNED;
85 else
86 return MATE_BG_PLACEMENT_SCALED;
87}
88
89MateBGColorType wp_item_string_to_shading (const gchar *shade_type)
90{
91 if (!g_strcmp0(shade_type, "solid"))
92 return MATE_BG_COLOR_SOLID;
93 else if (!g_strcmp0(shade_type, "horizontal-gradient"))
94 return MATE_BG_COLOR_H_GRADIENT;
95 else if (!g_strcmp0(shade_type, "vertical-gradient"))
96 return MATE_BG_COLOR_V_GRADIENT;
97 else
98 return MATE_BG_COLOR_SOLID;
99}
100
101static void set_bg_properties (MateWPItem *item)
102{
103 if (item->filename)
104 mate_bg_set_filename (item->bg, item->filename);
105
106 mate_bg_set_color (item->bg, item->shade_type, item->pcolor, item->scolor);
107 mate_bg_set_placement (item->bg, item->options);
108}
109
110void mate_wp_item_ensure_mate_bg (MateWPItem *item)
111{
112 if (!item->bg) {
113 item->bg = mate_bg_new ();
114
115 set_bg_properties (item);
116 }
117}
118
119void mate_wp_item_update (MateWPItem *item) {
120 GSettings *settings;
121 GdkRGBA color1 = { 0, 0, 0, 1.0 }, color2 = { 0, 0, 0, 1.0 };
122 gchar *s;
123
124 settings = g_settings_new (WP_SCHEMA"org.mate.background");
125
126 item->options = g_settings_get_enum (settings, WP_OPTIONS_KEY"picture-options");
127
128 item->shade_type = g_settings_get_enum (settings, WP_SHADING_KEY"color-shading-type");
129
130 s = g_settings_get_string (settings, WP_PCOLOR_KEY"primary-color");
131 if (s != NULL((void*)0)) {
132 gdk_rgba_parse (&color1, s);
133 g_free (s);
134 }
135
136 s = g_settings_get_string (settings, WP_SCOLOR_KEY"secondary-color");
137 if (s != NULL((void*)0)) {
138 gdk_rgba_parse (&color2, s);
139 g_free (s);
140 }
141
142 g_object_unref (settings);
143
144 if (item->pcolor != NULL((void*)0))
145 gdk_rgba_free (item->pcolor);
146
147 if (item->scolor != NULL((void*)0))
148 gdk_rgba_free (item->scolor);
149
150 item->pcolor = gdk_rgba_copy (&color1);
151 item->scolor = gdk_rgba_copy (&color2);
152}
153
154MateWPItem * mate_wp_item_new (const gchar * filename,
155 GHashTable * wallpapers,
156 MateDesktopThumbnailFactory * thumbnails) {
157 MateWPItem *item = g_new0 (MateWPItem, 1)((MateWPItem *) g_malloc0_n ((1), sizeof (MateWPItem)));
158
159 item->filename = g_strdup (filename)g_strdup_inline (filename);
160 item->fileinfo = mate_wp_info_new (filename, thumbnails);
161
162 if (item->fileinfo != NULL((void*)0) && item->fileinfo->mime_type != NULL((void*)0) &&
163 (g_str_has_prefix (item->fileinfo->mime_type, "image/")(__builtin_constant_p ("image/")? __extension__ ({ const char
* const __str = (item->fileinfo->mime_type); const char
* const __prefix = ("image/"); gboolean __result = (0); if (
__str == ((void*)0) || __prefix == ((void*)0)) __result = (g_str_has_prefix
) (__str, __prefix); else { const size_t __str_len = strlen (
((__str) + !(__str))); const size_t __prefix_len = strlen (((
__prefix) + !(__prefix))); if (__str_len >= __prefix_len) __result
= memcmp (((__str) + !(__str)), ((__prefix) + !(__prefix)), __prefix_len
) == 0; } __result; }) : (g_str_has_prefix) (item->fileinfo
->mime_type, "image/") )
||
164 strcmp (item->fileinfo->mime_type, "application/xml") == 0)) {
165
166 if (g_utf8_validate (item->fileinfo->name, -1, NULL((void*)0)))
167 item->name = g_strdup (item->fileinfo->name)g_strdup_inline (item->fileinfo->name);
168 else
169 item->name = g_filename_to_utf8 (item->fileinfo->name, -1, NULL((void*)0),
170 NULL((void*)0), NULL((void*)0));
171
172 mate_wp_item_update (item);
173 mate_wp_item_ensure_mate_bg (item);
174 mate_wp_item_update_description (item);
175
176 g_hash_table_insert (wallpapers, item->filename, item);
177 } else {
178 mate_wp_item_free (item);
179 item = NULL((void*)0);
180 }
181
182 return item;
183}
184
185void mate_wp_item_free (MateWPItem * item) {
186 if (item == NULL((void*)0)) {
187 return;
188 }
189
190 g_free (item->name);
191 g_free (item->filename);
192 g_free (item->description);
193 g_free (item->artist);
194
195 if (item->pcolor != NULL((void*)0))
196 gdk_rgba_free (item->pcolor);
197
198 if (item->scolor != NULL((void*)0))
199 gdk_rgba_free (item->scolor);
200
201 mate_wp_info_free (item->fileinfo);
202 if (item->bg)
203 g_object_unref (item->bg);
204
205 gtk_tree_row_reference_free (item->rowref);
206
207 g_free (item);
208}
209
210static GdkPixbuf *
211add_slideshow_frame (GdkPixbuf *pixbuf)
212{
213 GdkPixbuf *sheet, *sheet2;
214 GdkPixbuf *tmp;
215 gint w, h;
216
217 w = gdk_pixbuf_get_width (pixbuf);
218 h = gdk_pixbuf_get_height (pixbuf);
219
220 sheet = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE(0), 8, w, h);
221 gdk_pixbuf_fill (sheet, 0x00000000);
222 sheet2 = gdk_pixbuf_new_subpixbuf (sheet, 1, 1, w - 2, h - 2);
223 gdk_pixbuf_fill (sheet2, 0xffffffff);
224 g_object_unref (sheet2);
225
226 tmp = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE(!(0)), 8, w + 6, h + 6);
227
228 gdk_pixbuf_fill (tmp, 0x00000000);
229 gdk_pixbuf_composite (sheet, tmp, 6, 6, w, h, 6.0, 6.0, 1.0, 1.0, GDK_INTERP_NEAREST, 255);
230 gdk_pixbuf_composite (sheet, tmp, 3, 3, w, h, 3.0, 3.0, 1.0, 1.0, GDK_INTERP_NEAREST, 255);
231 gdk_pixbuf_composite (pixbuf, tmp, 0, 0, w, h, 0.0, 0.0, 1.0, 1.0, GDK_INTERP_NEAREST, 255);
232
233 g_object_unref (sheet);
234
235 return tmp;
236}
237
238GdkPixbuf * mate_wp_item_get_frame_thumbnail (MateWPItem * item,
239 MateDesktopThumbnailFactory * thumbs,
240 int width,
241 int height,
242 gint frame) {
243 GdkPixbuf *pixbuf = NULL((void*)0);
244
245 set_bg_properties (item);
246
247 if (frame != -1)
248 pixbuf = mate_bg_create_frame_thumbnail (item->bg, thumbs, gdk_screen_get_default (), width, height, frame);
249 else
250 pixbuf = mate_bg_create_thumbnail (item->bg, thumbs, gdk_screen_get_default(), width, height);
251
252 if (pixbuf && mate_bg_changes_with_time (item->bg))
253 {
254 GdkPixbuf *tmp;
255
256 tmp = add_slideshow_frame (pixbuf);
257 g_object_unref (pixbuf);
258 pixbuf = tmp;
259 }
260
261 mate_bg_get_image_size (item->bg, thumbs, width, height, &item->width, &item->height);
262
263 return pixbuf;
264}
265
266GdkPixbuf * mate_wp_item_get_thumbnail (MateWPItem * item,
267 MateDesktopThumbnailFactory * thumbs,
268 gint width,
269 gint height) {
270 return mate_wp_item_get_frame_thumbnail (item, thumbs, width, height, -1);
271}
272
273void mate_wp_item_update_description (MateWPItem * item) {
274 g_free (item->description);
275
276 if (!strcmp (item->filename, "(none)")) {
277 item->description = g_strdup (item->name)g_strdup_inline (item->name);
278 } else {
279 gchar *description;
280 gchar *size;
281 gchar *dirname = g_path_get_dirname (item->filename);
282 gchar *artist;
283
284 description = NULL((void*)0);
285 size = NULL((void*)0);
286
287 if (!item->artist || item->artist[0] == 0 || !g_strcmp0(item->artist, "(none)"))
288 artist = g_strdup (_("unknown"))g_strdup_inline (gettext ("unknown"));
289 else
290 artist = g_strdup (item->artist)g_strdup_inline (item->artist);
291
292 if (strcmp (item->fileinfo->mime_type, "application/xml") == 0)
293 {
294 if (mate_bg_changes_with_time (item->bg))
295 description = g_strdup (_("Slide Show"))g_strdup_inline (gettext ("Slide Show"));
296 else if (item->width > 0 && item->height > 0)
297 description = g_strdup (_("Image"))g_strdup_inline (gettext ("Image"));
298 }
299 else
300 description = g_content_type_get_description (item->fileinfo->mime_type);
301
302 if (mate_bg_has_multiple_sizes (item->bg))
303 size = g_strdup (_("multiple sizes"))g_strdup_inline (gettext ("multiple sizes"));
304 else if (item->width > 0 && item->height > 0) {
305 /* translators: x pixel(s) by y pixel(s) */
306 size = g_strdup_printf (_("%d %s by %d %s")gettext ("%d %s by %d %s"),
307 item->width,
308 ngettext ("pixel", "pixels", item->width),
309 item->height,
310 ngettext ("pixel", "pixels", item->height));
311 }
312
313 if (description && size) {
314 /* translators: <b>wallpaper name</b>
315 * mime type, size
316 * Folder: /path/to/file
317 * Artist: wallpaper author
318 */
319 item->description = g_markup_printf_escaped (_("<b>%s</b>\n"gettext ("<b>%s</b>\n" "%s, %s\n" "Folder: %s\n" "Artist: %s"
)
320 "%s, %s\n"gettext ("<b>%s</b>\n" "%s, %s\n" "Folder: %s\n" "Artist: %s"
)
321 "Folder: %s\n"gettext ("<b>%s</b>\n" "%s, %s\n" "Folder: %s\n" "Artist: %s"
)
322 "Artist: %s")gettext ("<b>%s</b>\n" "%s, %s\n" "Folder: %s\n" "Artist: %s"
)
,
323 item->name,
324 description,
325 size,
326 dirname,
327 artist);
328 } else {
329 /* translators: <b>wallpaper name</b>
330 * Image missing
331 * Folder: /path/to/file
332 * Artist: wallpaper author
333 */
334 item->description = g_markup_printf_escaped (_("<b>%s</b>\n"gettext ("<b>%s</b>\n" "%s\n" "Folder: %s\n" "Artist: %s"
)
335 "%s\n"gettext ("<b>%s</b>\n" "%s\n" "Folder: %s\n" "Artist: %s"
)
336 "Folder: %s\n"gettext ("<b>%s</b>\n" "%s\n" "Folder: %s\n" "Artist: %s"
)
337 "Artist: %s")gettext ("<b>%s</b>\n" "%s\n" "Folder: %s\n" "Artist: %s"
)
,
338 item->name,
339 _("Image missing")gettext ("Image missing"),
340 dirname,
341 artist);
342 }
343
344 g_free (size);
345 g_free (dirname);
346 g_free (artist);
347 g_free (description);
348 }
349}
diff --git a/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-1a3269.html b/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-1a3269.html new file mode 100644 index 00000000..e6be3c15 --- /dev/null +++ b/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-1a3269.html @@ -0,0 +1,1978 @@ + + + +bookmark-agent.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:shell/bookmark-agent.c
Warning:line 686, column 7
Access of 'char *' element in the heap area at index 1
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name bookmark-agent.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/shell -fcoverage-compilation-dir=/rootdir/shell -resource-dir /usr/bin/../lib/clang/18 -D HAVE_CONFIG_H -I . -I .. -I .. -I /usr/include/udisks2 -I /usr/include/libgtop-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/atk-1.0 -I /usr/include/startup-notification-1.0 -I /usr/include/mate-menus -I /usr/include/gio-unix-2.0 -I /usr/include/librsvg-2.0 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/libxml2 -I /usr/include/harfbuzz -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/freetype2 -I /usr/include/cloudproviders -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/dconf -I /usr/include/webp -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libpng16 -D WITH_GZFILEOP -I /usr/include/sysprof-6 -I /usr/include/pixman-1 -D MATELOCALEDIR="/usr/local/share/locale" -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-06-07-044335-13427-1 -x c bookmark-agent.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 * This file is part of the Main Menu.
3 *
4 * Copyright (c) 2007 Novell, Inc.
5 *
6 * The Main Menu is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free
8 * Software Foundation; either version 2 of the License, or (at your option)
9 * any later version.
10 *
11 * The Main Menu is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * more details.
15 *
16 * You should have received a copy of the GNU General Public License along with
17 * the Main Menu; if not, write to the Free Software Foundation, Inc., 51
18 * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#include "bookmark-agent.h"
22
23#ifdef HAVE_CONFIG_H1
24# include <config.h>
25#else
26# define PACKAGE"mate-control-center" "mate-main-menu"
27#endif
28
29#include <gtk/gtk.h>
30
31#include <string.h>
32#include <stdlib.h>
33#include <glib/gi18n-lib.h>
34#include <glib/gstdio.h>
35#include <gio/gio.h>
36
37#include "libslab-utils.h"
38
39#define USER_APPS_STORE_FILE_NAME"applications.xbel" "applications.xbel"
40#define USER_DOCS_STORE_FILE_NAME"documents.xbel" "documents.xbel"
41#define USER_DIRS_STORE_FILE_NAME"places.xbel" "places.xbel"
42#define SYSTEM_STORE_FILE_NAME"system-items.xbel" "system-items.xbel"
43#define CALC_TEMPLATE_FILE_NAME"empty.ots" "empty.ots"
44#define WRITER_TEMPLATE_FILE_NAME"empty.ott" "empty.ott"
45
46#define GTK_BOOKMARKS_FILE"bookmarks" "bookmarks"
47
48#define TYPE_IS_RECENT(type)((type) == BOOKMARK_STORE_RECENT_APPS || (type) == BOOKMARK_STORE_RECENT_DOCS
)
((type) == BOOKMARK_STORE_RECENT_APPS || (type) == BOOKMARK_STORE_RECENT_DOCS)
49
50typedef struct {
51 BookmarkStoreType type;
52
53 BookmarkItem **items;
54 gint n_items;
55 BookmarkStoreStatus status;
56
57 GBookmarkFile *store;
58 gboolean needs_sync;
59
60 gchar *store_path;
61 gchar *user_store_path;
62 gboolean user_modifiable;
63 gboolean reorderable;
64 const gchar *store_filename;
65
66 GFileMonitor *store_monitor;
67 GFileMonitor *user_store_monitor;
68
69 void (* update_path) (BookmarkAgent *);
70 void (* load_store) (BookmarkAgent *);
71 void (* save_store) (BookmarkAgent *);
72 void (* create_item) (BookmarkAgent *, const gchar *);
73
74 gchar *gtk_store_path;
75 GFileMonitor *gtk_store_monitor;
76} BookmarkAgentPrivate;
77
78enum {
79 PROP_0,
80 PROP_ITEMS,
81 PROP_STATUS
82};
83
84static BookmarkAgent *instances [BOOKMARK_STORE_N_TYPES];
85
86static BookmarkAgentClass *bookmark_agent_parent_class = NULL((void*)0);
87
88static void bookmark_agent_base_init (BookmarkAgentClass *);
89static void bookmark_agent_class_init (BookmarkAgentClass *);
90static void bookmark_agent_init (BookmarkAgent *);
91static BookmarkAgent *bookmark_agent_new (BookmarkStoreType );
92
93static void get_property (GObject *, guint, GValue *, GParamSpec *);
94static void set_property (GObject *, guint, const GValue *, GParamSpec *);
95static void finalize (GObject *);
96
97static void update_agent (BookmarkAgent *);
98static void update_items (BookmarkAgent *);
99static void save_store (BookmarkAgent *);
100static gint get_rank (BookmarkAgent *, const gchar *);
101static void set_rank (BookmarkAgent *, const gchar *, gint);
102
103static void load_xbel_store (BookmarkAgent *);
104static void load_places_store (BookmarkAgent *);
105static void update_user_spec_path (BookmarkAgent *);
106static void save_xbel_store (BookmarkAgent *);
107static void create_app_item (BookmarkAgent *, const gchar *);
108static void create_doc_item (BookmarkAgent *, const gchar *);
109static void create_dir_item (BookmarkAgent *, const gchar *);
110
111static void store_monitor_cb (GFileMonitor *, GFile *, GFile *,
112 GFileMonitorEvent, gpointer);
113static void weak_destroy_cb (gpointer, GObject *);
114
115static gchar *find_package_data_file (const gchar *filename);
116
117static gint BookmarkAgent_private_offset;
118
119static inline gpointer bookmark_agent_get_instance_private (BookmarkAgent *this)
120{
121 return (G_STRUCT_MEMBER_P (this, BookmarkAgent_private_offset)((gpointer) ((guint8*) (this) + (glong) (BookmarkAgent_private_offset
)))
);
122}
123
124GType
125bookmark_agent_get_type ()
126{
127 static GType g_define_type_id = 0;
128
129 if (G_UNLIKELY (g_define_type_id == 0)(g_define_type_id == 0)) {
130 static const GTypeInfo info = {
131 sizeof (BookmarkAgentClass),
132 (GBaseInitFunc) bookmark_agent_base_init,
133 NULL((void*)0),
134 (GClassInitFunc) bookmark_agent_class_init,
135 NULL((void*)0), NULL((void*)0),
136 sizeof (BookmarkAgent), 0,
137 (GInstanceInitFunc) bookmark_agent_init,
138 NULL((void*)0)
139 };
140
141 g_define_type_id = g_type_register_static (
142 G_TYPE_OBJECT((GType) ((20) << (2))), "BookmarkAgent", & info, 0);
143 G_ADD_PRIVATE (BookmarkAgent){ BookmarkAgent_private_offset = g_type_add_instance_private (
g_define_type_id, sizeof (BookmarkAgentPrivate)); }
;
144 }
145
146 return g_define_type_id;
147}
148
149gboolean
150bookmark_agent_has_item (BookmarkAgent *this, const gchar *uri)
151{
152 BookmarkAgentPrivate *priv = bookmark_agent_get_instance_private (this);
153 return g_bookmark_file_has_item (priv->store, uri);
154}
155
156void
157bookmark_agent_add_item (BookmarkAgent *this, const BookmarkItem *item)
158{
159 BookmarkAgentPrivate *priv = bookmark_agent_get_instance_private (this);
160
161 if (! item)
162 return;
163
164 g_return_if_fail (priv->user_modifiable)do { if ((priv->user_modifiable)) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "priv->user_modifiable"
); return; } } while (0)
;
165 g_return_if_fail (item->uri)do { if ((item->uri)) { } else { g_return_if_fail_warning (
((gchar*) 0), ((const char*) (__func__)), "item->uri"); return
; } } while (0)
;
166 g_return_if_fail (item->mime_type)do { if ((item->mime_type)) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "item->mime_type"
); return; } } while (0)
;
167
168 g_bookmark_file_set_mime_type (priv->store, item->uri, item->mime_type);
169
170 if (item->mtime)
171#if GLIB_CHECK_VERSION(2,66,0)(2 > (2) || (2 == (2) && 80 > (66)) || (2 == (2
) && 80 == (66) && 2 >= (0)))
172 g_bookmark_file_set_modified_date_time (priv->store, item->uri, item->mtime);
173#else
174 g_bookmark_file_set_modified (priv->store, item->uri, item->mtime);
175#endif
176
177 if (item->title)
178 g_bookmark_file_set_title (priv->store, item->uri, item->title);
179
180 g_bookmark_file_add_application (priv->store, item->uri, item->app_name, item->app_exec);
181
182 set_rank (this, item->uri, g_bookmark_file_get_size (priv->store) - 1);
183
184 save_store (this);
185}
186
187void
188bookmark_agent_move_item (BookmarkAgent *this, const gchar *uri, const gchar *uri_new)
189{
190 BookmarkAgentPrivate *priv = bookmark_agent_get_instance_private (this);
191
192 GError *error = NULL((void*)0);
193
194 if (! TYPE_IS_RECENT (priv->type)((priv->type) == BOOKMARK_STORE_RECENT_APPS || (priv->type
) == BOOKMARK_STORE_RECENT_DOCS)
)
195 return;
196
197 gtk_recent_manager_move_item (gtk_recent_manager_get_default (), uri, uri_new, &error);
198 if (error) {
199 g_warning ("Unable to update %s with renamed file, [%s] -> [%s]: %s",
200 priv->store_path, uri, uri_new, error->message);
201 g_error_free (error);
202 }
203}
204
205void
206bookmark_agent_purge_items (BookmarkAgent *this)
207{
208 BookmarkAgentPrivate *priv = bookmark_agent_get_instance_private (this);
209
210 GError *error = NULL((void*)0);
211
212 gchar **uris = NULL((void*)0);
213 gsize uris_len;
214 gint i;
215 g_return_if_fail (priv->user_modifiable)do { if ((priv->user_modifiable)) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "priv->user_modifiable"
); return; } } while (0)
;
216
217 uris = g_bookmark_file_get_uris (priv->store, &uris_len);
218 if (TYPE_IS_RECENT (priv->type)((priv->type) == BOOKMARK_STORE_RECENT_APPS || (priv->type
) == BOOKMARK_STORE_RECENT_DOCS)
) {
219 for (i = 0; i < uris_len; i++) {
220 gtk_recent_manager_remove_item (gtk_recent_manager_get_default (), uris [i], &error);
221 if (error) {
222 g_warning ("Unable to remove [%s] from %s: %s",
223 priv->store_path, uris [i], error->message);
224 g_error_free (error);
225 }
226 }
227 } else {
228 for (i = 0; i < uris_len; i++) {
229 g_bookmark_file_remove_item (priv->store, uris [i], NULL((void*)0));
230 }
231 save_store (this);
232 }
233 g_strfreev (uris);
234}
235
236void
237bookmark_agent_remove_item (BookmarkAgent *this, const gchar *uri)
238{
239 BookmarkAgentPrivate *priv = bookmark_agent_get_instance_private (this);
240 gint rank;
241
242 GError *error = NULL((void*)0);
243
244 gchar **uris = NULL((void*)0);
245 gint rank_i;
246 gint i;
247
248 g_return_if_fail (priv->user_modifiable)do { if ((priv->user_modifiable)) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "priv->user_modifiable"
); return; } } while (0)
;
249
250 if (! bookmark_agent_has_item (this, uri))
251 return;
252
253 if (TYPE_IS_RECENT (priv->type)((priv->type) == BOOKMARK_STORE_RECENT_APPS || (priv->type
) == BOOKMARK_STORE_RECENT_DOCS)
) {
254 gtk_recent_manager_remove_item (gtk_recent_manager_get_default (), uri, &error);
255 if (error) {
256 g_warning ("Unable to remove [%s] from %s: %s", priv->store_path, uri, error->message);
257 g_error_free (error);
258 }
259 }
260 else {
261 rank = get_rank (this, uri);
262
263 g_bookmark_file_remove_item (priv->store, uri, NULL((void*)0));
264
265 if (rank >= 0) {
266 uris = g_bookmark_file_get_uris (priv->store, NULL((void*)0));
267
268 for (i = 0; uris && uris [i]; ++i) {
269 rank_i = get_rank (this, uris [i]);
270
271 if (rank_i > rank)
272 set_rank (this, uris [i], rank_i - 1);
273 }
274
275 g_strfreev (uris);
276 }
277
278 save_store (this);
279 }
280}
281
282void
283bookmark_agent_reorder_items (BookmarkAgent *this, const gchar **uris)
284{
285 BookmarkAgentPrivate *priv = bookmark_agent_get_instance_private (this);
286
287 gint i;
288
289 g_return_if_fail (priv->reorderable)do { if ((priv->reorderable)) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "priv->reorderable"
); return; } } while (0)
;
290
291 for (i = 0; uris && uris [i]; ++i)
292 set_rank (this, uris [i], i);
293
294 save_store (this);
295}
296
297#if !GLIB_CHECK_VERSION(2,66,0)(2 > (2) || (2 == (2) && 80 > (66)) || (2 == (2
) && 80 == (66) && 2 >= (0)))
298static gint
299recent_item_mru_comp_func (gconstpointer a, gconstpointer b)
300{
301 return ((BookmarkItem *) b)->mtime - ((BookmarkItem *) a)->mtime;
302}
303#endif
304
305static GList *
306make_items_from_bookmark_file (BookmarkAgent *this, GBookmarkFile *store)
307{
308 BookmarkAgentPrivate *priv = bookmark_agent_get_instance_private (this);
309 gchar **uris;
310 gint i;
311 GList *items_ordered;
312
313 if (!store)
314 return NULL((void*)0);
315
316 uris = g_bookmark_file_get_uris (store, NULL((void*)0));
317 items_ordered = NULL((void*)0);
318
319 for (i = 0; uris && uris [i]; ++i) {
320 gboolean include;
321
322 if (priv->type == BOOKMARK_STORE_RECENT_APPS)
323 include = g_bookmark_file_has_group (store, uris [i], "recently-used-apps", NULL((void*)0));
324 else
325 include = ! g_bookmark_file_get_is_private (store, uris [i], NULL((void*)0));
326
327 if (include) {
328 BookmarkItem *item;
329
330 item = g_new0 (BookmarkItem, 1)((BookmarkItem *) g_malloc0_n ((1), sizeof (BookmarkItem)));
331
332 item->uri = g_strdup (uris [i])g_strdup_inline (uris [i]);
333 item->mime_type = g_bookmark_file_get_mime_type (store, uris [i], NULL((void*)0));
334#if GLIB_CHECK_VERSION(2,66,0)(2 > (2) || (2 == (2) && 80 > (66)) || (2 == (2
) && 80 == (66) && 2 >= (0)))
335 item->mtime = g_bookmark_file_get_modified_date_time (store, uris [i], NULL((void*)0));
336#else
337 item->mtime = g_bookmark_file_get_modified (store, uris [i], NULL((void*)0));
338#endif
339
340 items_ordered = g_list_prepend (items_ordered, item);
341 }
342 }
343
344#if GLIB_CHECK_VERSION(2,66,0)(2 > (2) || (2 == (2) && 80 > (66)) || (2 == (2
) && 80 == (66) && 2 >= (0)))
345 items_ordered = g_list_sort (items_ordered, g_date_time_compare);
346#else
347 items_ordered = g_list_sort (items_ordered, recent_item_mru_comp_func);
348#endif
349 g_strfreev (uris);
350
351 return items_ordered;
352}
353
354void
355bookmark_agent_update_from_bookmark_file (BookmarkAgent *this, GBookmarkFile *store)
356{
357 BookmarkAgentPrivate *priv;
358 GList *items_ordered;
359 GList *node;
360
361 g_return_if_fail (IS_BOOKMARK_AGENT (this))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((this)); GType __t = ((bookmark_agent_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "IS_BOOKMARK_AGENT (this)"); return; } } while
(0)
;
362
363 priv = bookmark_agent_get_instance_private (this);
364
365 items_ordered = make_items_from_bookmark_file (this, store);
366
367 g_bookmark_file_free (priv->store);
368 priv->store = g_bookmark_file_new ();
369
370 for (node = items_ordered; node; node = node->next) {
371 BookmarkItem *item;
372
373 item = (BookmarkItem *) node->data;
374
375 g_bookmark_file_set_mime_type (priv->store, item->uri, item->mime_type);
376 #if GLIB_CHECK_VERSION(2,66,0)(2 > (2) || (2 == (2) && 80 > (66)) || (2 == (2
) && 80 == (66) && 2 >= (0)))
377 g_bookmark_file_set_modified_date_time (priv->store, item->uri, item->mtime);
378 #else
379 g_bookmark_file_set_modified (priv->store, item->uri, item->mtime);
380 #endif
381
382 bookmark_item_free (item);
383 }
384
385 g_list_free (items_ordered);
386
387 update_items (this);
388}
389
390void
391bookmark_item_free (BookmarkItem *item)
392{
393 if (! item)
394 return;
395
396 g_free (item->uri);
397 g_free (item->title);
398 g_free (item->mime_type);
399 g_free (item->icon);
400 g_free (item->app_name);
401 g_free (item->app_exec);
402 g_free (item);
403}
404
405static void
406bookmark_agent_base_init (BookmarkAgentClass *this_class)
407{
408 gint i;
409
410 for (i = 0; i < BOOKMARK_STORE_N_TYPES; ++i)
411 instances [i] = NULL((void*)0);
412}
413
414static void
415bookmark_agent_class_init (BookmarkAgentClass *this_class)
416{
417 GObjectClass *g_obj_class = G_OBJECT_CLASS (this_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((this_class)), (((GType) ((20) << (2))))))))
;
418
419 GParamSpec *items_pspec;
420 GParamSpec *status_pspec;
421
422 if (BookmarkAgent_private_offset != 0)
423 g_type_class_adjust_private_offset (this_class, &BookmarkAgent_private_offset);
424
425 g_obj_class->get_property = get_property;
426 g_obj_class->set_property = set_property;
427 g_obj_class->finalize = finalize;
428
429 items_pspec = g_param_spec_pointer (
430 BOOKMARK_AGENT_ITEMS_PROP"items", BOOKMARK_AGENT_ITEMS_PROP"items",
431 "the null-terminated list which contains the bookmark items in this store",
432 G_PARAM_READABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB);
433
434 status_pspec = g_param_spec_int (
435 BOOKMARK_AGENT_STORE_STATUS_PROP"store-status", BOOKMARK_AGENT_STORE_STATUS_PROP"store-status", "the status of the store",
436 BOOKMARK_STORE_DEFAULT_ONLY, BOOKMARK_STORE_USER, BOOKMARK_STORE_DEFAULT,
437 G_PARAM_READABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB);
438
439 g_object_class_install_property (g_obj_class, PROP_ITEMS, items_pspec);
440 g_object_class_install_property (g_obj_class, PROP_STATUS, status_pspec);
441
442 bookmark_agent_parent_class = g_type_class_peek_parent (this_class);
443}
444
445static void
446bookmark_agent_init (BookmarkAgent *this)
447{
448 BookmarkAgentPrivate *priv = bookmark_agent_get_instance_private (this);
449
450 priv->type = -1;
451
452 priv->items = NULL((void*)0);
453 priv->n_items = 0;
454 priv->status = BOOKMARK_STORE_ABSENT;
455
456 priv->store = NULL((void*)0);
457 priv->needs_sync = FALSE(0);
458
459 priv->store_path = NULL((void*)0);
460 priv->user_store_path = NULL((void*)0);
461 priv->user_modifiable = FALSE(0);
462 priv->reorderable = FALSE(0);
463 priv->store_filename = NULL((void*)0);
464
465 priv->store_monitor = NULL((void*)0);
466 priv->user_store_monitor = NULL((void*)0);
467
468 priv->update_path = NULL((void*)0);
469 priv->load_store = NULL((void*)0);
470 priv->save_store = NULL((void*)0);
471 priv->create_item = NULL((void*)0);
472
473 priv->gtk_store_path = NULL((void*)0);
474 priv->gtk_store_monitor = NULL((void*)0);
475}
476
477static BookmarkAgent *
478bookmark_agent_new (BookmarkStoreType type)
479{
480 BookmarkAgent *this;
481 BookmarkAgentPrivate *priv;
482 GFile *gtk_store_file;
483
484 this = g_object_new (BOOKMARK_AGENT_TYPE(bookmark_agent_get_type ()), NULL((void*)0));
485 priv = bookmark_agent_get_instance_private (this);
486
487 priv->type = type;
488 priv->store = g_bookmark_file_new ();
489
490 switch (type) {
491 case BOOKMARK_STORE_USER_APPS:
492 priv->store_filename = USER_APPS_STORE_FILE_NAME"applications.xbel";
493 priv->create_item = create_app_item;
494
495 break;
496
497 case BOOKMARK_STORE_USER_DOCS:
498 priv->store_filename = USER_DOCS_STORE_FILE_NAME"documents.xbel";
499 priv->create_item = create_doc_item;
500
501 break;
502
503 case BOOKMARK_STORE_USER_DIRS:
504 priv->store_filename = USER_DIRS_STORE_FILE_NAME"places.xbel";
505 priv->create_item = create_dir_item;
506
507 priv->user_modifiable = TRUE(!(0));
508 priv->reorderable = FALSE(0);
509
510 priv->load_store = load_places_store;
511
512 priv->gtk_store_path = g_build_filename (g_get_user_config_dir (),
513 "gtk-3.0", GTK_BOOKMARKS_FILE"bookmarks", NULL((void*)0));
514 gtk_store_file = g_file_new_for_path (priv->gtk_store_path);
515 priv->gtk_store_monitor = g_file_monitor_file (gtk_store_file,
516 0, NULL((void*)0), NULL((void*)0));
517 if (priv->gtk_store_monitor) {
518 g_signal_connect (priv->gtk_store_monitor, "changed",g_signal_connect_data ((priv->gtk_store_monitor), ("changed"
), (((GCallback) (store_monitor_cb))), (this), ((void*)0), (GConnectFlags
) 0)
519 G_CALLBACK (store_monitor_cb), this)g_signal_connect_data ((priv->gtk_store_monitor), ("changed"
), (((GCallback) (store_monitor_cb))), (this), ((void*)0), (GConnectFlags
) 0)
;
520 }
521
522 g_object_unref (gtk_store_file);
523
524 break;
525
526 case BOOKMARK_STORE_RECENT_APPS:
527 case BOOKMARK_STORE_RECENT_DOCS:
528 priv->user_modifiable = TRUE(!(0));
529 priv->reorderable = FALSE(0);
530
531 priv->store_path = g_build_filename (g_get_user_data_dir (), "recently-used.xbel", NULL((void*)0));
532
533 break;
534
535 case BOOKMARK_STORE_SYSTEM:
536 priv->store_filename = SYSTEM_STORE_FILE_NAME"system-items.xbel";
537 priv->create_item = create_app_item;
538
539 break;
540
541 default:
542 break;
543 }
544
545 if (
546 type == BOOKMARK_STORE_USER_APPS || type == BOOKMARK_STORE_USER_DOCS ||
547 type == BOOKMARK_STORE_USER_DIRS || type == BOOKMARK_STORE_SYSTEM)
548 {
549 priv->user_modifiable = TRUE(!(0));
550
551 priv->user_store_path = g_build_filename (
552 g_get_user_data_dir (), PACKAGE"mate-control-center", priv->store_filename, NULL((void*)0));
553
554 priv->update_path = update_user_spec_path;
555 }
556
557 if (type == BOOKMARK_STORE_USER_APPS || type == BOOKMARK_STORE_USER_DOCS || type == BOOKMARK_STORE_SYSTEM) {
558 priv->reorderable = TRUE(!(0));
559 priv->load_store = load_xbel_store;
560 priv->save_store = save_xbel_store;
561 }
562
563 update_agent (this);
564
565 return this;
566}
567
568BookmarkAgent *
569bookmark_agent_get_instance (BookmarkStoreType type)
570{
571 g_return_val_if_fail (0 <= type, NULL)do { if ((0 <= type)) { } else { g_return_if_fail_warning (
((gchar*) 0), ((const char*) (__func__)), "0 <= type"); return
(((void*)0)); } } while (0)
;
572 g_return_val_if_fail (type < BOOKMARK_STORE_N_TYPES, NULL)do { if ((type < BOOKMARK_STORE_N_TYPES)) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "type < BOOKMARK_STORE_N_TYPES"
); return (((void*)0)); } } while (0)
;
573
574 if (! instances [type]) {
575 instances [type] = bookmark_agent_new (type);
576 g_object_weak_ref (G_OBJECT (instances [type])((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((instances [type])), (((GType) ((20) << (2))))))))
, weak_destroy_cb, GINT_TO_POINTER (type)((gpointer) (glong) (type)));
577 }
578 else
579 g_object_ref (G_OBJECT (instances [type]))((__typeof__ (((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((instances [type])), (((GType) ((20) <<
(2)))))))))) (g_object_ref) (((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((instances [type])), (((GType) ((20) <<
(2))))))))))
;
580
581 return instances [type];
582}
583
584static void
585get_property (GObject *g_obj, guint prop_id, GValue *value, GParamSpec *pspec)
586{
587 BookmarkAgent *this = BOOKMARK_AGENT (g_obj)((((BookmarkAgent*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((g_obj)), ((bookmark_agent_get_type ()))))))
;
588 BookmarkAgentPrivate *priv = bookmark_agent_get_instance_private (this);
589
590 switch (prop_id) {
591 case PROP_ITEMS:
592 g_value_set_pointer (value, priv->items);
593 break;
594
595 case PROP_STATUS:
596 g_value_set_int (value, priv->status);
597 break;
598 }
599}
600
601static void
602set_property (GObject *g_obj, guint prop_id, const GValue *value, GParamSpec *pspec)
603{
604 /* no writeable properties */
605}
606
607static void
608finalize (GObject *g_obj)
609{
610 BookmarkAgent *this = BOOKMARK_AGENT (g_obj)((((BookmarkAgent*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((g_obj)), ((bookmark_agent_get_type ()))))))
;
611 BookmarkAgentPrivate *priv = bookmark_agent_get_instance_private (this);
612
613 gint i;
614
615 for (i = 0; priv->items && priv->items [i]; ++i)
616 bookmark_item_free (priv->items [i]);
617
618 g_free (priv->items);
619 g_free (priv->store_path);
620 g_free (priv->user_store_path);
621 g_free (priv->gtk_store_path);
622
623 if (priv->store_monitor) {
624 g_signal_handlers_disconnect_by_func (priv->store_monitor, store_monitor_cb, this)g_signal_handlers_disconnect_matched ((priv->store_monitor
), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (store_monitor_cb), (this))
;
625 g_file_monitor_cancel (priv->store_monitor);
626 g_object_unref (priv->store_monitor);
627 }
628
629 if (priv->user_store_monitor) {
630 g_signal_handlers_disconnect_by_func (priv->user_store_monitor, store_monitor_cb, this)g_signal_handlers_disconnect_matched ((priv->user_store_monitor
), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (store_monitor_cb), (this))
;
631 g_file_monitor_cancel (priv->user_store_monitor);
632 g_object_unref (priv->user_store_monitor);
633 }
634
635 if (priv->gtk_store_monitor) {
636 g_signal_handlers_disconnect_by_func (priv->gtk_store_monitor, store_monitor_cb, this)g_signal_handlers_disconnect_matched ((priv->gtk_store_monitor
), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (store_monitor_cb), (this))
;
637 g_file_monitor_cancel (priv->gtk_store_monitor);
638 g_object_unref (priv->gtk_store_monitor);
639 }
640
641 g_bookmark_file_free (priv->store);
642
643 G_OBJECT_CLASS (bookmark_agent_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((bookmark_agent_parent_class)), (((GType) ((20) << (
2))))))))
->finalize (g_obj);
644}
645
646static void
647update_agent (BookmarkAgent *this)
648{
649 BookmarkAgentPrivate *priv = bookmark_agent_get_instance_private (this);
650
651 if (priv->update_path)
2
Assuming field 'update_path' is null
3
Taking false branch
652 priv->update_path (this);
653
654 if (priv->load_store)
4
Assuming field 'load_store' is null
5
Taking false branch
655 priv->load_store (this);
656
657 update_items (this);
6
Calling 'update_items'
658}
659
660static void
661update_items (BookmarkAgent *this)
662{
663 BookmarkAgentPrivate *priv = bookmark_agent_get_instance_private (this);
664
665 gchar **uris = NULL((void*)0);
666 gchar **uris_ordered = NULL((void*)0);
667 gsize n_uris = 0;
668 gint rank = -1;
669 gint rank_corr = -1;
670 gboolean needs_update = FALSE(0);
671 gboolean store_corrupted = FALSE(0);
672 gchar *new_title, *old_title;
673
674 gint i;
675
676 uris = g_bookmark_file_get_uris (priv->store, & n_uris);
677 uris_ordered = g_new0 (gchar *, n_uris + 1)((gchar * *) g_malloc0_n ((n_uris + 1), sizeof (gchar *)));
678 uris_ordered [n_uris] = NULL((void*)0);
679
680 for (i = 0; uris
12.1
'uris' is non-null
&& uris [i]; ++i) {
7
Assuming 'uris' is non-null
8
Loop condition is true. Entering loop body
13
Loop condition is true. Entering loop body
681 rank = get_rank (this, uris [i]);
682
683 if (rank
8.1
'rank' is < 0
13.1
'rank' is < 0
< 0 || rank >= n_uris)
684 rank = i;
685
686 if (uris_ordered [rank]) {
9
Assuming the condition is true
10
Taking true branch
14
Access of 'char *' element in the heap area at index 1
687 store_corrupted = TRUE(!(0));
688 rank_corr = rank;
689
690 for (rank = 0; rank < n_uris; ++rank)
11
Assuming 'rank' is >= 'n_uris'
12
Loop condition is false. Execution continues on line 694
691 if (! uris_ordered [rank])
692 break;
693
694 g_warning (
695 "store corruption [%s] - multiple uris with same rank (%d): [%s] [%s], moving latter to %d",
696 priv->store_path, rank_corr, uris_ordered [rank_corr], uris [i], rank);
697 }
698
699 set_rank (this, uris [i], rank);
700
701 uris_ordered [rank] = uris [i];
702 }
703
704 if (priv->n_items != n_uris)
705 needs_update = TRUE(!(0));
706
707 for (i = 0; ! needs_update && uris_ordered && uris_ordered [i]; ++i) {
708 if (priv->type == BOOKMARK_STORE_USER_DIRS) {
709 new_title = g_bookmark_file_get_title (priv->store, uris_ordered [i], NULL((void*)0));
710 old_title = priv->items [i]->title;
711 if (!new_title && !old_title) {
712 if (strcmp (priv->items [i]->uri, uris_ordered [i]))
713 needs_update = TRUE(!(0));
714 }
715 else if ((new_title && !old_title) || (!new_title && old_title))
716 needs_update = TRUE(!(0));
717 else if (strcmp (old_title, new_title))
718 needs_update = TRUE(!(0));
719 g_free (new_title);
720 }
721 else if (strcmp (priv->items [i]->uri, uris_ordered [i]))
722 needs_update = TRUE(!(0));
723 }
724
725 if (needs_update) {
726 for (i = 0; priv->items && priv->items [i]; ++i)
727 bookmark_item_free (priv->items [i]);
728
729 g_free (priv->items);
730
731 priv->n_items = n_uris;
732 priv->items = g_new0 (BookmarkItem *, priv->n_items + 1)((BookmarkItem * *) g_malloc0_n ((priv->n_items + 1), sizeof
(BookmarkItem *)))
;
733
734 for (i = 0; uris_ordered && uris_ordered [i]; ++i) {
735 priv->items [i] = g_new0 (BookmarkItem, 1)((BookmarkItem *) g_malloc0_n ((1), sizeof (BookmarkItem)));
736 priv->items [i]->uri = g_strdup (uris_ordered [i])g_strdup_inline (uris_ordered [i]);
737 priv->items [i]->title = g_bookmark_file_get_title (priv->store, uris_ordered [i], NULL((void*)0));
738 priv->items [i]->mime_type = g_bookmark_file_get_mime_type (priv->store, uris_ordered [i], NULL((void*)0));
739 #if GLIB_CHECK_VERSION(2,66,0)(2 > (2) || (2 == (2) && 80 > (66)) || (2 == (2
) && 80 == (66) && 2 >= (0)))
740 priv->items [i]->mtime = g_bookmark_file_get_modified_date_time (priv->store, uris_ordered [i], NULL((void*)0));
741 #else
742 priv->items [i]->mtime = g_bookmark_file_get_modified (priv->store, uris_ordered [i], NULL((void*)0));
743 #endif
744 priv->items [i]->app_name = NULL((void*)0);
745 priv->items [i]->app_exec = NULL((void*)0);
746
747 g_bookmark_file_get_icon (priv->store, uris_ordered [i], & priv->items [i]->icon, NULL((void*)0), NULL((void*)0));
748 }
749
750 /* Since the bookmark store for recently-used items is updated by the caller of BookmarkAgent,
751 * we don't emit notifications in that case. The caller will know when to update itself.
752 */
753 if (!TYPE_IS_RECENT (priv->type)((priv->type) == BOOKMARK_STORE_RECENT_APPS || (priv->type
) == BOOKMARK_STORE_RECENT_DOCS)
)
754 g_object_notify (G_OBJECT (this)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((this)), (((GType) ((20) << (2))))))))
, BOOKMARK_AGENT_ITEMS_PROP"items");
755 }
756
757 if (store_corrupted)
758 save_store (this);
759
760 g_strfreev (uris);
761 g_free (uris_ordered);
762}
763
764static void
765save_store (BookmarkAgent *this)
766{
767 BookmarkAgentPrivate *priv = bookmark_agent_get_instance_private (this);
768
769 gchar *dir;
770
771 g_return_if_fail (priv->user_modifiable)do { if ((priv->user_modifiable)) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "priv->user_modifiable"
); return; } } while (0)
;
772
773 priv->needs_sync = TRUE(!(0));
774 priv->update_path (this);
775
776 dir = g_path_get_dirname (priv->store_path);
777 g_mkdir_with_parents (dir, 0700);
778 g_free (dir);
779
780 priv->save_store (this);
781 update_items (this);
782}
783
784static gint
785get_rank (BookmarkAgent *this, const gchar *uri)
786{
787 BookmarkAgentPrivate *priv = bookmark_agent_get_instance_private (this);
788
789 gchar **groups;
790 gint rank;
791
792 gint i;
793
794 if (! priv->reorderable)
795 return -1;
796
797 groups = g_bookmark_file_get_groups (priv->store, uri, NULL((void*)0), NULL((void*)0));
798 rank = -1;
799
800 for (i = 0; groups && groups [i]; ++i) {
801 if (g_str_has_prefix (groups [i], "rank-")(__builtin_constant_p ("rank-")? __extension__ ({ const char *
const __str = (groups [i]); const char * const __prefix = ("rank-"
); gboolean __result = (0); if (__str == ((void*)0) || __prefix
== ((void*)0)) __result = (g_str_has_prefix) (__str, __prefix
); else { const size_t __str_len = strlen (((__str) + !(__str
))); const size_t __prefix_len = strlen (((__prefix) + !(__prefix
))); if (__str_len >= __prefix_len) __result = memcmp (((__str
) + !(__str)), ((__prefix) + !(__prefix)), __prefix_len) == 0
; } __result; }) : (g_str_has_prefix) (groups [i], "rank-") )
) {
802 if (rank >= 0)
803 g_warning (
804 "store corruption - multiple ranks for same uri: [%s] [%s]",
805 priv->store_path, uri);
806
807 rank = atoi (& groups [i] [5]);
808 }
809 }
810
811 g_strfreev (groups);
812
813 return rank;
814}
815
816static void
817set_rank (BookmarkAgent *this, const gchar *uri, gint rank)
818{
819 BookmarkAgentPrivate *priv = bookmark_agent_get_instance_private (this);
820
821 gchar **groups;
822 gchar *group;
823
824 gint i;
825
826 if (! (priv->reorderable && bookmark_agent_has_item (this, uri)))
827 return;
828
829 groups = g_bookmark_file_get_groups (priv->store, uri, NULL((void*)0), NULL((void*)0));
830
831 for (i = 0; groups && groups [i]; ++i)
832 if (g_str_has_prefix (groups [i], "rank-")(__builtin_constant_p ("rank-")? __extension__ ({ const char *
const __str = (groups [i]); const char * const __prefix = ("rank-"
); gboolean __result = (0); if (__str == ((void*)0) || __prefix
== ((void*)0)) __result = (g_str_has_prefix) (__str, __prefix
); else { const size_t __str_len = strlen (((__str) + !(__str
))); const size_t __prefix_len = strlen (((__prefix) + !(__prefix
))); if (__str_len >= __prefix_len) __result = memcmp (((__str
) + !(__str)), ((__prefix) + !(__prefix)), __prefix_len) == 0
; } __result; }) : (g_str_has_prefix) (groups [i], "rank-") )
)
833 g_bookmark_file_remove_group (priv->store, uri, groups [i], NULL((void*)0));
834
835 g_strfreev (groups);
836
837 group = g_strdup_printf ("rank-%d", rank);
838 g_bookmark_file_add_group (priv->store, uri, group);
839 g_free (group);
840}
841
842static void
843load_xbel_store (BookmarkAgent *this)
844{
845 BookmarkAgentPrivate *priv = bookmark_agent_get_instance_private (this);
846
847 gchar **uris = NULL((void*)0);
848
849 GError *error = NULL((void*)0);
850
851 gint i;
852 gboolean success;
853
854 if (!priv->store_path)
855 success = FALSE(0);
856 else {
857 success = g_bookmark_file_load_from_file (priv->store, priv->store_path, & error);
858 }
859
860 if (!success) {
861 g_bookmark_file_free (priv->store);
862 priv->store = g_bookmark_file_new ();
863
864 if (error) {
865 g_debug ("Couldn't load bookmark file [%s]: %s", priv->store_path, error->message);
866 g_error_free (error);
867 } else {
868 g_debug ("Couldn't load bookmark file [NULL]");
869 }
870 return;
871 }
872
873 uris = g_bookmark_file_get_uris (priv->store, NULL((void*)0));
874
875 for (i = 0; uris && uris [i]; ++i)
876 priv->create_item (this, uris [i]);
877
878 g_strfreev (uris);
879}
880
881static void
882load_places_store (BookmarkAgent *this)
883{
884 BookmarkAgentPrivate *priv = bookmark_agent_get_instance_private (this);
885
886 gchar **uris;
887 gchar **groups;
888 gchar **bookmarks = NULL((void*)0);
889
890 gchar *buf, *label, *uri;
891
892 gint i, j, bookmark_len;
893
894 load_xbel_store (this);
895
896 uris = g_bookmark_file_get_uris (priv->store, NULL((void*)0));
897
898 for (i = 0; uris && uris [i]; ++i) {
899 groups = g_bookmark_file_get_groups (priv->store, uris [i], NULL((void*)0), NULL((void*)0));
900
901 for (j = 0; groups && groups [j]; ++j) {
902 if (! strcmp (groups [j], "gtk-bookmarks")) {
903 g_bookmark_file_remove_item (priv->store, uris [i], NULL((void*)0));
904
905 break;
906 }
907 }
908
909 g_strfreev (groups);
910 }
911
912 g_strfreev (uris);
913
914 g_file_get_contents (priv->gtk_store_path, & buf, NULL((void*)0), NULL((void*)0));
915
916 if (buf) {
917 bookmarks = g_strsplit (buf, "\n", -1);
918 g_free (buf);
919 }
920
921 for (i = 0; bookmarks && bookmarks [i]; ++i) {
922 bookmark_len = strlen (bookmarks [i]);
923 if (bookmark_len > 0) {
924 label = strstr (bookmarks[i], " ");
925 if (label != NULL((void*)0))
926 uri = g_strndup (bookmarks [i], bookmark_len - strlen (label));
927 else
928 uri = bookmarks [i];
929 g_bookmark_file_add_group (priv->store, uri, "gtk-bookmarks");
930 priv->create_item (this, uri);
931 if (label != NULL((void*)0)) {
932 label++;
933 if (strlen (label) > 0)
934 g_bookmark_file_set_title (priv->store, uri, label);
935 g_free (uri);
936 }
937 }
938 }
939
940 g_strfreev (bookmarks);
941}
942
943static gchar *
944find_package_data_file (const gchar *filename)
945{
946 const gchar * const *dirs = NULL((void*)0);
947 gchar *path = NULL((void*)0);
948 gint i;
949
950 dirs = g_get_system_data_dirs ();
951
952 for (i = 0; ! path && dirs && dirs [i]; ++i) {
953 path = g_build_filename (dirs [i], PACKAGE"mate-control-center", filename, NULL((void*)0));
954
955 if (! g_file_test (path, G_FILE_TEST_EXISTS)) {
956 g_free (path);
957 path = NULL((void*)0);
958 }
959 }
960
961 return path;
962}
963
964static void
965update_user_spec_path (BookmarkAgent *this)
966{
967 BookmarkAgentPrivate *priv = bookmark_agent_get_instance_private (this);
968
969 gboolean use_user_path;
970 gchar *path = NULL((void*)0);
971
972 BookmarkStoreStatus status;
973
974 use_user_path = priv->user_modifiable &&
975 (priv->needs_sync || g_file_test (priv->user_store_path, G_FILE_TEST_EXISTS));
976
977 if (use_user_path)
978 path = g_strdup (priv->user_store_path)g_strdup_inline (priv->user_store_path);
979 else
980 path = find_package_data_file (priv->store_filename);
981
982 if (use_user_path)
983 status = BOOKMARK_STORE_USER;
984 else if (path && priv->user_modifiable)
985 status = BOOKMARK_STORE_DEFAULT;
986 else if (path)
987 status = BOOKMARK_STORE_DEFAULT_ONLY;
988 else
989 status = BOOKMARK_STORE_ABSENT;
990
991 if (priv->status != status) {
992 priv->status = status;
993 g_object_notify (G_OBJECT (this)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((this)), (((GType) ((20) << (2))))))))
, BOOKMARK_AGENT_STORE_STATUS_PROP"store-status");
994
995 if (priv->user_store_monitor) {
996 g_file_monitor_cancel (priv->user_store_monitor);
997 g_object_unref (priv->user_store_monitor);
998 priv->user_store_monitor = NULL((void*)0);
999 }
1000
1001 if (priv->status == BOOKMARK_STORE_DEFAULT) {
1002 GFile *user_store_file;
1003
1004 user_store_file = g_file_new_for_path (priv->user_store_path);
1005 priv->user_store_monitor = g_file_monitor_file (user_store_file,
1006 0, NULL((void*)0), NULL((void*)0));
1007 if (priv->user_store_monitor) {
1008 g_signal_connect (priv->user_store_monitor, "changed",g_signal_connect_data ((priv->user_store_monitor), ("changed"
), (((GCallback) (store_monitor_cb))), (this), ((void*)0), (GConnectFlags
) 0)
1009 G_CALLBACK (store_monitor_cb), this)g_signal_connect_data ((priv->user_store_monitor), ("changed"
), (((GCallback) (store_monitor_cb))), (this), ((void*)0), (GConnectFlags
) 0)
;
1010 }
1011
1012 g_object_unref (user_store_file);
1013 }
1014 }
1015
1016 if (g_strcmp0 (priv->store_path, path)) {
1017 g_free (priv->store_path);
1018 priv->store_path = path;
1019
1020 if (priv->store_monitor) {
1021 g_file_monitor_cancel (priv->store_monitor);
1022 g_object_unref (priv->store_monitor);
1023 }
1024
1025 if (priv->store_path) {
1026 GFile *store_file;
1027
1028 store_file = g_file_new_for_path (priv->store_path);
1029 priv->store_monitor = g_file_monitor_file (store_file,
1030 0, NULL((void*)0), NULL((void*)0));
1031 if (priv->store_monitor) {
1032 g_signal_connect (priv->store_monitor, "changed",g_signal_connect_data ((priv->store_monitor), ("changed"),
(((GCallback) (store_monitor_cb))), (this), ((void*)0), (GConnectFlags
) 0)
1033 G_CALLBACK (store_monitor_cb), this)g_signal_connect_data ((priv->store_monitor), ("changed"),
(((GCallback) (store_monitor_cb))), (this), ((void*)0), (GConnectFlags
) 0)
;
1034 }
1035
1036 g_object_unref (store_file);
1037 }
1038 }
1039 else
1040 g_free (path);
1041}
1042
1043static void
1044save_xbel_store (BookmarkAgent *this)
1045{
1046 BookmarkAgentPrivate *priv = bookmark_agent_get_instance_private (this);
1047
1048 GError *error = NULL((void*)0);
1049
1050 if (g_bookmark_file_to_file (priv->store, priv->store_path, &error))
1051 return;
1052
1053 if (error) {
1054 g_warning ("Couldn't save bookmark file [%s]: %s", priv->store_path, error->message);
1055 g_error_free (error);
1056 } else {
1057 g_warning ("Couldn't save bookmark file [%s]", priv->store_path);
1058 }
1059}
1060
1061static void
1062create_app_item (BookmarkAgent *this, const gchar *uri)
1063{
1064 BookmarkAgentPrivate *priv = bookmark_agent_get_instance_private (this);
1065
1066 MateDesktopItem *ditem;
1067 gchar *uri_new = NULL((void*)0);
1068
1069 ditem = libslab_mate_desktop_item_new_from_unknown_id (uri);
1070
1071 if (ditem) {
1072 uri_new = g_strdup (mate_desktop_item_get_location (ditem))g_strdup_inline (mate_desktop_item_get_location (ditem));
1073 mate_desktop_item_unref (ditem);
1074 }
1075
1076 if (! uri_new)
1077 return;
1078
1079 if (g_strcmp0 (uri, uri_new))
1080 g_bookmark_file_move_item (priv->store, uri, uri_new, NULL((void*)0));
1081
1082 g_free (uri_new);
1083}
1084
1085static void
1086create_doc_item (BookmarkAgent *this, const gchar *uri)
1087{
1088 BookmarkAgentPrivate *priv = bookmark_agent_get_instance_private (this);
1089
1090 gchar *uri_new = NULL((void*)0);
1091
1092 if ((strcmp (uri, "BLANK_SPREADSHEET") == 0) || (strcmp (uri, "BLANK_DOCUMENT") == 0)) {
1093 gchar *template = NULL((void*)0);
1094 gchar *file;
1095
1096 gchar *dir = g_strdup (g_get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS))g_strdup_inline (g_get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS
))
;
1097 if (!dir)
1098 dir = g_build_filename (g_get_home_dir (), "Documents", NULL((void*)0));
1099
1100 if (strcmp (uri, "BLANK_SPREADSHEET") == 0) {
1101 g_bookmark_file_set_title (priv->store, uri, "BLANK_SPREADSHEET");
1102 file = g_strconcat (_("New Spreadsheet")((char *) g_dgettext ("mate-control-center", "New Spreadsheet"
))
, ".ots", NULL((void*)0));
1103 template = find_package_data_file (CALC_TEMPLATE_FILE_NAME"empty.ots");
1104 } else {
1105 g_bookmark_file_set_title (priv->store, uri, "BLANK_DOCUMENT");
1106 file = g_strconcat (_("New Document")((char *) g_dgettext ("mate-control-center", "New Document")), ".ott", NULL((void*)0));
1107 template = find_package_data_file (WRITER_TEMPLATE_FILE_NAME"empty.ott");
1108 }
1109
1110 gchar *path = g_build_filename (dir, file, NULL((void*)0));
1111 if (!g_file_test (path, G_FILE_TEST_EXISTS)) {
1112 g_mkdir_with_parents (dir, 0700);
1113
1114 if (template != NULL((void*)0)) {
1115 gchar *contents;
1116 gsize length;
1117
1118 if (g_file_get_contents (template, &contents, &length, NULL((void*)0)))
1119 g_file_set_contents (path, contents, length, NULL((void*)0));
1120
1121 g_free (contents);
1122 } else {
1123 fclose (g_fopenfopen (path, "w"));
1124 }
1125 }
1126
1127 uri_new = g_filename_to_uri (path, NULL((void*)0), NULL((void*)0));
1128
1129 g_free (dir);
1130 g_free (file);
1131 g_free (path);
1132 g_free (template);
1133 }
1134
1135 if (!uri_new)
1136 return;
1137
1138 if (g_strcmp0 (uri, uri_new))
1139 g_bookmark_file_move_item (priv->store, uri, uri_new, NULL((void*)0));
1140
1141 g_free (uri_new);
1142}
1143
1144static void
1145create_dir_item (BookmarkAgent *this, const gchar *uri)
1146{
1147 BookmarkAgentPrivate *priv = bookmark_agent_get_instance_private (this);
1148
1149 gchar *uri_new = NULL((void*)0);
1150 gchar *path = NULL((void*)0);
1151 gchar *name = NULL((void*)0);
1152 gchar *icon = NULL((void*)0);
1153
1154 gchar *search_string = NULL((void*)0);
1155
1156 gboolean gotta_free_name = FALSE(0);
1157
1158 if (strcmp (uri, "HOME") == 0) {
1159 uri_new = g_filename_to_uri (g_get_home_dir (), NULL((void*)0), NULL((void*)0));
1160 name = g_strdup (C_("Home folder", "Home"))g_strdup_inline (g_dpgettext ("mate-control-center", "Home folder"
"\004" "Home", strlen ("Home folder") + 1))
;
1161 gotta_free_name = TRUE(!(0));
1162 icon = "user-home";
1163 } else if (strcmp (uri, "DOCUMENTS") == 0) {
1164 path = g_strdup (g_get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS))g_strdup_inline (g_get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS
))
;
1165 if (!path)
1166 path = g_build_filename (g_get_home_dir (), "Documents", NULL((void*)0));
1167 name = _("Documents")((char *) g_dgettext ("mate-control-center", "Documents"));
1168 uri_new = g_filename_to_uri (path, NULL((void*)0), NULL((void*)0));
1169 } else if (strcmp (uri, "DESKTOP") == 0) {
1170 path = g_strdup (g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP))g_strdup_inline (g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP
))
;
1171 if (!path)
1172 path = g_build_filename (g_get_home_dir (), "Desktop", NULL((void*)0));
1173 name = _("Desktop")((char *) g_dgettext ("mate-control-center", "Desktop"));
1174 uri_new = g_filename_to_uri (path, NULL((void*)0), NULL((void*)0));
1175 icon = "user-desktop";
1176 } else if (strcmp (uri, "file:///") == 0) {
1177 icon = "drive-harddisk";
1178 name = _("File System")((char *) g_dgettext ("mate-control-center", "File System"));
1179 } else if (strcmp (uri, "network:") == 0) {
1180 icon = "network-workgroup";
1181 name = _("Network Servers")((char *) g_dgettext ("mate-control-center", "Network Servers"
))
;
1182 } else if (g_str_has_prefix (uri, "x-caja-search")(__builtin_constant_p ("x-caja-search")? __extension__ ({ const
char * const __str = (uri); const char * const __prefix = ("x-caja-search"
); gboolean __result = (0); if (__str == ((void*)0) || __prefix
== ((void*)0)) __result = (g_str_has_prefix) (__str, __prefix
); else { const size_t __str_len = strlen (((__str) + !(__str
))); const size_t __prefix_len = strlen (((__prefix) + !(__prefix
))); if (__str_len >= __prefix_len) __result = memcmp (((__str
) + !(__str)), ((__prefix) + !(__prefix)), __prefix_len) == 0
; } __result; }) : (g_str_has_prefix) (uri, "x-caja-search") )
) {
1183 icon = "system-search";
1184
1185 path = g_build_filename (g_get_user_data_dir (), "caja", "searches", & uri [21], NULL((void*)0));
1186
1187 if (g_file_test (path, G_FILE_TEST_EXISTS)) {
1188 gchar *buf = NULL((void*)0);
1189 g_file_get_contents (path, &buf, NULL((void*)0), NULL((void*)0));
1190
1191 gchar *tag_open_ptr = NULL((void*)0);
1192 gchar *tag_close_ptr = NULL((void*)0);
1193
1194 if (buf) {
1195 tag_open_ptr = strstr (buf, "<text>");
1196 tag_close_ptr = strstr (buf, "</text>");
1197 }
1198
1199 if (tag_open_ptr && tag_close_ptr) {
1200 tag_close_ptr [0] = '\0';
1201 tag_close_ptr [0] = 'a';
1202 search_string = g_strdup_printf ("\"%s\"", &tag_open_ptr[6]);
1203 }
1204
1205 g_free (buf);
1206 }
1207
1208 if (search_string) {
1209 name = search_string;
1210 gotta_free_name = TRUE(!(0));
1211 } else {
1212 name = _("Search")((char *) g_dgettext ("mate-control-center", "Search"));
1213 }
1214 }
1215
1216 if (icon)
1217 g_bookmark_file_set_icon (priv->store, uri, icon, "image/png");
1218
1219 if (name)
1220 g_bookmark_file_set_title (priv->store, uri, name);
1221
1222 if (uri_new && g_strcmp0 (uri, uri_new))
1223 g_bookmark_file_move_item (priv->store, uri, uri_new, NULL((void*)0));
1224
1225 if (gotta_free_name) {
1226 g_free (name);
1227 }
1228
1229 g_free (path);
1230 g_free (uri_new);
1231}
1232
1233static void
1234store_monitor_cb (GFileMonitor *mon, GFile *f1, GFile *f2,
1235 GFileMonitorEvent event_type, gpointer user_data)
1236{
1237 update_agent (BOOKMARK_AGENT (user_data)((((BookmarkAgent*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((bookmark_agent_get_type ()))))))
)
;
1
Calling 'update_agent'
1238}
1239
1240static void
1241weak_destroy_cb (gpointer data, GObject *g_obj)
1242{
1243 instances [GPOINTER_TO_INT (data)((gint) (glong) (data))] = NULL((void*)0);
1244}
diff --git a/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-409fe3.html b/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-409fe3.html new file mode 100644 index 00000000..00c5adae --- /dev/null +++ b/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-409fe3.html @@ -0,0 +1,1796 @@ + + + +theme-thumbnail.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:capplets/common/theme-thumbnail.c
Warning:line 928, column 3
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name theme-thumbnail.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/capplets/common -fcoverage-compilation-dir=/rootdir/capplets/common -resource-dir /usr/bin/../lib/clang/18 -D HAVE_CONFIG_H -I . -I ../.. -D MATECC_DATA_DIR="/usr/local/share/mate-control-center" -D MATELOCALEDIR="/usr/local/share/locale" -D MATEDATADIR="/usr/local/share" -D GTK_ENGINE_DIR="/usr/lib64/gtk-3.0/3.0.0/theming-engines" -D G_LOG_DOMAIN="capplet-common" -D INSTALL_PREFIX="/usr/local" -I ../.. -D PIXMAP_DIR="/usr/local/share/mate-control-center/pixmaps" -I /usr/include/udisks2 -I /usr/include/libgtop-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/libxml2 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/gio-unix-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/dconf -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/startup-notification-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/gio-unix-2.0 -I /usr/include/dconf -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I /usr/include/marco-1 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/gio-unix-2.0 -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I /usr/include/dconf -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -D PIC -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-06-07-044335-13427-1 -x c theme-thumbnail.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#include <config.h>
2#include <unistd.h>
3#include <string.h>
4#include <marco-private/util.h>
5#include <marco-private/theme.h>
6#include <marco-private/theme-parser.h>
7#include <marco-private/preview-widget.h>
8#include <signal.h>
9#include <errno(*__errno_location ()).h>
10#include <math.h>
11
12/* We have to #undef this as marco #defines these. */
13#undef _
14#undef N_
15
16#include <glib.h>
17
18#include "theme-thumbnail.h"
19#include "gtkrc-utils.h"
20#include "capplet-util.h"
21
22typedef struct {
23 gboolean set;
24 gint thumbnail_width;
25 gint thumbnail_height;
26 GByteArray* data;
27 gchar* theme_name;
28 ThemeThumbnailFunc func;
29 gpointer user_data;
30 GDestroyNotify destroy;
31 GIOChannel* channel;
32 guint watch_id;
33} ThemeThumbnailAsyncData;
34
35static ThemeThumbnailAsyncData async_data;
36
37/* Protocol */
38
39/* Our protocol is pretty simple. The parent process will write several strings
40 * (separated by a '\000'). They are the widget theme, the wm theme, the icon
41 * theme, etc. Then, it will wait for the child to write back the data. The
42 * parent expects ICON_SIZE_WIDTH * ICON_SIZE_HEIGHT * 4 bytes of information.
43 * After that, the child is ready for the next theme to render.
44 */
45
46enum {
47 READY_FOR_THEME,
48 READING_TYPE,
49 READING_CONTROL_THEME_NAME,
50 READING_GTK_COLOR_SCHEME,
51 READING_WM_THEME_NAME,
52 READING_ICON_THEME_NAME,
53 READING_APPLICATION_FONT,
54 WRITING_PIXBUF_DATA
55};
56
57typedef struct {
58 gint status;
59 GByteArray* type;
60 GByteArray* control_theme_name;
61 GByteArray* gtk_color_scheme;
62 GByteArray* wm_theme_name;
63 GByteArray* icon_theme_name;
64 GByteArray* application_font;
65} ThemeThumbnailData;
66
67typedef struct {
68 gchar* thumbnail_type;
69 gpointer theme_info;
70 ThemeThumbnailFunc func;
71 gpointer user_data;
72 GDestroyNotify destroy;
73} ThemeQueueItem;
74
75static GList* theme_queue = NULL((void*)0);
76
77static int pipe_to_factory_fd[2];
78static int pipe_from_factory_fd[2];
79
80#define THUMBNAIL_TYPE_META"meta" "meta"
81#define THUMBNAIL_TYPE_GTK"gtk" "gtk"
82#define THUMBNAIL_TYPE_MARCO"marco" "marco"
83#define THUMBNAIL_TYPE_ICON"icon" "icon"
84
85#define META_THUMBNAIL_SIZE128 128
86#define GTK_THUMBNAIL_SIZE96 96
87#define MARCO_THUMBNAIL_WIDTH120 120
88#define MARCO_THUMBNAIL_HEIGHT60 60
89
90static void pixbuf_apply_mask_region(GdkPixbuf* pixbuf, cairo_region_t* region)
91{
92 gint nchannels, rowstride, w, h;
93 guchar *pixels, *p;
94
95 g_return_if_fail (pixbuf)do { if ((pixbuf)) { } else { g_return_if_fail_warning ("capplet-common"
, ((const char*) (__func__)), "pixbuf"); return; } } while (0
)
;
96 g_return_if_fail (region)do { if ((region)) { } else { g_return_if_fail_warning ("capplet-common"
, ((const char*) (__func__)), "region"); return; } } while (0
)
;
97
98 nchannels = gdk_pixbuf_get_n_channels (pixbuf);
99 rowstride = gdk_pixbuf_get_rowstride (pixbuf);
100 pixels = gdk_pixbuf_get_pixels (pixbuf);
101
102 /* we need an alpha channel ... */
103 if (!gdk_pixbuf_get_has_alpha (pixbuf) || nchannels != 4)
104 return;
105
106 for (w = 0; w < gdk_pixbuf_get_width (pixbuf); ++w)
107 for (h = 0; h < gdk_pixbuf_get_height (pixbuf); ++h)
108 {
109 if (!cairo_region_contains_point (region, w, h))
110 {
111 p = pixels + h * rowstride + w * nchannels;
112 if (G_BYTE_ORDER1234 == G_BIG_ENDIAN4321)
113 p[0] = 0x0;
114 else
115 p[3] = 0x0;
116 }
117 }
118
119}
120
121static GdkPixbuf *
122create_folder_icon (char *icon_theme_name)
123{
124 GtkIconTheme *icon_theme;
125 GdkPixbuf *folder_icon = NULL((void*)0);
126 GtkIconInfo *folder_icon_info;
127 gchar *example_icon_name;
128 const gchar *icon_names[5];
129 gint i;
130
131 icon_theme = gtk_icon_theme_new ();
132 gtk_icon_theme_set_custom_theme (icon_theme, icon_theme_name);
133
134 i = 0;
135 /* Get the Example icon name in the theme if specified */
136 example_icon_name = gtk_icon_theme_get_example_icon_name (icon_theme);
137 if (example_icon_name != NULL((void*)0))
138 icon_names[i++] = example_icon_name;
139 icon_names[i++] = "x-directory-normal";
140 icon_names[i++] = "mate-fs-directory";
141 icon_names[i++] = "folder";
142 icon_names[i++] = NULL((void*)0);
143
144 folder_icon_info = gtk_icon_theme_choose_icon (icon_theme, icon_names, 48, GTK_ICON_LOOKUP_FORCE_SIZE);
145 if (folder_icon_info != NULL((void*)0))
146 {
147 folder_icon = gtk_icon_info_load_icon (folder_icon_info, NULL((void*)0));
148 g_object_unref (folder_icon_info);
149 }
150
151 if (folder_icon == NULL((void*)0))
152 {
153 folder_icon = gtk_icon_theme_load_icon (icon_theme,
154 "image-missing",
155 48, 0, NULL((void*)0));
156 }
157
158 g_object_unref (icon_theme);
159 g_free (example_icon_name);
160
161 return folder_icon;
162}
163
164static GdkPixbuf *
165create_meta_theme_pixbuf (ThemeThumbnailData *theme_thumbnail_data)
166{
167 GtkWidget *window;
168 GtkWidget *preview;
169 GtkWidget *vbox;
170 GtkWidget *box;
171 GtkWidget *image_button;
172 GtkWidget *checkbox;
173 GtkWidget *radio;
174
175 GtkRequisition requisition;
176 GtkAllocation allocation;
177 GtkAllocation vbox_allocation;
178 MetaFrameFlags flags;
179 MetaTheme *theme;
180 GdkPixbuf *pixbuf, *icon;
181 int icon_width, icon_height;
182 cairo_region_t *region;
183
184 g_object_set (gtk_settings_get_default (),
185 "gtk-theme-name", (char *) theme_thumbnail_data->control_theme_name->data,
186 "gtk-font-name", (char *) theme_thumbnail_data->application_font->data,
187 "gtk-icon-theme-name", (char *) theme_thumbnail_data->icon_theme_name->data,
188 "gtk-color-scheme", (char *) theme_thumbnail_data->gtk_color_scheme->data,
189 NULL((void*)0));
190
191 theme = meta_theme_load ((char *) theme_thumbnail_data->wm_theme_name->data, NULL((void*)0));
192 if (theme == NULL((void*)0))
193 return NULL((void*)0);
194
195 /* Represent the icon theme */
196 icon = create_folder_icon ((char *) theme_thumbnail_data->icon_theme_name->data);
197 icon_width = gdk_pixbuf_get_width (icon);
198 icon_height = gdk_pixbuf_get_height (icon);
199
200 /* Create a fake window */
201 flags = META_FRAME_ALLOWS_DELETE |
202 META_FRAME_ALLOWS_MENU |
203 META_FRAME_ALLOWS_MINIMIZE |
204 META_FRAME_ALLOWS_MAXIMIZE |
205 META_FRAME_ALLOWS_VERTICAL_RESIZE |
206 META_FRAME_ALLOWS_HORIZONTAL_RESIZE |
207 META_FRAME_HAS_FOCUS |
208 META_FRAME_ALLOWS_SHADE |
209 META_FRAME_ALLOWS_MOVE;
210
211 window = gtk_offscreen_window_new ();
212 preview = meta_preview_new ();
213 gtk_container_add (GTK_CONTAINER (window)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_container_get_type ()))))))
, preview);
214 gtk_widget_show_all (window);
215
216 vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
217 gtk_container_set_border_width (GTK_CONTAINER (vbox)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((vbox)), ((gtk_container_get_type ()))))))
, 6);
218 gtk_container_add (GTK_CONTAINER (preview)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((preview)), ((gtk_container_get_type ()))))))
, vbox);
219
220 image_button = gtk_button_new_with_mnemonic (_("_Open")gettext ("_Open"));
221 gtk_button_set_image (GTK_BUTTON (image_button)((((GtkButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((image_button)), ((gtk_button_get_type ()))))))
, gtk_image_new_from_icon_name ("document-open", GTK_ICON_SIZE_BUTTON));
222
223 gtk_widget_set_halign (image_button, GTK_ALIGN_START);
224 gtk_widget_set_valign (image_button, GTK_ALIGN_START);
225 gtk_widget_show (image_button);
226 gtk_box_pack_start (GTK_BOX (vbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((vbox)), ((gtk_box_get_type ()))))))
, image_button, FALSE(0), FALSE(0), 0);
227 box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
228 gtk_box_pack_start (GTK_BOX (vbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((vbox)), ((gtk_box_get_type ()))))))
, box, FALSE(0), FALSE(0), 0);
229 checkbox = gtk_check_button_new ();
230 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbox)((((GtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((checkbox)), ((gtk_toggle_button_get_type ()))))))
, TRUE(!(0)));
231 gtk_box_pack_start (GTK_BOX (box)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((box)), ((gtk_box_get_type ()))))))
, checkbox, FALSE(0), FALSE(0), 0);
232 radio = gtk_radio_button_new (NULL((void*)0));
233 gtk_box_pack_start (GTK_BOX (box)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((box)), ((gtk_box_get_type ()))))))
, radio, FALSE(0), FALSE(0), 0);
234
235 gtk_widget_show_all (preview);
236
237 meta_preview_set_frame_flags (META_PREVIEW (preview)((((MetaPreview*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((preview)), ((meta_preview_get_type ()))))))
, flags);
238 meta_preview_set_theme (META_PREVIEW (preview)((((MetaPreview*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((preview)), ((meta_preview_get_type ()))))))
, theme);
239 meta_preview_set_title (META_PREVIEW (preview)((((MetaPreview*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((preview)), ((meta_preview_get_type ()))))))
, "");
240
241 gtk_window_set_default_size (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
, META_THUMBNAIL_SIZE128, META_THUMBNAIL_SIZE128);
242
243 gtk_widget_get_preferred_size (window, &requisition, NULL((void*)0));
244 allocation.x = 0;
245 allocation.y = 0;
246 allocation.width = META_THUMBNAIL_SIZE128;
247 allocation.height = META_THUMBNAIL_SIZE128;
248 gtk_widget_size_allocate (window, &allocation);
249 gtk_widget_get_preferred_size (window, &requisition, NULL((void*)0));
250
251 gtk_widget_queue_draw (window);
252 while (gtk_events_pending ())
253 gtk_main_iteration ();
254
255 pixbuf = gtk_offscreen_window_get_pixbuf (GTK_OFFSCREEN_WINDOW (window)((((GtkOffscreenWindow*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((window)), ((gtk_offscreen_window_get_type (
)))))))
);
256
257 gtk_widget_get_allocation (vbox, &vbox_allocation);
258
259 /* Add the icon theme to the pixbuf */
260 gdk_pixbuf_composite (icon, pixbuf,
261 vbox_allocation.x + vbox_allocation.width - icon_width - 5,
262 vbox_allocation.y + vbox_allocation.height - icon_height - 5,
263 icon_width, icon_height,
264 vbox_allocation.x + vbox_allocation.width - icon_width - 5,
265 vbox_allocation.y + vbox_allocation.height - icon_height - 5,
266 1.0, 1.0, GDK_INTERP_BILINEAR, 255);
267 region = meta_preview_get_clip_region (META_PREVIEW (preview)((((MetaPreview*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((preview)), ((meta_preview_get_type ()))))))
,
268 META_THUMBNAIL_SIZE128, META_THUMBNAIL_SIZE128);
269 pixbuf_apply_mask_region (pixbuf, region);
270 cairo_region_destroy (region);
271
272 g_object_unref (icon);
273 gtk_widget_destroy (window);
274 meta_theme_free (theme);
275
276 return pixbuf;
277}
278
279static GdkPixbuf *
280create_gtk_theme_pixbuf (ThemeThumbnailData *theme_thumbnail_data)
281{
282 GtkSettings *settings;
283 GtkWidget *window, *vbox, *box, *image_button, *checkbox, *radio;
284 GtkRequisition requisition;
285 GtkAllocation allocation;
286 GdkPixbuf *pixbuf, *retval;
287 gint width, height;
288
289 settings = gtk_settings_get_default ();
290 g_object_set (settings, "gtk-theme-name", (char *) theme_thumbnail_data->control_theme_name->data,
291 "gtk-color-scheme", (char *) theme_thumbnail_data->gtk_color_scheme->data,
292 NULL((void*)0));
293
294 window = gtk_offscreen_window_new ();
295
296 vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
297 gtk_container_add (GTK_CONTAINER (window)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_container_get_type ()))))))
, vbox);
298 box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
299 gtk_container_set_border_width (GTK_CONTAINER (box)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((box)), ((gtk_container_get_type ()))))))
, 6);
300 gtk_box_pack_start (GTK_BOX (vbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((vbox)), ((gtk_box_get_type ()))))))
, box, FALSE(0), FALSE(0), 0);
301
302 image_button = gtk_button_new_with_mnemonic (_("_Open")gettext ("_Open"));
303 gtk_button_set_image (GTK_BUTTON (image_button)((((GtkButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((image_button)), ((gtk_button_get_type ()))))))
, gtk_image_new_from_icon_name ("document-open", GTK_ICON_SIZE_BUTTON));
304
305 gtk_box_pack_start (GTK_BOX (box)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((box)), ((gtk_box_get_type ()))))))
, image_button, FALSE(0), FALSE(0), 0);
306 checkbox = gtk_check_button_new ();
307 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbox)((((GtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((checkbox)), ((gtk_toggle_button_get_type ()))))))
, TRUE(!(0)));
308 gtk_box_pack_start (GTK_BOX (box)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((box)), ((gtk_box_get_type ()))))))
, checkbox, FALSE(0), FALSE(0), 0);
309 radio = gtk_radio_button_new_from_widget (NULL((void*)0));
310 gtk_box_pack_start (GTK_BOX (box)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((box)), ((gtk_box_get_type ()))))))
, radio, FALSE(0), FALSE(0), 0);
311
312 gtk_widget_show_all (window);
313 gtk_widget_show_all (vbox);
314 gtk_widget_realize (image_button);
315 gtk_widget_realize (gtk_bin_get_child (GTK_BIN (image_button)((((GtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((image_button)), ((gtk_bin_get_type ()))))))
));
316 gtk_widget_realize (checkbox);
317 gtk_widget_realize (radio);
318 gtk_widget_map (image_button);
319 gtk_widget_map (gtk_bin_get_child (GTK_BIN (image_button)((((GtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((image_button)), ((gtk_bin_get_type ()))))))
));
320 gtk_widget_map (checkbox);
321 gtk_widget_map (radio);
322
323 gtk_widget_get_preferred_size (window, &requisition, NULL((void*)0));
324 allocation.x = 0;
325 allocation.y = 0;
326 allocation.width = requisition.width;
327 allocation.height = requisition.height;
328 gtk_widget_size_allocate (window, &allocation);
329 gtk_widget_get_preferred_size (window, &requisition, NULL((void*)0));
330
331 gtk_window_get_size (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
, &width, &height);
332
333 gtk_widget_queue_draw (window);
334 while (gtk_events_pending ())
335 gtk_main_iteration ();
336
337 pixbuf = gtk_offscreen_window_get_pixbuf (GTK_OFFSCREEN_WINDOW (window)((((GtkOffscreenWindow*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((window)), ((gtk_offscreen_window_get_type (
)))))))
);
338
339 retval = gdk_pixbuf_scale_simple (pixbuf,
340 GTK_THUMBNAIL_SIZE96,
341 (int) GTK_THUMBNAIL_SIZE96 * (((double) height) / ((double) width)),
342 GDK_INTERP_BILINEAR);
343 g_object_unref (pixbuf);
344 gtk_widget_destroy (window);
345
346 return retval;
347}
348
349static GdkPixbuf *
350create_marco_theme_pixbuf (ThemeThumbnailData *theme_thumbnail_data)
351{
352 GtkWidget *window, *preview, *dummy;
353 MetaFrameFlags flags;
354 MetaTheme *theme;
355 GtkRequisition requisition;
356 GtkAllocation allocation;
357 GdkPixbuf *pixbuf, *retval;
358 cairo_region_t *region;
359
360 theme = meta_theme_load ((char *) theme_thumbnail_data->wm_theme_name->data, NULL((void*)0));
361 if (theme == NULL((void*)0))
362 return NULL((void*)0);
363
364 flags = META_FRAME_ALLOWS_DELETE |
365 META_FRAME_ALLOWS_MENU |
366 META_FRAME_ALLOWS_MINIMIZE |
367 META_FRAME_ALLOWS_MAXIMIZE |
368 META_FRAME_ALLOWS_VERTICAL_RESIZE |
369 META_FRAME_ALLOWS_HORIZONTAL_RESIZE |
370 META_FRAME_HAS_FOCUS |
371 META_FRAME_ALLOWS_SHADE |
372 META_FRAME_ALLOWS_MOVE;
373
374 window = gtk_offscreen_window_new ();
375 gtk_window_set_default_size (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
, (int) MARCO_THUMBNAIL_WIDTH120 * 1.2, (int) MARCO_THUMBNAIL_HEIGHT60 * 1.2);
376
377 preview = meta_preview_new ();
378 meta_preview_set_frame_flags (META_PREVIEW (preview)((((MetaPreview*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((preview)), ((meta_preview_get_type ()))))))
, flags);
379 meta_preview_set_theme (META_PREVIEW (preview)((((MetaPreview*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((preview)), ((meta_preview_get_type ()))))))
, theme);
380 meta_preview_set_title (META_PREVIEW (preview)((((MetaPreview*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((preview)), ((meta_preview_get_type ()))))))
, "");
381 gtk_container_add (GTK_CONTAINER (window)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_container_get_type ()))))))
, preview);
382
383 dummy = gtk_label_new ("");
384 gtk_container_add (GTK_CONTAINER (preview)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((preview)), ((gtk_container_get_type ()))))))
, dummy);
385
386 gtk_widget_show_all (window);
387
388 gtk_widget_get_preferred_size (window, &requisition, NULL((void*)0));
389 allocation.x = 0;
390 allocation.y = 0;
391 allocation.width = (int) MARCO_THUMBNAIL_WIDTH120 * 1.2;
392 allocation.height = (int) MARCO_THUMBNAIL_HEIGHT60 * 1.2;
393 gtk_widget_size_allocate (window, &allocation);
394 gtk_widget_get_preferred_size (window, &requisition, NULL((void*)0));
395
396 gtk_widget_queue_draw (window);
397 while (gtk_events_pending ())
398 gtk_main_iteration ();
399
400 pixbuf = gtk_offscreen_window_get_pixbuf (GTK_OFFSCREEN_WINDOW (window)((((GtkOffscreenWindow*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((window)), ((gtk_offscreen_window_get_type (
)))))))
);
401
402 region = meta_preview_get_clip_region (META_PREVIEW (preview)((((MetaPreview*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((preview)), ((meta_preview_get_type ()))))))
,
403 MARCO_THUMBNAIL_WIDTH120 * 1.2, MARCO_THUMBNAIL_HEIGHT60 * 1.2);
404 pixbuf_apply_mask_region (pixbuf, region);
405 cairo_region_destroy (region);
406
407 retval = gdk_pixbuf_scale_simple (pixbuf,
408 MARCO_THUMBNAIL_WIDTH120,
409 MARCO_THUMBNAIL_HEIGHT60,
410 GDK_INTERP_BILINEAR);
411 g_object_unref (pixbuf);
412
413 gtk_widget_destroy (window);
414 meta_theme_free (theme);
415
416 return retval;
417}
418
419static GdkPixbuf *
420create_icon_theme_pixbuf (ThemeThumbnailData *theme_thumbnail_data)
421{
422 return create_folder_icon ((char *) theme_thumbnail_data->icon_theme_name->data);
423}
424
425static void
426handle_bytes (const guint8 *buffer,
427 gint bytes_read,
428 ThemeThumbnailData *theme_thumbnail_data)
429{
430 const guint8 *ptr;
431 ptr = buffer;
432
433 while (bytes_read > 0)
434 {
435 guint8 *nil;
436
437 switch (theme_thumbnail_data->status)
438 {
439 case READY_FOR_THEME:
440 theme_thumbnail_data->status = READING_TYPE;
441 /* fall through */
442 case READING_TYPE:
443 nil = memchr (ptr, '\000', bytes_read);
444 if (nil == NULL((void*)0))
445 {
446 g_byte_array_append (theme_thumbnail_data->type, ptr, bytes_read);
447 bytes_read = 0;
448 }
449 else
450 {
451 g_byte_array_append (theme_thumbnail_data->type, ptr, nil - ptr + 1);
452 bytes_read -= (nil - ptr + 1);
453 ptr = nil + 1;
454 theme_thumbnail_data->status = READING_CONTROL_THEME_NAME;
455 }
456 break;
457
458 case READING_CONTROL_THEME_NAME:
459 nil = memchr (ptr, '\000', bytes_read);
460 if (nil == NULL((void*)0))
461 {
462 g_byte_array_append (theme_thumbnail_data->control_theme_name, ptr, bytes_read);
463 bytes_read = 0;
464 }
465 else
466 {
467 g_byte_array_append (theme_thumbnail_data->control_theme_name, ptr, nil - ptr + 1);
468 bytes_read -= (nil - ptr + 1);
469 ptr = nil + 1;
470 theme_thumbnail_data->status = READING_GTK_COLOR_SCHEME;
471 }
472 break;
473
474 case READING_GTK_COLOR_SCHEME:
475 nil = memchr (ptr, '\000', bytes_read);
476 if (nil == NULL((void*)0))
477 {
478 g_byte_array_append (theme_thumbnail_data->gtk_color_scheme, ptr, bytes_read);
479 bytes_read = 0;
480 }
481 else
482 {
483 g_byte_array_append (theme_thumbnail_data->gtk_color_scheme, ptr, nil - ptr + 1);
484 bytes_read -= (nil - ptr + 1);
485 ptr = nil + 1;
486 theme_thumbnail_data->status = READING_WM_THEME_NAME;
487 }
488 break;
489
490 case READING_WM_THEME_NAME:
491 nil = memchr (ptr, '\000', bytes_read);
492 if (nil == NULL((void*)0))
493 {
494 g_byte_array_append (theme_thumbnail_data->wm_theme_name, ptr, bytes_read);
495 bytes_read = 0;
496 }
497 else
498 {
499 g_byte_array_append (theme_thumbnail_data->wm_theme_name, ptr, nil - ptr + 1);
500 bytes_read -= (nil - ptr + 1);
501 ptr = nil + 1;
502 theme_thumbnail_data->status = READING_ICON_THEME_NAME;
503 }
504 break;
505
506 case READING_ICON_THEME_NAME:
507 nil = memchr (ptr, '\000', bytes_read);
508 if (nil == NULL((void*)0))
509 {
510 g_byte_array_append (theme_thumbnail_data->icon_theme_name, ptr, bytes_read);
511 bytes_read = 0;
512 }
513 else
514 {
515 g_byte_array_append (theme_thumbnail_data->icon_theme_name, ptr, nil - ptr + 1);
516 bytes_read -= (nil - ptr + 1);
517 ptr = nil + 1;
518 theme_thumbnail_data->status = READING_APPLICATION_FONT;
519 }
520 break;
521
522 case READING_APPLICATION_FONT:
523 nil = memchr (ptr, '\000', bytes_read);
524 if (nil == NULL((void*)0))
525 {
526 g_byte_array_append (theme_thumbnail_data->application_font, ptr, bytes_read);
527 bytes_read = 0;
528 }
529 else
530 {
531 g_byte_array_append (theme_thumbnail_data->application_font, ptr, nil - ptr + 1);
532 bytes_read -= (nil - ptr + 1);
533 ptr = nil + 1;
534 theme_thumbnail_data->status = WRITING_PIXBUF_DATA;
535 }
536 break;
537
538 default:
539 g_assert_not_reached ()do { g_assertion_message_expr ("capplet-common", "theme-thumbnail.c"
, 539, ((const char*) (__func__)), ((void*)0)); } while (0)
;
540 }
541 }
542}
543
544static gboolean
545message_from_capplet (GIOChannel *source,
546 GIOCondition condition,
547 gpointer data)
548{
549 gchar buffer[1024];
550 GIOStatus status;
551 gsize bytes_read;
552 ThemeThumbnailData *theme_thumbnail_data;
553
554 theme_thumbnail_data = (ThemeThumbnailData *) data;
555 status = g_io_channel_read_chars (source,
556 buffer,
557 1024,
558 &bytes_read,
559 NULL((void*)0));
560
561 switch (status)
562 {
563 case G_IO_STATUS_NORMAL:
564 handle_bytes ((guint8 *) buffer, bytes_read, theme_thumbnail_data);
565
566 if (theme_thumbnail_data->status == WRITING_PIXBUF_DATA)
567 {
568 GdkPixbuf *pixbuf = NULL((void*)0);
569 gint i, rowstride;
570 guchar *pixels;
571 gint width, height;
572 const gchar *type = (const gchar *) theme_thumbnail_data->type->data;
573
574 if (!strcmp (type, THUMBNAIL_TYPE_META"meta"))
575 pixbuf = create_meta_theme_pixbuf (theme_thumbnail_data);
576 else if (!strcmp (type, THUMBNAIL_TYPE_GTK"gtk"))
577 pixbuf = create_gtk_theme_pixbuf (theme_thumbnail_data);
578 else if (!strcmp (type, THUMBNAIL_TYPE_MARCO"marco"))
579 pixbuf = create_marco_theme_pixbuf (theme_thumbnail_data);
580 else if (!strcmp (type, THUMBNAIL_TYPE_ICON"icon"))
581 pixbuf = create_icon_theme_pixbuf (theme_thumbnail_data);
582 else
583 g_assert_not_reached ()do { g_assertion_message_expr ("capplet-common", "theme-thumbnail.c"
, 583, ((const char*) (__func__)), ((void*)0)); } while (0)
;
584
585 if (pixbuf == NULL((void*)0)) {
586 width = height = rowstride = 0;
587 pixels = NULL((void*)0);
588 } else {
589 width = gdk_pixbuf_get_width (pixbuf);
590 height = gdk_pixbuf_get_height (pixbuf);
591 rowstride = gdk_pixbuf_get_rowstride (pixbuf);
592 pixels = gdk_pixbuf_get_pixels (pixbuf);
593 }
594
595 /* Write the pixbuf's size */
596
597 if (write (pipe_from_factory_fd[1], &width, sizeof (width)) == -1)
598 perror ("write error");
599
600 if (write (pipe_from_factory_fd[1], &height, sizeof (height)) == -1)
601 perror ("write error");
602
603 for (i = 0; i < height; i++)
604 {
605 if (write (pipe_from_factory_fd[1], pixels + rowstride * i, width * gdk_pixbuf_get_n_channels (pixbuf)) == -1)
606 perror ("write error");
607 }
608
609 if (pixbuf)
610 g_object_unref (pixbuf);
611 g_byte_array_set_size (theme_thumbnail_data->type, 0);
612 g_byte_array_set_size (theme_thumbnail_data->control_theme_name, 0);
613 g_byte_array_set_size (theme_thumbnail_data->gtk_color_scheme, 0);
614 g_byte_array_set_size (theme_thumbnail_data->wm_theme_name, 0);
615 g_byte_array_set_size (theme_thumbnail_data->icon_theme_name, 0);
616 g_byte_array_set_size (theme_thumbnail_data->application_font, 0);
617 theme_thumbnail_data->status = READY_FOR_THEME;
618 }
619 return TRUE(!(0));
620
621 case G_IO_STATUS_AGAIN:
622 return TRUE(!(0));
623
624 case G_IO_STATUS_EOF:
625 case G_IO_STATUS_ERROR:
626 _exit (0);
627
628 default:
629 g_assert_not_reached ()do { g_assertion_message_expr ("capplet-common", "theme-thumbnail.c"
, 629, ((const char*) (__func__)), ((void*)0)); } while (0)
;
630 }
631
632 return TRUE(!(0));
633}
634
635static void
636generate_next_in_queue (void)
637{
638 ThemeQueueItem *item;
639
640 if (theme_queue == NULL((void*)0))
641 return;
642
643 item = theme_queue->data;
644 theme_queue = g_list_delete_link (theme_queue, g_list_first (theme_queue));
645
646 if (!strcmp (item->thumbnail_type, THUMBNAIL_TYPE_META"meta"))
647 generate_meta_theme_thumbnail_async ((MateThemeMetaInfo *) item->theme_info,
648 item->func,
649 item->user_data,
650 item->destroy);
651 else if (!strcmp (item->thumbnail_type, THUMBNAIL_TYPE_GTK"gtk"))
652 generate_gtk_theme_thumbnail_async ((MateThemeInfo *) item->theme_info,
653 item->func,
654 item->user_data,
655 item->destroy);
656 else if (!strcmp (item->thumbnail_type, THUMBNAIL_TYPE_MARCO"marco"))
657 generate_marco_theme_thumbnail_async ((MateThemeInfo *) item->theme_info,
658 item->func,
659 item->user_data,
660 item->destroy);
661 else if (!strcmp (item->thumbnail_type, THUMBNAIL_TYPE_ICON"icon"))
662 generate_icon_theme_thumbnail_async ((MateThemeIconInfo *) item->theme_info,
663 item->func,
664 item->user_data,
665 item->destroy);
666
667 g_free (item);
668}
669
670static gboolean
671message_from_child (GIOChannel *source,
672 GIOCondition condition,
673 gpointer data)
674{
675 gchar buffer[1024];
676 GIOStatus status;
677 gsize bytes_read;
678
679 if (async_data.set == FALSE(0))
680 return TRUE(!(0));
681
682 if (condition == G_IO_HUP)
683 return FALSE(0);
684
685 status = g_io_channel_read_chars (source,
686 buffer,
687 1024,
688 &bytes_read,
689 NULL((void*)0));
690 switch (status)
691 {
692 case G_IO_STATUS_NORMAL:
693 g_byte_array_append (async_data.data, (guchar *) buffer, bytes_read);
694
695 if (async_data.thumbnail_width == -1 && async_data.data->len >= 2 * sizeof (gint))
696 {
697 async_data.thumbnail_width = *((gint *) async_data.data->data);
698 async_data.thumbnail_height = *(((gint *) async_data.data->data) + 1);
699 g_byte_array_remove_range (async_data.data, 0, 2 * sizeof (gint));
700 }
701
702 if (async_data.thumbnail_width >= 0 && async_data.data->len == async_data.thumbnail_width * async_data.thumbnail_height * 4)
703 {
704 GdkPixbuf *pixbuf = NULL((void*)0);
705
706 if (async_data.thumbnail_width > 0) {
707 gchar *pixels;
708 gint i, rowstride;
709
710 pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE(!(0)), 8, async_data.thumbnail_width, async_data.thumbnail_height);
711 pixels = (gchar *) gdk_pixbuf_get_pixels (pixbuf);
712 rowstride = gdk_pixbuf_get_rowstride (pixbuf);
713
714 for (i = 0; i < async_data.thumbnail_height; ++i)
715 memcpy (pixels + rowstride * i, async_data.data->data + 4 * async_data.thumbnail_width * i, async_data.thumbnail_width * 4);
716 }
717
718 /* callback function needs to ref the pixbuf if it wants to keep it */
719 (* async_data.func) (pixbuf, async_data.theme_name, async_data.user_data);
720
721 if (async_data.destroy)
722 (* async_data.destroy) (async_data.user_data);
723
724 if (pixbuf)
725 g_object_unref (pixbuf);
726
727 /* Clean up async_data */
728 g_free (async_data.theme_name);
729 g_source_remove (async_data.watch_id);
730 g_io_channel_unref (async_data.channel);
731
732 /* reset async_data */
733 async_data.thumbnail_width = -1;
734 async_data.thumbnail_height = -1;
735 async_data.theme_name = NULL((void*)0);
736 async_data.channel = NULL((void*)0);
737 async_data.func = NULL((void*)0);
738 async_data.user_data = NULL((void*)0);
739 async_data.destroy = NULL((void*)0);
740 async_data.set = FALSE(0);
741 g_byte_array_set_size (async_data.data, 0);
742
743 generate_next_in_queue ();
744 }
745 return TRUE(!(0));
746
747 case G_IO_STATUS_AGAIN:
748 return TRUE(!(0));
749
750 case G_IO_STATUS_EOF:
751 case G_IO_STATUS_ERROR:
752 return FALSE(0);
753
754 default:
755 g_assert_not_reached ()do { g_assertion_message_expr ("capplet-common", "theme-thumbnail.c"
, 755, ((const char*) (__func__)), ((void*)0)); } while (0)
;
756 }
757
758 return TRUE(!(0));
759}
760
761static void
762send_thumbnail_request (gchar *thumbnail_type,
763 gchar *gtk_theme_name,
764 gchar *gtk_color_scheme,
765 gchar *marco_theme_name,
766 gchar *icon_theme_name,
767 gchar *application_font)
768{
769 if (write (pipe_to_factory_fd[1], thumbnail_type, strlen (thumbnail_type) + 1) == -1)
770 perror ("write error");
771
772 if (gtk_theme_name)
773 {
774 if (write (pipe_to_factory_fd[1], gtk_theme_name, strlen (gtk_theme_name) + 1) == -1)
775 perror ("write error");
776 }
777 else
778 {
779 if (write (pipe_to_factory_fd[1], "", 1) == -1)
780 perror ("write error");
781 }
782
783 if (gtk_color_scheme)
784 {
785 if (write (pipe_to_factory_fd[1], gtk_color_scheme, strlen (gtk_color_scheme) + 1) == -1)
786 perror ("write error");
787 }
788 else
789 {
790 if (write (pipe_to_factory_fd[1], "", 1) == -1)
791 perror ("write error");
792 }
793
794 if (marco_theme_name)
795 {
796 if (write (pipe_to_factory_fd[1], marco_theme_name, strlen (marco_theme_name) + 1) == -1)
797 perror ("write error");
798 }
799 else
800 {
801 if (write (pipe_to_factory_fd[1], "", 1) == -1)
802 perror ("write error");
803 }
804
805 if (icon_theme_name)
806 {
807 if (write (pipe_to_factory_fd[1], icon_theme_name, strlen (icon_theme_name) + 1) == -1)
808 perror ("write error");
809 }
810 else
811 {
812 if (write (pipe_to_factory_fd[1], "", 1) == -1)
813 perror ("write error");
814 }
815
816 if (application_font)
817 {
818 if (write (pipe_to_factory_fd[1], application_font, strlen (application_font) + 1) == -1)
819 perror ("write error");
820 }
821 else
822 {
823 if (write (pipe_to_factory_fd[1], "Sans 10", strlen ("Sans 10") + 1) == -1)
824 perror ("write error");
825 }
826}
827
828static GdkPixbuf *
829read_pixbuf (void)
830{
831 gint bytes_read, i, j = 0;
832 gint size[2];
833 GdkPixbuf *pixbuf;
834 gint rowstride;
835 guchar *pixels;
836
837 do
838 {
839 bytes_read = read (pipe_from_factory_fd[0], ((guint8*) size) + j, 2 * sizeof (gint));
840 if (bytes_read == 0)
841 goto eof;
842 j += bytes_read;
843 }
844 while (j < 2 * sizeof (gint));
845
846 if (size[0] <= 0 || size[1] <= 0)
847 return NULL((void*)0);
848
849 pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE(!(0)), 8, size[0], size[1]);
850 rowstride = gdk_pixbuf_get_rowstride (pixbuf);
851 pixels = gdk_pixbuf_get_pixels (pixbuf);
852
853 for (i = 0; i < size[1]; i++)
854 {
855 j = 0;
856
857 do
858 {
859 bytes_read = read (pipe_from_factory_fd[0], pixels + rowstride * i + j, size[0] * gdk_pixbuf_get_n_channels (pixbuf) - j);
860
861 if (bytes_read > 0)
862 j += bytes_read;
863 else if (bytes_read == 0)
864 {
865 g_object_unref (pixbuf);
866 goto eof;
867 }
868 }
869 while (j < size[0] * gdk_pixbuf_get_n_channels (pixbuf));
870 }
871
872 return pixbuf;
873
874eof:
875 g_warning ("Received EOF while reading thumbnail");
876 close (pipe_to_factory_fd[1]);
877 pipe_to_factory_fd[1] = 0;
878 close (pipe_from_factory_fd[0]);
879 pipe_from_factory_fd[0] = 0;
880 return NULL((void*)0);
881}
882
883static GdkPixbuf *
884generate_theme_thumbnail (gchar *thumbnail_type,
885 gchar *gtk_theme_name,
886 gchar *gtk_color_scheme,
887 gchar *marco_theme_name,
888 gchar *icon_theme_name,
889 gchar *application_font)
890{
891 if (async_data.set || !pipe_to_factory_fd[1] || !pipe_from_factory_fd[0])
892 return NULL((void*)0);
893
894 send_thumbnail_request (thumbnail_type,
895 gtk_theme_name,
896 gtk_color_scheme,
897 marco_theme_name,
898 icon_theme_name,
899 application_font);
900
901 return read_pixbuf ();
902}
903
904GdkPixbuf *
905generate_meta_theme_thumbnail (MateThemeMetaInfo *theme_info)
906{
907 return generate_theme_thumbnail (THUMBNAIL_TYPE_META"meta",
908 theme_info->gtk_theme_name,
909 theme_info->gtk_color_scheme,
910 theme_info->marco_theme_name,
911 theme_info->icon_theme_name,
912 theme_info->application_font);
913}
914
915GdkPixbuf *
916generate_gtk_theme_thumbnail (MateThemeInfo *theme_info)
917{
918 gchar *scheme;
919
920 scheme = gtkrc_get_color_scheme_for_theme (theme_info->name);
921
922 return generate_theme_thumbnail (THUMBNAIL_TYPE_GTK"gtk",
923 theme_info->name,
924 scheme,
925 NULL((void*)0),
926 NULL((void*)0),
927 NULL((void*)0));
928 g_free (scheme);
This statement is never executed
929}
930
931GdkPixbuf *
932generate_marco_theme_thumbnail (MateThemeInfo *theme_info)
933{
934 return generate_theme_thumbnail (THUMBNAIL_TYPE_MARCO"marco",
935 NULL((void*)0),
936 NULL((void*)0),
937 theme_info->name,
938 NULL((void*)0),
939 NULL((void*)0));
940}
941
942GdkPixbuf *
943generate_icon_theme_thumbnail (MateThemeIconInfo *theme_info)
944{
945 return generate_theme_thumbnail (THUMBNAIL_TYPE_ICON"icon",
946 NULL((void*)0),
947 NULL((void*)0),
948 NULL((void*)0),
949 theme_info->name,
950 NULL((void*)0));
951}
952
953static void generate_theme_thumbnail_async(gpointer theme_info, gchar* theme_name, gchar* thumbnail_type, gchar* gtk_theme_name, gchar* gtk_color_scheme, gchar* marco_theme_name, gchar* icon_theme_name, gchar* application_font, ThemeThumbnailFunc func, gpointer user_data, GDestroyNotify destroy)
954{
955 if (async_data.set)
956 {
957 ThemeQueueItem* item = g_new0 (ThemeQueueItem, 1)((ThemeQueueItem *) g_malloc0_n ((1), sizeof (ThemeQueueItem)
))
;
958
959 item->thumbnail_type = thumbnail_type;
960 item->theme_info = theme_info;
961 item->func = func;
962 item->user_data = user_data;
963 item->destroy = destroy;
964
965 theme_queue = g_list_append(theme_queue, item);
966
967 return;
968 }
969
970 if (!pipe_to_factory_fd[1] || !pipe_from_factory_fd[0])
971 {
972 (*func)(NULL((void*)0), theme_name, user_data);
973
974 if (destroy)
975 {
976 (*destroy)(user_data);
977 }
978
979 return;
980 }
981
982 if (async_data.channel == NULL((void*)0))
983 {
984 async_data.channel = g_io_channel_unix_new(pipe_from_factory_fd[0]);
985
986 g_io_channel_set_flags(async_data.channel, g_io_channel_get_flags (async_data.channel) | G_IO_FLAG_NONBLOCK, NULL((void*)0));
987 g_io_channel_set_encoding(async_data.channel, NULL((void*)0), NULL((void*)0));
988
989 async_data.watch_id = g_io_add_watch(async_data.channel, G_IO_IN | G_IO_HUP, message_from_child, NULL((void*)0));
990 }
991
992 async_data.set = TRUE(!(0));
993 async_data.thumbnail_width = -1;
994 async_data.thumbnail_height = -1;
995 async_data.theme_name = g_strdup(theme_name)g_strdup_inline (theme_name);
996 async_data.func = func;
997 async_data.user_data = user_data;
998 async_data.destroy = destroy;
999
1000 send_thumbnail_request(thumbnail_type, gtk_theme_name, gtk_color_scheme, marco_theme_name, icon_theme_name, application_font);
1001}
1002
1003void
1004generate_meta_theme_thumbnail_async (MateThemeMetaInfo *theme_info,
1005 ThemeThumbnailFunc func,
1006 gpointer user_data,
1007 GDestroyNotify destroy)
1008{
1009 generate_theme_thumbnail_async (theme_info,
1010 theme_info->name,
1011 THUMBNAIL_TYPE_META"meta",
1012 theme_info->gtk_theme_name,
1013 theme_info->gtk_color_scheme,
1014 theme_info->marco_theme_name,
1015 theme_info->icon_theme_name,
1016 theme_info->application_font,
1017 func, user_data, destroy);
1018}
1019
1020void generate_gtk_theme_thumbnail_async (MateThemeInfo* theme_info, ThemeThumbnailFunc func, gpointer user_data, GDestroyNotify destroy)
1021{
1022 gchar* scheme = gtkrc_get_color_scheme_for_theme(theme_info->name);
1023
1024 generate_theme_thumbnail_async(theme_info, theme_info->name, THUMBNAIL_TYPE_GTK"gtk", theme_info->name, scheme, NULL((void*)0), NULL((void*)0), NULL((void*)0), func, user_data, destroy);
1025
1026 g_free(scheme);
1027}
1028
1029void
1030generate_marco_theme_thumbnail_async (MateThemeInfo *theme_info,
1031 ThemeThumbnailFunc func,
1032 gpointer user_data,
1033 GDestroyNotify destroy)
1034{
1035 generate_theme_thumbnail_async (theme_info,
1036 theme_info->name,
1037 THUMBNAIL_TYPE_MARCO"marco",
1038 NULL((void*)0),
1039 NULL((void*)0),
1040 theme_info->name,
1041 NULL((void*)0),
1042 NULL((void*)0),
1043 func, user_data, destroy);
1044}
1045
1046void
1047generate_icon_theme_thumbnail_async (MateThemeIconInfo *theme_info,
1048 ThemeThumbnailFunc func,
1049 gpointer user_data,
1050 GDestroyNotify destroy)
1051{
1052 generate_theme_thumbnail_async (theme_info,
1053 theme_info->name,
1054 THUMBNAIL_TYPE_ICON"icon",
1055 NULL((void*)0),
1056 NULL((void*)0),
1057 NULL((void*)0),
1058 theme_info->name,
1059 NULL((void*)0),
1060 func, user_data, destroy);
1061}
1062
1063void
1064theme_thumbnail_factory_init (int argc, char *argv[])
1065{
1066 gint child_pid;
1067
1068 if (pipe (pipe_to_factory_fd) == -1)
1069 perror ("pipe error");
1070
1071 if (pipe (pipe_from_factory_fd) == -1)
1072 perror ("pipe error");
1073
1074 child_pid = fork ();
1075 if (child_pid == 0)
1076 {
1077 ThemeThumbnailData data;
1078 GIOChannel *channel;
1079
1080 /* Child */
1081 gtk_init (&argc, &argv);
1082
1083 close (pipe_to_factory_fd[1]);
1084 pipe_to_factory_fd[1] = 0;
1085 close (pipe_from_factory_fd[0]);
1086 pipe_from_factory_fd[0] = 0;
1087
1088 data.status = READY_FOR_THEME;
1089 data.type = g_byte_array_new ();
1090 data.control_theme_name = g_byte_array_new ();
1091 data.gtk_color_scheme = g_byte_array_new ();
1092 data.wm_theme_name = g_byte_array_new ();
1093 data.icon_theme_name = g_byte_array_new ();
1094 data.application_font = g_byte_array_new ();
1095
1096 channel = g_io_channel_unix_new (pipe_to_factory_fd[0]);
1097 g_io_channel_set_flags (channel, g_io_channel_get_flags (channel) |
1098 G_IO_FLAG_NONBLOCK, NULL((void*)0));
1099 g_io_channel_set_encoding (channel, NULL((void*)0), NULL((void*)0));
1100 g_io_add_watch (channel, G_IO_IN | G_IO_HUP, message_from_capplet, &data);
1101 g_io_channel_unref (channel);
1102
1103 gtk_main ();
1104 _exit (0);
1105 }
1106
1107 g_assert (child_pid > 0)do { if (child_pid > 0) ; else g_assertion_message_expr ("capplet-common"
, "theme-thumbnail.c", 1107, ((const char*) (__func__)), "child_pid > 0"
); } while (0)
;
1108
1109 /* Parent */
1110 close (pipe_to_factory_fd[0]);
1111 close (pipe_from_factory_fd[1]);
1112
1113 async_data.set = FALSE(0);
1114 async_data.theme_name = NULL((void*)0);
1115 async_data.data = g_byte_array_new ();
1116}
diff --git a/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-434006.html b/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-434006.html new file mode 100644 index 00000000..e74d690e --- /dev/null +++ b/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-434006.html @@ -0,0 +1,1132 @@ + + + +theme-save.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:capplets/appearance/theme-save.c
Warning:line 63, column 4
Access of the heap area at index 4, while it holds only 4 'char' elements
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name theme-save.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/capplets/appearance -fcoverage-compilation-dir=/rootdir/capplets/appearance -resource-dir /usr/bin/../lib/clang/18 -D HAVE_CONFIG_H -I . -I ../.. -I /usr/include/marco-1 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/gio-unix-2.0 -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I ../../capplets/common -I /usr/include/udisks2 -I /usr/include/libgtop-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/libxml2 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/gio-unix-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/dconf -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I ../../ -D G_LOG_DOMAIN="appearance-properties" -I /usr/include/polkit-1 -I /usr/include/gio-unix-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I /usr/include/udisks2 -I /usr/include/libgtop-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/gio-unix-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/libxml2 -I /usr/include/harfbuzz -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/freetype2 -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/dconf -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libpng16 -D WITH_GZFILEOP -I /usr/include/sysprof-6 -I /usr/include/pixman-1 -D MATECC_DATA_DIR="/usr/local/share/mate-control-center" -D MATECC_PIXMAP_DIR="/usr/local/share/mate-control-center/pixmaps" -D WALLPAPER_DATADIR="/usr/local/share/mate-background-properties" -D BACKGROUND_DATADIR="/usr/local/share/backgrounds" -D MATE_DESKTOP_USE_UNSTABLE_API -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-06-07-044335-13427-1 -x c theme-save.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 * Copyright (C) 2007 The GNOME Foundation
3 * Written by Thomas Wood <thos@gnome.org>
4 * Jens Granseuer <jensgr@gmx.net>
5 * All Rights Reserved
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 */
21
22#include "appearance.h"
23
24#include <glib/gstdio.h>
25#include <glib/gi18n.h>
26#include <gio/gio.h>
27#include <string.h>
28
29#include "theme-save.h"
30#include "theme-util.h"
31#include "capplet-util.h"
32
33static GQuark error_quark;
34enum {
35 INVALID_THEME_NAME
36};
37
38/* taken from mate-desktop-item.c */
39static gchar *
40escape_string_and_dup (const gchar *s)
41{
42 gchar *return_value, *p;
43 const gchar *q;
44 int len = 0;
45
46 if (s == NULL((void*)0))
4
Assuming 's' is not equal to NULL
5
Taking false branch
47 return g_strdup("")g_strdup_inline ("");
48
49 q = s;
50 while (*q)
6
Loop condition is true. Entering loop body
9
Loop condition is true. Entering loop body
12
Loop condition is true. Entering loop body
15
Loop condition is false. Execution continues on line 57
51 {
52 len++;
53 if (strchr ("\n\r\t\\", *q) != NULL((void*)0))
7
Assuming the condition is false
8
Taking false branch
10
Assuming the condition is false
11
Taking false branch
13
Assuming the condition is false
14
Taking false branch
54 len++;
55 q++;
56 }
57 return_value = p = (gchar *) g_malloc (len + 1);
58 do
18
Loop condition is true. Execution continues on line 60
21
Loop condition is true. Execution continues on line 60
59 {
60 switch (*s)
16
Control jumps to 'case 92:' at line 74
19
Control jumps to 'case 13:' at line 70
22
Control jumps to 'case 9:' at line 62
61 {
62 case '\t':
63 *p++ = '\\';
23
Access of the heap area at index 4, while it holds only 4 'char' elements
64 *p++ = 't';
65 break;
66 case '\n':
67 *p++ = '\\';
68 *p++ = 'n';
69 break;
70 case '\r':
71 *p++ = '\\';
72 *p++ = 'r';
73 break;
20
Execution continues on line 82
74 case '\\':
75 *p++ = '\\';
76 *p++ = '\\';
77 break;
17
Execution continues on line 82
78 default:
79 *p++ = *s;
80 }
81 }
82 while (*s++);
83 return return_value;
84}
85
86static gboolean
87check_theme_name (const gchar *theme_name,
88 GError **error)
89{
90 if (theme_name == NULL((void*)0)) {
91 g_set_error (error,
92 error_quark,
93 INVALID_THEME_NAME,
94 _("Theme name must be present")gettext ("Theme name must be present"));
95 return FALSE(0);
96 }
97 return TRUE(!(0));
98}
99
100static gchar *
101str_remove_slash (const gchar *src)
102{
103 const gchar *i;
104 gchar *rtn;
105 gint len = 0;
106 i = src;
107
108 while (*i) {
109 if (*i != '/')
110 len++;
111 i++;
112 }
113
114 rtn = (gchar *) g_malloc (len + 1);
115 while (*src) {
116 if (*src != '/') {
117 *rtn = *src;
118 rtn++;
119 }
120 src++;
121 }
122 *rtn = '\0';
123 return rtn - len;
124}
125
126static gboolean
127setup_directory_structure (const gchar *theme_name,
128 GError **error)
129{
130 gchar *dir, *theme_name_dir;
131 gboolean retval = TRUE(!(0));
132
133 theme_name_dir = str_remove_slash (theme_name);
134
135 dir = g_build_filename (g_get_home_dir (), ".themes", NULL((void*)0));
136 if (!g_file_test (dir, G_FILE_TEST_EXISTS))
137 g_mkdirmkdir (dir, 0775);
138 g_free (dir);
139
140 dir = g_build_filename (g_get_home_dir (), ".themes", theme_name_dir, NULL((void*)0));
141 if (!g_file_test (dir, G_FILE_TEST_EXISTS))
142 g_mkdirmkdir (dir, 0775);
143 g_free (dir);
144
145 dir = g_build_filename (g_get_home_dir (), ".themes", theme_name_dir, "index.theme", NULL((void*)0));
146 g_free (theme_name_dir);
147
148 if (g_file_test (dir, G_FILE_TEST_EXISTS)) {
149 GtkDialog *dialog;
150 GtkWidget *button;
151 gint response;
152
153 dialog = (GtkDialog *) gtk_message_dialog_new (NULL((void*)0),
154 GTK_DIALOG_MODAL,
155 GTK_MESSAGE_QUESTION,
156 GTK_BUTTONS_CANCEL,
157 _("The theme already exists. Would you like to replace it?")gettext ("The theme already exists. Would you like to replace it?"
)
);
158 button = gtk_dialog_add_button (dialog, _("_Overwrite")gettext ("_Overwrite"), GTK_RESPONSE_ACCEPT);
159 gtk_button_set_image (GTK_BUTTON (button)((((GtkButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((button)), ((gtk_button_get_type ()))))))
,
160 gtk_image_new_from_icon_name ("document-save", GTK_ICON_SIZE_BUTTON));
161 response = gtk_dialog_run (dialog);
162 gtk_widget_destroy (GTK_WIDGET (dialog)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_widget_get_type ()))))))
);
163 retval = (response != GTK_RESPONSE_CANCEL);
164 }
165 g_free (dir);
166
167 return retval;
168}
169
170static gboolean
171write_theme_to_disk (MateThemeMetaInfo *theme_info,
172 const gchar *theme_name,
173 const gchar *theme_description,
174 gboolean save_background,
175 gboolean save_notification,
176 GError **error)
177{
178 gchar* dir;
179 gchar* theme_name_dir;
180 GFile* tmp_file;
181 GFile* target_file;
182 GOutputStream* output;
183
184 gchar* str;
185 gchar* current_background;
186
187 GSettings* settings;
188 const gchar* theme_header = ""
189 "[Desktop Entry]\n"
190 "Name=%s\n"
191 "Type=X-GNOME-Metatheme\n"
192 "Comment=%s\n"
193 "\n"
194 "[X-GNOME-Metatheme]\n"
195 "GtkTheme=%s\n"
196 "MetacityTheme=%s\n"
197 "IconTheme=%s\n";
198
199 theme_name_dir = str_remove_slash (theme_name);
200 dir = g_build_filename (g_get_home_dir (), ".themes", theme_name_dir, "index.theme~", NULL((void*)0));
201 g_free (theme_name_dir);
202
203 tmp_file = g_file_new_for_path (dir);
204 dir [strlen (dir) - 1] = '\000';
205 target_file = g_file_new_for_path (dir);
206 g_free (dir);
207
208 /* start making the theme file */
209 str = g_strdup_printf(theme_header, theme_name, theme_description, theme_info->gtk_theme_name, theme_info->marco_theme_name, theme_info->icon_theme_name);
210
211 output = G_OUTPUT_STREAM (g_file_replace (tmp_file, NULL, FALSE, G_FILE_CREATE_NONE, NULL, NULL))((((GOutputStream*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((g_file_replace (tmp_file, ((void*)0), (0), G_FILE_CREATE_NONE
, ((void*)0), ((void*)0)))), ((g_output_stream_get_type ())))
)))
;
212 g_output_stream_write (output, str, strlen (str), NULL((void*)0), NULL((void*)0));
213 g_free (str);
214
215 if (theme_info->gtk_color_scheme) {
216 gchar *a, *tmp;
217 tmp = g_strdup (theme_info->gtk_color_scheme)g_strdup_inline (theme_info->gtk_color_scheme);
218 for (a = tmp; *a != '\0'; a++)
219 if (*a == '\n')
220 *a = ',';
221 str = g_strdup_printf ("GtkColorScheme=%s\n", tmp);
222 g_output_stream_write (output, str, strlen (str), NULL((void*)0), NULL((void*)0));
223
224 g_free (str);
225 g_free (tmp);
226 }
227
228 if (theme_info->cursor_theme_name) {
229 str = g_strdup_printf ("CursorTheme=%s\n"
230 "CursorSize=%i\n",
231 theme_info->cursor_theme_name,
232 theme_info->cursor_size);
233 g_output_stream_write (output, str, strlen (str), NULL((void*)0), NULL((void*)0));
234 g_free (str);
235 }
236
237 if (theme_info->notification_theme_name && save_notification) {
238 str = g_strdup_printf ("NotificationTheme=%s\n", theme_info->notification_theme_name);
239 g_output_stream_write (output, str, strlen (str), NULL((void*)0), NULL((void*)0));
240 g_free (str);
241 }
242
243 if (save_background) {
244 settings = g_settings_new (WP_SCHEMA"org.mate.background");
245 current_background = g_settings_get_string (settings, WP_FILE_KEY"picture-filename");
246
247 if (current_background != NULL((void*)0)) {
248 str = g_strdup_printf ("BackgroundImage=%s\n", current_background);
249
250 g_output_stream_write (output, str, strlen (str), NULL((void*)0), NULL((void*)0));
251
252 g_free (current_background);
253 g_free (str);
254 }
255 g_object_unref (settings);
256 }
257
258 g_file_move (tmp_file, target_file, G_FILE_COPY_OVERWRITE, NULL((void*)0), NULL((void*)0), NULL((void*)0), NULL((void*)0));
259 g_output_stream_close (output, NULL((void*)0), NULL((void*)0));
260
261 g_object_unref (tmp_file);
262 g_object_unref (target_file);
263
264 return TRUE(!(0));
265}
266
267static gboolean
268save_theme_to_disk (MateThemeMetaInfo *theme_info,
269 const gchar *theme_name,
270 const gchar *theme_description,
271 gboolean save_background,
272 gboolean save_notification,
273 GError **error)
274{
275 if (!check_theme_name (theme_name, error))
276 return FALSE(0);
277
278 if (!setup_directory_structure (theme_name, error))
279 return FALSE(0);
280
281 if (!write_theme_to_disk (theme_info, theme_name, theme_description, save_background, save_notification, error))
282 return FALSE(0);
283
284 return TRUE(!(0));
285}
286
287static void
288save_dialog_response (GtkWidget *save_dialog,
289 gint response_id,
290 AppearanceData *data)
291{
292 if (response_id == GTK_RESPONSE_OK) {
1
Assuming 'response_id' is equal to GTK_RESPONSE_OK
2
Taking true branch
293 GtkWidget *entry;
294 GtkWidget *text_view;
295 GtkTextBuffer *buffer;
296 GtkTextIter start_iter;
297 GtkTextIter end_iter;
298 gchar *buffer_text;
299 MateThemeMetaInfo *theme_info;
300 gchar *theme_description = NULL((void*)0);
301 gchar *theme_name = NULL((void*)0);
302 gboolean save_background;
303 gboolean save_notification;
304 GError *error = NULL((void*)0);
305
306 entry = appearance_capplet_get_widget (data, "save_dialog_entry")(GtkWidget*) gtk_builder_get_object(data->ui, "save_dialog_entry"
)
;
307 theme_name = escape_string_and_dup (gtk_entry_get_text (GTK_ENTRY (entry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((entry)), ((gtk_entry_get_type ()))))))
))
;
3
Calling 'escape_string_and_dup'
308
309 text_view = appearance_capplet_get_widget (data, "save_dialog_textview")(GtkWidget*) gtk_builder_get_object(data->ui, "save_dialog_textview"
)
;
310 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view)((((GtkTextView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((text_view)), ((gtk_text_view_get_type ()))))))
);
311 gtk_text_buffer_get_start_iter (buffer, &start_iter);
312 gtk_text_buffer_get_end_iter (buffer, &end_iter);
313 buffer_text = gtk_text_buffer_get_text (buffer, &start_iter, &end_iter, FALSE(0));
314 theme_description = escape_string_and_dup (buffer_text);
315 g_free (buffer_text);
316 theme_info = (MateThemeMetaInfo *) g_object_get_data (G_OBJECT (save_dialog)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((save_dialog)), (((GType) ((20) << (2))))))))
, "meta-theme-info");
317 save_background = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (((((GtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (((GtkWidget*) gtk_builder_get_object(data->ui, "save_background_checkbutton"
))), ((gtk_toggle_button_get_type ()))))))
318 appearance_capplet_get_widget (data, "save_background_checkbutton"))((((GtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (((GtkWidget*) gtk_builder_get_object(data->ui, "save_background_checkbutton"
))), ((gtk_toggle_button_get_type ()))))))
);
319 save_notification = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (((((GtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (((GtkWidget*) gtk_builder_get_object(data->ui, "save_notification_checkbutton"
))), ((gtk_toggle_button_get_type ()))))))
320 appearance_capplet_get_widget (data, "save_notification_checkbutton"))((((GtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (((GtkWidget*) gtk_builder_get_object(data->ui, "save_notification_checkbutton"
))), ((gtk_toggle_button_get_type ()))))))
);
321
322 if (save_theme_to_disk (theme_info, theme_name, theme_description, save_background, save_notification, &error)) {
323 /* remove the custom theme */
324 GtkTreeIter iter;
325
326 if (theme_find_in_model (GTK_TREE_MODEL (data->theme_store)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data->theme_store)), ((gtk_tree_model_get_type ()))))
))
, "__custom__", &iter))
327 gtk_list_store_remove (data->theme_store, &iter);
328 }
329
330 g_free (theme_name);
331 g_free (theme_description);
332 g_clear_error (&error);
333 }
334
335 gtk_widget_hide (save_dialog);
336}
337
338static void
339entry_text_changed (GtkEditable *editable,
340 AppearanceData *data)
341{
342 const gchar *text;
343 GtkWidget *button;
344
345 text = gtk_entry_get_text (GTK_ENTRY (editable)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((editable)), ((gtk_entry_get_type ()))))))
);
346 button = appearance_capplet_get_widget (data, "save_dialog_save_button")(GtkWidget*) gtk_builder_get_object(data->ui, "save_dialog_save_button"
)
;
347
348 gtk_widget_set_sensitive (button, text != NULL((void*)0) && text[0] != '\000');
349}
350
351void
352theme_save_dialog_run (MateThemeMetaInfo *theme_info,
353 AppearanceData *data)
354{
355 GtkWidget *entry;
356 GtkWidget *text_view;
357 GtkTextBuffer *text_buffer;
358
359 entry = appearance_capplet_get_widget (data, "save_dialog_entry")(GtkWidget*) gtk_builder_get_object(data->ui, "save_dialog_entry"
)
;
360 text_view = appearance_capplet_get_widget (data, "save_dialog_textview")(GtkWidget*) gtk_builder_get_object(data->ui, "save_dialog_textview"
)
;
361
362 if (data->theme_save_dialog == NULL((void*)0)) {
363 data->theme_save_dialog = appearance_capplet_get_widget (data, "theme_save_dialog")(GtkWidget*) gtk_builder_get_object(data->ui, "theme_save_dialog"
)
;
364
365 g_signal_connect (data->theme_save_dialog, "response", (GCallback) save_dialog_response, data)g_signal_connect_data ((data->theme_save_dialog), ("response"
), ((GCallback) save_dialog_response), (data), ((void*)0), (GConnectFlags
) 0)
;
366 g_signal_connect (data->theme_save_dialog, "delete-event", (GCallback) gtk_true, NULL)g_signal_connect_data ((data->theme_save_dialog), ("delete-event"
), ((GCallback) gtk_true), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
;
367 g_signal_connect (entry, "changed", (GCallback) entry_text_changed, data)g_signal_connect_data ((entry), ("changed"), ((GCallback) entry_text_changed
), (data), ((void*)0), (GConnectFlags) 0)
;
368
369 error_quark = g_quark_from_string ("mate-theme-save");
370 gtk_widget_set_size_request (text_view, 300, 100);
371 }
372
373 gtk_entry_set_text (GTK_ENTRY (entry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((entry)), ((gtk_entry_get_type ()))))))
, "");
374 entry_text_changed (GTK_EDITABLE (entry)((((GtkEditable*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((entry)), ((gtk_editable_get_type ()))))))
, data);
375 gtk_widget_grab_focus (entry);
376
377 text_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view)((((GtkTextView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((text_view)), ((gtk_text_view_get_type ()))))))
);
378 gtk_text_buffer_set_text (text_buffer, "", 0);
379 g_object_set_data (G_OBJECT (data->theme_save_dialog)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data->theme_save_dialog)), (((GType) ((20) << (
2))))))))
, "meta-theme-info", theme_info);
380 gtk_window_set_transient_for (GTK_WINDOW (data->theme_save_dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data->theme_save_dialog)), ((gtk_window_get_type ()))
))))
,
381 GET_WINDOW ("appearance_window")(((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (data->ui, ("appearance_window"
)))), ((gtk_window_get_type ())))))))
);
382 gtk_widget_show (data->theme_save_dialog);
383}
diff --git a/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-465fc6.html b/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-465fc6.html new file mode 100644 index 00000000..d6b5565d --- /dev/null +++ b/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-465fc6.html @@ -0,0 +1,1452 @@ + + + +time-zone.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:capplets/time-admin/src/time-zone.c
Warning:line 145, column 13
Null pointer passed to 1st parameter expecting 'nonnull'
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name time-zone.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/capplets/time-admin/src -fcoverage-compilation-dir=/rootdir/capplets/time-admin/src -resource-dir /usr/bin/../lib/clang/18 -D HAVE_CONFIG_H -I . -I ../../.. -I ../../../capplets/common -I /usr/include/udisks2 -I /usr/include/libgtop-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/libxml2 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/gio-unix-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/dconf -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I ../../../ -D G_LOG_DOMAIN="time-admin-properties" -I /usr/include/polkit-1 -I /usr/include/gio-unix-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -D TIMPZONEDIR="/usr/local/share/mate-time-admin/map/" -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-06-07-044335-13427-1 -x c time-zone.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 * Copyright (C) 2010 Intel, Inc
3 * Copyright (C) 2010-2018 The GNOME Project
4 * Copyright (C) 2018, 2019 zhuyaliang https://github.com/zhuyaliang/
5 * Copyright (C) 2019-2021 MATE Developers
6 *
7 * Portions from Ubiquity, Copyright (C) 2009 Canonical Ltd.
8 * Written by Evan Dandrea <evand@ubuntu.com>
9 *
10 * This program is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 *
23 * Author: Thomas Wood <thomas.wood@intel.com>
24 *
25 */
26
27#ifdef HAVE_CONFIG_H1
28#include "config.h"
29#endif
30#include "time-zone.h"
31#include "time-map.h"
32#include "time-tool.h"
33#include <math.h>
34#define MATE_DESKTOP_USE_UNSTABLE_API
35
36#include <string.h>
37#include <stdio.h>
38#include <stdlib.h>
39#include <glib/gi18n.h>
40
41#include <libmate-desktop/mate-languages.h> /* mate_get_country_from_code */
42
43#define DEFAULT_TZ"Europe/London" "Europe/London"
44#define BACKFILE"/usr/local/share/mate-time-admin/map/" "backward" TIMPZONEDIR"/usr/local/share/mate-time-admin/map/" "backward"
45
46static void LocationChanged(TimezoneMap *map,
47 TzLocation *location,
48 TimeAdmin *ta);
49
50enum {
51 CITY_COL_CITY_HUMAN_READABLE,
52 CITY_COL_ZONE,
53 CITY_NUM_COLS
54};
55
56static gchar*
57tz_data_file_get (void)
58{
59 gchar *file;
60
61 file = g_strdup (TZ_DATA_FILE)g_strdup_inline ("/usr/share/zoneinfo/zone.tab");
62
63 return file;
64}
65
66static float
67convert_pos (gchar *pos, int digits)
68{
69 gchar whole[10], *fraction;
70 gint i;
71 float t1, t2;
72
73 if (!pos || strlen(pos) < 4 || digits > 9)
74 return 0.0;
75
76 for (i = 0; i < digits + 1; i++)
77 whole[i] = pos[i];
78
79 whole[i] = '\0';
80 fraction = pos + digits + 1;
81
82 t1 = g_strtod (whole, NULL((void*)0));
83 t2 = g_strtod (fraction, NULL((void*)0));
84
85 if (t1 >= 0.0)
86 return t1 + t2/pow (10.0, strlen(fraction));
87 else
88 return t1 - t2/pow (10.0, strlen(fraction));
89}
90
91static int compare_country_names (const void *a, const void *b)
92{
93 const TzLocation *tza = * (TzLocation **) a;
94 const TzLocation *tzb = * (TzLocation **) b;
95
96 return strcmp (tza->zone, tzb->zone);
97}
98
99static void sort_locations_by_country (GPtrArray *locations)
100{
101 qsort (locations->pdata, locations->len, sizeof (gpointer),
102 compare_country_names);
103}
104static void load_backward_tz (TzDB *tz_db)
105{
106 FILE *fp;
107 char buf[128] = { 0 };
108
109 tz_db->backward = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
110
111 fp = fopen(BACKFILE"/usr/local/share/mate-time-admin/map/" "backward","r");
112 if(fp == NULL((void*)0))
9
Assuming 'fp' is not equal to NULL
10
Taking false branch
113 {
114 g_error("%s does not exist\r\n",BACKFILE"/usr/local/share/mate-time-admin/map/" "backward");
115
116 }
117 while(fgets(buf,128,fp))
11
Loop condition is true. Entering loop body
118 {
119 g_auto(GStrv)__attribute__((cleanup(glib_auto_cleanup_GStrv))) GStrv items = NULL((void*)0);
120 guint j;
121 char *real, *alias;
122
123 if (g_ascii_strncasecmp (buf, "Link\t", 5) != 0)
12
Assuming the condition is false
13
Taking false branch
124 continue;
125
126 items = g_strsplit (buf, "\t", -1);
127 real = NULL((void*)0);
14
Null pointer value stored to 'real'
128 alias = NULL((void*)0);
129 for (j = 1; items[j] != NULL((void*)0); j++)
15
Assuming the condition is false
130 {
131 if (items[j][0] == '\0')
132 continue;
133 if (real == NULL((void*)0))
134 {
135 real = items[j];
136 continue;
137 }
138 alias = items[j];
139 break;
140 }
141 if (real
15.1
'real' is equal to NULL
== NULL((void*)0) || alias == NULL((void*)0))
142 g_warning ("Could not parse line: %s", buf);
143
144 /* We don't need more than one name for it */
145 if (g_str_equal (real, "Etc/UTC")(strcmp ((const char *) (real), (const char *) ("Etc/UTC")) ==
0)
||
16
Null pointer passed to 1st parameter expecting 'nonnull'
146 g_str_equal (real, "Etc/UCT")(strcmp ((const char *) (real), (const char *) ("Etc/UCT")) ==
0)
)
147 real = "Etc/GMT";
148
149 g_hash_table_insert (tz_db->backward, g_strdup (alias)g_strdup_inline (alias), g_strdup (real)g_strdup_inline (real));
150
151 }
152 fclose(fp);
153}
154
155TzDB *tz_load_db (void)
156{
157 g_autofree__attribute__((cleanup(g_autoptr_cleanup_generic_gfree))) gchar *tz_data_file = NULL((void*)0);
158 TzDB *tz_db;
159 FILE *tzfile;
160 char buf[4096];
161
162 tz_data_file = tz_data_file_get ();
163 if (!tz_data_file)
3
Assuming 'tz_data_file' is non-null
4
Taking false branch
164 {
165 g_warning ("Could not get the TimeZone data file name");
166 return NULL((void*)0);
167 }
168 tzfile = fopen (tz_data_file, "r");
169 if (!tzfile)
5
Assuming 'tzfile' is non-null
6
Taking false branch
170 {
171 g_warning ("Could not open *%s*\n", tz_data_file);
172 return NULL((void*)0);
173 }
174
175 tz_db = g_new0 (TzDB, 1)((TzDB *) g_malloc0_n ((1), sizeof (TzDB)));
176 tz_db->locations = g_ptr_array_new ();
177
178 while (fgets (buf, sizeof(buf), tzfile))
7
Loop condition is false. Execution continues on line 228
179 {
180 g_auto(GStrv)__attribute__((cleanup(glib_auto_cleanup_GStrv))) GStrv tmpstrarr = NULL((void*)0);
181 g_autofree__attribute__((cleanup(g_autoptr_cleanup_generic_gfree))) gchar *latstr = NULL((void*)0);
182 g_autofree__attribute__((cleanup(g_autoptr_cleanup_generic_gfree))) gchar *lngstr = NULL((void*)0);
183 gchar *p;
184 TzLocation *loc;
185
186 if (*buf == '#')
187 continue;
188
189 g_strchomp(buf);
190 tmpstrarr = g_strsplit(buf,"\t", 6);
191
192 latstr = g_strdup (tmpstrarr[1])g_strdup_inline (tmpstrarr[1]);
193 p = latstr + 1;
194 while (*p != '-' && *p != '+')
195 p++;
196 lngstr = g_strdup (p)g_strdup_inline (p);
197 *p = '\0';
198
199 loc = g_new0 (TzLocation, 1)((TzLocation *) g_malloc0_n ((1), sizeof (TzLocation)));
200 loc->country = g_strdup (tmpstrarr[0])g_strdup_inline (tmpstrarr[0]);
201 loc->zone = g_strdup (tmpstrarr[2])g_strdup_inline (tmpstrarr[2]);
202 loc->latitude = convert_pos (latstr, 2);
203 loc->longitude = convert_pos (lngstr, 3);
204
205#ifdef __sun
206 if (tmpstrarr[3] && *tmpstrarr[3] == '-' && tmpstrarr[4])
207 loc->comment = g_strdup (tmpstrarr[4])g_strdup_inline (tmpstrarr[4]);
208
209 if (tmpstrarr[3] && *tmpstrarr[3] != '-' && !islower(loc->zone))
210 {
211 TzLocation *locgrp;
212 locgrp = g_new0 (TzLocation, 1)((TzLocation *) g_malloc0_n ((1), sizeof (TzLocation)));
213 locgrp->country = g_strdup (tmpstrarr[0])g_strdup_inline (tmpstrarr[0]);
214 locgrp->zone = g_strdup (tmpstrarr[3])g_strdup_inline (tmpstrarr[3]);
215 locgrp->latitude = convert_pos (latstr, 2);
216 locgrp->longitude = convert_pos (lngstr, 3);
217 locgrp->comment = (tmpstrarr[4]) ? g_strdup (tmpstrarr[4])g_strdup_inline (tmpstrarr[4]) : NULL((void*)0);
218
219 g_ptr_array_add (tz_db->locations, (gpointer) locgrp);
220 }
221#else
222 loc->comment = (tmpstrarr[3]) ? g_strdup(tmpstrarr[3])g_strdup_inline (tmpstrarr[3]) : NULL((void*)0);
223#endif
224
225 g_ptr_array_add (tz_db->locations, (gpointer) loc);
226 }
227
228 fclose (tzfile);
229
230 /* now sort by country */
231 sort_locations_by_country (tz_db->locations);
232
233 /* Load up the hashtable of backward links */
234 load_backward_tz (tz_db);
8
Calling 'load_backward_tz'
235
236 return tz_db;
237}
238
239static GtkWidget*
240GetTimeZoneMap(TimeAdmin *ta)
241{
242 GtkWidget *map;
243 g_autoptr(GtkEntryCompletion)__attribute__((cleanup(glib_autoptr_cleanup_GtkEntryCompletion
))) GtkEntryCompletion_autoptr
completion = NULL((void*)0);
244
245 map = (GtkWidget *) timezone_map_new ();
246 g_signal_connect (map,g_signal_connect_data ((map), ("location-changed"), (((GCallback
) (LocationChanged))), (ta), ((void*)0), (GConnectFlags) 0)
247 "location-changed",g_signal_connect_data ((map), ("location-changed"), (((GCallback
) (LocationChanged))), (ta), ((void*)0), (GConnectFlags) 0)
248 G_CALLBACK (LocationChanged),g_signal_connect_data ((map), ("location-changed"), (((GCallback
) (LocationChanged))), (ta), ((void*)0), (GConnectFlags) 0)
249 ta)g_signal_connect_data ((map), ("location-changed"), (((GCallback
) (LocationChanged))), (ta), ((void*)0), (GConnectFlags) 0)
;
250
251 completion = gtk_entry_completion_new ();
252 gtk_entry_set_completion (GTK_ENTRY (ta->TimezoneEntry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((ta->TimezoneEntry)), ((gtk_entry_get_type ()))))))
, completion);
253 gtk_entry_completion_set_model (completion, GTK_TREE_MODEL (ta->CityListStore)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((ta->CityListStore)), ((gtk_tree_model_get_type ()))))
))
);
254 gtk_entry_completion_set_text_column (completion, CITY_COL_CITY_HUMAN_READABLE);
255
256 return map;
257}
258static char *
259translated_city_name (TzLocation *loc)
260{
261 g_autofree__attribute__((cleanup(g_autoptr_cleanup_generic_gfree))) gchar *zone_translated = NULL((void*)0);
262 g_auto(GStrv)__attribute__((cleanup(glib_auto_cleanup_GStrv))) GStrv split_translated = NULL((void*)0);
263 g_autofree__attribute__((cleanup(g_autoptr_cleanup_generic_gfree))) gchar *country = NULL((void*)0);
264 gchar *name;
265 gint length;
266
267 zone_translated = g_strdup (_(loc->zone))g_strdup_inline (gettext (loc->zone));
268 g_strdelimit (zone_translated, "_", ' ');
269 split_translated = g_regex_split_simple ("[\\x{2044}\\x{2215}\\x{29f8}\\x{ff0f}/]",
270 zone_translated,
271 0, 0);
272
273 length = g_strv_length (split_translated);
274
275 country = mate_get_country_from_code (loc->country, NULL((void*)0));
276 name = g_strdup_printf (C_("timezone loc", "%s, %s")g_dpgettext (((void*)0), "timezone loc" "\004" "%s, %s", strlen
("timezone loc") + 1)
,
277 split_translated[length-1],
278 country);
279
280 return name;
281}
282
283static void
284update_timezone (TimezoneMap *map)
285{
286 g_autofree__attribute__((cleanup(g_autoptr_cleanup_generic_gfree))) gchar *bubble_text = NULL((void*)0);
287 g_autoptr(GDateTime)__attribute__((cleanup(glib_autoptr_cleanup_GDateTime))) GDateTime_autoptr current_date = NULL((void*)0);
288 g_autoptr(GTimeZone)__attribute__((cleanup(glib_autoptr_cleanup_GTimeZone))) GTimeZone_autoptr timezone = NULL((void*)0);
289 g_autofree__attribute__((cleanup(g_autoptr_cleanup_generic_gfree))) gchar *city_country = NULL((void*)0);
290 g_autofree__attribute__((cleanup(g_autoptr_cleanup_generic_gfree))) gchar *utc_label = NULL((void*)0);
291 g_autofree__attribute__((cleanup(g_autoptr_cleanup_generic_gfree))) gchar *time_label = NULL((void*)0);
292 g_autofree__attribute__((cleanup(g_autoptr_cleanup_generic_gfree))) gchar *tz_desc = NULL((void*)0);
293 TzLocation *current_location;
294 GDateTime *date;
295
296 current_location = timezone_map_get_location (TIMEZONEMAP (map)((((TimezoneMap*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((map)), ((timezone_map_get_type ()))))))
);
297 city_country = translated_city_name (current_location);
298
299#if GLIB_CHECK_VERSION (2, 68, 0)(2 > (2) || (2 == (2) && 80 > (68)) || (2 == (2
) && 80 == (68) && 2 >= (0)))
300 if ((timezone = g_time_zone_new_identifier (current_location->zone)) == NULL((void*)0)) {
301 timezone_map_set_bubble_text (TIMEZONEMAP (map)((((TimezoneMap*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((map)), ((timezone_map_get_type ()))))))
,
302 _("Error: timezone identifier cannot be parsed or loaded")gettext ("Error: timezone identifier cannot be parsed or loaded"
)
);
303 return;
304 }
305#else
306 timezone = g_time_zone_new (current_location->zone);
307#endif
308
309 current_date = g_date_time_new_now_local ();
310 date = g_date_time_to_timezone (current_date, timezone);
311
312 utc_label = g_date_time_format (date, _("UTC%:::z")gettext ("UTC%:::z"));
313
314 tz_desc = g_strdup_printf ( "%s (%s)",
315 g_date_time_get_timezone_abbreviation (date),
316 utc_label);
317 time_label = g_date_time_format (date, _("%R")gettext ("%R"));
318
319 bubble_text = g_strdup_printf ("<b>%s</b>\n"
320 "<small>%s</small>\n"
321 "<b>%s</b>",
322 tz_desc,
323 city_country,
324 time_label);
325 timezone_map_set_bubble_text (TIMEZONEMAP (map)((((TimezoneMap*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((map)), ((timezone_map_get_type ()))))))
, bubble_text);
326 g_date_time_unref(date);
327}
328
329static void
330LocationChanged(TimezoneMap *map,
331 TzLocation *location,
332 TimeAdmin *ta)
333{
334 update_timezone (map);
335}
336
337static void
338get_initial_timezone (TimeAdmin *ta)
339{
340 const gchar *timezone;
341
342 timezone = GetTimeZone(ta);
343
344 if (timezone == NULL((void*)0) ||
345 !timezone_map_set_timezone (TIMEZONEMAP (ta->map)((((TimezoneMap*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((ta->map)), ((timezone_map_get_type ()))))))
, timezone))
346 {
347 g_warning ("Timezone '%s' is unhandled,setting %s as default", timezone ? timezone : "(null)", DEFAULT_TZ"Europe/London");
348 timezone_map_set_timezone (TIMEZONEMAP (ta->map)((((TimezoneMap*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((ta->map)), ((timezone_map_get_type ()))))))
, DEFAULT_TZ"Europe/London");
349 }
350 update_timezone (TIMEZONEMAP(ta->map)((((TimezoneMap*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((ta->map)), ((timezone_map_get_type ()))))))
);
351}
352
353static void
354LoadCities (TzLocation *loc,
355 GtkListStore *CityStore)
356{
357 g_autofree__attribute__((cleanup(g_autoptr_cleanup_generic_gfree))) gchar *human_readable = NULL((void*)0);
358
359 human_readable = translated_city_name (loc);
360 gtk_list_store_insert_with_values (CityStore,
361 NULL((void*)0),
362 0,
363 CITY_COL_CITY_HUMAN_READABLE,
364 human_readable,
365 CITY_COL_ZONE,
366 loc->zone,
367 -1);
368}
369
370static void
371CreateCityList(TimeAdmin *ta)
372{
373 TzDB *db;
374
375 ta->CityListStore = gtk_list_store_new (CITY_NUM_COLS, G_TYPE_STRING((GType) ((16) << (2))), G_TYPE_STRING((GType) ((16) << (2))));
376 if ((db = tz_load_db ()) != NULL((void*)0)) {
2
Calling 'tz_load_db'
377 g_ptr_array_foreach (db->locations, (GFunc) LoadCities, ta->CityListStore);
378 TimeZoneDateBaseFree (db);
379 }
380}
381
382static GtkWidget*
383CreateZoneFrame(TimeAdmin *ta)
384{
385 GtkWidget *TimeZoneFrame;
386
387 TimeZoneFrame = gtk_frame_new (_("Time Zone")gettext ("Time Zone"));
388 gtk_widget_set_size_request(TimeZoneFrame,300,200);
389 gtk_frame_set_shadow_type(GTK_FRAME(TimeZoneFrame)((((GtkFrame*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((TimeZoneFrame)), ((gtk_frame_get_type ()))))))
,GTK_SHADOW_NONE);
390
391 return TimeZoneFrame;
392}
393
394static GtkWidget*
395CreateZoneScrolled(TimeAdmin *ta)
396{
397 GtkWidget *Scrolled;
398
399 Scrolled = gtk_scrolled_window_new (NULL((void*)0), NULL((void*)0));
400
401 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (Scrolled)((((GtkScrolledWindow*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((Scrolled)), ((gtk_scrolled_window_get_type
()))))))
,
402 GTK_POLICY_AUTOMATIC,
403 GTK_POLICY_AUTOMATIC);
404
405 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (Scrolled)((((GtkScrolledWindow*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((Scrolled)), ((gtk_scrolled_window_get_type
()))))))
,
406 GTK_SHADOW_IN);
407
408 return Scrolled;
409}
410
411static void
412CreateZoneEntry(TimeAdmin *ta)
413{
414 GtkWidget *hbox;
415
416 ta->TimezoneEntry = gtk_search_entry_new ();
417 hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
418 gtk_widget_set_halign (hbox, GTK_ALIGN_CENTER);
419 gtk_box_pack_start (GTK_BOX (hbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((hbox)), ((gtk_box_get_type ()))))))
, ta->TimezoneEntry, FALSE(0), FALSE(0), 0);
420
421 ta->SearchBar = gtk_search_bar_new ();
422 gtk_search_bar_connect_entry (GTK_SEARCH_BAR (ta->SearchBar)((((GtkSearchBar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((ta->SearchBar)), ((gtk_search_bar_get_type ()))))))
,
423 GTK_ENTRY (ta->TimezoneEntry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((ta->TimezoneEntry)), ((gtk_entry_get_type ()))))))
);
424 gtk_search_bar_set_show_close_button (GTK_SEARCH_BAR (ta->SearchBar)((((GtkSearchBar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((ta->SearchBar)), ((gtk_search_bar_get_type ()))))))
,FALSE(0));
425 gtk_container_add (GTK_CONTAINER (ta->SearchBar)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((ta->SearchBar)), ((gtk_container_get_type ()))))))
, hbox);
426 gtk_search_bar_set_search_mode(GTK_SEARCH_BAR(ta->SearchBar)((((GtkSearchBar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((ta->SearchBar)), ((gtk_search_bar_get_type ()))))))
,TRUE(!(0)));
427}
428
429static gboolean
430CityChanged(GtkEntryCompletion *completion,
431 GtkTreeModel *model,
432 GtkTreeIter *iter,
433 TimeAdmin *self)
434{
435 GtkWidget *entry;
436 g_autofree__attribute__((cleanup(g_autoptr_cleanup_generic_gfree))) gchar *zone = NULL((void*)0);
437
438 gtk_tree_model_get (model,
439 iter,
440 CITY_COL_ZONE,
441 &zone,
442 -1);
443 timezone_map_set_timezone (TIMEZONEMAP (self->map)((((TimezoneMap*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((self->map)), ((timezone_map_get_type ()))))))
, zone);
444
445 entry = gtk_entry_completion_get_entry (completion);
446 gtk_entry_set_text (GTK_ENTRY (entry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((entry)), ((gtk_entry_get_type ()))))))
, "");
447
448 return TRUE(!(0));
449}
450
451static void
452ChoooseTimezoneDone (GtkWidget *widget,
453 TimeAdmin *ta)
454{
455 TimezoneMap *map;
456
457 map = TIMEZONEMAP(ta->map)((((TimezoneMap*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((ta->map)), ((timezone_map_get_type ()))))))
;
458 SetTimeZone(ta->proxy,map->location->zone);
459 gtk_entry_set_text (GTK_ENTRY (ta->TimeZoneEntry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((ta->TimeZoneEntry)), ((gtk_entry_get_type ()))))))
, _(map->location->zone)gettext (map->location->zone));
460 gtk_widget_hide_on_delete(GTK_WIDGET(ta->dialog)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((ta->dialog)), ((gtk_widget_get_type ()))))))
);
461}
462
463static void
464ChoooseTimezoneClose(GtkWidget *widget,
465 TimeAdmin *ta)
466{
467 gtk_widget_hide_on_delete(GTK_WIDGET(ta->dialog)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((ta->dialog)), ((gtk_widget_get_type ()))))))
);
468}
469
470void SetupTimezoneDialog(TimeAdmin *ta)
471{
472 GtkWidget *Vbox, *TimeZoneFrame, *Scrolled, *image;
473
474 ta->dialog = gtk_dialog_new_with_buttons (_("Time Zone Selection")gettext ("Time Zone Selection"),
475 NULL((void*)0),
476 GTK_DIALOG_DESTROY_WITH_PARENT,
477 NULL((void*)0),
478 NULL((void*)0));
479 gtk_window_set_default_size (GTK_WINDOW (ta->dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((ta->dialog)), ((gtk_window_get_type ()))))))
, 730, 520);
480
481 ta->TZclose = gtk_button_new_with_mnemonic (_("_Close")gettext ("_Close"));
482 image = gtk_image_new_from_icon_name ("window-close", GTK_ICON_SIZE_BUTTON);
483 gtk_button_set_image (GTK_BUTTON (ta->TZclose)((((GtkButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((ta->TZclose)), ((gtk_button_get_type ()))))))
, image);
484 gtk_button_set_use_underline (GTK_BUTTON (ta->TZclose)((((GtkButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((ta->TZclose)), ((gtk_button_get_type ()))))))
, TRUE(!(0)));
485 gtk_style_context_add_class (gtk_widget_get_style_context (ta->TZclose), "text-button");
486 gtk_widget_set_can_default (ta->TZclose, TRUE(!(0)));
487 gtk_dialog_add_action_widget (GTK_DIALOG (ta->dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((ta->dialog)), ((gtk_dialog_get_type ()))))))
, ta->TZclose, GTK_RESPONSE_CANCEL);
488
489 ta->TZconfire = gtk_button_new_with_mnemonic (_("Con_firm")gettext ("Con_firm"));
490 image = gtk_image_new_from_icon_name ("emblem-default", GTK_ICON_SIZE_BUTTON);
491 gtk_button_set_image (GTK_BUTTON (ta->TZconfire)((((GtkButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((ta->TZconfire)), ((gtk_button_get_type ()))))))
, image);
492 gtk_button_set_use_underline (GTK_BUTTON (ta->TZconfire)((((GtkButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((ta->TZconfire)), ((gtk_button_get_type ()))))))
, TRUE(!(0)));
493 gtk_style_context_add_class (gtk_widget_get_style_context (ta->TZconfire), "text-button");
494 gtk_widget_set_can_default (ta->TZconfire, TRUE(!(0)));
495 gtk_dialog_add_action_widget (GTK_DIALOG (ta->dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((ta->dialog)), ((gtk_dialog_get_type ()))))))
, ta->TZconfire, GTK_RESPONSE_OK);
496
497 g_signal_connect (ta->TZconfire,g_signal_connect_data ((ta->TZconfire), ("clicked"), (((GCallback
) (ChoooseTimezoneDone))), (ta), ((void*)0), (GConnectFlags) 0
)
498 "clicked",g_signal_connect_data ((ta->TZconfire), ("clicked"), (((GCallback
) (ChoooseTimezoneDone))), (ta), ((void*)0), (GConnectFlags) 0
)
499 G_CALLBACK (ChoooseTimezoneDone),g_signal_connect_data ((ta->TZconfire), ("clicked"), (((GCallback
) (ChoooseTimezoneDone))), (ta), ((void*)0), (GConnectFlags) 0
)
500 ta)g_signal_connect_data ((ta->TZconfire), ("clicked"), (((GCallback
) (ChoooseTimezoneDone))), (ta), ((void*)0), (GConnectFlags) 0
)
;
501
502 g_signal_connect (ta->TZclose,g_signal_connect_data ((ta->TZclose), ("clicked"), (((GCallback
) (ChoooseTimezoneClose))), (ta), ((void*)0), (GConnectFlags)
0)
503 "clicked",g_signal_connect_data ((ta->TZclose), ("clicked"), (((GCallback
) (ChoooseTimezoneClose))), (ta), ((void*)0), (GConnectFlags)
0)
504 G_CALLBACK (ChoooseTimezoneClose),g_signal_connect_data ((ta->TZclose), ("clicked"), (((GCallback
) (ChoooseTimezoneClose))), (ta), ((void*)0), (GConnectFlags)
0)
505 ta)g_signal_connect_data ((ta->TZclose), ("clicked"), (((GCallback
) (ChoooseTimezoneClose))), (ta), ((void*)0), (GConnectFlags)
0)
;
506
507 Vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
508 gtk_style_context_add_class (gtk_widget_get_style_context (Vbox), "linked");
509
510 TimeZoneFrame = CreateZoneFrame(ta);
511 Scrolled = CreateZoneScrolled(ta);
512 gtk_container_add (GTK_CONTAINER (TimeZoneFrame)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((TimeZoneFrame)), ((gtk_container_get_type ()))))))
, Scrolled);
513 CreateCityList(ta);
1
Calling 'CreateCityList'
514 CreateZoneEntry(ta);
515 gtk_box_pack_start (GTK_BOX (Vbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((Vbox)), ((gtk_box_get_type ()))))))
, ta->SearchBar,FALSE(0),FALSE(0), 0);
516 ta->map = GetTimeZoneMap(ta);
517 gtk_widget_show (ta->map);
518 gtk_container_add (GTK_CONTAINER (Scrolled)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((Scrolled)), ((gtk_container_get_type ()))))))
,ta->map);
519 gtk_box_pack_start(GTK_BOX(Vbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((Vbox)), ((gtk_box_get_type ()))))))
,TimeZoneFrame,TRUE(!(0)),TRUE(!(0)),10);
520 get_initial_timezone(ta);
521
522 g_signal_connect(gtk_entry_get_completion (GTK_ENTRY (ta->TimezoneEntry)),g_signal_connect_data ((gtk_entry_get_completion (((((GtkEntry
*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((ta
->TimezoneEntry)), ((gtk_entry_get_type ())))))))), ("match-selected"
), (((GCallback) (CityChanged))), (ta), ((void*)0), (GConnectFlags
) 0)
523 "match-selected",g_signal_connect_data ((gtk_entry_get_completion (((((GtkEntry
*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((ta
->TimezoneEntry)), ((gtk_entry_get_type ())))))))), ("match-selected"
), (((GCallback) (CityChanged))), (ta), ((void*)0), (GConnectFlags
) 0)
524 G_CALLBACK (CityChanged),g_signal_connect_data ((gtk_entry_get_completion (((((GtkEntry
*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((ta
->TimezoneEntry)), ((gtk_entry_get_type ())))))))), ("match-selected"
), (((GCallback) (CityChanged))), (ta), ((void*)0), (GConnectFlags
) 0)
525 ta)g_signal_connect_data ((gtk_entry_get_completion (((((GtkEntry
*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((ta
->TimezoneEntry)), ((gtk_entry_get_type ())))))))), ("match-selected"
), (((GCallback) (CityChanged))), (ta), ((void*)0), (GConnectFlags
) 0)
;
526
527 gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (ta->dialog)))((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_dialog_get_content_area (((((GtkDialog*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((ta->dialog)), ((gtk_dialog_get_type (
)))))))))), ((gtk_box_get_type ()))))))
,
528 Vbox,
529 TRUE(!(0)),
530 TRUE(!(0)), 8);
531}
532
533void tz_info_free (TzInfo *tzinfo)
534{
535 g_return_if_fail (tzinfo != NULL)do { if ((tzinfo != ((void*)0))) { } else { g_return_if_fail_warning
("time-admin-properties", ((const char*) (__func__)), "tzinfo != NULL"
); return; } } while (0)
;
536
537 if (tzinfo->tzname_normal) g_free (tzinfo->tzname_normal);
538 if (tzinfo->tzname_daylight) g_free (tzinfo->tzname_daylight);
539 g_free (tzinfo);
540}
541
542struct {
543 const char *orig;
544 const char *dest;
545} aliases[] = {
546 { "Asia/Istanbul", "Europe/Istanbul" }, /* Istanbul is in both Europe and Asia */
547 { "Europe/Nicosia", "Asia/Nicosia" }, /* Ditto */
548 { "EET", "Europe/Istanbul" }, /* Same tz as the 2 above */
549 { "HST", "Pacific/Honolulu" },
550 { "WET", "Europe/Brussels" }, /* Other name for the mainland Europe tz */
551 { "CET", "Europe/Brussels" }, /* ditto */
552 { "MET", "Europe/Brussels" },
553 { "Etc/Zulu", "Etc/GMT" },
554 { "Etc/UTC", "Etc/GMT" },
555 { "GMT", "Etc/GMT" },
556 { "Greenwich", "Etc/GMT" },
557 { "Etc/UCT", "Etc/GMT" },
558 { "Etc/GMT0", "Etc/GMT" },
559 { "Etc/GMT+0", "Etc/GMT" },
560 { "Etc/GMT-0", "Etc/GMT" },
561 { "Etc/Universal", "Etc/GMT" },
562 { "PST8PDT", "America/Los_Angeles" }, /* Other name for the Atlantic tz */
563 { "EST", "America/New_York" }, /* Other name for the Eastern tz */
564 { "EST5EDT", "America/New_York" }, /* ditto */
565 { "CST6CDT", "America/Chicago" }, /* Other name for the Central tz */
566 { "MST", "America/Denver" }, /* Other name for the mountain tz */
567 { "MST7MDT", "America/Denver" }, /* ditto */
568};
569
570static gboolean
571compare_timezones (const char *a,
572 const char *b)
573{
574 if (g_str_equal (a, b)(strcmp ((const char *) (a), (const char *) (b)) == 0))
575 return TRUE(!(0));
576 if (strchr (b, '/') == NULL((void*)0)) {
577 g_autofree__attribute__((cleanup(g_autoptr_cleanup_generic_gfree))) gchar *prefixed = NULL((void*)0);
578
579 prefixed = g_strdup_printf ("/%s", b);
580 if (g_str_has_suffix (a, prefixed)(__builtin_constant_p (prefixed)? __extension__ ({ const char
* const __str = (a); const char * const __suffix = (prefixed
); gboolean __result = (0); if (__str == ((void*)0) || __suffix
== ((void*)0)) __result = (g_str_has_suffix) (__str, __suffix
); else { const size_t __str_len = strlen (((__str) + !(__str
))); const size_t __suffix_len = strlen (((__suffix) + !(__suffix
))); if (__str_len >= __suffix_len) __result = memcmp (__str
+ __str_len - __suffix_len, ((__suffix) + !(__suffix)), __suffix_len
) == 0; } __result; }) : (g_str_has_suffix) (a, prefixed) )
)
581 return TRUE(!(0));
582 }
583
584 return FALSE(0);
585}
586
587char *tz_info_get_clean_name (TzDB *tz_db,
588 const char *tz)
589{
590 char *ret;
591 const char *timezone;
592 guint i;
593 gboolean replaced;
594
595 /* Remove useless prefixes */
596 if (g_str_has_prefix (tz, "right/")(__builtin_constant_p ("right/")? __extension__ ({ const char
* const __str = (tz); const char * const __prefix = ("right/"
); gboolean __result = (0); if (__str == ((void*)0) || __prefix
== ((void*)0)) __result = (g_str_has_prefix) (__str, __prefix
); else { const size_t __str_len = strlen (((__str) + !(__str
))); const size_t __prefix_len = strlen (((__prefix) + !(__prefix
))); if (__str_len >= __prefix_len) __result = memcmp (((__str
) + !(__str)), ((__prefix) + !(__prefix)), __prefix_len) == 0
; } __result; }) : (g_str_has_prefix) (tz, "right/") )
)
597 tz = tz + strlen ("right/");
598 else if (g_str_has_prefix (tz, "posix/")(__builtin_constant_p ("posix/")? __extension__ ({ const char
* const __str = (tz); const char * const __prefix = ("posix/"
); gboolean __result = (0); if (__str == ((void*)0) || __prefix
== ((void*)0)) __result = (g_str_has_prefix) (__str, __prefix
); else { const size_t __str_len = strlen (((__str) + !(__str
))); const size_t __prefix_len = strlen (((__prefix) + !(__prefix
))); if (__str_len >= __prefix_len) __result = memcmp (((__str
) + !(__str)), ((__prefix) + !(__prefix)), __prefix_len) == 0
; } __result; }) : (g_str_has_prefix) (tz, "posix/") )
)
599 tz = tz + strlen ("posix/");
600
601 /* Here start the crazies */
602 replaced = FALSE(0);
603
604 for (i = 0; i < G_N_ELEMENTS (aliases)(sizeof (aliases) / sizeof ((aliases)[0])); i++) {
605 if (compare_timezones (tz, aliases[i].orig)) {
606 replaced = TRUE(!(0));
607 timezone = aliases[i].dest;
608 break;
609 }
610 }
611
612 /* Try again! */
613 if (!replaced) {
614 /* Ignore crazy solar times from the '80s */
615 if (g_str_has_prefix (tz, "Asia/Riyadh")(__builtin_constant_p ("Asia/Riyadh")? __extension__ ({ const
char * const __str = (tz); const char * const __prefix = ("Asia/Riyadh"
); gboolean __result = (0); if (__str == ((void*)0) || __prefix
== ((void*)0)) __result = (g_str_has_prefix) (__str, __prefix
); else { const size_t __str_len = strlen (((__str) + !(__str
))); const size_t __prefix_len = strlen (((__prefix) + !(__prefix
))); if (__str_len >= __prefix_len) __result = memcmp (((__str
) + !(__str)), ((__prefix) + !(__prefix)), __prefix_len) == 0
; } __result; }) : (g_str_has_prefix) (tz, "Asia/Riyadh") )
||
616 g_str_has_prefix (tz, "Mideast/Riyadh")(__builtin_constant_p ("Mideast/Riyadh")? __extension__ ({ const
char * const __str = (tz); const char * const __prefix = ("Mideast/Riyadh"
); gboolean __result = (0); if (__str == ((void*)0) || __prefix
== ((void*)0)) __result = (g_str_has_prefix) (__str, __prefix
); else { const size_t __str_len = strlen (((__str) + !(__str
))); const size_t __prefix_len = strlen (((__prefix) + !(__prefix
))); if (__str_len >= __prefix_len) __result = memcmp (((__str
) + !(__str)), ((__prefix) + !(__prefix)), __prefix_len) == 0
; } __result; }) : (g_str_has_prefix) (tz, "Mideast/Riyadh") )
) {
617 timezone = "Asia/Riyadh";
618 replaced = TRUE(!(0));
619 }
620 }
621
622 if (!replaced)
623 timezone = tz;
624
625 ret = g_hash_table_lookup (tz_db->backward, timezone);
626 if (ret == NULL((void*)0))
627 return g_strdup (timezone)g_strdup_inline (timezone);
628 return g_strdup (ret)g_strdup_inline (ret);
629}
630
631TzInfo *tz_info_from_location (TzLocation *loc)
632{
633 TzInfo *tzinfo;
634 time_t curtime;
635 struct tm *curzone;
636 g_autofree__attribute__((cleanup(g_autoptr_cleanup_generic_gfree))) gchar *tz_env_value = NULL((void*)0);
637
638 g_return_val_if_fail (loc != NULL, NULL)do { if ((loc != ((void*)0))) { } else { g_return_if_fail_warning
("time-admin-properties", ((const char*) (__func__)), "loc != NULL"
); return (((void*)0)); } } while (0)
;
639 g_return_val_if_fail (loc->zone != NULL, NULL)do { if ((loc->zone != ((void*)0))) { } else { g_return_if_fail_warning
("time-admin-properties", ((const char*) (__func__)), "loc->zone != NULL"
); return (((void*)0)); } } while (0)
;
640
641 tz_env_value = g_strdup (getenv ("TZ"))g_strdup_inline (getenv ("TZ"));
642 setenv ("TZ", loc->zone, 1);
643
644#if 0
645 tzset ();
646#endif
647 tzinfo = g_new0 (TzInfo, 1)((TzInfo *) g_malloc0_n ((1), sizeof (TzInfo)));
648
649 curtime = time (NULL((void*)0));
650 curzone = localtime (&curtime);
651
652#ifndef __sun
653 tzinfo->tzname_normal = g_strdup (curzone->tm_zone)g_strdup_inline (curzone->tm_zone);
654 if (curzone->tm_isdst)
655 tzinfo->tzname_daylight =
656 g_strdup (&curzone->tm_zone[curzone->tm_isdst])g_strdup_inline (&curzone->tm_zone[curzone->tm_isdst
])
;
657 else
658 tzinfo->tzname_daylight = NULL((void*)0);
659
660 tzinfo->utc_offset = curzone->tm_gmtoff;
661#else
662 tzinfo->tzname_normal = NULL((void*)0);
663 tzinfo->tzname_daylight = NULL((void*)0);
664 tzinfo->utc_offset = 0;
665#endif
666
667 tzinfo->daylight = curzone->tm_isdst;
668
669 if (tz_env_value)
670 setenv ("TZ", tz_env_value, 1);
671 else
672 unsetenv ("TZ");
673
674 return tzinfo;
675}
676
677glong tz_location_get_utc_offset (TzLocation *loc)
678{
679 TzInfo *tz_info;
680 glong offset;
681
682 tz_info = tz_info_from_location (loc);
683 offset = tz_info->utc_offset;
684 tz_info_free (tz_info);
685
686 return offset;
687}
688
689void RunTimeZoneDialog (GtkButton *button,
690 gpointer data)
691{
692 TimeAdmin *ta = (TimeAdmin *)data;
693
694 gtk_widget_show_all(GTK_WIDGET(ta->dialog)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((ta->dialog)), ((gtk_widget_get_type ()))))))
);
695}
696
697static void
698tz_location_free (TzLocation *loc, gpointer data)
699{
700 g_free (loc->country);
701 g_free (loc->zone);
702 g_free (loc->comment);
703 g_free (loc);
704}
705
706void TimeZoneDateBaseFree (TzDB *db)
707{
708 g_ptr_array_foreach (db->locations, (GFunc) tz_location_free, NULL((void*)0));
709 g_ptr_array_free (db->locations, TRUE(!(0)));
710 g_hash_table_destroy (db->backward);
711 g_free (db);
712}
713
714GPtrArray *tz_get_locations (TzDB *db)
715{
716 return db->locations;
717}
diff --git a/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-549b25.html b/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-549b25.html new file mode 100644 index 00000000..800f9351 --- /dev/null +++ b/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-549b25.html @@ -0,0 +1,2678 @@ + + + +mate-keybinding-properties.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:capplets/keybindings/mate-keybinding-properties.c
Warning:line 1014, column 14
Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name mate-keybinding-properties.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/capplets/keybindings -fcoverage-compilation-dir=/rootdir/capplets/keybindings -resource-dir /usr/bin/../lib/clang/18 -D HAVE_CONFIG_H -I . -I ../.. -I ../../capplets/common -I /usr/include/udisks2 -I /usr/include/libgtop-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/libxml2 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/gio-unix-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/dconf -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I ../../ -D G_LOG_DOMAIN="keybinding-properties" -I /usr/include/polkit-1 -I /usr/include/gio-unix-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -D MATECC_DATA_DIR="/usr/local/share/mate-control-center" -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-06-07-044335-13427-1 -x c mate-keybinding-properties.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* This program was written with lots of love under the GPL by Jonathan
2 * Blandford <jrb@gnome.org>
3 */
4
5#include <config.h>
6
7#include <stdlib.h>
8#include <string.h>
9#include <gtk/gtk.h>
10#include <gio/gio.h>
11#include <gdk/gdkx.h>
12#include <X11/Xatom.h>
13#include <glib/gi18n.h>
14#include <gdk/gdkkeysyms.h>
15
16#include "wm-common.h"
17#include "capplet-util.h"
18#include "eggcellrendererkeys.h"
19#include "activate-settings-daemon.h"
20#include "dconf-util.h"
21
22#define GSETTINGS_KEYBINDINGS_DIR"/org/mate/desktop/keybindings/" "/org/mate/desktop/keybindings/"
23#define CUSTOM_KEYBINDING_SCHEMA"org.mate.control-center.keybinding" "org.mate.control-center.keybinding"
24
25#define MAX_ELEMENTS_BEFORE_SCROLLING10 10
26#define MAX_CUSTOM_SHORTCUTS1000 1000
27#define RESPONSE_ADD0 0
28#define RESPONSE_REMOVE1 1
29
30typedef struct {
31 /* The untranslated name, combine with ->package to translate */
32 char *name;
33 /* The gettext package to use to translate the section title */
34 char *package;
35 /* Name of the window manager the keys would apply to */
36 char *wm_name;
37 /* The GSettings schema for the whole file */
38 char *schema;
39 /* an array of KeyListEntry */
40 GArray *entries;
41} KeyList;
42
43typedef enum {
44 COMPARISON_NONE = 0,
45 COMPARISON_GT,
46 COMPARISON_LT,
47 COMPARISON_EQ
48} Comparison;
49
50typedef struct
51{
52 char *gsettings_path;
53 char *schema;
54 char *name;
55 int value;
56 char *value_schema; /* gsettings schema for key/value */
57 char *value_key;
58 char *description;
59 char *description_key;
60 char *cmd_key;
61 Comparison comparison;
62} KeyListEntry;
63
64enum
65{
66 DESCRIPTION_COLUMN,
67 KEYENTRY_COLUMN,
68 N_COLUMNS
69};
70
71typedef struct
72{
73 GSettings *settings;
74 char *gsettings_path;
75 char *gsettings_key;
76 guint keyval;
77 guint keycode;
78 EggVirtualModifierType mask;
79 gboolean editable;
80 GtkTreeModel *model;
81 char *description;
82 char *desc_gsettings_key;
83 gboolean desc_editable;
84 char *command;
85 char *cmd_gsettings_key;
86 gboolean cmd_editable;
87 gulong gsettings_cnxn;
88 gulong gsettings_cnxn_desc;
89 gulong gsettings_cnxn_cmd;
90} KeyEntry;
91
92static gboolean block_accels = FALSE(0);
93static GtkWidget *custom_shortcut_dialog = NULL((void*)0);
94static GtkWidget *custom_shortcut_name_entry = NULL((void*)0);
95static GtkWidget *custom_shortcut_command_entry = NULL((void*)0);
96
97static GtkWidget* _gtk_builder_get_widget(GtkBuilder* builder, const gchar* name)
98{
99 return GTK_WIDGET (gtk_builder_get_object (builder, name))((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, name))), ((gtk_widget_get_type
()))))))
;
100}
101
102static char* binding_name(guint keyval, guint keycode, EggVirtualModifierType mask, gboolean translate)
103{
104 if (keyval != 0 || keycode != 0)
105 {
106 if (translate)
107 {
108 return egg_virtual_accelerator_label (keyval, keycode, mask);
109 }
110 else
111 {
112 return egg_virtual_accelerator_name (keyval, keycode, mask);
113 }
114 }
115 else
116 {
117 return g_strdup (translate ? _("Disabled") : "")g_strdup_inline (translate ? gettext ("Disabled") : "");
118 }
119}
120
121static gboolean
122binding_from_string (const char *str,
123 guint *accelerator_key,
124 guint *keycode,
125 EggVirtualModifierType *accelerator_mods)
126{
127 g_return_val_if_fail (accelerator_key != NULL, FALSE)do { if ((accelerator_key != ((void*)0))) { } else { g_return_if_fail_warning
("keybinding-properties", ((const char*) (__func__)), "accelerator_key != NULL"
); return ((0)); } } while (0)
;
128
129 if (str == NULL((void*)0) || strcmp (str, "disabled") == 0)
130 {
131 *accelerator_key = 0;
132 *keycode = 0;
133 *accelerator_mods = 0;
134 return TRUE(!(0));
135 }
136
137 egg_accelerator_parse_virtual (str, accelerator_key, keycode, accelerator_mods);
138
139 if (*accelerator_key == 0)
140 return FALSE(0);
141 else
142 return TRUE(!(0));
143}
144
145static void
146accel_set_func (GtkTreeViewColumn *tree_column,
147 GtkCellRenderer *cell,
148 GtkTreeModel *model,
149 GtkTreeIter *iter,
150 gpointer data)
151{
152 KeyEntry *key_entry;
153
154 gtk_tree_model_get (model, iter,
155 KEYENTRY_COLUMN, &key_entry,
156 -1);
157
158 if (key_entry == NULL((void*)0))
159 g_object_set (cell,
160 "visible", FALSE(0),
161 NULL((void*)0));
162 else if (! key_entry->editable)
163 g_object_set (cell,
164 "visible", TRUE(!(0)),
165 "editable", FALSE(0),
166 "accel_key", key_entry->keyval,
167 "accel_mask", key_entry->mask,
168 "keycode", key_entry->keycode,
169 "style", PANGO_STYLE_ITALIC,
170 NULL((void*)0));
171 else
172 g_object_set (cell,
173 "visible", TRUE(!(0)),
174 "editable", TRUE(!(0)),
175 "accel_key", key_entry->keyval,
176 "accel_mask", key_entry->mask,
177 "keycode", key_entry->keycode,
178 "style", PANGO_STYLE_NORMAL,
179 NULL((void*)0));
180}
181
182static void
183description_set_func (GtkTreeViewColumn *tree_column,
184 GtkCellRenderer *cell,
185 GtkTreeModel *model,
186 GtkTreeIter *iter,
187 gpointer data)
188{
189 KeyEntry *key_entry;
190
191 gtk_tree_model_get (model, iter,
192 KEYENTRY_COLUMN, &key_entry,
193 -1);
194
195 if (key_entry != NULL((void*)0))
196 g_object_set (cell,
197 "editable", FALSE(0),
198 "text", key_entry->description != NULL((void*)0) ?
199 key_entry->description : _("<Unknown Action>")gettext ("<Unknown Action>"),
200 NULL((void*)0));
201 else
202 g_object_set (cell,
203 "editable", FALSE(0), NULL((void*)0));
204}
205
206static gboolean
207keybinding_key_changed_foreach (GtkTreeModel *model,
208 GtkTreePath *path,
209 GtkTreeIter *iter,
210 gpointer user_data)
211{
212 KeyEntry *key_entry;
213 KeyEntry *tmp_key_entry;
214
215 key_entry = (KeyEntry *)user_data;
216 gtk_tree_model_get (key_entry->model, iter,
217 KEYENTRY_COLUMN, &tmp_key_entry,
218 -1);
219
220 if (key_entry == tmp_key_entry)
221 {
222 gtk_tree_model_row_changed (key_entry->model, path, iter);
223 return TRUE(!(0));
224 }
225 return FALSE(0);
226}
227
228static void
229keybinding_key_changed (GSettings *settings,
230 gchar *key,
231 KeyEntry *key_entry)
232{
233 gchar *key_value;
234
235 key_value = g_settings_get_string (settings, key);
236
237 binding_from_string (key_value, &key_entry->keyval, &key_entry->keycode, &key_entry->mask);
238 key_entry->editable = g_settings_is_writable (settings, key);
239
240 /* update the model */
241 gtk_tree_model_foreach (key_entry->model, keybinding_key_changed_foreach, key_entry);
242}
243
244static void
245keybinding_description_changed (GSettings *settings,
246 gchar *key,
247 KeyEntry *key_entry)
248{
249 gchar *key_value;
250
251 key_value = g_settings_get_string (settings, key);
252
253 g_free (key_entry->description);
254 key_entry->description = key_value ? g_strdup (key_value)g_strdup_inline (key_value) : NULL((void*)0);
255 g_free (key_value);
256
257 key_entry->desc_editable = g_settings_is_writable (settings, key);
258
259 /* update the model */
260 gtk_tree_model_foreach (key_entry->model, keybinding_key_changed_foreach, key_entry);
261}
262
263static void
264keybinding_command_changed (GSettings *settings,
265 gchar *key,
266 KeyEntry *key_entry)
267{
268 gchar *key_value;
269
270 key_value = g_settings_get_string (settings, key);
271
272 g_free (key_entry->command);
273 key_entry->command = key_value ? g_strdup (key_value)g_strdup_inline (key_value) : NULL((void*)0);
274 key_entry->cmd_editable = g_settings_is_writable (settings, key);
275 g_free (key_value);
276
277 /* update the model */
278 gtk_tree_model_foreach (key_entry->model, keybinding_key_changed_foreach, key_entry);
279}
280
281static int
282keyentry_sort_func (GtkTreeModel *model,
283 GtkTreeIter *a,
284 GtkTreeIter *b,
285 gpointer user_data)
286{
287 KeyEntry *key_entry_a;
288 KeyEntry *key_entry_b;
289 int retval;
290
291 key_entry_a = NULL((void*)0);
292 gtk_tree_model_get (model, a,
293 KEYENTRY_COLUMN, &key_entry_a,
294 -1);
295
296 key_entry_b = NULL((void*)0);
297 gtk_tree_model_get (model, b,
298 KEYENTRY_COLUMN, &key_entry_b,
299 -1);
300
301 if (key_entry_a && key_entry_b)
302 {
303 if ((key_entry_a->keyval || key_entry_a->keycode) &&
304 (key_entry_b->keyval || key_entry_b->keycode))
305 {
306 gchar *name_a, *name_b;
307
308 name_a = binding_name (key_entry_a->keyval,
309 key_entry_a->keycode,
310 key_entry_a->mask,
311 TRUE(!(0)));
312
313 name_b = binding_name (key_entry_b->keyval,
314 key_entry_b->keycode,
315 key_entry_b->mask,
316 TRUE(!(0)));
317
318 retval = g_utf8_collate (name_a, name_b);
319
320 g_free (name_a);
321 g_free (name_b);
322 }
323 else if (key_entry_a->keyval || key_entry_a->keycode)
324 retval = -1;
325 else if (key_entry_b->keyval || key_entry_b->keycode)
326 retval = 1;
327 else
328 retval = 0;
329 }
330 else if (key_entry_a)
331 retval = -1;
332 else if (key_entry_b)
333 retval = 1;
334 else
335 retval = 0;
336
337 return retval;
338}
339
340static void
341clear_old_model (GtkBuilder *builder)
342{
343 GtkWidget *tree_view;
344 GtkWidget *actions_swindow;
345 GtkTreeModel *model;
346
347 tree_view = _gtk_builder_get_widget (builder, "shortcut_treeview");
348 model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tree_view)), ((gtk_tree_view_get_type ()))))))
);
349
350 if (model == NULL((void*)0))
351 {
352 /* create a new model */
353 model = (GtkTreeModel *) gtk_tree_store_new (N_COLUMNS, G_TYPE_STRING((GType) ((16) << (2))), G_TYPE_POINTER((GType) ((17) << (2))));
354
355 gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (model)((((GtkTreeSortable*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_sortable_get_type ()))))))
,
356 KEYENTRY_COLUMN,
357 keyentry_sort_func,
358 NULL((void*)0), NULL((void*)0));
359
360 gtk_tree_view_set_model (GTK_TREE_VIEW (tree_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tree_view)), ((gtk_tree_view_get_type ()))))))
, model);
361
362 g_object_unref (model);
363 }
364 else
365 {
366 /* clear the existing model */
367 gboolean valid;
368 GtkTreeIter iter;
369 KeyEntry *key_entry;
370
371 for (valid = gtk_tree_model_get_iter_first (model, &iter);
372 valid;
373 valid = gtk_tree_model_iter_next (model, &iter))
374 {
375 gtk_tree_model_get (model, &iter,
376 KEYENTRY_COLUMN, &key_entry,
377 -1);
378
379 if (key_entry != NULL((void*)0))
380 {
381 g_signal_handler_disconnect (key_entry->settings, key_entry->gsettings_cnxn);
382 if (key_entry->gsettings_cnxn_desc != 0)
383 g_signal_handler_disconnect (key_entry->settings, key_entry->gsettings_cnxn_desc);
384 if (key_entry->gsettings_cnxn_cmd != 0)
385 g_signal_handler_disconnect (key_entry->settings, key_entry->gsettings_cnxn_cmd);
386
387 g_object_unref (key_entry->settings);
388 if (key_entry->gsettings_path)
389 g_free (key_entry->gsettings_path);
390 g_free (key_entry->gsettings_key);
391 g_free (key_entry->description);
392 g_free (key_entry->desc_gsettings_key);
393 g_free (key_entry->command);
394 g_free (key_entry->cmd_gsettings_key);
395 g_free (key_entry);
396 }
397 }
398
399 gtk_tree_store_clear (GTK_TREE_STORE (model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
);
400 }
401
402 actions_swindow = _gtk_builder_get_widget (builder, "actions_swindow");
403 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (actions_swindow)((((GtkScrolledWindow*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((actions_swindow)), ((gtk_scrolled_window_get_type
()))))))
,
404 GTK_POLICY_NEVER, GTK_POLICY_NEVER);
405 gtk_widget_set_size_request (actions_swindow, -1, -1);
406}
407
408typedef struct {
409 const char *key;
410 const char *path;
411 const char *schema;
412 gboolean found;
413} KeyMatchData;
414
415static gboolean
416key_match (GtkTreeModel *model,
417 GtkTreePath *path,
418 GtkTreeIter *iter,
419 gpointer data)
420{
421 KeyMatchData *match_data = data;
422 KeyEntry *element;
423 gchar *element_schema = NULL((void*)0);
424 gchar *element_path = NULL((void*)0);
425 gboolean found = FALSE(0);
426
427 gtk_tree_model_get (model, iter,
428 KEYENTRY_COLUMN, &element,
429 -1);
430
431 if (!element)
432 return FALSE(0);
433
434 if (!element->settings || !G_IS_SETTINGS (element->settings)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(element->settings)); GType __t = ((g_settings_get_type ()
)); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
)
435 return FALSE(0);
436
437 g_object_get (element->settings, "schema-id", &element_schema, NULL((void*)0));
438 g_object_get (element->settings, "path", &element_path, NULL((void*)0));
439
440 if ((g_strcmp0 (element->gsettings_key, match_data->key) == 0) &&
441 (g_strcmp0 (element_schema, match_data->schema) == 0) &&
442 (g_strcmp0 (element_path, match_data->path) == 0))
443 {
444 match_data->found = TRUE(!(0));
445 found = TRUE(!(0));
446 }
447
448 g_free (element_schema);
449 g_free (element_path);
450
451 return found;
452}
453
454static gboolean key_is_already_shown(GtkTreeModel* model, const KeyListEntry* entry)
455{
456 KeyMatchData data;
457
458 data.key = entry->name;
459 data.schema = entry->schema;
460 data.path = entry->gsettings_path;
461 data.found = FALSE(0);
462 gtk_tree_model_foreach(model, key_match, &data);
463
464 return data.found;
465}
466
467static gboolean should_show_key(const KeyListEntry* entry)
468{
469 GSettings *settings;
470 int value;
471
472 if (entry->comparison == COMPARISON_NONE)
473 {
474 return TRUE(!(0));
475 }
476
477 g_return_val_if_fail(entry->value_key != NULL, FALSE)do { if ((entry->value_key != ((void*)0))) { } else { g_return_if_fail_warning
("keybinding-properties", ((const char*) (__func__)), "entry->value_key != NULL"
); return ((0)); } } while (0)
;
478 g_return_val_if_fail(entry->value_schema != NULL, FALSE)do { if ((entry->value_schema != ((void*)0))) { } else { g_return_if_fail_warning
("keybinding-properties", ((const char*) (__func__)), "entry->value_schema != NULL"
); return ((0)); } } while (0)
;
479
480 settings = g_settings_new (entry->value_schema);
481 value = g_settings_get_int (settings, entry->value_key);
482 g_object_unref (settings);
483
484 switch (entry->comparison)
485 {
486 case COMPARISON_NONE:
487 /* For compiler warnings */
488 g_assert_not_reached ()do { g_assertion_message_expr ("keybinding-properties", "mate-keybinding-properties.c"
, 488, ((const char*) (__func__)), ((void*)0)); } while (0)
;
489 return FALSE(0);
490 case COMPARISON_GT:
491 if (value > entry->value)
492 {
493 return TRUE(!(0));
494 }
495 break;
496 case COMPARISON_LT:
497 if (value < entry->value)
498 {
499 return TRUE(!(0));
500 }
501 break;
502 case COMPARISON_EQ:
503 if (value == entry->value)
504 {
505 return TRUE(!(0));
506 }
507 break;
508 }
509
510 return FALSE(0);
511}
512
513static gboolean
514count_rows_foreach (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
515{
516 gint *rows = data;
517
518 (*rows)++;
519
520 return FALSE(0);
521}
522
523static void
524ensure_scrollbar (GtkBuilder *builder, int i)
525{
526 if (i == MAX_ELEMENTS_BEFORE_SCROLLING10)
527 {
528 GtkRequisition rectangle;
529 GObject *actions_swindow = gtk_builder_get_object (builder,
530 "actions_swindow");
531 GtkWidget *treeview = _gtk_builder_get_widget (builder,
532 "shortcut_treeview");
533 gtk_widget_get_preferred_size (treeview, &rectangle, NULL((void*)0));
534 gtk_widget_set_size_request (treeview, -1, rectangle.height);
535 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (actions_swindow)((((GtkScrolledWindow*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((actions_swindow)), ((gtk_scrolled_window_get_type
()))))))
,
536 GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
537 }
538}
539
540static void
541find_section (GtkTreeModel *model,
542 GtkTreeIter *iter,
543 const char *title)
544{
545 GtkTreeStore *store;
546 gboolean success;
547
548 success = gtk_tree_model_get_iter_first (model, iter);
549 while (success)
550 {
551 char *description;
552 gint res;
553
554 gtk_tree_model_get (model, iter,
555 DESCRIPTION_COLUMN, &description,
556 -1);
557 res = g_strcmp0 (description, title);
558 g_free (description);
559 if (res == 0)
560 return;
561 success = gtk_tree_model_iter_next (model, iter);
562 }
563 store = GTK_TREE_STORE (model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
;
564 gtk_tree_store_append (store, iter, NULL((void*)0));
565 gtk_tree_store_set (store, iter,
566 DESCRIPTION_COLUMN, title,
567 -1);
568}
569
570static void
571append_keys_to_tree (GtkBuilder *builder,
572 const gchar *title,
573 const gchar *schema,
574 const gchar *package,
575 const KeyListEntry *keys_list)
576{
577 GtkTreeIter parent_iter, iter;
578 GtkTreeModel *model;
579 gint i, j;
580
581 model = gtk_tree_view_get_model (GTK_TREE_VIEW (gtk_builder_get_object (builder, "shortcut_treeview"))((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, "shortcut_treeview"))),
((gtk_tree_view_get_type ()))))))
);
582
583 /* Try to find a section parent iter, if it already exists */
584 find_section (model, &iter, title);
585 parent_iter = iter;
586
587 i = 0;
588 gtk_tree_model_foreach (model, count_rows_foreach, &i);
589
590 /* If the header we just added is the MAX_ELEMENTS_BEFORE_SCROLLING th,
591 * then we need to scroll now */
592 ensure_scrollbar (builder, i - 1);
593
594 for (j = 0; keys_list[j].name != NULL((void*)0); j++)
595 {
596 GSettings *settings = NULL((void*)0);
597 gchar *settings_path;
598 KeyEntry *key_entry;
599 const gchar *key_string;
600 gchar *key_value;
601 gchar *description;
602 gchar *command;
603
604 if (!should_show_key (&keys_list[j]))
605 continue;
606
607 if (key_is_already_shown (model, &keys_list[j]))
608 continue;
609
610 key_string = keys_list[j].name;
611
612 if (keys_list[j].gsettings_path != NULL((void*)0))
613 {
614 settings = g_settings_new_with_path (schema, keys_list[j].gsettings_path);
615 settings_path = g_strdup(keys_list[j].gsettings_path)g_strdup_inline (keys_list[j].gsettings_path);
616 }
617 else
618 {
619 settings = g_settings_new (schema);
620 settings_path = NULL((void*)0);
621 }
622
623 if (keys_list[j].description_key != NULL((void*)0))
624 {
625 /* it's a custom shortcut, so description is in gsettings */
626 description = g_settings_get_string (settings, keys_list[j].description_key);
627 }
628 else
629 {
630 /* it's from keyfile, so description need to be translated */
631 description = keys_list[j].description;
632 if (package)
633 {
634 bind_textdomain_codeset (package, "UTF-8");
635 description = dgettext (package, description);
636 }
637 else
638 {
639 description = _(description)gettext (description);
640 }
641 }
642
643 if (description == NULL((void*)0))
644 {
645 /* Only print a warning for keys that should have a schema */
646 if (keys_list[j].description_key == NULL((void*)0))
647 g_warning ("No description for key '%s'", key_string);
648 }
649
650 if (keys_list[j].cmd_key != NULL((void*)0))
651 {
652 command = g_settings_get_string (settings, keys_list[j].cmd_key);
653 }
654 else
655 {
656 command = NULL((void*)0);
657 }
658
659 key_entry = g_new0 (KeyEntry, 1)((KeyEntry *) g_malloc0_n ((1), sizeof (KeyEntry)));
660 key_entry->settings = settings;
661 key_entry->gsettings_path = settings_path;
662 key_entry->gsettings_key = g_strdup (key_string)g_strdup_inline (key_string);
663 key_entry->editable = g_settings_is_writable (settings, key_string);
664 key_entry->model = model;
665 key_entry->description = description;
666 key_entry->command = command;
667 if (keys_list[j].description_key != NULL((void*)0))
668 {
669 key_entry->desc_gsettings_key = g_strdup (keys_list[j].description_key)g_strdup_inline (keys_list[j].description_key);
670 key_entry->desc_editable = g_settings_is_writable (settings, key_entry->desc_gsettings_key);
671 gchar *gsettings_signal = g_strconcat ("changed::", key_entry->desc_gsettings_key, NULL((void*)0));
672 key_entry->gsettings_cnxn_desc = g_signal_connect (settings,g_signal_connect_data ((settings), (gsettings_signal), (((GCallback
) (keybinding_description_changed))), (key_entry), ((void*)0)
, (GConnectFlags) 0)
673 gsettings_signal,g_signal_connect_data ((settings), (gsettings_signal), (((GCallback
) (keybinding_description_changed))), (key_entry), ((void*)0)
, (GConnectFlags) 0)
674 G_CALLBACK (keybinding_description_changed),g_signal_connect_data ((settings), (gsettings_signal), (((GCallback
) (keybinding_description_changed))), (key_entry), ((void*)0)
, (GConnectFlags) 0)
675 key_entry)g_signal_connect_data ((settings), (gsettings_signal), (((GCallback
) (keybinding_description_changed))), (key_entry), ((void*)0)
, (GConnectFlags) 0)
;
676 g_free (gsettings_signal);
677 }
678 if (keys_list[j].cmd_key != NULL((void*)0))
679 {
680 key_entry->cmd_gsettings_key = g_strdup (keys_list[j].cmd_key)g_strdup_inline (keys_list[j].cmd_key);
681 key_entry->cmd_editable = g_settings_is_writable (settings, key_entry->cmd_gsettings_key);
682 gchar *gsettings_signal = g_strconcat ("changed::", key_entry->cmd_gsettings_key, NULL((void*)0));
683 key_entry->gsettings_cnxn_cmd = g_signal_connect (settings,g_signal_connect_data ((settings), (gsettings_signal), (((GCallback
) (keybinding_command_changed))), (key_entry), ((void*)0), (GConnectFlags
) 0)
684 gsettings_signal,g_signal_connect_data ((settings), (gsettings_signal), (((GCallback
) (keybinding_command_changed))), (key_entry), ((void*)0), (GConnectFlags
) 0)
685 G_CALLBACK (keybinding_command_changed),g_signal_connect_data ((settings), (gsettings_signal), (((GCallback
) (keybinding_command_changed))), (key_entry), ((void*)0), (GConnectFlags
) 0)
686 key_entry)g_signal_connect_data ((settings), (gsettings_signal), (((GCallback
) (keybinding_command_changed))), (key_entry), ((void*)0), (GConnectFlags
) 0)
;
687 g_free (gsettings_signal);
688 }
689
690 gchar *gsettings_signal = g_strconcat ("changed::", key_string, NULL((void*)0));
691 key_entry->gsettings_cnxn = g_signal_connect (settings,g_signal_connect_data ((settings), (gsettings_signal), (((GCallback
) (keybinding_key_changed))), (key_entry), ((void*)0), (GConnectFlags
) 0)
692 gsettings_signal,g_signal_connect_data ((settings), (gsettings_signal), (((GCallback
) (keybinding_key_changed))), (key_entry), ((void*)0), (GConnectFlags
) 0)
693 G_CALLBACK (keybinding_key_changed),g_signal_connect_data ((settings), (gsettings_signal), (((GCallback
) (keybinding_key_changed))), (key_entry), ((void*)0), (GConnectFlags
) 0)
694 key_entry)g_signal_connect_data ((settings), (gsettings_signal), (((GCallback
) (keybinding_key_changed))), (key_entry), ((void*)0), (GConnectFlags
) 0)
;
695 g_free (gsettings_signal);
696
697 key_value = g_settings_get_string (settings, key_string);
698 binding_from_string (key_value, &key_entry->keyval, &key_entry->keycode, &key_entry->mask);
699 g_free (key_value);
700
701 ensure_scrollbar (builder, i);
702
703 ++i;
704 gtk_tree_store_append (GTK_TREE_STORE (model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, &iter, &parent_iter);
705 /* we use the DESCRIPTION_COLUMN only for the section headers */
706 gtk_tree_store_set (GTK_TREE_STORE (model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, &iter,
707 KEYENTRY_COLUMN, key_entry,
708 -1);
709 gtk_tree_view_expand_all (GTK_TREE_VIEW (gtk_builder_get_object (builder, "shortcut_treeview"))((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, "shortcut_treeview"))),
((gtk_tree_view_get_type ()))))))
);
710 }
711
712 /* Don't show an empty section */
713 if (gtk_tree_model_iter_n_children (model, &parent_iter) == 0)
714 gtk_tree_store_remove (GTK_TREE_STORE (model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, &parent_iter);
715
716 if (i == 0)
717 gtk_widget_hide (_gtk_builder_get_widget (builder, "shortcuts_vbox"));
718 else
719 gtk_widget_show (_gtk_builder_get_widget (builder, "shortcuts_vbox"));
720}
721
722static void
723parse_start_tag (GMarkupParseContext *ctx,
724 const gchar *element_name,
725 const gchar **attr_names,
726 const gchar **attr_values,
727 gpointer user_data,
728 GError **error)
729{
730 KeyList *keylist = (KeyList *) user_data;
731 KeyListEntry key;
732 const char *name, *value_key, *description, *value_schema;
733 int value;
734 Comparison comparison;
735 const char *schema = NULL((void*)0);
736
737 name = NULL((void*)0);
738
739 /* The top-level element, names the section in the tree */
740 if (g_str_equal (element_name, "KeyListEntries")(strcmp ((const char *) (element_name), (const char *) ("KeyListEntries"
)) == 0)
)
741 {
742 const char *wm_name = NULL((void*)0);
743 const char *package = NULL((void*)0);
744
745 while (*attr_names && *attr_values)
746 {
747 if (g_str_equal (*attr_names, "name")(strcmp ((const char *) (*attr_names), (const char *) ("name"
)) == 0)
)
748 {
749 if (**attr_values)
750 name = *attr_values;
751 }
752 else if (g_str_equal (*attr_names, "wm_name")(strcmp ((const char *) (*attr_names), (const char *) ("wm_name"
)) == 0)
)
753 {
754 if (**attr_values)
755 wm_name = *attr_values;
756 }
757 else if (g_str_equal (*attr_names, "package")(strcmp ((const char *) (*attr_names), (const char *) ("package"
)) == 0)
)
758 {
759 if (**attr_values)
760 package = *attr_values;
761 }
762 else if (g_str_equal (*attr_names, "schema")(strcmp ((const char *) (*attr_names), (const char *) ("schema"
)) == 0)
)
763 {
764 if (**attr_values)
765 schema = *attr_values;
766 }
767 ++attr_names;
768 ++attr_values;
769 }
770
771 if (name)
772 {
773 if (keylist->name)
774 g_warning ("Duplicate section name");
775 g_free (keylist->name);
776 keylist->name = g_strdup (name)g_strdup_inline (name);
777 }
778 if (wm_name)
779 {
780 if (keylist->wm_name)
781 g_warning ("Duplicate window manager name");
782 g_free (keylist->wm_name);
783 keylist->wm_name = g_strdup (wm_name)g_strdup_inline (wm_name);
784 }
785 if (package)
786 {
787 if (keylist->package)
788 g_warning ("Duplicate gettext package name");
789 g_free (keylist->package);
790 keylist->package = g_strdup (package)g_strdup_inline (package);
791 }
792 if (schema)
793 {
794 if (keylist->schema)
795 g_warning ("Duplicate schema name");
796 g_free (keylist->schema);
797 keylist->schema = g_strdup (schema)g_strdup_inline (schema);
798 }
799 return;
800 }
801
802 if (!g_str_equal (element_name, "KeyListEntry")(strcmp ((const char *) (element_name), (const char *) ("KeyListEntry"
)) == 0)
803 || attr_names == NULL((void*)0)
804 || attr_values == NULL((void*)0))
805 return;
806
807 value = 0;
808 comparison = COMPARISON_NONE;
809 value_key = NULL((void*)0);
810 value_schema = NULL((void*)0);
811 description = NULL((void*)0);
812
813 while (*attr_names && *attr_values)
814 {
815 if (g_str_equal (*attr_names, "name")(strcmp ((const char *) (*attr_names), (const char *) ("name"
)) == 0)
)
816 {
817 /* skip if empty */
818 if (**attr_values)
819 name = *attr_values;
820 } else if (g_str_equal (*attr_names, "value")(strcmp ((const char *) (*attr_names), (const char *) ("value"
)) == 0)
) {
821 if (**attr_values) {
822 value = (int) g_ascii_strtoull (*attr_values, NULL((void*)0), 0);
823 }
824 } else if (g_str_equal (*attr_names, "key")(strcmp ((const char *) (*attr_names), (const char *) ("key")
) == 0)
) {
825 if (**attr_values) {
826 value_key = *attr_values;
827 }
828 } else if (g_str_equal (*attr_names, "comparison")(strcmp ((const char *) (*attr_names), (const char *) ("comparison"
)) == 0)
) {
829 if (**attr_values) {
830 if (g_str_equal (*attr_values, "gt")(strcmp ((const char *) (*attr_values), (const char *) ("gt")
) == 0)
) {
831 comparison = COMPARISON_GT;
832 } else if (g_str_equal (*attr_values, "lt")(strcmp ((const char *) (*attr_values), (const char *) ("lt")
) == 0)
) {
833 comparison = COMPARISON_LT;
834 } else if (g_str_equal (*attr_values, "eq")(strcmp ((const char *) (*attr_values), (const char *) ("eq")
) == 0)
) {
835 comparison = COMPARISON_EQ;
836 }
837 }
838 } else if (g_str_equal (*attr_names, "description")(strcmp ((const char *) (*attr_names), (const char *) ("description"
)) == 0)
) {
839 if (**attr_values) {
840 description = *attr_values;
841 }
842 } else if (g_str_equal (*attr_names, "schema")(strcmp ((const char *) (*attr_names), (const char *) ("schema"
)) == 0)
) {
843 if (**attr_values) {
844 value_schema = *attr_values;
845 }
846 }
847
848 ++attr_names;
849 ++attr_values;
850 }
851
852 if (name == NULL((void*)0))
853 return;
854
855 key.name = g_strdup (name)g_strdup_inline (name);
856 key.gsettings_path = NULL((void*)0);
857 key.description_key = NULL((void*)0);
858 key.description = g_strdup(description)g_strdup_inline (description);
859 key.schema = g_strdup(schema)g_strdup_inline (schema);
860 key.value = value;
861 if (value_key) {
862 key.value_key = g_strdup (value_key)g_strdup_inline (value_key);
863 key.value_schema = g_strdup (value_schema)g_strdup_inline (value_schema);
864 }
865 else {
866 key.value_key = NULL((void*)0);
867 key.value_schema = NULL((void*)0);
868 }
869 key.comparison = comparison;
870 key.cmd_key = NULL((void*)0);
871 g_array_append_val (keylist->entries, key)g_array_append_vals (keylist->entries, &(key), 1);
872}
873
874static gboolean
875strv_contains (char **strv,
876 char *str)
877{
878 char **p;
879
880 for (p = strv; *p; p++)
881 if (strcmp (*p, str) == 0)
882 return TRUE(!(0));
883
884 return FALSE(0);
885}
886
887static void
888append_keys_to_tree_from_file (GtkBuilder *builder,
889 const char *filename,
890 char **wm_keybindings)
891{
892 GMarkupParseContext *ctx;
893 GMarkupParser parser = { parse_start_tag, NULL((void*)0), NULL((void*)0), NULL((void*)0), NULL((void*)0) };
894 KeyList *keylist;
895 KeyListEntry key, *keys;
896 GError *err = NULL((void*)0);
897 char *buf;
898 const char *title;
899 gsize buf_len;
900 guint i;
901
902 if (!g_file_get_contents (filename, &buf, &buf_len, &err))
903 return;
904
905 keylist = g_new0 (KeyList, 1)((KeyList *) g_malloc0_n ((1), sizeof (KeyList)));
906 keylist->entries = g_array_new (FALSE(0), TRUE(!(0)), sizeof (KeyListEntry));
907 ctx = g_markup_parse_context_new (&parser, 0, keylist, NULL((void*)0));
908
909 if (!g_markup_parse_context_parse (ctx, buf, buf_len, &err))
910 {
911 g_warning ("Failed to parse '%s': '%s'", filename, err->message);
912 g_error_free (err);
913 g_free (keylist->name);
914 g_free (keylist->package);
915 g_free (keylist->wm_name);
916 g_free (keylist->schema);
917 for (i = 0; i < keylist->entries->len; i++)
918 g_free (((KeyListEntry *) &(keylist->entries->data[i]))->name);
919 g_array_free (keylist->entries, TRUE(!(0)));
920 g_free (keylist);
921 keylist = NULL((void*)0);
922 }
923 g_markup_parse_context_free (ctx);
924 g_free (buf);
925
926 if (keylist == NULL((void*)0))
927 return;
928
929 /* If there's no keys to add, or the settings apply to a window manager
930 * that's not the one we're running */
931 if (keylist->entries->len == 0
932 || (keylist->wm_name != NULL((void*)0) && !strv_contains (wm_keybindings, keylist->wm_name))
933 || keylist->name == NULL((void*)0))
934 {
935 g_free (keylist->name);
936 g_free (keylist->package);
937 g_free (keylist->wm_name);
938 g_free (keylist->schema);
939 g_array_free (keylist->entries, TRUE(!(0)));
940 g_free (keylist);
941 return;
942 }
943
944 /* Empty KeyListEntry to end the array */
945 key.name = NULL((void*)0);
946 key.description_key = NULL((void*)0);
947 key.value_key = NULL((void*)0);
948 key.value = 0;
949 key.comparison = COMPARISON_NONE;
950 g_array_append_val (keylist->entries, key)g_array_append_vals (keylist->entries, &(key), 1);
951
952 keys = (KeyListEntry *) g_array_free (keylist->entries, FALSE(0));
953 if (keylist->package)
954 {
955 bind_textdomain_codeset (keylist->package, "UTF-8");
956 title = dgettext (keylist->package, keylist->name);
957 } else {
958 title = _(keylist->name)gettext (keylist->name);
959 }
960
961 append_keys_to_tree (builder, title, keylist->schema, keylist->package, keys);
962
963 g_free (keylist->name);
964 g_free (keylist->package);
965 for (i = 0; keys[i].name != NULL((void*)0); i++)
966 g_free (keys[i].name);
967 g_free (keylist);
968}
969
970static void
971append_keys_to_tree_from_gsettings (GtkBuilder *builder, const gchar *gsettings_path)
972{
973 gchar **custom_list;
974 GArray *entries;
975 KeyListEntry key;
976 gint i;
977
978 /* load custom shortcuts from GSettings */
979 entries = g_array_new (FALSE(0), TRUE(!(0)), sizeof (KeyListEntry));
980
981 key.value_key = NULL((void*)0);
982 key.value = 0;
983 key.comparison = COMPARISON_NONE;
984
985 custom_list = dconf_util_list_subdirs (gsettings_path, FALSE(0));
986
987 if (custom_list != NULL((void*)0))
988 {
989 for (i = 0; custom_list[i] != NULL((void*)0); i++)
990 {
991 key.gsettings_path = g_strdup_printf("%s%s", gsettings_path, custom_list[i]);
992 key.name = g_strdup("binding")g_strdup_inline ("binding");
993 key.cmd_key = g_strdup("action")g_strdup_inline ("action");
994 key.description_key = g_strdup("name")g_strdup_inline ("name");
995 key.schema = NULL((void*)0);
996 g_array_append_val (entries, key)g_array_append_vals (entries, &(key), 1);
997 }
998 }
999
1000 g_strfreev (custom_list);
1001
1002 if (entries->len > 0)
1003 {
1004 KeyListEntry *keys;
1005 int i;
1006
1007 /* Empty KeyListEntry to end the array */
1008 key.gsettings_path = NULL((void*)0);
1009 key.name = NULL((void*)0);
1010 key.description_key = NULL((void*)0);
1011 key.cmd_key = NULL((void*)0);
1012 g_array_append_val (entries, key)g_array_append_vals (entries, &(key), 1);
1013
1014 keys = (KeyListEntry *) entries->data;
Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption
1015 append_keys_to_tree (builder, _("Custom Shortcuts")gettext ("Custom Shortcuts"), CUSTOM_KEYBINDING_SCHEMA"org.mate.control-center.keybinding", NULL((void*)0), keys);
1016 for (i = 0; i < entries->len; ++i)
1017 {
1018 g_free (keys[i].name);
1019 g_free (keys[i].description_key);
1020 g_free (keys[i].cmd_key);
1021 g_free (keys[i].gsettings_path);
1022 }
1023 }
1024
1025 g_array_free (entries, TRUE(!(0)));
1026}
1027
1028static void
1029reload_key_entries (GtkBuilder *builder)
1030{
1031 gchar **wm_keybindings;
1032 GList *list, *l;
1033 const gchar * const * data_dirs;
1034 GHashTable *loaded_files;
1035 guint i;
1036
1037 wm_keybindings = wm_common_get_current_keybindings();
1038
1039 clear_old_model (builder);
1040
1041 loaded_files = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
1042 data_dirs = g_get_system_data_dirs ();
1043 for (i = 0; data_dirs[i] != NULL((void*)0); i++)
1044 {
1045 g_autofree__attribute__((cleanup(g_autoptr_cleanup_generic_gfree))) gchar *dir_path = NULL((void*)0);
1046 GDir *dir;
1047 const gchar *name;
1048
1049 dir_path = g_build_filename (data_dirs[i], "mate-control-center", "keybindings", NULL((void*)0));
1050 g_debug ("Keybinding dir: %s", dir_path);
1051
1052 dir = g_dir_open (dir_path, 0, NULL((void*)0));
1053 if (!dir)
1054 continue;
1055
1056 for (name = g_dir_read_name (dir) ; name ; name = g_dir_read_name (dir))
1057 {
1058 if (g_str_has_suffix (name, ".xml")(__builtin_constant_p (".xml")? __extension__ ({ const char *
const __str = (name); const char * const __suffix = (".xml")
; gboolean __result = (0); if (__str == ((void*)0) || __suffix
== ((void*)0)) __result = (g_str_has_suffix) (__str, __suffix
); else { const size_t __str_len = strlen (((__str) + !(__str
))); const size_t __suffix_len = strlen (((__suffix) + !(__suffix
))); if (__str_len >= __suffix_len) __result = memcmp (__str
+ __str_len - __suffix_len, ((__suffix) + !(__suffix)), __suffix_len
) == 0; } __result; }) : (g_str_has_suffix) (name, ".xml") )
== FALSE(0))
1059 continue;
1060
1061 if (g_hash_table_lookup (loaded_files, name) != NULL((void*)0))
1062 {
1063 g_debug ("Not loading %s, it was already loaded from another directory", name);
1064 continue;
1065 }
1066
1067 g_hash_table_insert (loaded_files, g_strdup (name)g_strdup_inline (name), g_strdup (dir_path)g_strdup_inline (dir_path));
1068 }
1069
1070 g_dir_close (dir);
1071 }
1072 list = g_hash_table_get_keys (loaded_files);
1073 list = g_list_sort(list, (GCompareFunc) g_str_equal);
1074 for (l = list; l != NULL((void*)0); l = l->next)
1075 {
1076 g_autofree__attribute__((cleanup(g_autoptr_cleanup_generic_gfree))) gchar *path = NULL((void*)0);
1077 path = g_build_filename (g_hash_table_lookup (loaded_files, l->data), l->data, NULL((void*)0));
1078 g_debug ("Keybinding file: %s", path);
1079 append_keys_to_tree_from_file (builder, path, wm_keybindings);
1080 }
1081 g_list_free (list);
1082 g_hash_table_destroy (loaded_files);
1083
1084 /* Load custom shortcuts _after_ system-provided ones,
1085 * since some of the custom shortcuts may also be listed
1086 * in a file. Loading the custom shortcuts last makes
1087 * such keys not show up in the custom section.
1088 */
1089 append_keys_to_tree_from_gsettings (builder, GSETTINGS_KEYBINDINGS_DIR"/org/mate/desktop/keybindings/");
1090
1091 g_strfreev (wm_keybindings);
1092}
1093
1094static void
1095key_entry_controlling_key_changed (GSettings *settings, gchar *key, gpointer user_data)
1096{
1097 reload_key_entries (user_data);
1098}
1099
1100static gboolean cb_check_for_uniqueness(GtkTreeModel* model, GtkTreePath* path, GtkTreeIter* iter, KeyEntry* new_key)
1101{
1102 KeyEntry* element;
1103
1104 gtk_tree_model_get (new_key->model, iter,
1105 KEYENTRY_COLUMN, &element,
1106 -1);
1107
1108 /* no conflict for : blanks, different modifiers, or ourselves */
1109 if (element == NULL((void*)0) || new_key->mask != element->mask)
1110 {
1111 return FALSE(0);
1112 }
1113
1114 gchar *new_key_schema = NULL((void*)0);
1115 gchar *element_schema = NULL((void*)0);
1116 gchar *new_key_path = NULL((void*)0);
1117 gchar *element_path = NULL((void*)0);
1118
1119 if (new_key && new_key->settings)
1120 {
1121 g_object_get (new_key->settings, "schema-id", &new_key_schema, NULL((void*)0));
1122 g_object_get (new_key->settings, "path", &new_key_path, NULL((void*)0));
1123 }
1124
1125 if (element->settings)
1126 {
1127 g_object_get (element->settings, "schema-id", &element_schema, NULL((void*)0));
1128 g_object_get (element->settings, "path", &element_path, NULL((void*)0));
1129 }
1130
1131 if (!g_strcmp0 (new_key->gsettings_key, element->gsettings_key) &&
1132 !g_strcmp0 (new_key_schema, element_schema) &&
1133 !g_strcmp0 (new_key_path, element_path))
1134 {
1135 return FALSE(0);
1136 }
1137
1138 if (new_key->keyval != 0)
1139 {
1140 if (new_key->keyval != element->keyval)
1141 {
1142 return FALSE(0);
1143 }
1144 }
1145 else if (element->keyval != 0 || new_key->keycode != element->keycode)
1146 {
1147 return FALSE(0);
1148 }
1149
1150 new_key->editable = FALSE(0);
1151 new_key->settings = element->settings;
1152 new_key->gsettings_key = element->gsettings_key;
1153 new_key->description = element->description;
1154 new_key->desc_gsettings_key = element->desc_gsettings_key;
1155 new_key->desc_editable = element->desc_editable;
1156
1157 return TRUE(!(0));
1158}
1159
1160static const guint forbidden_keyvals[] = {
1161 /* Navigation keys */
1162 GDK_KEY_Home0xff50,
1163 GDK_KEY_Left0xff51,
1164 GDK_KEY_Up0xff52,
1165 GDK_KEY_Right0xff53,
1166 GDK_KEY_Down0xff54,
1167 GDK_KEY_Page_Up0xff55,
1168 GDK_KEY_Page_Down0xff56,
1169 GDK_KEY_End0xff57,
1170 GDK_KEY_Tab0xff09,
1171
1172 /* Return */
1173 GDK_KEY_KP_Enter0xff8d,
1174 GDK_KEY_Return0xff0d,
1175
1176 GDK_KEY_space0x020,
1177 GDK_KEY_Mode_switch0xff7e
1178};
1179
1180static gboolean keyval_is_forbidden(guint keyval)
1181{
1182 guint i;
1183
1184 for (i = 0; i < G_N_ELEMENTS(forbidden_keyvals)(sizeof (forbidden_keyvals) / sizeof ((forbidden_keyvals)[0])
)
; i++)
1185 {
1186 if (keyval == forbidden_keyvals[i])
1187 {
1188 return TRUE(!(0));
1189 }
1190 }
1191
1192 return FALSE(0);
1193}
1194
1195static void show_error(GtkWindow* parent, GError* err)
1196{
1197 GtkWidget *dialog;
1198
1199 dialog = gtk_message_dialog_new (parent,
1200 GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL,
1201 GTK_MESSAGE_WARNING,
1202 GTK_BUTTONS_OK,
1203 _("Error saving the new shortcut")gettext ("Error saving the new shortcut"));
1204
1205 gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog)((((GtkMessageDialog*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((dialog)), ((gtk_message_dialog_get_type ())
)))))
,
1206 "%s", err->message);
1207 gtk_dialog_run (GTK_DIALOG (dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_dialog_get_type ()))))))
);
1208 gtk_widget_destroy (dialog);
1209}
1210
1211static void accel_edited_callback(GtkCellRendererText* cell, const char* path_string, guint keyval, EggVirtualModifierType mask, guint keycode, gpointer data)
1212{
1213 GtkTreeView* view = (GtkTreeView*) data;
1214 GtkTreeModel* model;
1215 GtkTreePath* path = gtk_tree_path_new_from_string (path_string);
1216 GtkTreeIter iter;
1217 KeyEntry* key_entry, tmp_key;
1218 char* str;
1219
1220 block_accels = FALSE(0);
1221
1222 model = gtk_tree_view_get_model (view);
1223 gtk_tree_model_get_iter (model, &iter, path);
1224 gtk_tree_path_free (path);
1225 gtk_tree_model_get (model, &iter,
1226 KEYENTRY_COLUMN, &key_entry,
1227 -1);
1228
1229 /* sanity check */
1230 if (key_entry == NULL((void*)0))
1231 {
1232 return;
1233 }
1234
1235 /* CapsLock isn't supported as a keybinding modifier, so keep it from confusing us */
1236 mask &= ~EGG_VIRTUAL_LOCK_MASK;
1237
1238 tmp_key.model = model;
1239 tmp_key.keyval = keyval;
1240 tmp_key.keycode = keycode;
1241 tmp_key.mask = mask;
1242 tmp_key.settings = key_entry->settings;
1243 tmp_key.gsettings_key = key_entry->gsettings_key;
1244 tmp_key.description = NULL((void*)0);
1245 tmp_key.editable = TRUE(!(0)); /* kludge to stuff in a return flag */
1246
1247 if (keyval != 0 || keycode != 0) /* any number of keys can be disabled */
1248 {
1249 gtk_tree_model_foreach(model, (GtkTreeModelForeachFunc) cb_check_for_uniqueness, &tmp_key);
1250 }
1251
1252 /* Check for unmodified keys */
1253 if (tmp_key.mask == 0 && tmp_key.keycode != 0)
1254 {
1255 if ((tmp_key.keyval >= GDK_KEY_a0x061 && tmp_key.keyval <= GDK_KEY_z0x07a)
1256 || (tmp_key.keyval >= GDK_KEY_A0x041 && tmp_key.keyval <= GDK_KEY_Z0x05a)
1257 || (tmp_key.keyval >= GDK_KEY_00x030 && tmp_key.keyval <= GDK_KEY_90x039)
1258 || (tmp_key.keyval >= GDK_KEY_kana_fullstop0x4a1 && tmp_key.keyval <= GDK_KEY_semivoicedsound0x4df)
1259 || (tmp_key.keyval >= GDK_KEY_Arabic_comma0x5ac && tmp_key.keyval <= GDK_KEY_Arabic_sukun0x5f2)
1260 || (tmp_key.keyval >= GDK_KEY_Serbian_dje0x6a1 && tmp_key.keyval <= GDK_KEY_Cyrillic_HARDSIGN0x6ff)
1261 || (tmp_key.keyval >= GDK_KEY_Greek_ALPHAaccent0x7a1 && tmp_key.keyval <= GDK_KEY_Greek_omega0x7f9)
1262 || (tmp_key.keyval >= GDK_KEY_hebrew_doublelowline0xcdf && tmp_key.keyval <= GDK_KEY_hebrew_taf0xcfa)
1263 || (tmp_key.keyval >= GDK_KEY_Thai_kokai0xda1 && tmp_key.keyval <= GDK_KEY_Thai_lekkao0xdf9)
1264 || (tmp_key.keyval >= GDK_KEY_Hangul0xff31 && tmp_key.keyval <= GDK_KEY_Hangul_Special0xff3f)
1265 || (tmp_key.keyval >= GDK_KEY_Hangul_Kiyeog0xea1 && tmp_key.keyval <= GDK_KEY_Hangul_J_YeorinHieuh0xefa)
1266 || keyval_is_forbidden (tmp_key.keyval))
1267 {
1268
1269 GtkWidget *dialog;
1270 char *name;
1271
1272 name = binding_name (keyval, keycode, mask, TRUE(!(0)));
1273
1274 dialog = gtk_message_dialog_new (
1275 GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (view)))((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_widget_get_toplevel (((((GtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((view)), ((gtk_widget_get_type ()))))))))
), ((gtk_window_get_type ()))))))
,
1276 GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL,
1277 GTK_MESSAGE_WARNING,
1278 GTK_BUTTONS_CANCEL,
1279 _("The shortcut \"%s\" cannot be used because it will become impossible to type using this key.\n"gettext ("The shortcut \"%s\" cannot be used because it will become impossible to type using this key.\n"
"Please try with a key such as Control, Alt or Shift at the same time."
)
1280 "Please try with a key such as Control, Alt or Shift at the same time.")gettext ("The shortcut \"%s\" cannot be used because it will become impossible to type using this key.\n"
"Please try with a key such as Control, Alt or Shift at the same time."
)
,
1281 name);
1282
1283 g_free (name);
1284 gtk_dialog_run (GTK_DIALOG (dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_dialog_get_type ()))))))
);
1285 gtk_widget_destroy (dialog);
1286
1287 /* set it back to its previous value. */
1288 egg_cell_renderer_keys_set_accelerator(
1289 EGG_CELL_RENDERER_KEYS(cell)((((EggCellRendererKeys*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((cell)), ((egg_cell_renderer_keys_get_type
()))))))
,
1290 key_entry->keyval,
1291 key_entry->keycode,
1292 key_entry->mask);
1293 return;
1294 }
1295 }
1296
1297 /* flag to see if the new accelerator was in use by something */
1298 if (!tmp_key.editable)
1299 {
1300 GtkWidget* dialog;
1301 char* name;
1302 int response;
1303
1304 name = binding_name(keyval, keycode, mask, TRUE(!(0)));
1305
1306 dialog = gtk_message_dialog_new(
1307 GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(view)))((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_widget_get_toplevel(((((GtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((view)), ((gtk_widget_get_type ()))))))))
), ((gtk_window_get_type ()))))))
,
1308 GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL,
1309 GTK_MESSAGE_WARNING,
1310 GTK_BUTTONS_CANCEL,
1311 _("The shortcut \"%s\" is already used for\n\"%s\"")gettext ("The shortcut \"%s\" is already used for\n\"%s\""),
1312 name,
1313 tmp_key.description ? tmp_key.description : tmp_key.gsettings_key);
1314 g_free (name);
1315
1316 gtk_message_dialog_format_secondary_text (
1317 GTK_MESSAGE_DIALOG (dialog)((((GtkMessageDialog*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((dialog)), ((gtk_message_dialog_get_type ())
)))))
,
1318 _("If you reassign the shortcut to \"%s\", the \"%s\" shortcut "gettext ("If you reassign the shortcut to \"%s\", the \"%s\" shortcut "
"will be disabled.")
1319 "will be disabled.")gettext ("If you reassign the shortcut to \"%s\", the \"%s\" shortcut "
"will be disabled.")
,
1320 key_entry->description ? key_entry->description : key_entry->gsettings_key,
1321 tmp_key.description ? tmp_key.description : tmp_key.gsettings_key);
1322
1323 gtk_dialog_add_button(GTK_DIALOG (dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_dialog_get_type ()))))))
, _("_Reassign")gettext ("_Reassign"), GTK_RESPONSE_ACCEPT);
1324
1325 gtk_dialog_set_default_response(GTK_DIALOG (dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_dialog_get_type ()))))))
, GTK_RESPONSE_ACCEPT);
1326
1327 response = gtk_dialog_run (GTK_DIALOG (dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_dialog_get_type ()))))))
);
1328 gtk_widget_destroy (dialog);
1329
1330 if (response == GTK_RESPONSE_ACCEPT)
1331 {
1332 g_settings_set_string (tmp_key.settings, tmp_key.gsettings_key, "disabled");
1333
1334 str = binding_name (keyval, keycode, mask, FALSE(0));
1335 g_settings_set_string (key_entry->settings, key_entry->gsettings_key, str);
1336
1337 g_free (str);
1338 }
1339 else
1340 {
1341 /* set it back to its previous value. */
1342 egg_cell_renderer_keys_set_accelerator(
1343 EGG_CELL_RENDERER_KEYS(cell)((((EggCellRendererKeys*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((cell)), ((egg_cell_renderer_keys_get_type
()))))))
,
1344 key_entry->keyval,
1345 key_entry->keycode,
1346 key_entry->mask);
1347 }
1348
1349 return;
1350 }
1351
1352 str = binding_name (keyval, keycode, mask, FALSE(0));
1353
1354 g_settings_set_string(
1355 key_entry->settings,
1356 key_entry->gsettings_key,
1357 str);
1358
1359 g_free (str);
1360
1361}
1362
1363static void
1364accel_cleared_callback (GtkCellRendererText *cell,
1365 const char *path_string,
1366 gpointer data)
1367{
1368 GtkTreeView *view = (GtkTreeView *) data;
1369 GtkTreePath *path = gtk_tree_path_new_from_string (path_string);
1370 KeyEntry *key_entry;
1371 GtkTreeIter iter;
1372 GtkTreeModel *model;
1373
1374 block_accels = FALSE(0);
1375
1376 model = gtk_tree_view_get_model (view);
1377 gtk_tree_model_get_iter (model, &iter, path);
1378 gtk_tree_path_free (path);
1379 gtk_tree_model_get (model, &iter,
1380 KEYENTRY_COLUMN, &key_entry,
1381 -1);
1382
1383 /* sanity check */
1384 if (key_entry == NULL((void*)0))
1385 return;
1386
1387 /* Unset the key */
1388 g_settings_set_string (key_entry->settings,
1389 key_entry->gsettings_key,
1390 "disabled");
1391}
1392
1393static void
1394description_edited_callback (GtkCellRendererText *renderer,
1395 gchar *path_string,
1396 gchar *new_text,
1397 gpointer user_data)
1398{
1399 GtkTreeView *view = GTK_TREE_VIEW (user_data)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((gtk_tree_view_get_type ()))))))
;
1400 GtkTreeModel *model;
1401 GtkTreePath *path = gtk_tree_path_new_from_string (path_string);
1402 GtkTreeIter iter;
1403 KeyEntry *key_entry;
1404
1405 model = gtk_tree_view_get_model (view);
1406 gtk_tree_model_get_iter (model, &iter, path);
1407 gtk_tree_path_free (path);
1408
1409 gtk_tree_model_get (model, &iter,
1410 KEYENTRY_COLUMN, &key_entry,
1411 -1);
1412
1413 /* sanity check */
1414 if (key_entry == NULL((void*)0) || key_entry->desc_gsettings_key == NULL((void*)0))
1415 return;
1416
1417 if (!g_settings_set_string (key_entry->settings, key_entry->desc_gsettings_key, new_text))
1418 key_entry->desc_editable = FALSE(0);
1419}
1420
1421typedef struct
1422{
1423 GtkTreeView *tree_view;
1424 GtkTreePath *path;
1425 GtkTreeViewColumn *column;
1426} IdleData;
1427
1428static gboolean
1429real_start_editing_cb (IdleData *idle_data)
1430{
1431 gtk_widget_grab_focus (GTK_WIDGET (idle_data->tree_view)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((idle_data->tree_view)), ((gtk_widget_get_type ())))))
)
);
1432 gtk_tree_view_set_cursor (idle_data->tree_view,
1433 idle_data->path,
1434 idle_data->column,
1435 TRUE(!(0)));
1436 gtk_tree_path_free (idle_data->path);
1437 g_free (idle_data);
1438 return FALSE(0);
1439}
1440
1441static gboolean
1442edit_custom_shortcut (KeyEntry *key)
1443{
1444 gint result;
1445 const gchar *text;
1446 gboolean ret;
1447
1448 gtk_entry_set_text (GTK_ENTRY (custom_shortcut_name_entry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((custom_shortcut_name_entry)), ((gtk_entry_get_type ())))
)))
, key->description ? key->description : "");
1449 gtk_widget_set_sensitive (custom_shortcut_name_entry, key->desc_editable);
1450 gtk_widget_grab_focus (custom_shortcut_name_entry);
1451 gtk_entry_set_text (GTK_ENTRY (custom_shortcut_command_entry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((custom_shortcut_command_entry)), ((gtk_entry_get_type ()
))))))
, key->command ? key->command : "");
1452 gtk_widget_set_sensitive (custom_shortcut_command_entry, key->cmd_editable);
1453
1454 gtk_window_present (GTK_WINDOW (custom_shortcut_dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((custom_shortcut_dialog)), ((gtk_window_get_type ()))))))
);
1455 result = gtk_dialog_run (GTK_DIALOG (custom_shortcut_dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((custom_shortcut_dialog)), ((gtk_dialog_get_type ()))))))
);
1456 switch (result)
1457 {
1458 case GTK_RESPONSE_OK:
1459 text = gtk_entry_get_text (GTK_ENTRY (custom_shortcut_name_entry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((custom_shortcut_name_entry)), ((gtk_entry_get_type ())))
)))
);
1460 g_free (key->description);
1461 key->description = g_strdup (text)g_strdup_inline (text);
1462 text = gtk_entry_get_text (GTK_ENTRY (custom_shortcut_command_entry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((custom_shortcut_command_entry)), ((gtk_entry_get_type ()
))))))
);
1463 g_free (key->command);
1464 key->command = g_strdup (text)g_strdup_inline (text);
1465 ret = TRUE(!(0));
1466 break;
1467 default:
1468 ret = FALSE(0);
1469 break;
1470 }
1471
1472 gtk_widget_hide (custom_shortcut_dialog);
1473
1474 return ret;
1475}
1476
1477static gboolean
1478remove_custom_shortcut (GtkTreeModel *model, GtkTreeIter *iter)
1479{
1480 GtkTreeIter parent;
1481 KeyEntry *key;
1482
1483 gtk_tree_model_get (model, iter,
1484 KEYENTRY_COLUMN, &key,
1485 -1);
1486
1487 /* not a custom shortcut */
1488 if (key->command == NULL((void*)0))
1489 return FALSE(0);
1490
1491 g_signal_handler_disconnect (key->settings, key->gsettings_cnxn);
1492 if (key->gsettings_cnxn_desc != 0)
1493 g_signal_handler_disconnect (key->settings, key->gsettings_cnxn_desc);
1494 if (key->gsettings_cnxn_cmd != 0)
1495 g_signal_handler_disconnect (key->settings, key->gsettings_cnxn_cmd);
1496
1497 dconf_util_recursive_reset (key->gsettings_path, NULL((void*)0));
1498 g_object_unref (key->settings);
1499
1500 g_free (key->gsettings_path);
1501 g_free (key->gsettings_key);
1502 g_free (key->description);
1503 g_free (key->desc_gsettings_key);
1504 g_free (key->command);
1505 g_free (key->cmd_gsettings_key);
1506 g_free (key);
1507
1508 gtk_tree_model_iter_parent (model, &parent, iter);
1509 gtk_tree_store_remove (GTK_TREE_STORE (model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter);
1510 if (!gtk_tree_model_iter_has_child (model, &parent))
1511 gtk_tree_store_remove (GTK_TREE_STORE (model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, &parent);
1512
1513 return TRUE(!(0));
1514}
1515
1516static void
1517update_custom_shortcut (GtkTreeModel *model, GtkTreeIter *iter)
1518{
1519 KeyEntry *key;
1520
1521 gtk_tree_model_get (model, iter,
1522 KEYENTRY_COLUMN, &key,
1523 -1);
1524
1525 edit_custom_shortcut (key);
1526 if (key->command == NULL((void*)0) || key->command[0] == '\0')
1527 {
1528 remove_custom_shortcut (model, iter);
1529 }
1530 else
1531 {
1532 gtk_tree_store_set (GTK_TREE_STORE (model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter,
1533 KEYENTRY_COLUMN, key, -1);
1534 if (key->description != NULL((void*)0))
1535 g_settings_set_string (key->settings, key->desc_gsettings_key, key->description);
1536 else
1537 g_settings_reset (key->settings, key->desc_gsettings_key);
1538 g_settings_set_string (key->settings, key->cmd_gsettings_key, key->command);
1539 }
1540}
1541
1542static gchar *
1543find_free_gsettings_path (GError **error)
1544{
1545 gchar **existing_dirs;
1546 gchar *dir = NULL((void*)0);
1547 gchar *fulldir = NULL((void*)0);
1548 int i;
1549 int j;
1550 gboolean found;
1551
1552 existing_dirs = dconf_util_list_subdirs (GSETTINGS_KEYBINDINGS_DIR"/org/mate/desktop/keybindings/", FALSE(0));
1553
1554 for (i = 0; i < MAX_CUSTOM_SHORTCUTS1000; i++)
1555 {
1556 found = TRUE(!(0));
1557 dir = g_strdup_printf ("custom%d/", i);
1558 for (j = 0; existing_dirs[j] != NULL((void*)0); j++)
1559 if (!g_strcmp0(dir, existing_dirs[j]))
1560 {
1561 found = FALSE(0);
1562 g_free (dir);
1563 break;
1564 }
1565 if (found)
1566 break;
1567 }
1568 g_strfreev (existing_dirs);
1569
1570 if (i == MAX_CUSTOM_SHORTCUTS1000)
1571 {
1572 g_free (dir);
1573 dir = NULL((void*)0);
1574 g_set_error_literal (error,
1575 g_quark_from_string ("Keyboard Shortcuts"),
1576 0,
1577 _("Too many custom shortcuts")gettext ("Too many custom shortcuts"));
1578 }
1579
1580 fulldir = g_strdup_printf ("%s%s", GSETTINGS_KEYBINDINGS_DIR"/org/mate/desktop/keybindings/", dir);
1581 g_free (dir);
1582 return fulldir;
1583}
1584
1585static void
1586add_custom_shortcut (GtkTreeView *tree_view,
1587 GtkTreeModel *model)
1588{
1589 KeyEntry *key_entry;
1590 GtkTreeIter iter;
1591 GtkTreeIter parent_iter;
1592 GtkTreePath *path;
1593 gchar *dir;
1594 GError *error;
1595
1596 error = NULL((void*)0);
1597 dir = find_free_gsettings_path (&error);
1598 if (dir == NULL((void*)0))
1599 {
1600 show_error (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (tree_view)))((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_widget_get_toplevel (((((GtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((tree_view)), ((gtk_widget_get_type ())))
)))))), ((gtk_window_get_type ()))))))
, error);
1601
1602 g_error_free (error);
1603 return;
1604 }
1605
1606 key_entry = g_new0 (KeyEntry, 1)((KeyEntry *) g_malloc0_n ((1), sizeof (KeyEntry)));
1607 key_entry->gsettings_path = g_strdup(dir)g_strdup_inline (dir);
1608 key_entry->gsettings_key = g_strdup("binding")g_strdup_inline ("binding");
1609 key_entry->editable = TRUE(!(0));
1610 key_entry->model = model;
1611 key_entry->desc_gsettings_key = g_strdup("name")g_strdup_inline ("name");
1612 key_entry->description = g_strdup ("")g_strdup_inline ("");
1613 key_entry->desc_editable = TRUE(!(0));
1614 key_entry->cmd_gsettings_key = g_strdup("action")g_strdup_inline ("action");
1615 key_entry->command = g_strdup ("")g_strdup_inline ("");
1616 key_entry->cmd_editable = TRUE(!(0));
1617 g_free (dir);
1618
1619 if (edit_custom_shortcut (key_entry) &&
1620 key_entry->command && key_entry->command[0])
1621 {
1622 find_section (model, &iter, _("Custom Shortcuts")gettext ("Custom Shortcuts"));
1623 parent_iter = iter;
1624 gtk_tree_store_append (GTK_TREE_STORE (model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, &iter, &parent_iter);
1625 gtk_tree_store_set (GTK_TREE_STORE (model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, &iter, KEYENTRY_COLUMN, key_entry, -1);
1626
1627 /* store in gsettings */
1628 key_entry->settings = g_settings_new_with_path (CUSTOM_KEYBINDING_SCHEMA"org.mate.control-center.keybinding", key_entry->gsettings_path);
1629 g_settings_set_string (key_entry->settings, key_entry->gsettings_key, "disabled");
1630 g_settings_set_string (key_entry->settings, key_entry->desc_gsettings_key, key_entry->description);
1631 g_settings_set_string (key_entry->settings, key_entry->cmd_gsettings_key, key_entry->command);
1632
1633 /* add gsettings watches */
1634 key_entry->gsettings_cnxn_desc = g_signal_connect (key_entry->settings,g_signal_connect_data ((key_entry->settings), ("changed::name"
), (((GCallback) (keybinding_description_changed))), (key_entry
), ((void*)0), (GConnectFlags) 0)
1635 "changed::name",g_signal_connect_data ((key_entry->settings), ("changed::name"
), (((GCallback) (keybinding_description_changed))), (key_entry
), ((void*)0), (GConnectFlags) 0)
1636 G_CALLBACK (keybinding_description_changed),g_signal_connect_data ((key_entry->settings), ("changed::name"
), (((GCallback) (keybinding_description_changed))), (key_entry
), ((void*)0), (GConnectFlags) 0)
1637 key_entry)g_signal_connect_data ((key_entry->settings), ("changed::name"
), (((GCallback) (keybinding_description_changed))), (key_entry
), ((void*)0), (GConnectFlags) 0)
;
1638 key_entry->gsettings_cnxn_cmd = g_signal_connect (key_entry->settings,g_signal_connect_data ((key_entry->settings), ("changed::action"
), (((GCallback) (keybinding_command_changed))), (key_entry),
((void*)0), (GConnectFlags) 0)
1639 "changed::action",g_signal_connect_data ((key_entry->settings), ("changed::action"
), (((GCallback) (keybinding_command_changed))), (key_entry),
((void*)0), (GConnectFlags) 0)
1640 G_CALLBACK (keybinding_command_changed),g_signal_connect_data ((key_entry->settings), ("changed::action"
), (((GCallback) (keybinding_command_changed))), (key_entry),
((void*)0), (GConnectFlags) 0)
1641 key_entry)g_signal_connect_data ((key_entry->settings), ("changed::action"
), (((GCallback) (keybinding_command_changed))), (key_entry),
((void*)0), (GConnectFlags) 0)
;
1642 key_entry->gsettings_cnxn = g_signal_connect (key_entry->settings,g_signal_connect_data ((key_entry->settings), ("changed::binding"
), (((GCallback) (keybinding_key_changed))), (key_entry), ((void
*)0), (GConnectFlags) 0)
1643 "changed::binding",g_signal_connect_data ((key_entry->settings), ("changed::binding"
), (((GCallback) (keybinding_key_changed))), (key_entry), ((void
*)0), (GConnectFlags) 0)
1644 G_CALLBACK (keybinding_key_changed),g_signal_connect_data ((key_entry->settings), ("changed::binding"
), (((GCallback) (keybinding_key_changed))), (key_entry), ((void
*)0), (GConnectFlags) 0)
1645 key_entry)g_signal_connect_data ((key_entry->settings), ("changed::binding"
), (((GCallback) (keybinding_key_changed))), (key_entry), ((void
*)0), (GConnectFlags) 0)
;
1646
1647 /* make the new shortcut visible */
1648 path = gtk_tree_model_get_path (model, &iter);
1649 gtk_tree_view_expand_to_path (tree_view, path);
1650 gtk_tree_view_scroll_to_cell (tree_view, path, NULL((void*)0), FALSE(0), 0, 0);
1651 gtk_tree_path_free (path);
1652 }
1653 else
1654 {
1655 g_free (key_entry->gsettings_path);
1656 g_free (key_entry->gsettings_key);
1657 g_free (key_entry->description);
1658 g_free (key_entry->desc_gsettings_key);
1659 g_free (key_entry->command);
1660 g_free (key_entry->cmd_gsettings_key);
1661 g_free (key_entry);
1662 }
1663}
1664
1665static void
1666start_editing_kb_cb (GtkTreeView *treeview,
1667 GtkTreePath *path,
1668 GtkTreeViewColumn *column,
1669 gpointer user_data)
1670{
1671 GtkTreeModel *model;
1672 GtkTreeIter iter;
1673 KeyEntry *key;
1674
1675 model = gtk_tree_view_get_model (treeview);
1676 gtk_tree_model_get_iter (model, &iter, path);
1677 gtk_tree_model_get (model, &iter,
1678 KEYENTRY_COLUMN, &key,
1679 -1);
1680
1681 if (key == NULL((void*)0))
1682 {
1683 /* This is a section heading - expand or collapse */
1684 if (gtk_tree_view_row_expanded (treeview, path))
1685 gtk_tree_view_collapse_row (treeview, path);
1686 else
1687 gtk_tree_view_expand_row (treeview, path, FALSE(0));
1688 return;
1689 }
1690
1691 /* if only the accel can be edited on the selected row
1692 * always select the accel column */
1693 if (key->desc_editable &&
1694 column == gtk_tree_view_get_column (treeview, 0))
1695 {
1696 gtk_widget_grab_focus (GTK_WIDGET (treeview)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((treeview)), ((gtk_widget_get_type ()))))))
);
1697 gtk_tree_view_set_cursor (treeview, path,
1698 gtk_tree_view_get_column (treeview, 0),
1699 FALSE(0));
1700 update_custom_shortcut (model, &iter);
1701 }
1702 else
1703 {
1704 gtk_widget_grab_focus (GTK_WIDGET (treeview)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((treeview)), ((gtk_widget_get_type ()))))))
);
1705 gtk_tree_view_set_cursor (treeview,
1706 path,
1707 gtk_tree_view_get_column (treeview, 1),
1708 TRUE(!(0)));
1709 }
1710}
1711
1712static gboolean
1713start_editing_cb (GtkTreeView *tree_view,
1714 GdkEventButton *event,
1715 gpointer user_data)
1716{
1717 GtkTreePath *path;
1718 GtkTreeViewColumn *column;
1719
1720 if ((event->window != gtk_tree_view_get_bin_window (tree_view)) ||
1721 (event->type != GDK_2BUTTON_PRESS))
1722 return FALSE(0);
1723
1724 if (gtk_tree_view_get_path_at_pos (tree_view,
1725 (gint) event->x,
1726 (gint) event->y,
1727 &path, &column,
1728 NULL((void*)0), NULL((void*)0)))
1729 {
1730 IdleData *idle_data;
1731 GtkTreeModel *model;
1732 GtkTreeIter iter;
1733 KeyEntry *key;
1734
1735 if (gtk_tree_path_get_depth (path) == 1)
1736 {
1737 gtk_tree_path_free (path);
1738 return FALSE(0);
1739 }
1740
1741 model = gtk_tree_view_get_model (tree_view);
1742 gtk_tree_model_get_iter (model, &iter, path);
1743 gtk_tree_model_get (model, &iter,
1744 KEYENTRY_COLUMN, &key,
1745 -1);
1746
1747 /* if only the accel can be edited on the selected row
1748 * always select the accel column */
1749 if (key->desc_editable &&
1750 column == gtk_tree_view_get_column (tree_view, 0))
1751 {
1752 gtk_widget_grab_focus (GTK_WIDGET (tree_view)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tree_view)), ((gtk_widget_get_type ()))))))
);
1753 gtk_tree_view_set_cursor (tree_view, path,
1754 gtk_tree_view_get_column (tree_view, 0),
1755 FALSE(0));
1756 update_custom_shortcut (model, &iter);
1757 }
1758 else
1759 {
1760 idle_data = g_new (IdleData, 1)((IdleData *) g_malloc_n ((1), sizeof (IdleData)));
1761 idle_data->tree_view = tree_view;
1762 idle_data->path = path;
1763 idle_data->column = key->desc_editable ? column :
1764 gtk_tree_view_get_column (tree_view, 1);
1765 g_idle_add ((GSourceFunc) real_start_editing_cb, idle_data);
1766 block_accels = TRUE(!(0));
1767 }
1768 g_signal_stop_emission_by_name (tree_view, "button_press_event");
1769 }
1770 return TRUE(!(0));
1771}
1772
1773/* this handler is used to keep accels from activating while the user
1774 * is assigning a new shortcut so that he won't accidentally trigger one
1775 * of the widgets */
1776static gboolean maybe_block_accels(GtkWidget* widget, GdkEventKey* event, gpointer user_data)
1777{
1778 if (block_accels)
1779 {
1780 return gtk_window_propagate_key_event(GTK_WINDOW(widget)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_window_get_type ()))))))
, event);
1781 }
1782
1783 return FALSE(0);
1784}
1785
1786static void
1787cb_dialog_response (GtkWidget *widget, gint response_id, gpointer data)
1788{
1789 GtkBuilder *builder = data;
1790 GtkTreeView *treeview;
1791 GtkTreeModel *model;
1792 GtkTreeSelection *selection;
1793 GtkTreeIter iter;
1794
1795 treeview = GTK_TREE_VIEW (gtk_builder_get_object (builder,((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, "shortcut_treeview"))),
((gtk_tree_view_get_type ()))))))
1796 "shortcut_treeview"))((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, "shortcut_treeview"))),
((gtk_tree_view_get_type ()))))))
;
1797 model = gtk_tree_view_get_model (treeview);
1798
1799 if (response_id == GTK_RESPONSE_HELP)
1800 {
1801 capplet_help (GTK_WINDOW (widget)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_window_get_type ()))))))
,
1802 "goscustdesk-39");
1803 }
1804 else if (response_id == RESPONSE_ADD0)
1805 {
1806 add_custom_shortcut (treeview, model);
1807 }
1808 else if (response_id == RESPONSE_REMOVE1)
1809 {
1810 selection = gtk_tree_view_get_selection (treeview);
1811 if (gtk_tree_selection_get_selected (selection, NULL((void*)0), &iter))
1812 {
1813 remove_custom_shortcut (model, &iter);
1814 }
1815 }
1816 else
1817 {
1818 clear_old_model (builder);
1819 gtk_main_quit ();
1820 }
1821}
1822
1823static void
1824selection_changed (GtkTreeSelection *selection, gpointer data)
1825{
1826 GtkWidget *button = data;
1827 GtkTreeModel *model;
1828 GtkTreeIter iter;
1829 KeyEntry *key;
1830 gboolean can_remove;
1831
1832 can_remove = FALSE(0);
1833 if (gtk_tree_selection_get_selected (selection, &model, &iter))
1834 {
1835 gtk_tree_model_get (model, &iter, KEYENTRY_COLUMN, &key, -1);
1836 if (key && key->command != NULL((void*)0) && key->editable)
1837 can_remove = TRUE(!(0));
1838 }
1839
1840 gtk_widget_set_sensitive (button, can_remove);
1841}
1842
1843static void
1844cb_app_dialog_response (GtkWidget *dialog, gint response_id, gpointer data)
1845{
1846 if (response_id == GTK_RESPONSE_OK)
1847 {
1848 GAppInfo *info;
1849 const gchar *custom_name;
1850
1851 info = gtk_app_chooser_get_app_info (GTK_APP_CHOOSER (dialog)((((GtkAppChooser*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_app_chooser_get_type ()))))))
);
1852
1853 gtk_entry_set_text (GTK_ENTRY (custom_shortcut_command_entry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((custom_shortcut_command_entry)), ((gtk_entry_get_type ()
))))))
,
1854 g_app_info_get_executable (info));
1855 /* if name isn't set yet, use the associated one */
1856 custom_name = gtk_entry_get_text (GTK_ENTRY (custom_shortcut_name_entry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((custom_shortcut_name_entry)), ((gtk_entry_get_type ())))
)))
);
1857 if (! custom_name || custom_name[0] == '\0')
1858 gtk_entry_set_text (GTK_ENTRY (custom_shortcut_name_entry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((custom_shortcut_name_entry)), ((gtk_entry_get_type ())))
)))
,
1859 g_app_info_get_display_name (info));
1860
1861 g_object_unref (info);
1862 }
1863
1864 gtk_widget_hide (dialog);
1865}
1866
1867static void
1868setup_dialog (GtkBuilder *builder, GSettings *marco_settings)
1869{
1870 GtkCellRenderer *renderer;
1871 GtkTreeViewColumn *column;
1872 GtkWidget *widget;
1873 GtkTreeView *treeview;
1874 GtkTreeSelection *selection;
1875 GtkWidget *button;
1876
1877 treeview = GTK_TREE_VIEW (gtk_builder_get_object (builder,((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, "shortcut_treeview"))),
((gtk_tree_view_get_type ()))))))
1878 "shortcut_treeview"))((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, "shortcut_treeview"))),
((gtk_tree_view_get_type ()))))))
;
1879
1880 g_signal_connect (treeview, "button_press_event",g_signal_connect_data ((treeview), ("button_press_event"), ((
(GCallback) (start_editing_cb))), (builder), ((void*)0), (GConnectFlags
) 0)
1881 G_CALLBACK (start_editing_cb), builder)g_signal_connect_data ((treeview), ("button_press_event"), ((
(GCallback) (start_editing_cb))), (builder), ((void*)0), (GConnectFlags
) 0)
;
1882 g_signal_connect (treeview, "row-activated",g_signal_connect_data ((treeview), ("row-activated"), (((GCallback
) (start_editing_kb_cb))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
1883 G_CALLBACK (start_editing_kb_cb), NULL)g_signal_connect_data ((treeview), ("row-activated"), (((GCallback
) (start_editing_kb_cb))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
;
1884
1885 renderer = gtk_cell_renderer_text_new ();
1886
1887 g_signal_connect (renderer, "edited",g_signal_connect_data ((renderer), ("edited"), (((GCallback) (
description_edited_callback))), (treeview), ((void*)0), (GConnectFlags
) 0)
1888 G_CALLBACK (description_edited_callback),g_signal_connect_data ((renderer), ("edited"), (((GCallback) (
description_edited_callback))), (treeview), ((void*)0), (GConnectFlags
) 0)
1889 treeview)g_signal_connect_data ((renderer), ("edited"), (((GCallback) (
description_edited_callback))), (treeview), ((void*)0), (GConnectFlags
) 0)
;
1890
1891 column = gtk_tree_view_column_new_with_attributes (_("Action")gettext ("Action"),
1892 renderer,
1893 "text", DESCRIPTION_COLUMN,
1894 NULL((void*)0));
1895 gtk_tree_view_column_set_cell_data_func (column, renderer, description_set_func, NULL((void*)0), NULL((void*)0));
1896 gtk_tree_view_column_set_resizable (column, FALSE(0));
1897
1898 gtk_tree_view_append_column (treeview, column);
1899 gtk_tree_view_column_set_sort_column_id (column, DESCRIPTION_COLUMN);
1900
1901 renderer = (GtkCellRenderer *) g_object_new (EGG_TYPE_CELL_RENDERER_KEYS(egg_cell_renderer_keys_get_type ()),
1902 "accel_mode", EGG_CELL_RENDERER_KEYS_MODE_X,
1903 NULL((void*)0));
1904
1905 g_signal_connect (renderer, "accel_edited",g_signal_connect_data ((renderer), ("accel_edited"), (((GCallback
) (accel_edited_callback))), (treeview), ((void*)0), (GConnectFlags
) 0)
1906 G_CALLBACK (accel_edited_callback),g_signal_connect_data ((renderer), ("accel_edited"), (((GCallback
) (accel_edited_callback))), (treeview), ((void*)0), (GConnectFlags
) 0)
1907 treeview)g_signal_connect_data ((renderer), ("accel_edited"), (((GCallback
) (accel_edited_callback))), (treeview), ((void*)0), (GConnectFlags
) 0)
;
1908
1909 g_signal_connect (renderer, "accel_cleared",g_signal_connect_data ((renderer), ("accel_cleared"), (((GCallback
) (accel_cleared_callback))), (treeview), ((void*)0), (GConnectFlags
) 0)
1910 G_CALLBACK (accel_cleared_callback),g_signal_connect_data ((renderer), ("accel_cleared"), (((GCallback
) (accel_cleared_callback))), (treeview), ((void*)0), (GConnectFlags
) 0)
1911 treeview)g_signal_connect_data ((renderer), ("accel_cleared"), (((GCallback
) (accel_cleared_callback))), (treeview), ((void*)0), (GConnectFlags
) 0)
;
1912
1913 column = gtk_tree_view_column_new_with_attributes (_("Shortcut")gettext ("Shortcut"), renderer, NULL((void*)0));
1914 gtk_tree_view_column_set_cell_data_func (column, renderer, accel_set_func, NULL((void*)0), NULL((void*)0));
1915 gtk_tree_view_column_set_resizable (column, FALSE(0));
1916
1917 gtk_tree_view_append_column (treeview, column);
1918 gtk_tree_view_column_set_sort_column_id (column, KEYENTRY_COLUMN);
1919
1920 g_signal_connect (marco_settings,g_signal_connect_data ((marco_settings), ("changed::num-workspaces"
), (((GCallback) (key_entry_controlling_key_changed))), (builder
), ((void*)0), (GConnectFlags) 0)
1921 "changed::num-workspaces",g_signal_connect_data ((marco_settings), ("changed::num-workspaces"
), (((GCallback) (key_entry_controlling_key_changed))), (builder
), ((void*)0), (GConnectFlags) 0)
1922 G_CALLBACK (key_entry_controlling_key_changed),g_signal_connect_data ((marco_settings), ("changed::num-workspaces"
), (((GCallback) (key_entry_controlling_key_changed))), (builder
), ((void*)0), (GConnectFlags) 0)
1923 builder)g_signal_connect_data ((marco_settings), ("changed::num-workspaces"
), (((GCallback) (key_entry_controlling_key_changed))), (builder
), ((void*)0), (GConnectFlags) 0)
;
1924
1925 /* set up the dialog */
1926 reload_key_entries (builder);
1927
1928 widget = _gtk_builder_get_widget (builder, "mate-keybinding-dialog");
1929 gtk_window_set_default_size (GTK_WINDOW (widget)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_window_get_type ()))))))
, 400, 500);
1930 widget = _gtk_builder_get_widget (builder, "label-suggest");
1931 gtk_label_set_line_wrap (GTK_LABEL (widget)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_label_get_type ()))))))
, TRUE(!(0)));
1932 gtk_label_set_max_width_chars (GTK_LABEL (widget)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_label_get_type ()))))))
, 60);
1933
1934 widget = _gtk_builder_get_widget (builder, "mate-keybinding-dialog");
1935 capplet_set_icon (widget, "preferences-desktop-keyboard-shortcuts");
1936 gtk_widget_show (widget);
1937
1938 g_signal_connect (widget, "key_press_event", G_CALLBACK (maybe_block_accels), NULL)g_signal_connect_data ((widget), ("key_press_event"), (((GCallback
) (maybe_block_accels))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
;
1939 g_signal_connect (widget, "response", G_CALLBACK (cb_dialog_response), builder)g_signal_connect_data ((widget), ("response"), (((GCallback) (
cb_dialog_response))), (builder), ((void*)0), (GConnectFlags)
0)
;
1940
1941 selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((treeview)), ((gtk_tree_view_get_type ()))))))
);
1942 g_signal_connect (selection, "changed",g_signal_connect_data ((selection), ("changed"), (((GCallback
) (selection_changed))), (_gtk_builder_get_widget (builder, "remove-button"
)), ((void*)0), (GConnectFlags) 0)
1943 G_CALLBACK (selection_changed),g_signal_connect_data ((selection), ("changed"), (((GCallback
) (selection_changed))), (_gtk_builder_get_widget (builder, "remove-button"
)), ((void*)0), (GConnectFlags) 0)
1944 _gtk_builder_get_widget (builder, "remove-button"))g_signal_connect_data ((selection), ("changed"), (((GCallback
) (selection_changed))), (_gtk_builder_get_widget (builder, "remove-button"
)), ((void*)0), (GConnectFlags) 0)
;
1945
1946 /* setup the custom shortcut dialog */
1947 custom_shortcut_dialog = _gtk_builder_get_widget (builder,
1948 "custom-shortcut-dialog");
1949 custom_shortcut_name_entry = _gtk_builder_get_widget (builder,
1950 "custom-shortcut-name-entry");
1951 custom_shortcut_command_entry = _gtk_builder_get_widget (builder,
1952 "custom-shortcut-command-entry");
1953 gtk_dialog_set_default_response (GTK_DIALOG (custom_shortcut_dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((custom_shortcut_dialog)), ((gtk_dialog_get_type ()))))))
,
1954 GTK_RESPONSE_OK);
1955 gtk_window_set_transient_for (GTK_WINDOW (custom_shortcut_dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((custom_shortcut_dialog)), ((gtk_window_get_type ()))))))
,
1956 GTK_WINDOW (widget)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_window_get_type ()))))))
);
1957 button = _gtk_builder_get_widget (builder, "custom-shortcut-command-button");
1958 widget = _gtk_builder_get_widget (builder, "custom-shortcut-application-dialog");
1959 g_signal_connect_swapped (button, "clicked", G_CALLBACK (gtk_dialog_run), widget)g_signal_connect_data ((button), ("clicked"), (((GCallback) (
gtk_dialog_run))), (widget), ((void*)0), G_CONNECT_SWAPPED)
;
1960 g_signal_connect (widget, "response", G_CALLBACK (cb_app_dialog_response), NULL)g_signal_connect_data ((widget), ("response"), (((GCallback) (
cb_app_dialog_response))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
;
1961 widget = gtk_app_chooser_dialog_get_widget (GTK_APP_CHOOSER_DIALOG (widget)((((GtkAppChooserDialog*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((widget)), ((gtk_app_chooser_dialog_get_type
()))))))
);
1962 gtk_app_chooser_widget_set_show_all (GTK_APP_CHOOSER_WIDGET (widget)((((GtkAppChooserWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((widget)), ((gtk_app_chooser_widget_get_type
()))))))
, TRUE(!(0)));
1963}
1964
1965static void
1966on_window_manager_change (const char *wm_name, GtkBuilder *builder)
1967{
1968 reload_key_entries (builder);
1969}
1970
1971int
1972main (int argc, char *argv[])
1973{
1974 GtkBuilder *builder;
1975 GSettings *marco_settings;
1976
1977 capplet_init (NULL((void*)0), &argc, &argv);
1978
1979 activate_settings_daemon ();
1980
1981 builder = gtk_builder_new_from_resource ("/org/mate/mcc/keybindings/mate-keybinding-properties.ui");
1982
1983 wm_common_register_window_manager_change ((GFunc) on_window_manager_change, builder);
1984
1985 marco_settings = g_settings_new ("org.mate.Marco.general");
1986
1987 setup_dialog (builder, marco_settings);
1988
1989 gtk_main ();
1990
1991 g_object_unref (marco_settings);
1992 g_object_unref (builder);
1993 return 0;
1994}
1995
1996/*
1997 * vim: sw=2 ts=8 cindent noai bs=2
1998 */
diff --git a/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-56f85a.html b/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-56f85a.html new file mode 100644 index 00000000..2bd6f702 --- /dev/null +++ b/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-56f85a.html @@ -0,0 +1,1455 @@ + + + +mate-system-info.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:capplets/system-info/mate-system-info.c
Warning:line 369, column 16
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name mate-system-info.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/capplets/system-info -fcoverage-compilation-dir=/rootdir/capplets/system-info -resource-dir /usr/bin/../lib/clang/18 -D HAVE_CONFIG_H -I . -I ../.. -I ../../capplets/common -I /usr/include/udisks2 -I /usr/include/libgtop-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/libxml2 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/gio-unix-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/dconf -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I ../../ -D G_LOG_DOMAIN="system-info-properties" -I /usr/include/polkit-1 -I /usr/include/gio-unix-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -D MATECC_DATA_DIR="/usr/local/share/mate-control-center" -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-06-07-044335-13427-1 -x c mate-system-info.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
2 *
3 * Copyright (C) 2023 MATE Developers
4 * Copyright (C) 2019 Purism SPC
5 * Copyright (C) 2017 Mohammed Sadiq <sadiq@sadiqpk.org>
6 * Copyright (C) 2010 Red Hat, Inc
7 * Copyright (C) 2008 William Jon McCann <jmccann@redhat.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, see <http://www.gnu.org/licenses/>.
21 *
22 */
23#include <gtk/gtk.h>
24#include <glib.h>
25#include <glibtop/fsusage.h>
26#include <glibtop/mountlist.h>
27#include <glibtop/mem.h>
28#include <glibtop/sysinfo.h>
29#include <udisks/udisks.h>
30#include <sys/utsname.h>
31
32#ifdef GDK_WINDOWING_WAYLAND
33#include <gdk/gdkwayland.h>
34#endif
35#ifdef GDK_WINDOWING_X11
36#include <gdk/gdkx.h>
37#endif
38
39#include "info-cleanup.h"
40#include "mate-system-info.h"
41#include "mate-system-info-resources.h"
42
43struct _MateSystemInfo
44{
45 GtkDialog parent_instance;
46 GtkWidget *logo_image;
47 GtkWidget *hostname_row;
48 GtkListBox *hardware_box;
49 GtkWidget *hardware_model_row;
50 GtkWidget *memory_row;
51 GtkWidget *processor_row;
52 GtkWidget *graphics_row;
53 GtkWidget *disk_row;
54 GtkListBox *os_box;
55 GtkWidget *kernel_row;
56 GtkWidget *virtualization_row;
57 GtkWidget *windowing_system_row;
58 GtkWidget *mate_version_row;
59 GtkWidget *os_name_row;
60 GtkWidget *os_type_row;
61};
62
63G_DEFINE_TYPE (MateSystemInfo, mate_system_info, GTK_TYPE_DIALOG)static void mate_system_info_init (MateSystemInfo *self); static
void mate_system_info_class_init (MateSystemInfoClass *klass
); static GType mate_system_info_get_type_once (void); static
gpointer mate_system_info_parent_class = ((void*)0); static gint
MateSystemInfo_private_offset; static void mate_system_info_class_intern_init
(gpointer klass) { mate_system_info_parent_class = g_type_class_peek_parent
(klass); if (MateSystemInfo_private_offset != 0) g_type_class_adjust_private_offset
(klass, &MateSystemInfo_private_offset); mate_system_info_class_init
((MateSystemInfoClass*) klass); } __attribute__ ((__unused__
)) static inline gpointer mate_system_info_get_instance_private
(MateSystemInfo *self) { return (((gpointer) ((guint8*) (self
) + (glong) (MateSystemInfo_private_offset)))); } GType mate_system_info_get_type
(void) { static GType static_g_define_type_id = 0; if ((__extension__
({ _Static_assert (sizeof *(&static_g_define_type_id) ==
sizeof (gpointer), "Expression evaluates to false"); (void) (
0 ? (gpointer) * (&static_g_define_type_id) : ((void*)0))
; (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter_pointer (
&static_g_define_type_id)); })) ) { GType g_define_type_id
= mate_system_info_get_type_once (); (__extension__ ({ _Static_assert
(sizeof *(&static_g_define_type_id) == sizeof (gpointer)
, "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id
) = (g_define_type_id)) : (void) 0; g_once_init_leave_pointer
((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id
)); })) ; } return static_g_define_type_id; } __attribute__ (
(__noinline__)) static GType mate_system_info_get_type_once (
void) { GType g_define_type_id = g_type_register_static_simple
((gtk_dialog_get_type ()), g_intern_static_string ("MateSystemInfo"
), sizeof (MateSystemInfoClass), (GClassInitFunc)(void (*)(void
)) mate_system_info_class_intern_init, sizeof (MateSystemInfo
), (GInstanceInitFunc)(void (*)(void)) mate_system_info_init,
(GTypeFlags) 0); { {{};} } return g_define_type_id; }
64
65static void
66set_lable_style (GtkWidget *lable,
67 const char *color,
68 int font_szie,
69 const char *text,
70 gboolean blod)
71{
72 g_autofree__attribute__((cleanup(g_autoptr_cleanup_generic_gfree))) gchar *lable_text = NULL((void*)0);
73
74 if (color == NULL((void*)0))
75 {
76 lable_text = g_strdup_printf ("<span weight=\'light\'font_desc=\'%d\'><b>%s</b></span>", font_szie, text);
77 }
78 else
79 {
80 if(blod)
81 {
82 lable_text = g_strdup_printf ("<span foreground=\'%s\'weight=\'light\'font_desc=\'%d\'><b>%s</b></span>",
83 color,
84 font_szie,
85 text);
86 }
87 else
88 {
89 lable_text = g_strdup_printf ("<span foreground=\'%s\'weight=\'light\'font_desc=\'%d\'>%s</span>",
90 color,
91 font_szie,
92 text);
93 }
94 }
95
96 gtk_label_set_markup (GTK_LABEL(lable)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((lable)), ((gtk_label_get_type ()))))))
, lable_text);
97}
98
99static void
100mate_system_info_row_fill (GtkWidget *row,
101 const char *labelname,
102 gboolean is_separator)
103{
104 GtkWidget *vbox;
105 GtkWidget *box;
106 GtkWidget *label;
107 GtkWidget *separator;
108
109 vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
110 box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
111 gtk_box_set_spacing (GTK_BOX (box)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((box)), ((gtk_box_get_type ()))))))
, 12);
112 g_object_set (box, "margin", 12, NULL((void*)0));
113 gtk_box_pack_start (GTK_BOX (vbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((vbox)), ((gtk_box_get_type ()))))))
, box, FALSE(0), FALSE(0), 3);
114
115 label = gtk_label_new (NULL((void*)0));
116 set_lable_style (label, NULL((void*)0), 12, labelname, TRUE(!(0)));
117 gtk_label_set_ellipsize (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, PANGO_ELLIPSIZE_END);
118 gtk_box_pack_start (GTK_BOX (box)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((box)), ((gtk_box_get_type ()))))))
, label, FALSE(0), FALSE(0), 6);
119
120 label = gtk_label_new (NULL((void*)0));
121 gtk_box_pack_end (GTK_BOX (box)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((box)), ((gtk_box_get_type ()))))))
, label, FALSE(0), FALSE(0), 6);
122 g_object_set_data (G_OBJECT (row)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((row)), (((GType) ((20) << (2))))))))
, "labelvalue", label);
123
124 separator = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
125 if (is_separator)
126 gtk_box_pack_start (GTK_BOX (vbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((vbox)), ((gtk_box_get_type ()))))))
, separator, FALSE(0), FALSE(0), 0);
127
128 gtk_container_add (GTK_CONTAINER (row)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((row)), ((gtk_container_get_type ()))))))
, vbox);
129}
130
131static void
132mate_system_info_set_row (MateSystemInfo *info)
133{
134 mate_system_info_row_fill (info->hostname_row, _("Device Name")gettext ("Device Name"), FALSE(0));
135# ifdef HAVE_SYSTEMD
136 mate_system_info_row_fill (info->hardware_model_row, _("Hardware Model")gettext ("Hardware Model"), TRUE(!(0)));
137 mate_system_info_row_fill (info->virtualization_row, _("Virtualization")gettext ("Virtualization"), TRUE(!(0)));
138# endif
139 mate_system_info_row_fill (info->memory_row, _("Memory")gettext ("Memory"), TRUE(!(0)));
140 mate_system_info_row_fill (info->processor_row, _("Processor")gettext ("Processor"), TRUE(!(0)));
141 mate_system_info_row_fill (info->graphics_row, _("Graphics")gettext ("Graphics"), TRUE(!(0)));
142 mate_system_info_row_fill (info->disk_row, _("Disk Capacity")gettext ("Disk Capacity"), FALSE(0));
143 mate_system_info_row_fill (info->kernel_row, _("Kernel Version")gettext ("Kernel Version"), FALSE(0));
144 mate_system_info_row_fill (info->windowing_system_row, _("Windowing System")gettext ("Windowing System"), TRUE(!(0)));
145 mate_system_info_row_fill (info->mate_version_row, _("MATE Version")gettext ("MATE Version"), TRUE(!(0)));
146 mate_system_info_row_fill (info->os_name_row, _("OS Name")gettext ("OS Name"), TRUE(!(0)));
147 mate_system_info_row_fill (info->os_type_row, _("OS Type")gettext ("OS Type"), TRUE(!(0)));
148
149 gtk_widget_show (info->logo_image);
150 gtk_widget_show_all (info->hostname_row);
151 gtk_widget_show_all (info->memory_row);
152 gtk_widget_show_all (info->processor_row);
153 gtk_widget_show_all (info->graphics_row);
154 gtk_widget_show_all (info->disk_row);
155 gtk_widget_show_all (info->kernel_row);
156 gtk_widget_show_all (info->windowing_system_row);
157 gtk_widget_show_all (info->mate_version_row);
158 gtk_widget_show_all (info->os_type_row);
159 gtk_widget_show_all (info->os_name_row);
160}
161
162static char *
163get_system_hostname (void)
164{
165# ifdef HAVE_SYSTEMD
166 GDBusProxy *hostnamed_proxy;
167 g_autoptr(GVariant)__attribute__((cleanup(glib_autoptr_cleanup_GVariant))) GVariant_autoptr variant = NULL((void*)0);
168 g_autoptr(GError)__attribute__((cleanup(glib_autoptr_cleanup_GError))) GError_autoptr error = NULL((void*)0);
169
170 hostnamed_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
171 G_DBUS_PROXY_FLAGS_NONE,
172 NULL((void*)0),
173 "org.freedesktop.hostname1",
174 "/org/freedesktop/hostname1",
175 "org.freedesktop.hostname1",
176 NULL((void*)0),
177 &error);
178
179 if (!hostnamed_proxy)
180 return g_strdup ("")g_strdup_inline ("");
181
182 variant = g_dbus_proxy_get_cached_property (hostnamed_proxy, "Hostname");
183 if (!variant)
184 {
185 g_autoptr(GError)__attribute__((cleanup(glib_autoptr_cleanup_GError))) GError_autoptr error = NULL((void*)0);
186 g_autoptr(GVariant)__attribute__((cleanup(glib_autoptr_cleanup_GVariant))) GVariant_autoptr inner = NULL((void*)0);
187
188 /* Work around systemd-hostname not sending us back
189 * the property value when changing values */
190 variant = g_dbus_proxy_call_sync (hostnamed_proxy,
191 "org.freedesktop.DBus.Properties.Get",
192 g_variant_new ("(ss)", "org.freedesktop.hostname1", "Hostname"),
193 G_DBUS_CALL_FLAGS_NONE,
194 -1,
195 NULL((void*)0),
196 &error);
197 if (variant == NULL((void*)0))
198 {
199 g_warning ("Failed to get property '%s': %s", "Hostname", error->message);
200 g_object_unref (hostnamed_proxy);
201 return NULL((void*)0);
202 }
203
204 g_variant_get (variant, "(v)", &inner);
205 g_object_unref (hostnamed_proxy);
206 return g_variant_dup_string (inner, NULL((void*)0));
207 }
208 else
209 {
210 g_object_unref (hostnamed_proxy);
211 return g_variant_dup_string (variant, NULL((void*)0));
212 }
213# else
214 return g_strdup (g_get_host_name ())g_strdup_inline (g_get_host_name ());
215# endif
216}
217
218# ifdef HAVE_SYSTEMD
219static char *
220get_hardware_model (void)
221{
222 g_autoptr(GDBusProxy)__attribute__((cleanup(glib_autoptr_cleanup_GDBusProxy))) GDBusProxy_autoptr hostnamed_proxy = NULL((void*)0);
223 g_autoptr(GVariant)__attribute__((cleanup(glib_autoptr_cleanup_GVariant))) GVariant_autoptr vendor_variant = NULL((void*)0);
224 g_autoptr(GVariant)__attribute__((cleanup(glib_autoptr_cleanup_GVariant))) GVariant_autoptr model_variant = NULL((void*)0);
225 const char *vendor_string, *model_string;
226 g_autoptr(GError)__attribute__((cleanup(glib_autoptr_cleanup_GError))) GError_autoptr error = NULL((void*)0);
227
228 hostnamed_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
229 G_DBUS_PROXY_FLAGS_NONE,
230 NULL((void*)0),
231 "org.freedesktop.hostname1",
232 "/org/freedesktop/hostname1",
233 "org.freedesktop.hostname1",
234 NULL((void*)0),
235 &error);
236 if (hostnamed_proxy == NULL((void*)0))
237 {
238 g_debug ("Couldn't get hostnamed to start, bailing: %s", error->message);
239 return NULL((void*)0);
240 }
241
242 vendor_variant = g_dbus_proxy_get_cached_property (hostnamed_proxy, "HardwareVendor");
243 if (!vendor_variant)
244 {
245 g_debug ("Unable to retrieve org.freedesktop.hostname1.HardwareVendor property");
246 return NULL((void*)0);
247 }
248
249 model_variant = g_dbus_proxy_get_cached_property (hostnamed_proxy, "HardwareModel");
250 if (!model_variant)
251 {
252 g_debug ("Unable to retrieve org.freedesktop.hostname1.HardwareModel property");
253 return NULL((void*)0);
254 }
255
256 vendor_string = g_variant_get_string (vendor_variant, NULL((void*)0)),
257 model_string = g_variant_get_string (model_variant, NULL((void*)0));
258
259 if (vendor_string && g_strcmp0 (vendor_string, "") != 0)
260 {
261 gchar *vendor_model = NULL((void*)0);
262
263 vendor_model = g_strdup_printf ("%s %s", vendor_string, model_string);
264 return vendor_model;
265 }
266
267 return NULL((void*)0);
268}
269# endif
270
271static char *
272get_cpu_info (void)
273{
274 g_autoptr(GHashTable)__attribute__((cleanup(glib_autoptr_cleanup_GHashTable))) GHashTable_autoptr counts = NULL((void*)0);
275 const glibtop_sysinfo *info;
276 g_autoptr(GString)__attribute__((cleanup(glib_autoptr_cleanup_GString))) GString_autoptr cpu = NULL((void*)0);
277 GHashTableIter iter;
278 gpointer key, value;
279 int i;
280 int j;
281
282 counts = g_hash_table_new (g_str_hash, g_str_equal);
283 info = glibtop_get_sysinfo ();
284
285 /* count duplicates */
286 for (i = 0; i != info->ncpu; ++i)
287 {
288 const char * const keys[] = { "model name", "cpu", "Processor" ,"Model Name"};
289 char *model;
290 int *count;
291 model = NULL((void*)0);
292
293 for (j = 0; model == NULL((void*)0) && j != G_N_ELEMENTS (keys)(sizeof (keys) / sizeof ((keys)[0])); ++j)
294 {
295 model = g_hash_table_lookup (info->cpuinfo[i].values,
296 keys[j]);
297 }
298
299 if (model == NULL((void*)0))
300 continue;
301 count = g_hash_table_lookup (counts, model);
302 if (count == NULL((void*)0))
303 g_hash_table_insert (counts, model, GINT_TO_POINTER (1)((gpointer) (glong) (1)));
304 else
305 g_hash_table_replace (counts, model, GINT_TO_POINTER (GPOINTER_TO_INT (count) + 1)((gpointer) (glong) (((gint) (glong) (count)) + 1)));
306 }
307
308 cpu = g_string_new (NULL((void*)0));
309 g_hash_table_iter_init (&iter, counts);
310 while (g_hash_table_iter_next (&iter, &key, &value))
311 {
312 g_autofree__attribute__((cleanup(g_autoptr_cleanup_generic_gfree))) char *cleanedup = NULL((void*)0);
313 int count;
314
315 count = GPOINTER_TO_INT (value)((gint) (glong) (value));
316 cleanedup = info_cleanup ((const char *) key);
317 if (count > 1)
318 g_string_append_printf (cpu, "%s \303\227 %d ", cleanedup, count);
319 else
320 g_string_append_printf (cpu, "%s ", cleanedup);
321 }
322
323 return g_strdup (cpu->str)g_strdup_inline (cpu->str);
324}
325
326static char *
327get_renderer_from_session (void)
328{
329 g_autoptr(GDBusProxy)__attribute__((cleanup(glib_autoptr_cleanup_GDBusProxy))) GDBusProxy_autoptr session_proxy = NULL((void*)0);
330 g_autoptr(GVariant)__attribute__((cleanup(glib_autoptr_cleanup_GVariant))) GVariant_autoptr renderer_variant = NULL((void*)0);
331 char *renderer;
332 g_autoptr(GError)__attribute__((cleanup(glib_autoptr_cleanup_GError))) GError_autoptr error = NULL((void*)0);
333
334 session_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
335 G_DBUS_PROXY_FLAGS_NONE,
336 NULL((void*)0),
337 "org.gnome.SessionManager",
338 "/org/gnome/SessionManager",
339 "org.gnome.SessionManager",
340 NULL((void*)0), &error);
341 if (error != NULL((void*)0))
342 {
343 g_warning ("Unable to connect to create a proxy for org.gnome.SessionManager: %s",
344 error->message);
345 return NULL((void*)0);
346 }
347
348 renderer_variant = g_dbus_proxy_get_cached_property (session_proxy, "Renderer");
349
350 if (!renderer_variant)
351 {
352 g_warning ("Unable to retrieve org.gnome.SessionManager.Renderer property");
353 return NULL((void*)0);
354 }
355
356 renderer = info_cleanup (g_variant_get_string (renderer_variant, NULL((void*)0)));
357
358 return renderer;
359}
360
361static gchar *
362get_graphics_hardware_string (void)
363{
364 g_autofree__attribute__((cleanup(g_autoptr_cleanup_generic_gfree))) char *discrete_renderer = NULL((void*)0);
365 g_autofree__attribute__((cleanup(g_autoptr_cleanup_generic_gfree))) char *renderer = NULL((void*)0);
366
367 renderer = get_renderer_from_session ();
368 if (!renderer)
369 return g_strdup ("Unknown")g_strdup_inline ("Unknown");
This statement is never executed
370
371 return g_strdup (renderer)g_strdup_inline (renderer);
372}
373
374static char *
375get_primary_disk_size (void)
376{
377 g_autoptr(UDisksClient)__attribute__((cleanup(glib_autoptr_cleanup_UDisksClient))) UDisksClient_autoptr client = NULL((void*)0);
378 GDBusObjectManager *manager;
379 g_autolist(GDBusObject)__attribute__((cleanup(glib_listautoptr_cleanup_GDBusObject))
) GDBusObject_listautoptr
objects = NULL((void*)0);
380 GList *l;
381 gchar *size;
382 guint64 total_size;
383 g_autoptr(GError)__attribute__((cleanup(glib_autoptr_cleanup_GError))) GError_autoptr error = NULL((void*)0);
384
385 total_size = 0;
386
387 client = udisks_client_new_sync (NULL((void*)0), &error);
388 if (client == NULL((void*)0))
389 {
390 g_warning ("Unable to get UDisks client: %s. Disk information will not be available.",
391 error->message);
392 return g_strdup ("Unknown")g_strdup_inline ("Unknown");
393 }
394
395 manager = udisks_client_get_object_manager (client);
396 objects = g_dbus_object_manager_get_objects (manager);
397
398 for (l = objects; l != NULL((void*)0); l = l->next)
399 {
400 UDisksDrive *drive;
401 drive = udisks_object_peek_drive (UDISKS_OBJECT (l->data)((((UDisksObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((l->data)), ((udisks_object_get_type ()))))))
);
402
403 /* Skip removable devices */
404 if (drive == NULL((void*)0) ||
405 udisks_drive_get_removable (drive) ||
406 udisks_drive_get_ejectable (drive))
407 {
408 continue;
409 }
410
411 total_size += udisks_drive_get_size (drive);
412 }
413 if (total_size > 0)
414 {
415 size = g_format_size (total_size);
416 }
417 else
418 {
419 size = g_strdup ("Unknown")g_strdup_inline ("Unknown");
420 }
421
422 return size;
423}
424
425static char *
426get_os_name (void)
427{
428 g_autofree__attribute__((cleanup(g_autoptr_cleanup_generic_gfree))) gchar *name = NULL((void*)0);
429 g_autofree__attribute__((cleanup(g_autoptr_cleanup_generic_gfree))) gchar *version_id = NULL((void*)0);
430 g_autofree__attribute__((cleanup(g_autoptr_cleanup_generic_gfree))) gchar *pretty_name = NULL((void*)0);
431 g_autofree__attribute__((cleanup(g_autoptr_cleanup_generic_gfree))) gchar *name_version = NULL((void*)0);
432 gchar *result = NULL((void*)0);
433
434 name = g_get_os_info (G_OS_INFO_KEY_NAME"NAME");
435 version_id = g_get_os_info (G_OS_INFO_KEY_VERSION_ID"VERSION_ID");
436 pretty_name = g_get_os_info (G_OS_INFO_KEY_PRETTY_NAME"PRETTY_NAME");
437
438 if (pretty_name)
439 name_version = g_strdup (pretty_name)g_strdup_inline (pretty_name);
440 else if (name && version_id)
441 name_version = g_strdup_printf ("%s %s", name, version_id);
442 else
443 name_version = g_strdup (("Unknown"))g_strdup_inline (("Unknown"));
444
445 result = g_strdup (name_version)g_strdup_inline (name_version);
446
447 return result;
448}
449
450static char *
451get_os_type (void)
452{
453 if (GLIB_SIZEOF_VOID_P8 == 8)
454 /* translators: This is the type of architecture for the OS */
455 return g_strdup_printf ("64-bit");
456 else
457 /* translators: This is the type of architecture for the OS */
458 return g_strdup_printf ("32-bit");
459}
460
461static char *
462get_windowing_system (void)
463{
464 GdkDisplay *display;
465
466 display = gdk_display_get_default ();
467
468#if defined(GDK_WINDOWING_X11)
469 if (GDK_IS_X11_DISPLAY (display)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(display)); GType __t = ((gdk_x11_display_get_type())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
)
470 return g_strdup ("X11")g_strdup_inline ("X11");
471#endif /* GDK_WINDOWING_X11 */
472#if defined(GDK_WINDOWING_WAYLAND)
473 if (GDK_IS_WAYLAND_DISPLAY (display)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(display)); GType __t = ((gdk_wayland_display_get_type())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
)
474 return g_strdup ("Wayland")g_strdup_inline ("Wayland");
475#endif /* GDK_WINDOWING_WAYLAND */
476 return g_strdup (C_("Windowing system (Wayland, X11, or Unknown)", "Unknown"))g_strdup_inline (g_dpgettext (((void*)0), "Windowing system (Wayland, X11, or Unknown)"
"\004" "Unknown", strlen ("Windowing system (Wayland, X11, or Unknown)"
) + 1))
;
477}
478
479static char *
480get_kernel_vesrion (void)
481{
482 struct utsname un;
483
484 if (uname (&un) < 0)
485 return NULL((void*)0);
486
487 return g_strdup_printf ("%s %s", un.sysname, un.release);
488}
489
490# ifdef HAVE_SYSTEMD
491static struct {
492 const char *id;
493 const char *display;
494} const virt_tech[] = {
495 { "kvm", "KVM" },
496 { "qemu", "QEmu" },
497 { "vmware", "VMware" },
498 { "microsoft", "Microsoft" },
499 { "oracle", "Oracle" },
500 { "xen", "Xen" },
501 { "bochs", "Bochs" },
502 { "chroot", "chroot" },
503 { "openvz", "OpenVZ" },
504 { "lxc", "LXC" },
505 { "lxc-libvirt", "LXC (libvirt)" },
506 { "systemd-nspawn", "systemd (nspawn)" }
507};
508
509static char *
510get_virtualization_label (const char *virt)
511{
512 const char *display_name;
513 guint i;
514
515 if (virt == NULL((void*)0) || *virt == '\0')
516 {
517 return NULL((void*)0);
518 }
519
520 display_name = NULL((void*)0);
521 for (i = 0; i < G_N_ELEMENTS (virt_tech)(sizeof (virt_tech) / sizeof ((virt_tech)[0])); i++)
522 {
523 if (g_str_equal (virt_tech[i].id, virt)(strcmp ((const char *) (virt_tech[i].id), (const char *) (virt
)) == 0)
)
524 {
525 display_name = virt_tech[i].display;
526 break;
527 }
528 }
529
530 return display_name ? g_strdup (display_name)g_strdup_inline (display_name) : g_strdup (virt)g_strdup_inline (virt);
531}
532
533static char *
534get_system_virt (void)
535{
536 g_autoptr(GError)__attribute__((cleanup(glib_autoptr_cleanup_GError))) GError_autoptr error = NULL((void*)0);
537 g_autoptr(GDBusProxy)__attribute__((cleanup(glib_autoptr_cleanup_GDBusProxy))) GDBusProxy_autoptr systemd_proxy = NULL((void*)0);
538 g_autoptr(GVariant)__attribute__((cleanup(glib_autoptr_cleanup_GVariant))) GVariant_autoptr variant = NULL((void*)0);
539 GVariant *inner;
540
541 systemd_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
542 G_DBUS_PROXY_FLAGS_NONE,
543 NULL((void*)0),
544 "org.freedesktop.systemd1",
545 "/org/freedesktop/systemd1",
546 "org.freedesktop.systemd1",
547 NULL((void*)0),
548 &error);
549
550 if (systemd_proxy == NULL((void*)0))
551 {
552 g_debug ("systemd not available, bailing: %s", error->message);
553 return NULL((void*)0);
554 }
555
556 variant = g_dbus_proxy_call_sync (systemd_proxy,
557 "org.freedesktop.DBus.Properties.Get",
558 g_variant_new ("(ss)", "org.freedesktop.systemd1.Manager", "Virtualization"),
559 G_DBUS_CALL_FLAGS_NONE,
560 -1,
561 NULL((void*)0),
562 &error);
563 if (variant == NULL((void*)0))
564 {
565 g_debug ("Failed to get property '%s': %s", "Virtualization", error->message);
566 return NULL((void*)0);
567 }
568
569 g_variant_get (variant, "(v)", &inner);
570
571 return get_virtualization_label (g_variant_get_string (inner, NULL((void*)0)));
572}
573# endif
574
575static char *
576get_mate_desktop_version ()
577{
578 int status;
579 int i = 0;
580 char *version = NULL((void*)0);
581 char *argv[] = {"/usr/bin/mate-about", "-v", NULL((void*)0)};
582 g_autoptr(GError)__attribute__((cleanup(glib_autoptr_cleanup_GError))) GError_autoptr error = NULL((void*)0);
583
584 g_debug ("About to launch '%s'", argv[0]);
585
586 if (!g_spawn_sync (NULL((void*)0), (char **) argv, NULL((void*)0), 0, NULL((void*)0), NULL((void*)0), &version, NULL((void*)0), &status, &error))
587 {
588 g_warning ("Failed to get GPU: %s", error->message);
589 return NULL((void*)0);
590 }
591#if GLIB_CHECK_VERSION(2, 70, 0)(2 > (2) || (2 == (2) && 80 > (70)) || (2 == (2
) && 80 == (70) && 2 >= (0)))
592 if (!g_spawn_check_wait_status (status, NULL((void*)0)))
593#else
594 if (!g_spawn_check_exit_status (status, NULL((void*)0)))
595#endif
596 return NULL((void*)0);
597
598 while (version[i] != '\0')
599 {
600 if (version[i] == '\n')
601 {
602 version[i] = '\0';
603 break;
604 }
605 i++;
606 }
607
608 return version;
609}
610
611static char *
612get_logo_name (void)
613{
614 char *logo_name = NULL((void*)0);
615
616 logo_name = g_get_os_info ("LOGO");
617
618 if (logo_name == NULL((void*)0))
619 logo_name = g_strdup ("mate-desktop")g_strdup_inline ("mate-desktop");
620
621 return logo_name;
622}
623
624void
625mate_system_info_setup (MateSystemInfo *info)
626{
627 g_autofree__attribute__((cleanup(g_autoptr_cleanup_generic_gfree))) char *logo_name = NULL((void*)0);
628 g_autofree__attribute__((cleanup(g_autoptr_cleanup_generic_gfree))) char *hostname_text = NULL((void*)0);
629# ifdef HAVE_SYSTEMD
630 g_autofree__attribute__((cleanup(g_autoptr_cleanup_generic_gfree))) char *hw_model_text = NULL((void*)0);
631 g_autofree__attribute__((cleanup(g_autoptr_cleanup_generic_gfree))) char *virt_text = NULL((void*)0);
632# endif
633 g_autofree__attribute__((cleanup(g_autoptr_cleanup_generic_gfree))) char *memory_text = NULL((void*)0);
634 g_autofree__attribute__((cleanup(g_autoptr_cleanup_generic_gfree))) char *cpu_text = NULL((void*)0);
635 g_autofree__attribute__((cleanup(g_autoptr_cleanup_generic_gfree))) char *os_type_text = NULL((void*)0);
636 g_autofree__attribute__((cleanup(g_autoptr_cleanup_generic_gfree))) char *os_name_text = NULL((void*)0);
637 g_autofree__attribute__((cleanup(g_autoptr_cleanup_generic_gfree))) char *disk_text = NULL((void*)0);
638 g_autofree__attribute__((cleanup(g_autoptr_cleanup_generic_gfree))) char *kernel_text = NULL((void*)0);
639 g_autofree__attribute__((cleanup(g_autoptr_cleanup_generic_gfree))) char *windowing_system_text = NULL((void*)0);
640 g_autofree__attribute__((cleanup(g_autoptr_cleanup_generic_gfree))) char *de_text = NULL((void*)0);
641 g_autofree__attribute__((cleanup(g_autoptr_cleanup_generic_gfree))) char *graphics_hardware_string = NULL((void*)0);
642
643 GtkWidget *label;
644 glibtop_mem mem;
645
646 logo_name = get_logo_name ();
647 gtk_image_set_from_icon_name (GTK_IMAGE (info->logo_image)((((GtkImage*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((info->logo_image)), ((gtk_image_get_type ()))))))
, logo_name, GTK_ICON_SIZE_INVALID);
648 gtk_image_set_pixel_size (GTK_IMAGE (info->logo_image)((((GtkImage*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((info->logo_image)), ((gtk_image_get_type ()))))))
, 128);
649
650 hostname_text = get_system_hostname ();
651 label = g_object_get_data (G_OBJECT (info->hostname_row)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((info->hostname_row)), (((GType) ((20) << (2))))
))))
, "labelvalue");
652 set_lable_style (label, "gray", 12, hostname_text, FALSE(0));
653
654# if HAVE_SYSTEMD
655 hw_model_text = get_hardware_model ();
656 if (hw_model_text != NULL((void*)0))
657 {
658 gtk_widget_show_all (info->hardware_model_row);
659 label = g_object_get_data (G_OBJECT (info->hardware_model_row)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((info->hardware_model_row)), (((GType) ((20) << (
2))))))))
, "labelvalue");
660 set_lable_style (label, "gray", 12, hw_model_text, FALSE(0));
661 }
662# endif
663 glibtop_get_mem (&mem);
664 memory_text = g_format_size_full (mem.total, G_FORMAT_SIZE_IEC_UNITS);
665 label = g_object_get_data (G_OBJECT (info->memory_row)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((info->memory_row)), (((GType) ((20) << (2))))))
))
, "labelvalue");
666 set_lable_style (label, "gray", 12, memory_text, FALSE(0));
667
668 cpu_text = get_cpu_info ();
669 label = g_object_get_data (G_OBJECT (info->processor_row)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((info->processor_row)), (((GType) ((20) << (2)))
)))))
, "labelvalue");
670 set_lable_style (label, "gray", 12, cpu_text, FALSE(0));
671
672 graphics_hardware_string = get_graphics_hardware_string ();
673 label = g_object_get_data (G_OBJECT (info->graphics_row)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((info->graphics_row)), (((GType) ((20) << (2))))
))))
, "labelvalue");
674 set_lable_style (label, "gray", 12, graphics_hardware_string, FALSE(0));
675
676 disk_text = get_primary_disk_size ();
677 label = g_object_get_data (G_OBJECT (info->disk_row)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((info->disk_row)), (((GType) ((20) << (2))))))))
, "labelvalue");
678 set_lable_style (label, "gray", 12, disk_text, FALSE(0));
679
680 kernel_text = get_kernel_vesrion ();
681 label = g_object_get_data (G_OBJECT (info->kernel_row)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((info->kernel_row)), (((GType) ((20) << (2))))))
))
, "labelvalue");
682 set_lable_style (label, "gray", 12, kernel_text, FALSE(0));
683# ifdef HAVE_SYSTEMD
684 virt_text = get_system_virt ();
685 if (virt_text != NULL((void*)0))
686 {
687 gtk_widget_show_all (info->virtualization_row);
688 label = g_object_get_data (G_OBJECT (info->virtualization_row)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((info->virtualization_row)), (((GType) ((20) << (
2))))))))
, "labelvalue");
689 set_lable_style (label, "gray", 12, virt_text, FALSE(0));
690 }
691# endif
692 windowing_system_text = get_windowing_system ();
693 label = g_object_get_data (G_OBJECT (info->windowing_system_row)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((info->windowing_system_row)), (((GType) ((20) <<
(2))))))))
, "labelvalue");
694 set_lable_style (label, "gray", 12, windowing_system_text, FALSE(0));
695
696 de_text = get_mate_desktop_version ();
697 label = g_object_get_data (G_OBJECT (info->mate_version_row)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((info->mate_version_row)), (((GType) ((20) << (2
))))))))
, "labelvalue");
698 set_lable_style (label, "gray", 12, de_text, FALSE(0));
699
700 os_type_text = get_os_type ();
701 label = g_object_get_data (G_OBJECT (info->os_type_row)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((info->os_type_row)), (((GType) ((20) << (2)))))
)))
, "labelvalue");
702 set_lable_style (label, "gray", 12, os_type_text, FALSE(0));
703
704 os_name_text = get_os_name ();
705 label = g_object_get_data (G_OBJECT (info->os_name_row)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((info->os_name_row)), (((GType) ((20) << (2)))))
)))
, "labelvalue");
706 set_lable_style (label, "gray", 12, os_name_text, FALSE(0));
707}
708
709static void
710mate_system_info_destroy (GtkWidget *widget)
711{
712 GTK_WIDGET_CLASS (mate_system_info_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((mate_system_info_parent_class)), ((gtk_widget_get_type (
)))))))
->destroy (widget);
713}
714
715static void
716mate_system_info_class_init (MateSystemInfoClass *klass)
717{
718 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((klass)), ((gtk_widget_get_type ()))))))
;
719
720 widget_class->destroy = mate_system_info_destroy;
721 gtk_widget_class_set_template_from_resource (widget_class, "/org/mate/control-center/system-info/mate-system-info.ui");
722
723 gtk_widget_class_bind_template_child (widget_class, MateSystemInfo, hostname_row)gtk_widget_class_bind_template_child_full (widget_class, "hostname_row"
, (0), ((glong) __builtin_offsetof(MateSystemInfo, hostname_row
)))
;
724# ifdef HAVE_SYSTEMD
725 gtk_widget_class_bind_template_child (widget_class, MateSystemInfo, hardware_box)gtk_widget_class_bind_template_child_full (widget_class, "hardware_box"
, (0), ((glong) __builtin_offsetof(MateSystemInfo, hardware_box
)))
;
726 gtk_widget_class_bind_template_child (widget_class, MateSystemInfo, virtualization_row)gtk_widget_class_bind_template_child_full (widget_class, "virtualization_row"
, (0), ((glong) __builtin_offsetof(MateSystemInfo, virtualization_row
)))
;
727# endif
728 gtk_widget_class_bind_template_child (widget_class, MateSystemInfo, disk_row)gtk_widget_class_bind_template_child_full (widget_class, "disk_row"
, (0), ((glong) __builtin_offsetof(MateSystemInfo, disk_row))
)
;
729 gtk_widget_class_bind_template_child (widget_class, MateSystemInfo, mate_version_row)gtk_widget_class_bind_template_child_full (widget_class, "mate_version_row"
, (0), ((glong) __builtin_offsetof(MateSystemInfo, mate_version_row
)))
;
730 gtk_widget_class_bind_template_child (widget_class, MateSystemInfo, graphics_row)gtk_widget_class_bind_template_child_full (widget_class, "graphics_row"
, (0), ((glong) __builtin_offsetof(MateSystemInfo, graphics_row
)))
;
731 gtk_widget_class_bind_template_child (widget_class, MateSystemInfo, hardware_model_row)gtk_widget_class_bind_template_child_full (widget_class, "hardware_model_row"
, (0), ((glong) __builtin_offsetof(MateSystemInfo, hardware_model_row
)))
;
732 gtk_widget_class_bind_template_child (widget_class, MateSystemInfo, memory_row)gtk_widget_class_bind_template_child_full (widget_class, "memory_row"
, (0), ((glong) __builtin_offsetof(MateSystemInfo, memory_row
)))
;
733 gtk_widget_class_bind_template_child (widget_class, MateSystemInfo, os_box)gtk_widget_class_bind_template_child_full (widget_class, "os_box"
, (0), ((glong) __builtin_offsetof(MateSystemInfo, os_box)))
;
734 gtk_widget_class_bind_template_child (widget_class, MateSystemInfo, logo_image)gtk_widget_class_bind_template_child_full (widget_class, "logo_image"
, (0), ((glong) __builtin_offsetof(MateSystemInfo, logo_image
)))
;
735 gtk_widget_class_bind_template_child (widget_class, MateSystemInfo, os_name_row)gtk_widget_class_bind_template_child_full (widget_class, "os_name_row"
, (0), ((glong) __builtin_offsetof(MateSystemInfo, os_name_row
)))
;
736 gtk_widget_class_bind_template_child (widget_class, MateSystemInfo, os_type_row)gtk_widget_class_bind_template_child_full (widget_class, "os_type_row"
, (0), ((glong) __builtin_offsetof(MateSystemInfo, os_type_row
)))
;
737 gtk_widget_class_bind_template_child (widget_class, MateSystemInfo, processor_row)gtk_widget_class_bind_template_child_full (widget_class, "processor_row"
, (0), ((glong) __builtin_offsetof(MateSystemInfo, processor_row
)))
;
738 gtk_widget_class_bind_template_child (widget_class, MateSystemInfo, kernel_row)gtk_widget_class_bind_template_child_full (widget_class, "kernel_row"
, (0), ((glong) __builtin_offsetof(MateSystemInfo, kernel_row
)))
;
739 gtk_widget_class_bind_template_child (widget_class, MateSystemInfo, windowing_system_row)gtk_widget_class_bind_template_child_full (widget_class, "windowing_system_row"
, (0), ((glong) __builtin_offsetof(MateSystemInfo, windowing_system_row
)))
;
740}
741
742static void
743mate_system_info_init (MateSystemInfo *self)
744{
745 gtk_widget_init_template (GTK_WIDGET (self)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((self)), ((gtk_widget_get_type ()))))))
);
746 g_resources_register (mate_system_info_get_resource ());
747 mate_system_info_set_row (MATE_SYSTEM_INFO (self));
748}
749
750GtkWidget *
751mate_system_info_new (void)
752{
753 GtkWidget *dialog;
754 gboolean use_header;
755 GdkDisplay *display;
756
757 g_object_get (gtk_settings_get_default (),
758 "gtk-dialogs-use-header", &use_header,
759 NULL((void*)0));
760
761 display = gdk_display_get_default ();
762#if defined(GDK_WINDOWING_WAYLAND)
763 if (GDK_IS_WAYLAND_DISPLAY (display)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(display)); GType __t = ((gdk_wayland_display_get_type())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
)
764 use_header = FALSE(0);
765#endif /* GDK_WINDOWING_WAYLAND */
766
767 dialog = g_object_new (MATE_TYPE_SYSTEM_INFO(mate_system_info_get_type ()),
768 "use-header-bar", use_header,
769 NULL((void*)0));
770 gtk_window_set_title (GTK_WINDOW (dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_window_get_type ()))))))
, _("Mate System Info")gettext ("Mate System Info"));
771 gtk_widget_set_size_request (GTK_WIDGET (dialog)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_widget_get_type ()))))))
, 600, 500);
772 gtk_window_set_resizable (GTK_WINDOW (dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_window_get_type ()))))))
, FALSE(0));
773
774 return dialog;
775}
diff --git a/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-5941f9.html b/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-5941f9.html new file mode 100644 index 00000000..58a8149f --- /dev/null +++ b/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-5941f9.html @@ -0,0 +1,816 @@ + + + +main.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:typing-break/main.c
Warning:line 116, column 12
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name main.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/typing-break -fcoverage-compilation-dir=/rootdir/typing-break -resource-dir /usr/bin/../lib/clang/18 -D HAVE_CONFIG_H -I . -I .. -D MATELOCALEDIR="/usr/local/share/locale" -D IMAGEDIR="/usr/local/share/mate-control-center/pixmaps" -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/gio-unix-2.0 -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I /usr/include/libappindicator3-0.1 -I /usr/include/libdbusmenu-glib-0.4 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/gio-unix-2.0 -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/startup-notification-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/gio-unix-2.0 -I /usr/include/dconf -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -D HAVE_CANBERRA_GTK -D _REENTRANT -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/gio-unix-2.0 -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-06-07-044335-13427-1 -x c main.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2/*
3 * Copyright (C) 2002 CodeFactory AB
4 * Copyright (C) 2002-2003 Richard Hult <richard@imendio.com>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of the
9 * License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public
17 * License along with this program; if not, write to the
18 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
20 */
21
22#include <config.h>
23#include <string.h>
24#include <stdlib.h>
25#include <glib/gi18n.h>
26#include <gdk/gdkx.h>
27#include <gtk/gtk.h>
28
29#include "drw-selection.h"
30#include "drwright.h"
31
32#define NOTIFIERAREA_NAME"org.kde.StatusNotifierWatcher" "org.kde.StatusNotifierWatcher"
33#define NOTIFIERAREA_PATH"/StatusNotifierWatcher" "/StatusNotifierWatcher"
34#define NOTIFIERAREA_INTERFACE"org.kde.StatusNotifierWatcher" "org.kde.StatusNotifierWatcher"
35#define NOTIFIERAREA_PROPERTY"IsStatusNotifierHostRegistered" "IsStatusNotifierHostRegistered"
36
37gboolean debug = FALSE(0);
38
39static gboolean
40is_status_notifier_host_available (void)
41{
42 g_autoptr (GDBusProxy)__attribute__((cleanup(glib_autoptr_cleanup_GDBusProxy))) GDBusProxy_autoptr proxy = NULL((void*)0);
43 g_autoptr (GError)__attribute__((cleanup(glib_autoptr_cleanup_GError))) GError_autoptr error = NULL((void*)0);
44
45 proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
46 G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS |
47 G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
48 NULL((void*)0),
49 NOTIFIERAREA_NAME"org.kde.StatusNotifierWatcher",
50 NOTIFIERAREA_PATH"/StatusNotifierWatcher",
51 NOTIFIERAREA_INTERFACE"org.kde.StatusNotifierWatcher",
52 NULL((void*)0), &error);
53
54 if (proxy == NULL((void*)0) || error)
55 {
56 return FALSE(0);
57 }
58 g_autoptr (GVariant)__attribute__((cleanup(glib_autoptr_cleanup_GVariant))) GVariant_autoptr variant = g_dbus_proxy_get_cached_property (proxy, NOTIFIERAREA_PROPERTY"IsStatusNotifierHostRegistered");
59 if (! variant)
60 {
61 return FALSE(0);
62 }
63
64 return g_variant_get_boolean (variant);
65}
66
67int
68main (int argc, char *argv[])
69{
70 DrwSelection *selection;
71 gboolean no_check = FALSE(0);
72 const GOptionEntry options[] = {
73 { "debug", 'd', 0, G_OPTION_ARG_NONE, &debug,
74 N_("Enable debugging code")("Enable debugging code"), NULL((void*)0) },
75 { "no-check", 'n', 0, G_OPTION_ARG_NONE, &no_check,
76 N_("Don't check whether the notification area exists")("Don't check whether the notification area exists"), NULL((void*)0) },
77 { NULL((void*)0), 0, 0, G_OPTION_ARG_NONE, NULL((void*)0), NULL((void*)0), NULL((void*)0) }
78 };
79 GOptionContext *option_context;
80 GError *error = NULL((void*)0);
81 gboolean retval;
82
83#ifdef ENABLE_NLS1
84 bindtextdomain (GETTEXT_PACKAGE"mate-control-center", MATELOCALEDIR"/usr/local/share/locale");
85 bind_textdomain_codeset (GETTEXT_PACKAGE"mate-control-center", "UTF-8");
86 textdomain (GETTEXT_PACKAGE"mate-control-center");
87#endif /* ENABLE_NLS */
88
89 option_context = g_option_context_new (NULL((void*)0));
90#ifdef ENABLE_NLS1
91 g_option_context_set_translation_domain (option_context, GETTEXT_PACKAGE"mate-control-center");
92#endif /* ENABLE_NLS */
93 g_option_context_add_main_entries (option_context, options, GETTEXT_PACKAGE"mate-control-center");
94 g_option_context_add_group (option_context, gtk_get_option_group (TRUE(!(0))));
95
96 retval = g_option_context_parse (option_context, &argc, &argv, &error);
97 g_option_context_free (option_context);
98 if (!retval) {
99 g_print ("%s\n", error->message);
100 g_error_free (error);
101 exit (1);
102 }
103
104 g_set_application_name (_("Typing Monitor")gettext ("Typing Monitor"));
105 gtk_window_set_default_icon_name ("mate-typing-monitor");
106
107 selection = drw_selection_start ();
108 if (!drw_selection_is_master (selection)) {
109 g_message ("The typing monitor is already running, exiting.");
110 return 0;
111 }
112
113 if (!no_check && !is_status_notifier_host_available ()) {
114 GtkWidget *dialog;
115
116 dialog = gtk_message_dialog_new (
This statement is never executed
117 NULL((void*)0), 0,
118 GTK_MESSAGE_INFO,
119 GTK_BUTTONS_CLOSE,
120 _("The typing monitor uses the notification area to display "gettext ("The typing monitor uses the notification area to display "
"information. You don't seem to have a notification area " "on your panel. You can add it by right-clicking on your "
"panel and choosing 'Add to panel', selecting 'Notification "
"area' and clicking 'Add'.")
121 "information. You don't seem to have a notification area "gettext ("The typing monitor uses the notification area to display "
"information. You don't seem to have a notification area " "on your panel. You can add it by right-clicking on your "
"panel and choosing 'Add to panel', selecting 'Notification "
"area' and clicking 'Add'.")
122 "on your panel. You can add it by right-clicking on your "gettext ("The typing monitor uses the notification area to display "
"information. You don't seem to have a notification area " "on your panel. You can add it by right-clicking on your "
"panel and choosing 'Add to panel', selecting 'Notification "
"area' and clicking 'Add'.")
123 "panel and choosing 'Add to panel', selecting 'Notification "gettext ("The typing monitor uses the notification area to display "
"information. You don't seem to have a notification area " "on your panel. You can add it by right-clicking on your "
"panel and choosing 'Add to panel', selecting 'Notification "
"area' and clicking 'Add'.")
124 "area' and clicking 'Add'.")gettext ("The typing monitor uses the notification area to display "
"information. You don't seem to have a notification area " "on your panel. You can add it by right-clicking on your "
"panel and choosing 'Add to panel', selecting 'Notification "
"area' and clicking 'Add'.")
);
125
126 gtk_dialog_run (GTK_DIALOG (dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_dialog_get_type ()))))))
);
127
128 gtk_widget_destroy (dialog);
129 }
130
131 drwright_new ();
132
133 gtk_main ();
134
135 return 0;
136}
diff --git a/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-5c0604.html b/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-5c0604.html new file mode 100644 index 00000000..6f36e0a7 --- /dev/null +++ b/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-5c0604.html @@ -0,0 +1,1105 @@ + + + +theme-save.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:capplets/appearance/theme-save.c
Warning:line 79, column 4
Access of the heap area at index 2, while it holds only 2 'char' elements
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name theme-save.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/capplets/appearance -fcoverage-compilation-dir=/rootdir/capplets/appearance -resource-dir /usr/bin/../lib/clang/18 -D HAVE_CONFIG_H -I . -I ../.. -I /usr/include/marco-1 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/gio-unix-2.0 -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I ../../capplets/common -I /usr/include/udisks2 -I /usr/include/libgtop-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/libxml2 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/gio-unix-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/dconf -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I ../../ -D G_LOG_DOMAIN="appearance-properties" -I /usr/include/polkit-1 -I /usr/include/gio-unix-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I /usr/include/udisks2 -I /usr/include/libgtop-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/gio-unix-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/libxml2 -I /usr/include/harfbuzz -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/freetype2 -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/dconf -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libpng16 -D WITH_GZFILEOP -I /usr/include/sysprof-6 -I /usr/include/pixman-1 -D MATECC_DATA_DIR="/usr/local/share/mate-control-center" -D MATECC_PIXMAP_DIR="/usr/local/share/mate-control-center/pixmaps" -D WALLPAPER_DATADIR="/usr/local/share/mate-background-properties" -D BACKGROUND_DATADIR="/usr/local/share/backgrounds" -D MATE_DESKTOP_USE_UNSTABLE_API -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-06-07-044335-13427-1 -x c theme-save.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 * Copyright (C) 2007 The GNOME Foundation
3 * Written by Thomas Wood <thos@gnome.org>
4 * Jens Granseuer <jensgr@gmx.net>
5 * All Rights Reserved
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 */
21
22#include "appearance.h"
23
24#include <glib/gstdio.h>
25#include <glib/gi18n.h>
26#include <gio/gio.h>
27#include <string.h>
28
29#include "theme-save.h"
30#include "theme-util.h"
31#include "capplet-util.h"
32
33static GQuark error_quark;
34enum {
35 INVALID_THEME_NAME
36};
37
38/* taken from mate-desktop-item.c */
39static gchar *
40escape_string_and_dup (const gchar *s)
41{
42 gchar *return_value, *p;
43 const gchar *q;
44 int len = 0;
45
46 if (s == NULL((void*)0))
4
Assuming 's' is not equal to NULL
5
Taking false branch
47 return g_strdup("")g_strdup_inline ("");
48
49 q = s;
50 while (*q)
6
Loop condition is true. Entering loop body
9
Loop condition is false. Execution continues on line 57
51 {
52 len++;
53 if (strchr ("\n\r\t\\", *q) != NULL((void*)0))
7
Assuming the condition is false
8
Taking false branch
54 len++;
55 q++;
56 }
57 return_value = p = (gchar *) g_malloc (len + 1);
58 do
12
Loop condition is true. Execution continues on line 60
59 {
60 switch (*s)
10
Control jumps to 'case 92:' at line 74
13
Control jumps to the 'default' case at line 78
61 {
62 case '\t':
63 *p++ = '\\';
64 *p++ = 't';
65 break;
66 case '\n':
67 *p++ = '\\';
68 *p++ = 'n';
69 break;
70 case '\r':
71 *p++ = '\\';
72 *p++ = 'r';
73 break;
74 case '\\':
75 *p++ = '\\';
76 *p++ = '\\';
77 break;
11
Execution continues on line 82
78 default:
79 *p++ = *s;
14
Access of the heap area at index 2, while it holds only 2 'char' elements
80 }
81 }
82 while (*s++);
83 return return_value;
84}
85
86static gboolean
87check_theme_name (const gchar *theme_name,
88 GError **error)
89{
90 if (theme_name == NULL((void*)0)) {
91 g_set_error (error,
92 error_quark,
93 INVALID_THEME_NAME,
94 _("Theme name must be present")gettext ("Theme name must be present"));
95 return FALSE(0);
96 }
97 return TRUE(!(0));
98}
99
100static gchar *
101str_remove_slash (const gchar *src)
102{
103 const gchar *i;
104 gchar *rtn;
105 gint len = 0;
106 i = src;
107
108 while (*i) {
109 if (*i != '/')
110 len++;
111 i++;
112 }
113
114 rtn = (gchar *) g_malloc (len + 1);
115 while (*src) {
116 if (*src != '/') {
117 *rtn = *src;
118 rtn++;
119 }
120 src++;
121 }
122 *rtn = '\0';
123 return rtn - len;
124}
125
126static gboolean
127setup_directory_structure (const gchar *theme_name,
128 GError **error)
129{
130 gchar *dir, *theme_name_dir;
131 gboolean retval = TRUE(!(0));
132
133 theme_name_dir = str_remove_slash (theme_name);
134
135 dir = g_build_filename (g_get_home_dir (), ".themes", NULL((void*)0));
136 if (!g_file_test (dir, G_FILE_TEST_EXISTS))
137 g_mkdirmkdir (dir, 0775);
138 g_free (dir);
139
140 dir = g_build_filename (g_get_home_dir (), ".themes", theme_name_dir, NULL((void*)0));
141 if (!g_file_test (dir, G_FILE_TEST_EXISTS))
142 g_mkdirmkdir (dir, 0775);
143 g_free (dir);
144
145 dir = g_build_filename (g_get_home_dir (), ".themes", theme_name_dir, "index.theme", NULL((void*)0));
146 g_free (theme_name_dir);
147
148 if (g_file_test (dir, G_FILE_TEST_EXISTS)) {
149 GtkDialog *dialog;
150 GtkWidget *button;
151 gint response;
152
153 dialog = (GtkDialog *) gtk_message_dialog_new (NULL((void*)0),
154 GTK_DIALOG_MODAL,
155 GTK_MESSAGE_QUESTION,
156 GTK_BUTTONS_CANCEL,
157 _("The theme already exists. Would you like to replace it?")gettext ("The theme already exists. Would you like to replace it?"
)
);
158 button = gtk_dialog_add_button (dialog, _("_Overwrite")gettext ("_Overwrite"), GTK_RESPONSE_ACCEPT);
159 gtk_button_set_image (GTK_BUTTON (button)((((GtkButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((button)), ((gtk_button_get_type ()))))))
,
160 gtk_image_new_from_icon_name ("document-save", GTK_ICON_SIZE_BUTTON));
161 response = gtk_dialog_run (dialog);
162 gtk_widget_destroy (GTK_WIDGET (dialog)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_widget_get_type ()))))))
);
163 retval = (response != GTK_RESPONSE_CANCEL);
164 }
165 g_free (dir);
166
167 return retval;
168}
169
170static gboolean
171write_theme_to_disk (MateThemeMetaInfo *theme_info,
172 const gchar *theme_name,
173 const gchar *theme_description,
174 gboolean save_background,
175 gboolean save_notification,
176 GError **error)
177{
178 gchar* dir;
179 gchar* theme_name_dir;
180 GFile* tmp_file;
181 GFile* target_file;
182 GOutputStream* output;
183
184 gchar* str;
185 gchar* current_background;
186
187 GSettings* settings;
188 const gchar* theme_header = ""
189 "[Desktop Entry]\n"
190 "Name=%s\n"
191 "Type=X-GNOME-Metatheme\n"
192 "Comment=%s\n"
193 "\n"
194 "[X-GNOME-Metatheme]\n"
195 "GtkTheme=%s\n"
196 "MetacityTheme=%s\n"
197 "IconTheme=%s\n";
198
199 theme_name_dir = str_remove_slash (theme_name);
200 dir = g_build_filename (g_get_home_dir (), ".themes", theme_name_dir, "index.theme~", NULL((void*)0));
201 g_free (theme_name_dir);
202
203 tmp_file = g_file_new_for_path (dir);
204 dir [strlen (dir) - 1] = '\000';
205 target_file = g_file_new_for_path (dir);
206 g_free (dir);
207
208 /* start making the theme file */
209 str = g_strdup_printf(theme_header, theme_name, theme_description, theme_info->gtk_theme_name, theme_info->marco_theme_name, theme_info->icon_theme_name);
210
211 output = G_OUTPUT_STREAM (g_file_replace (tmp_file, NULL, FALSE, G_FILE_CREATE_NONE, NULL, NULL))((((GOutputStream*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((g_file_replace (tmp_file, ((void*)0), (0), G_FILE_CREATE_NONE
, ((void*)0), ((void*)0)))), ((g_output_stream_get_type ())))
)))
;
212 g_output_stream_write (output, str, strlen (str), NULL((void*)0), NULL((void*)0));
213 g_free (str);
214
215 if (theme_info->gtk_color_scheme) {
216 gchar *a, *tmp;
217 tmp = g_strdup (theme_info->gtk_color_scheme)g_strdup_inline (theme_info->gtk_color_scheme);
218 for (a = tmp; *a != '\0'; a++)
219 if (*a == '\n')
220 *a = ',';
221 str = g_strdup_printf ("GtkColorScheme=%s\n", tmp);
222 g_output_stream_write (output, str, strlen (str), NULL((void*)0), NULL((void*)0));
223
224 g_free (str);
225 g_free (tmp);
226 }
227
228 if (theme_info->cursor_theme_name) {
229 str = g_strdup_printf ("CursorTheme=%s\n"
230 "CursorSize=%i\n",
231 theme_info->cursor_theme_name,
232 theme_info->cursor_size);
233 g_output_stream_write (output, str, strlen (str), NULL((void*)0), NULL((void*)0));
234 g_free (str);
235 }
236
237 if (theme_info->notification_theme_name && save_notification) {
238 str = g_strdup_printf ("NotificationTheme=%s\n", theme_info->notification_theme_name);
239 g_output_stream_write (output, str, strlen (str), NULL((void*)0), NULL((void*)0));
240 g_free (str);
241 }
242
243 if (save_background) {
244 settings = g_settings_new (WP_SCHEMA"org.mate.background");
245 current_background = g_settings_get_string (settings, WP_FILE_KEY"picture-filename");
246
247 if (current_background != NULL((void*)0)) {
248 str = g_strdup_printf ("BackgroundImage=%s\n", current_background);
249
250 g_output_stream_write (output, str, strlen (str), NULL((void*)0), NULL((void*)0));
251
252 g_free (current_background);
253 g_free (str);
254 }
255 g_object_unref (settings);
256 }
257
258 g_file_move (tmp_file, target_file, G_FILE_COPY_OVERWRITE, NULL((void*)0), NULL((void*)0), NULL((void*)0), NULL((void*)0));
259 g_output_stream_close (output, NULL((void*)0), NULL((void*)0));
260
261 g_object_unref (tmp_file);
262 g_object_unref (target_file);
263
264 return TRUE(!(0));
265}
266
267static gboolean
268save_theme_to_disk (MateThemeMetaInfo *theme_info,
269 const gchar *theme_name,
270 const gchar *theme_description,
271 gboolean save_background,
272 gboolean save_notification,
273 GError **error)
274{
275 if (!check_theme_name (theme_name, error))
276 return FALSE(0);
277
278 if (!setup_directory_structure (theme_name, error))
279 return FALSE(0);
280
281 if (!write_theme_to_disk (theme_info, theme_name, theme_description, save_background, save_notification, error))
282 return FALSE(0);
283
284 return TRUE(!(0));
285}
286
287static void
288save_dialog_response (GtkWidget *save_dialog,
289 gint response_id,
290 AppearanceData *data)
291{
292 if (response_id == GTK_RESPONSE_OK) {
1
Assuming 'response_id' is equal to GTK_RESPONSE_OK
2
Taking true branch
293 GtkWidget *entry;
294 GtkWidget *text_view;
295 GtkTextBuffer *buffer;
296 GtkTextIter start_iter;
297 GtkTextIter end_iter;
298 gchar *buffer_text;
299 MateThemeMetaInfo *theme_info;
300 gchar *theme_description = NULL((void*)0);
301 gchar *theme_name = NULL((void*)0);
302 gboolean save_background;
303 gboolean save_notification;
304 GError *error = NULL((void*)0);
305
306 entry = appearance_capplet_get_widget (data, "save_dialog_entry")(GtkWidget*) gtk_builder_get_object(data->ui, "save_dialog_entry"
)
;
307 theme_name = escape_string_and_dup (gtk_entry_get_text (GTK_ENTRY (entry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((entry)), ((gtk_entry_get_type ()))))))
))
;
3
Calling 'escape_string_and_dup'
308
309 text_view = appearance_capplet_get_widget (data, "save_dialog_textview")(GtkWidget*) gtk_builder_get_object(data->ui, "save_dialog_textview"
)
;
310 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view)((((GtkTextView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((text_view)), ((gtk_text_view_get_type ()))))))
);
311 gtk_text_buffer_get_start_iter (buffer, &start_iter);
312 gtk_text_buffer_get_end_iter (buffer, &end_iter);
313 buffer_text = gtk_text_buffer_get_text (buffer, &start_iter, &end_iter, FALSE(0));
314 theme_description = escape_string_and_dup (buffer_text);
315 g_free (buffer_text);
316 theme_info = (MateThemeMetaInfo *) g_object_get_data (G_OBJECT (save_dialog)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((save_dialog)), (((GType) ((20) << (2))))))))
, "meta-theme-info");
317 save_background = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (((((GtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (((GtkWidget*) gtk_builder_get_object(data->ui, "save_background_checkbutton"
))), ((gtk_toggle_button_get_type ()))))))
318 appearance_capplet_get_widget (data, "save_background_checkbutton"))((((GtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (((GtkWidget*) gtk_builder_get_object(data->ui, "save_background_checkbutton"
))), ((gtk_toggle_button_get_type ()))))))
);
319 save_notification = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (((((GtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (((GtkWidget*) gtk_builder_get_object(data->ui, "save_notification_checkbutton"
))), ((gtk_toggle_button_get_type ()))))))
320 appearance_capplet_get_widget (data, "save_notification_checkbutton"))((((GtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (((GtkWidget*) gtk_builder_get_object(data->ui, "save_notification_checkbutton"
))), ((gtk_toggle_button_get_type ()))))))
);
321
322 if (save_theme_to_disk (theme_info, theme_name, theme_description, save_background, save_notification, &error)) {
323 /* remove the custom theme */
324 GtkTreeIter iter;
325
326 if (theme_find_in_model (GTK_TREE_MODEL (data->theme_store)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data->theme_store)), ((gtk_tree_model_get_type ()))))
))
, "__custom__", &iter))
327 gtk_list_store_remove (data->theme_store, &iter);
328 }
329
330 g_free (theme_name);
331 g_free (theme_description);
332 g_clear_error (&error);
333 }
334
335 gtk_widget_hide (save_dialog);
336}
337
338static void
339entry_text_changed (GtkEditable *editable,
340 AppearanceData *data)
341{
342 const gchar *text;
343 GtkWidget *button;
344
345 text = gtk_entry_get_text (GTK_ENTRY (editable)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((editable)), ((gtk_entry_get_type ()))))))
);
346 button = appearance_capplet_get_widget (data, "save_dialog_save_button")(GtkWidget*) gtk_builder_get_object(data->ui, "save_dialog_save_button"
)
;
347
348 gtk_widget_set_sensitive (button, text != NULL((void*)0) && text[0] != '\000');
349}
350
351void
352theme_save_dialog_run (MateThemeMetaInfo *theme_info,
353 AppearanceData *data)
354{
355 GtkWidget *entry;
356 GtkWidget *text_view;
357 GtkTextBuffer *text_buffer;
358
359 entry = appearance_capplet_get_widget (data, "save_dialog_entry")(GtkWidget*) gtk_builder_get_object(data->ui, "save_dialog_entry"
)
;
360 text_view = appearance_capplet_get_widget (data, "save_dialog_textview")(GtkWidget*) gtk_builder_get_object(data->ui, "save_dialog_textview"
)
;
361
362 if (data->theme_save_dialog == NULL((void*)0)) {
363 data->theme_save_dialog = appearance_capplet_get_widget (data, "theme_save_dialog")(GtkWidget*) gtk_builder_get_object(data->ui, "theme_save_dialog"
)
;
364
365 g_signal_connect (data->theme_save_dialog, "response", (GCallback) save_dialog_response, data)g_signal_connect_data ((data->theme_save_dialog), ("response"
), ((GCallback) save_dialog_response), (data), ((void*)0), (GConnectFlags
) 0)
;
366 g_signal_connect (data->theme_save_dialog, "delete-event", (GCallback) gtk_true, NULL)g_signal_connect_data ((data->theme_save_dialog), ("delete-event"
), ((GCallback) gtk_true), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
;
367 g_signal_connect (entry, "changed", (GCallback) entry_text_changed, data)g_signal_connect_data ((entry), ("changed"), ((GCallback) entry_text_changed
), (data), ((void*)0), (GConnectFlags) 0)
;
368
369 error_quark = g_quark_from_string ("mate-theme-save");
370 gtk_widget_set_size_request (text_view, 300, 100);
371 }
372
373 gtk_entry_set_text (GTK_ENTRY (entry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((entry)), ((gtk_entry_get_type ()))))))
, "");
374 entry_text_changed (GTK_EDITABLE (entry)((((GtkEditable*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((entry)), ((gtk_editable_get_type ()))))))
, data);
375 gtk_widget_grab_focus (entry);
376
377 text_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view)((((GtkTextView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((text_view)), ((gtk_text_view_get_type ()))))))
);
378 gtk_text_buffer_set_text (text_buffer, "", 0);
379 g_object_set_data (G_OBJECT (data->theme_save_dialog)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data->theme_save_dialog)), (((GType) ((20) << (
2))))))))
, "meta-theme-info", theme_info);
380 gtk_window_set_transient_for (GTK_WINDOW (data->theme_save_dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data->theme_save_dialog)), ((gtk_window_get_type ()))
))))
,
381 GET_WINDOW ("appearance_window")(((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (data->ui, ("appearance_window"
)))), ((gtk_window_get_type ())))))))
);
382 gtk_widget_show (data->theme_save_dialog);
383}
diff --git a/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-6203f7.html b/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-6203f7.html new file mode 100644 index 00000000..c32963ca --- /dev/null +++ b/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-6203f7.html @@ -0,0 +1,1229 @@ + + + +mate-keyboard-properties-xkbltadd.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:capplets/keyboard/mate-keyboard-properties-xkbltadd.c
Warning:line 364, column 2
Value stored to 'options_list_strv' is never read
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name mate-keyboard-properties-xkbltadd.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/capplets/keyboard -fcoverage-compilation-dir=/rootdir/capplets/keyboard -resource-dir /usr/bin/../lib/clang/18 -D HAVE_CONFIG_H -I . -I ../.. -I ../../capplets/common -I /usr/include/udisks2 -I /usr/include/libgtop-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/libxml2 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/gio-unix-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/dconf -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I ../../ -D G_LOG_DOMAIN="keyboard-properties" -I /usr/include/polkit-1 -I /usr/include/gio-unix-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/cairo -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/webp -I /usr/include/gio-unix-2.0 -I /usr/include/libpng16 -I /usr/include/pixman-1 -I /usr/include/cloudproviders -I /usr/include/fribidi -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I /usr/include/libxml2 -D WITH_GZFILEOP -D MATECC_DATA_DIR="/usr/local/share/mate-control-center" -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-06-07-044335-13427-1 -x c mate-keyboard-properties-xkbltadd.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* -*- mode: c; style: linux -*- */
2
3/* mate-keyboard-properties-xkbltadd.c
4 * Copyright (C) 2007 Sergey V. Udaltsov
5 *
6 * Written by: Sergey V. Udaltsov <svu@gnome.org>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2, or (at your option)
11 * any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21 * 02110-1301, USA.
22 */
23
24#ifdef HAVE_CONFIG_H1
25# include <config.h>
26#endif
27
28#include <string.h>
29
30#include <libmatekbd/matekbd-keyboard-drawing.h>
31#include <libmatekbd/matekbd-util.h>
32
33#include "capplet-util.h"
34#include "mate-keyboard-properties-xkb.h"
35
36enum {
37 COMBO_BOX_MODEL_COL_SORT,
38 COMBO_BOX_MODEL_COL_VISIBLE,
39 COMBO_BOX_MODEL_COL_XKB_ID,
40 COMBO_BOX_MODEL_COL_REAL_ID
41};
42
43typedef void (*LayoutIterFunc) (XklConfigRegistry * config,
44 ConfigItemProcessFunc func, gpointer data);
45
46typedef struct {
47 GtkListStore *list_store;
48 const gchar *lang_id;
49} AddVariantData;
50
51static void
52xkb_layout_chooser_available_layouts_fill (GtkBuilder * chooser_dialog,
53 const gchar cblid[],
54 const gchar cbvid[],
55 LayoutIterFunc layout_iterator,
56 ConfigItemProcessFunc
57 layout_handler,
58 GCallback combo_changed_notify);
59
60static void
61xkb_layout_chooser_available_language_variants_fill (GtkBuilder *
62 chooser_dialog);
63
64static void
65xkb_layout_chooser_available_country_variants_fill (GtkBuilder *
66 chooser_dialog);
67
68static void
69 xkb_layout_chooser_add_variant_to_available_country_variants
70 (XklConfigRegistry * config_registry,
71 XklConfigItem * parent_config_item, XklConfigItem * config_item,
72 AddVariantData * data) {
73 gchar *utf_variant_name = config_item ?
74 xkb_layout_description_utf8 (matekbd_keyboard_config_merge_items
75 (parent_config_item->name,
76 config_item->name)) :
77 xci_desc_to_utf8 (parent_config_item);
78 GtkTreeIter iter;
79 const gchar *xkb_id =
80 config_item ?
81 matekbd_keyboard_config_merge_items (parent_config_item->name,
82 config_item->name) :
83 parent_config_item->name;
84
85 if (config_item && g_object_get_data
86 (G_OBJECT (config_item)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((config_item)), (((GType) ((20) << (2))))))))
, XCI_PROP_EXTRA_ITEM"extraItem")) {
87 gchar *buf =
88 g_strdup_printf ("<i>%s</i>", utf_variant_name);
89 gtk_list_store_insert_with_values (data->list_store, &iter,
90 -1,
91 COMBO_BOX_MODEL_COL_SORT,
92 utf_variant_name,
93 COMBO_BOX_MODEL_COL_VISIBLE,
94 buf,
95 COMBO_BOX_MODEL_COL_XKB_ID,
96 xkb_id, -1);
97 g_free (buf);
98 } else
99 gtk_list_store_insert_with_values (data->list_store, &iter,
100 -1,
101 COMBO_BOX_MODEL_COL_SORT,
102 utf_variant_name,
103 COMBO_BOX_MODEL_COL_VISIBLE,
104 utf_variant_name,
105 COMBO_BOX_MODEL_COL_XKB_ID,
106 xkb_id, -1);
107 g_free (utf_variant_name);
108}
109
110static void
111 xkb_layout_chooser_add_variant_to_available_language_variants
112 (XklConfigRegistry * config_registry,
113 XklConfigItem * parent_config_item, XklConfigItem * config_item,
114 AddVariantData * data) {
115 xkb_layout_chooser_add_variant_to_available_country_variants
116 (config_registry, parent_config_item, config_item, data);
117}
118
119static void
120xkb_layout_chooser_add_language_to_available_languages (XklConfigRegistry *
121 config_registry,
122 XklConfigItem *
123 config_item,
124 GtkListStore *
125 list_store)
126{
127 gtk_list_store_insert_with_values (list_store, NULL((void*)0), -1,
128 COMBO_BOX_MODEL_COL_SORT,
129 config_item->description,
130 COMBO_BOX_MODEL_COL_VISIBLE,
131 config_item->description,
132 COMBO_BOX_MODEL_COL_REAL_ID,
133 config_item->name, -1);
134}
135
136static void
137xkb_layout_chooser_add_country_to_available_countries (XklConfigRegistry *
138 config_registry,
139 XklConfigItem *
140 config_item,
141 GtkListStore *
142 list_store)
143{
144 gtk_list_store_insert_with_values (list_store, NULL((void*)0), -1,
145 COMBO_BOX_MODEL_COL_SORT,
146 config_item->description,
147 COMBO_BOX_MODEL_COL_VISIBLE,
148 config_item->description,
149 COMBO_BOX_MODEL_COL_REAL_ID,
150 config_item->name, -1);
151}
152
153static void
154xkb_layout_chooser_enable_disable_buttons (GtkBuilder * chooser_dialog)
155{
156 GtkWidget *cbv =
157 CWID (gtk_notebook_get_current_page((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (chooser_dialog, gtk_notebook_get_current_page
(((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (chooser_dialog, "choosers_nb")))
, ((gtk_notebook_get_type ()))))))) ? "xkb_language_variants_available"
: "xkb_country_variants_available"))), ((gtk_widget_get_type
()))))))
158 (GTK_NOTEBOOK (gtk_builder_get_object (chooser_dialog, "choosers_nb"))) ?((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (chooser_dialog, gtk_notebook_get_current_page
(((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (chooser_dialog, "choosers_nb")))
, ((gtk_notebook_get_type ()))))))) ? "xkb_language_variants_available"
: "xkb_country_variants_available"))), ((gtk_widget_get_type
()))))))
159 "xkb_language_variants_available" :((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (chooser_dialog, gtk_notebook_get_current_page
(((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (chooser_dialog, "choosers_nb")))
, ((gtk_notebook_get_type ()))))))) ? "xkb_language_variants_available"
: "xkb_country_variants_available"))), ((gtk_widget_get_type
()))))))
160 "xkb_country_variants_available")((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (chooser_dialog, gtk_notebook_get_current_page
(((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (chooser_dialog, "choosers_nb")))
, ((gtk_notebook_get_type ()))))))) ? "xkb_language_variants_available"
: "xkb_country_variants_available"))), ((gtk_widget_get_type
()))))))
;
161 GtkTreeIter viter;
162 gboolean enable_ok =
163 gtk_combo_box_get_active_iter (GTK_COMBO_BOX (cbv)((((GtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((cbv)), ((gtk_combo_box_get_type ()))))))
,
164 &viter);
165
166 gtk_dialog_set_response_sensitive (GTK_DIALOG((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (chooser_dialog, "xkb_layout_chooser"
))), ((gtk_widget_get_type ())))))))), ((gtk_dialog_get_type (
)))))))
167 (CWID((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (chooser_dialog, "xkb_layout_chooser"
))), ((gtk_widget_get_type ())))))))), ((gtk_dialog_get_type (
)))))))
168 ("xkb_layout_chooser"))((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (chooser_dialog, "xkb_layout_chooser"
))), ((gtk_widget_get_type ())))))))), ((gtk_dialog_get_type (
)))))))
,
169 GTK_RESPONSE_OK, enable_ok);
170 gtk_widget_set_sensitive (CWID ("btnPrint")((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (chooser_dialog, "btnPrint"))), (
(gtk_widget_get_type ()))))))
, enable_ok);
171}
172
173static void
174xkb_layout_chooser_available_variant_changed (GtkBuilder * chooser_dialog)
175{
176 xkb_layout_preview_update (chooser_dialog);
177 xkb_layout_chooser_enable_disable_buttons (chooser_dialog);
178}
179
180static void
181xkb_layout_chooser_available_language_changed (GtkBuilder * chooser_dialog)
182{
183 xkb_layout_chooser_available_language_variants_fill
184 (chooser_dialog);
185 xkb_layout_chooser_available_variant_changed (chooser_dialog);
186}
187
188static void
189xkb_layout_chooser_available_country_changed (GtkBuilder * chooser_dialog)
190{
191 xkb_layout_chooser_available_country_variants_fill
192 (chooser_dialog);
193 xkb_layout_chooser_available_variant_changed (chooser_dialog);
194}
195
196static void
197xkb_layout_chooser_page_changed (GtkWidget * notebook, GtkWidget * page,
198 gint page_num,
199 GtkBuilder * chooser_dialog)
200{
201 xkb_layout_chooser_available_variant_changed (chooser_dialog);
202}
203
204static void
205xkb_layout_chooser_available_language_variants_fill (GtkBuilder *
206 chooser_dialog)
207{
208 GtkWidget *cbl = CWID ("xkb_languages_available")((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (chooser_dialog, "xkb_languages_available"
))), ((gtk_widget_get_type ()))))))
;
209 GtkWidget *cbv = CWID ("xkb_language_variants_available")((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (chooser_dialog, "xkb_language_variants_available"
))), ((gtk_widget_get_type ()))))))
;
210 GtkListStore *list_store;
211 GtkTreeIter liter;
212
213 list_store = gtk_list_store_new
214 (4, G_TYPE_STRING((GType) ((16) << (2))), G_TYPE_STRING((GType) ((16) << (2))), G_TYPE_STRING((GType) ((16) << (2))),
215 G_TYPE_STRING((GType) ((16) << (2))));
216
217 if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (cbl)((((GtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((cbl)), ((gtk_combo_box_get_type ()))))))
, &liter)) {
218 GtkTreeModel *lm =
219 gtk_combo_box_get_model (GTK_COMBO_BOX (cbl)((((GtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((cbl)), ((gtk_combo_box_get_type ()))))))
);
220 gchar *lang_id;
221 AddVariantData data = { list_store, 0 };
222
223 /* Now the variants of the selected layout */
224 gtk_tree_model_get (lm, &liter,
225 COMBO_BOX_MODEL_COL_REAL_ID,
226 &lang_id, -1);
227 data.lang_id = lang_id;
228
229 xkl_config_registry_foreach_language_variant
230 (config_registry, lang_id, (TwoConfigItemsProcessFunc)
231 xkb_layout_chooser_add_variant_to_available_language_variants,
232 &data);
233 g_free (lang_id);
234 }
235
236 /* Turn on sorting after filling the store, since that's faster */
237 gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE((((GtkTreeSortable*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((list_store)), ((gtk_tree_sortable_get_type ()))))))
238 (list_store)((((GtkTreeSortable*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((list_store)), ((gtk_tree_sortable_get_type ()))))))
,
239 COMBO_BOX_MODEL_COL_SORT,
240 GTK_SORT_ASCENDING);
241
242 gtk_combo_box_set_model (GTK_COMBO_BOX (cbv)((((GtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((cbv)), ((gtk_combo_box_get_type ()))))))
,
243 GTK_TREE_MODEL (list_store)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((list_store)), ((gtk_tree_model_get_type ()))))))
);
244 gtk_combo_box_set_active (GTK_COMBO_BOX (cbv)((((GtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((cbv)), ((gtk_combo_box_get_type ()))))))
, 0);
245}
246
247static void
248xkb_layout_chooser_available_country_variants_fill (GtkBuilder *
249 chooser_dialog)
250{
251 GtkWidget *cbl = CWID ("xkb_countries_available")((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (chooser_dialog, "xkb_countries_available"
))), ((gtk_widget_get_type ()))))))
;
252 GtkWidget *cbv = CWID ("xkb_country_variants_available")((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (chooser_dialog, "xkb_country_variants_available"
))), ((gtk_widget_get_type ()))))))
;
253 GtkListStore *list_store;
254 GtkTreeIter liter;
255
256 list_store = gtk_list_store_new
257 (4, G_TYPE_STRING((GType) ((16) << (2))), G_TYPE_STRING((GType) ((16) << (2))), G_TYPE_STRING((GType) ((16) << (2))),
258 G_TYPE_STRING((GType) ((16) << (2))));
259
260 if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (cbl)((((GtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((cbl)), ((gtk_combo_box_get_type ()))))))
, &liter)) {
261 GtkTreeModel *lm =
262 gtk_combo_box_get_model (GTK_COMBO_BOX (cbl)((((GtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((cbl)), ((gtk_combo_box_get_type ()))))))
);
263 gchar *country_id;
264 AddVariantData data = { list_store, 0 };
265
266 /* Now the variants of the selected layout */
267 gtk_tree_model_get (lm, &liter,
268 COMBO_BOX_MODEL_COL_REAL_ID,
269 &country_id, -1);
270 xkl_config_registry_foreach_country_variant
271 (config_registry, country_id,
272 (TwoConfigItemsProcessFunc)
273 xkb_layout_chooser_add_variant_to_available_country_variants,
274 &data);
275 g_free (country_id);
276 }
277
278 /* Turn on sorting after filling the store, since that's faster */
279 gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE((((GtkTreeSortable*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((list_store)), ((gtk_tree_sortable_get_type ()))))))
280 (list_store)((((GtkTreeSortable*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((list_store)), ((gtk_tree_sortable_get_type ()))))))
,
281 COMBO_BOX_MODEL_COL_SORT,
282 GTK_SORT_ASCENDING);
283
284 gtk_combo_box_set_model (GTK_COMBO_BOX (cbv)((((GtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((cbv)), ((gtk_combo_box_get_type ()))))))
,
285 GTK_TREE_MODEL (list_store)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((list_store)), ((gtk_tree_model_get_type ()))))))
);
286 gtk_combo_box_set_active (GTK_COMBO_BOX (cbv)((((GtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((cbv)), ((gtk_combo_box_get_type ()))))))
, 0);
287}
288
289static void
290xkb_layout_chooser_available_layouts_fill (GtkBuilder *
291 chooser_dialog,
292 const gchar cblid[],
293 const gchar cbvid[],
294 LayoutIterFunc layout_iterator,
295 ConfigItemProcessFunc
296 layout_handler,
297 GCallback combo_changed_notify)
298{
299 GtkWidget *cbl = CWID (cblid)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (chooser_dialog, cblid))), ((gtk_widget_get_type
()))))))
;
300 GtkWidget *cbev = CWID (cbvid)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (chooser_dialog, cbvid))), ((gtk_widget_get_type
()))))))
;
301 GtkCellRenderer *renderer;
302 GtkListStore *list_store;
303
304 list_store = gtk_list_store_new
305 (4, G_TYPE_STRING((GType) ((16) << (2))), G_TYPE_STRING((GType) ((16) << (2))), G_TYPE_STRING((GType) ((16) << (2))),
306 G_TYPE_STRING((GType) ((16) << (2))));
307
308 gtk_combo_box_set_model (GTK_COMBO_BOX (cbl)((((GtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((cbl)), ((gtk_combo_box_get_type ()))))))
,
309 GTK_TREE_MODEL (list_store)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((list_store)), ((gtk_tree_model_get_type ()))))))
);
310
311 renderer = gtk_cell_renderer_text_new ();
312 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (cbl)((((GtkCellLayout*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((cbl)), ((gtk_cell_layout_get_type ()))))))
, renderer, TRUE(!(0)));
313 gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (cbl)((((GtkCellLayout*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((cbl)), ((gtk_cell_layout_get_type ()))))))
,
314 renderer, "markup",
315 COMBO_BOX_MODEL_COL_VISIBLE, NULL((void*)0));
316
317 layout_iterator (config_registry, layout_handler, list_store);
318
319 /* Turn on sorting after filling the model since that's faster */
320 gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE((((GtkTreeSortable*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((list_store)), ((gtk_tree_sortable_get_type ()))))))
321 (list_store)((((GtkTreeSortable*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((list_store)), ((gtk_tree_sortable_get_type ()))))))
,
322 COMBO_BOX_MODEL_COL_SORT,
323 GTK_SORT_ASCENDING);
324
325 g_signal_connect_swapped (cbl, "changed",g_signal_connect_data ((cbl), ("changed"), (((GCallback) (combo_changed_notify
))), (chooser_dialog), ((void*)0), G_CONNECT_SWAPPED)
326 G_CALLBACK (combo_changed_notify),g_signal_connect_data ((cbl), ("changed"), (((GCallback) (combo_changed_notify
))), (chooser_dialog), ((void*)0), G_CONNECT_SWAPPED)
327 chooser_dialog)g_signal_connect_data ((cbl), ("changed"), (((GCallback) (combo_changed_notify
))), (chooser_dialog), ((void*)0), G_CONNECT_SWAPPED)
;
328
329 /* Setup the variants combo */
330 renderer = gtk_cell_renderer_text_new ();
331 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (cbev)((((GtkCellLayout*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((cbev)), ((gtk_cell_layout_get_type ()))))))
,
332 renderer, TRUE(!(0)));
333 gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (cbev)((((GtkCellLayout*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((cbev)), ((gtk_cell_layout_get_type ()))))))
,
334 renderer, "markup",
335 COMBO_BOX_MODEL_COL_VISIBLE, NULL((void*)0));
336
337 g_signal_connect_swapped (cbev, "changed",g_signal_connect_data ((cbev), ("changed"), (((GCallback) (xkb_layout_chooser_available_variant_changed
))), (chooser_dialog), ((void*)0), G_CONNECT_SWAPPED)
338 G_CALLBACK(xkb_layout_chooser_available_variant_changed),g_signal_connect_data ((cbev), ("changed"), (((GCallback) (xkb_layout_chooser_available_variant_changed
))), (chooser_dialog), ((void*)0), G_CONNECT_SWAPPED)
339 chooser_dialog)g_signal_connect_data ((cbev), ("changed"), (((GCallback) (xkb_layout_chooser_available_variant_changed
))), (chooser_dialog), ((void*)0), G_CONNECT_SWAPPED)
;
340}
341
342static gchar **
343xkb_layout_strv_from_gslist (GSList *list)
344{
345 GArray *array;
346 GSList *l;
347 array = g_array_new (TRUE(!(0)), TRUE(!(0)), sizeof (gchar *));
348 for (l = list; l; l = l->next) {
349 array = g_array_append_val (array, l->data)g_array_append_vals (array, &(l->data), 1);
350 }
351 return (gchar **) array->data;
352}
353
354static void
355xkl_layout_chooser_add_default_switcher_if_necessary (GSList *
356 layouts_list)
357{
358 GSList *options_list = xkb_options_get_selected_list ();
359 gboolean was_appended;
360
361 gchar **layouts_list_strv = xkb_layout_strv_from_gslist (layouts_list);
362 gchar **options_list_strv = xkb_layout_strv_from_gslist (options_list);
363
364 options_list_strv =
Value stored to 'options_list_strv' is never read
365 matekbd_keyboard_config_add_default_switch_option_if_necessary
366 (layouts_list_strv, options_list_strv, &was_appended);
367 if (was_appended) {
368 xkb_options_set_selected_list (options_list);
369
370 }
371 clear_xkb_elements_list (options_list);
372}
373
374static void
375xkb_layout_chooser_print (GtkBuilder * chooser_dialog)
376{
377 GtkWidget *chooser = CWID ("xkb_layout_chooser")((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (chooser_dialog, "xkb_layout_chooser"
))), ((gtk_widget_get_type ()))))))
;
378 GtkWidget *kbdraw =
379 GTK_WIDGET (g_object_get_data (G_OBJECT (chooser), "kbdraw"))((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((g_object_get_data (((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((chooser)), (((GType) ((20) << (2))
)))))), "kbdraw"))), ((gtk_widget_get_type ()))))))
;
380 const char *id =
381 xkb_layout_chooser_get_selected_id (chooser_dialog);
382 char *descr = xkb_layout_description_utf8 (id);
383 matekbd_keyboard_drawing_print (MATEKBD_KEYBOARD_DRAWING((((MatekbdKeyboardDrawing*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((kbdraw)), (matekbd_keyboard_drawing_get_type
())))))
384 (kbdraw)((((MatekbdKeyboardDrawing*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((kbdraw)), (matekbd_keyboard_drawing_get_type
())))))
,
385 GTK_WINDOW (CWID((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (chooser_dialog, "xkb_layout_chooser"
))), ((gtk_widget_get_type ())))))))), ((gtk_window_get_type (
)))))))
386 ("xkb_layout_chooser"))((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (chooser_dialog, "xkb_layout_chooser"
))), ((gtk_widget_get_type ())))))))), ((gtk_window_get_type (
)))))))
,
387 descr);
388 g_free (descr);
389}
390
391static void
392xkb_layout_chooser_response (GtkDialog * dialog,
393 gint response, GtkBuilder * chooser_dialog)
394{
395 GdkRectangle rect;
396
397 if (response == GTK_RESPONSE_OK) {
398 gchar *selected_id = (gchar *)
399 xkb_layout_chooser_get_selected_id (chooser_dialog);
400
401 if (selected_id != NULL((void*)0)) {
402 GSList *layouts_list =
403 xkb_layouts_get_selected_list ();
404
405 selected_id = g_strdup (selected_id)g_strdup_inline (selected_id);
406
407 layouts_list =
408 g_slist_append (layouts_list, selected_id);
409 xkb_layouts_set_selected_list (layouts_list);
410
411 xkl_layout_chooser_add_default_switcher_if_necessary
412 (layouts_list);
413
414 clear_xkb_elements_list (layouts_list);
415 }
416 } else if (response == gtk_dialog_get_response_for_widget
417 (dialog, CWID ("btnPrint")((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (chooser_dialog, "btnPrint"))), (
(gtk_widget_get_type ()))))))
)) {
418 xkb_layout_chooser_print (chooser_dialog);
419 g_signal_stop_emission_by_name (dialog, "response");
420 return;
421 }
422
423 gtk_window_get_position (GTK_WINDOW (dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_window_get_type ()))))))
, &rect.x, &rect.y);
424 gtk_window_get_size (GTK_WINDOW (dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_window_get_type ()))))))
, &rect.width,
425 &rect.height);
426 matekbd_preview_save_position (&rect);
427}
428
429void
430xkb_layout_choose (GtkBuilder * dialog)
431{
432 GtkBuilder *chooser_dialog;
433
434 chooser_dialog = gtk_builder_new ();
435 gtk_builder_add_from_resource (chooser_dialog,
436 "/org/mate/mcc/keyboard/mate-keyboard-properties-layout-chooser.ui",
437 NULL((void*)0));
438 GtkWidget *chooser = CWID ("xkb_layout_chooser")((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (chooser_dialog, "xkb_layout_chooser"
))), ((gtk_widget_get_type ()))))))
;
439 GtkWidget *lang_chooser = CWID ("xkb_languages_available")((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (chooser_dialog, "xkb_languages_available"
))), ((gtk_widget_get_type ()))))))
;
440 GtkWidget *notebook = CWID ("choosers_nb")((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (chooser_dialog, "choosers_nb")))
, ((gtk_widget_get_type ()))))))
;
441 GtkWidget *kbdraw = NULL((void*)0);
442 GtkWidget *toplevel = NULL((void*)0);
443
444 gtk_window_set_transient_for (GTK_WINDOW (chooser)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((chooser)), ((gtk_window_get_type ()))))))
,
445 GTK_WINDOW (WID((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (dialog, "keyboard_dialog"))), ((
gtk_widget_get_type ())))))))), ((gtk_window_get_type ())))))
)
446 ("keyboard_dialog"))((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (dialog, "keyboard_dialog"))), ((
gtk_widget_get_type ())))))))), ((gtk_window_get_type ())))))
)
);
447
448 xkb_layout_chooser_available_layouts_fill (chooser_dialog,
449 "xkb_countries_available",
450 "xkb_country_variants_available",
451 xkl_config_registry_foreach_country,
452 (ConfigItemProcessFunc)
453 xkb_layout_chooser_add_country_to_available_countries,
454 G_CALLBACK((GCallback) (xkb_layout_chooser_available_country_changed))
455 (xkb_layout_chooser_available_country_changed)((GCallback) (xkb_layout_chooser_available_country_changed)));
456 xkb_layout_chooser_available_layouts_fill (chooser_dialog,
457 "xkb_languages_available",
458 "xkb_language_variants_available",
459 xkl_config_registry_foreach_language,
460 (ConfigItemProcessFunc)
461 xkb_layout_chooser_add_language_to_available_languages,
462 G_CALLBACK((GCallback) (xkb_layout_chooser_available_language_changed))
463 (xkb_layout_chooser_available_language_changed)((GCallback) (xkb_layout_chooser_available_language_changed)));
464
465 g_signal_connect_after (notebook, "switch_page",g_signal_connect_data ((notebook), ("switch_page"), (((GCallback
) (xkb_layout_chooser_page_changed))), (chooser_dialog), ((void
*)0), G_CONNECT_AFTER)
466 G_CALLBACK(xkb_layout_chooser_page_changed),g_signal_connect_data ((notebook), ("switch_page"), (((GCallback
) (xkb_layout_chooser_page_changed))), (chooser_dialog), ((void
*)0), G_CONNECT_AFTER)
467 chooser_dialog)g_signal_connect_data ((notebook), ("switch_page"), (((GCallback
) (xkb_layout_chooser_page_changed))), (chooser_dialog), ((void
*)0), G_CONNECT_AFTER)
;
468
469 gtk_combo_box_set_active (GTK_COMBO_BOX((((GtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (chooser_dialog, "xkb_countries_available"
))), ((gtk_widget_get_type ())))))))), ((gtk_combo_box_get_type
()))))))
470 (CWID ("xkb_countries_available"))((((GtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (chooser_dialog, "xkb_countries_available"
))), ((gtk_widget_get_type ())))))))), ((gtk_combo_box_get_type
()))))))
,
471 FALSE(0));
472
473 if (gtk_tree_model_iter_n_children
474 (gtk_combo_box_get_model (GTK_COMBO_BOX (lang_chooser)((((GtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((lang_chooser)), ((gtk_combo_box_get_type ()))))))
),
475 NULL((void*)0))) {
476 gtk_combo_box_set_active (GTK_COMBO_BOX((((GtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (chooser_dialog, "xkb_languages_available"
))), ((gtk_widget_get_type ())))))))), ((gtk_combo_box_get_type
()))))))
477 (CWID((((GtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (chooser_dialog, "xkb_languages_available"
))), ((gtk_widget_get_type ())))))))), ((gtk_combo_box_get_type
()))))))
478 ("xkb_languages_available"))((((GtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (chooser_dialog, "xkb_languages_available"
))), ((gtk_widget_get_type ())))))))), ((gtk_combo_box_get_type
()))))))
,
479 FALSE(0));
480 } else {
481 /* If language info is not available - remove the corresponding tab,
482 pretend there is no notebook at all */
483 gtk_notebook_remove_page (GTK_NOTEBOOK (notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((notebook)), ((gtk_notebook_get_type ()))))))
, 1);
484 gtk_notebook_set_show_tabs (GTK_NOTEBOOK (notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((notebook)), ((gtk_notebook_get_type ()))))))
,
485 FALSE(0));
486 gtk_notebook_set_show_border (GTK_NOTEBOOK (notebook)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((notebook)), ((gtk_notebook_get_type ()))))))
,
487 FALSE(0));
488 }
489
490#ifdef HAVE_X11_EXTENSIONS_XKB_H1
491 if (!strcmp (xkl_engine_get_backend_name (engine), "XKB")) {
492 kbdraw = xkb_layout_preview_create_widget (chooser_dialog);
493 g_object_set_data (G_OBJECT (chooser)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((chooser)), (((GType) ((20) << (2))))))))
, "kbdraw", kbdraw);
494 gtk_container_add (GTK_CONTAINER((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (chooser_dialog, "previewFrame"))
), ((gtk_widget_get_type ())))))))), ((gtk_container_get_type
()))))))
495 (CWID ("previewFrame"))((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (chooser_dialog, "previewFrame"))
), ((gtk_widget_get_type ())))))))), ((gtk_container_get_type
()))))))
, kbdraw);
496 gtk_widget_show_all (kbdraw);
497 gtk_button_box_set_child_secondary (GTK_BUTTON_BOX((((GtkButtonBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (chooser_dialog, "hbtnBox"))), ((
gtk_widget_get_type ())))))))), ((gtk_button_box_get_type ())
)))))
498 (CWID((((GtkButtonBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (chooser_dialog, "hbtnBox"))), ((
gtk_widget_get_type ())))))))), ((gtk_button_box_get_type ())
)))))
499 ("hbtnBox"))((((GtkButtonBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (chooser_dialog, "hbtnBox"))), ((
gtk_widget_get_type ())))))))), ((gtk_button_box_get_type ())
)))))
,
500 CWID((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (chooser_dialog, "btnPrint"))), (
(gtk_widget_get_type ()))))))
501 ("btnPrint")((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (chooser_dialog, "btnPrint"))), (
(gtk_widget_get_type ()))))))
, TRUE(!(0)));
502 } else
503#endif
504 {
505 gtk_widget_hide (CWID ("vboxPreview")((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (chooser_dialog, "vboxPreview")))
, ((gtk_widget_get_type ()))))))
);
506 gtk_widget_hide (CWID ("btnPrint")((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (chooser_dialog, "btnPrint"))), (
(gtk_widget_get_type ()))))))
);
507 }
508
509 g_signal_connect (chooser, "response",g_signal_connect_data ((chooser), ("response"), (((GCallback)
(xkb_layout_chooser_response))), (chooser_dialog), ((void*)0
), (GConnectFlags) 0)
510 G_CALLBACK (xkb_layout_chooser_response),g_signal_connect_data ((chooser), ("response"), (((GCallback)
(xkb_layout_chooser_response))), (chooser_dialog), ((void*)0
), (GConnectFlags) 0)
511 chooser_dialog)g_signal_connect_data ((chooser), ("response"), (((GCallback)
(xkb_layout_chooser_response))), (chooser_dialog), ((void*)0
), (GConnectFlags) 0)
;
512
513 toplevel = gtk_widget_get_toplevel (chooser);
514 if (gtk_widget_is_toplevel (toplevel)) {
515 GdkRectangle *rect = matekbd_preview_load_position ();
516 if (rect != NULL((void*)0)) {
517 gtk_window_move (GTK_WINDOW (toplevel)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_window_get_type ()))))))
,
518 rect->x, rect->y);
519 gtk_window_resize (GTK_WINDOW (toplevel)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((gtk_window_get_type ()))))))
,
520 rect->width, rect->height);
521 g_free (rect);
522 }
523 }
524
525 xkb_layout_preview_update (chooser_dialog);
526 gtk_dialog_run (GTK_DIALOG (chooser)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((chooser)), ((gtk_dialog_get_type ()))))))
);
527 gtk_widget_destroy (chooser);
528}
529
530gchar *
531xkb_layout_chooser_get_selected_id (GtkBuilder * chooser_dialog)
532{
533 GtkWidget *cbv =
534 CWID (gtk_notebook_get_current_page((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (chooser_dialog, gtk_notebook_get_current_page
(((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (chooser_dialog, "choosers_nb")))
, ((gtk_notebook_get_type ()))))))) ? "xkb_language_variants_available"
: "xkb_country_variants_available"))), ((gtk_widget_get_type
()))))))
535 (GTK_NOTEBOOK (gtk_builder_get_object (chooser_dialog, "choosers_nb"))) ?((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (chooser_dialog, gtk_notebook_get_current_page
(((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (chooser_dialog, "choosers_nb")))
, ((gtk_notebook_get_type ()))))))) ? "xkb_language_variants_available"
: "xkb_country_variants_available"))), ((gtk_widget_get_type
()))))))
536 "xkb_language_variants_available" :((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (chooser_dialog, gtk_notebook_get_current_page
(((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (chooser_dialog, "choosers_nb")))
, ((gtk_notebook_get_type ()))))))) ? "xkb_language_variants_available"
: "xkb_country_variants_available"))), ((gtk_widget_get_type
()))))))
537 "xkb_country_variants_available")((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (chooser_dialog, gtk_notebook_get_current_page
(((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (chooser_dialog, "choosers_nb")))
, ((gtk_notebook_get_type ()))))))) ? "xkb_language_variants_available"
: "xkb_country_variants_available"))), ((gtk_widget_get_type
()))))))
;
538 GtkTreeModel *vm = gtk_combo_box_get_model (GTK_COMBO_BOX (cbv)((((GtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((cbv)), ((gtk_combo_box_get_type ()))))))
);
539 GtkTreeIter viter;
540 gchar *v_id;
541
542 if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (cbv)((((GtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((cbv)), ((gtk_combo_box_get_type ()))))))
, &viter))
543 return NULL((void*)0);
544
545 gtk_tree_model_get (vm, &viter,
546 COMBO_BOX_MODEL_COL_XKB_ID, &v_id, -1);
547
548 return v_id;
549}
diff --git a/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-6370cb.html b/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-6370cb.html new file mode 100644 index 00000000..34e444ae --- /dev/null +++ b/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-6370cb.html @@ -0,0 +1,1289 @@ + + + +drw-break-window.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:typing-break/drw-break-window.c
Warning:line 497, column 18
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name drw-break-window.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/typing-break -fcoverage-compilation-dir=/rootdir/typing-break -resource-dir /usr/bin/../lib/clang/18 -D HAVE_CONFIG_H -I . -I .. -D MATELOCALEDIR="/usr/local/share/locale" -D IMAGEDIR="/usr/local/share/mate-control-center/pixmaps" -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/gio-unix-2.0 -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I /usr/include/libappindicator3-0.1 -I /usr/include/libdbusmenu-glib-0.4 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/gio-unix-2.0 -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/startup-notification-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/gio-unix-2.0 -I /usr/include/dconf -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -D HAVE_CANBERRA_GTK -D _REENTRANT -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/gio-unix-2.0 -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-06-07-044335-13427-1 -x c drw-break-window.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2/*
3 * Copyright (C) 2002 CodeFactory AB
4 * Copyright (C) 2002-2003 Richard Hult <richard@imendio.com>
5
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of the
10 * License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public
18 * License along with this program; if not, write to the
19 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
21 */
22
23#include <config.h>
24#include <string.h>
25#include <math.h>
26#include <glib/gi18n.h>
27#include <gtk/gtk.h>
28#include <gdk/gdkx.h>
29#include <gdk/gdkkeysyms.h>
30#include <gio/gio.h>
31
32#ifdef HAVE_CANBERRA_GTK1
33#include <canberra-gtk.h>
34#endif
35
36#include "drwright.h"
37#include "drw-utils.h"
38#include "drw-break-window.h"
39#include "drw-timer.h"
40
41struct _DrwBreakWindowPrivate {
42 GtkWidget *clock_label;
43 GtkWidget *break_label;
44 GtkWidget *image;
45
46 GtkWidget *postpone_entry;
47 GtkWidget *postpone_button;
48
49 DrwTimer *timer;
50
51 gint break_time;
52 gchar *break_text;
53 guint clock_timeout_id;
54 guint postpone_timeout_id;
55 guint postpone_sensitize_id;
56};
57
58#define POSTPONE_CANCEL30 30
59
60/* Signals */
61enum {
62 DONE,
63 POSTPONE,
64 LAST_SIGNAL
65};
66
67static void drw_break_window_finalize (GObject *object);
68static void drw_break_window_dispose (GObject *object);
69static gboolean postpone_sensitize_cb (DrwBreakWindow *window);
70static gboolean clock_timeout_cb (DrwBreakWindow *window);
71static void postpone_clicked_cb (GtkWidget *button,
72 GtkWidget *window);
73static gboolean label_draw_event_cb (GtkLabel *label,
74 cairo_t *cr,
75 gpointer user_data);
76static void label_size_allocate_cb (GtkLabel *label,
77 GdkRectangle *allocation,
78 gpointer user_data);
79
80G_DEFINE_TYPE_WITH_PRIVATE (DrwBreakWindow, drw_break_window, GTK_TYPE_WINDOW)static void drw_break_window_init (DrwBreakWindow *self); static
void drw_break_window_class_init (DrwBreakWindowClass *klass
); static GType drw_break_window_get_type_once (void); static
gpointer drw_break_window_parent_class = ((void*)0); static gint
DrwBreakWindow_private_offset; static void drw_break_window_class_intern_init
(gpointer klass) { drw_break_window_parent_class = g_type_class_peek_parent
(klass); if (DrwBreakWindow_private_offset != 0) g_type_class_adjust_private_offset
(klass, &DrwBreakWindow_private_offset); drw_break_window_class_init
((DrwBreakWindowClass*) klass); } __attribute__ ((__unused__
)) static inline gpointer drw_break_window_get_instance_private
(DrwBreakWindow *self) { return (((gpointer) ((guint8*) (self
) + (glong) (DrwBreakWindow_private_offset)))); } GType drw_break_window_get_type
(void) { static GType static_g_define_type_id = 0; if ((__extension__
({ _Static_assert (sizeof *(&static_g_define_type_id) ==
sizeof (gpointer), "Expression evaluates to false"); (void) (
0 ? (gpointer) * (&static_g_define_type_id) : ((void*)0))
; (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter_pointer (
&static_g_define_type_id)); })) ) { GType g_define_type_id
= drw_break_window_get_type_once (); (__extension__ ({ _Static_assert
(sizeof *(&static_g_define_type_id) == sizeof (gpointer)
, "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id
) = (g_define_type_id)) : (void) 0; g_once_init_leave_pointer
((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id
)); })) ; } return static_g_define_type_id; } __attribute__ (
(__noinline__)) static GType drw_break_window_get_type_once (
void) { GType g_define_type_id = g_type_register_static_simple
((gtk_window_get_type ()), g_intern_static_string ("DrwBreakWindow"
), sizeof (DrwBreakWindowClass), (GClassInitFunc)(void (*)(void
)) drw_break_window_class_intern_init, sizeof (DrwBreakWindow
), (GInstanceInitFunc)(void (*)(void)) drw_break_window_init,
(GTypeFlags) 0); { {{ DrwBreakWindow_private_offset = g_type_add_instance_private
(g_define_type_id, sizeof (DrwBreakWindowPrivate)); };} } return
g_define_type_id; }
81
82static guint signals[LAST_SIGNAL] = { 0 };
83
84static void
85drw_break_window_class_init (DrwBreakWindowClass *klass)
86{
87 GObjectClass *object_class = G_OBJECT_CLASS (klass)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((klass)), (((GType) ((20) << (2))))))))
;
88
89 object_class->finalize = drw_break_window_finalize;
90 object_class->dispose = drw_break_window_dispose;
91
92 signals[POSTPONE] =
93 g_signal_new ("postpone",
94 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
95 G_SIGNAL_RUN_LAST,
96 0,
97 NULL((void*)0), NULL((void*)0),
98 g_cclosure_marshal_VOID__VOID,
99 G_TYPE_NONE((GType) ((1) << (2))), 0);
100
101 signals[DONE] =
102 g_signal_new ("done",
103 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
104 G_SIGNAL_RUN_LAST,
105 0,
106 NULL((void*)0), NULL((void*)0),
107 g_cclosure_marshal_VOID__VOID,
108 G_TYPE_NONE((GType) ((1) << (2))), 0);
109}
110
111static void
112drw_break_window_init (DrwBreakWindow *window)
113{
114 DrwBreakWindowPrivate *priv;
115 GtkWidget *vbox;
116 GtkWidget *hbox;
117 gchar *str;
118 GtkWidget *outer_vbox;
119 GtkWidget *button_box;
120 gboolean allow_postpone;
121
122 gint root_monitor = 0;
123 GdkScreen *screen = NULL((void*)0);
124 GdkDisplay *display;
125 GdkRectangle monitor;
126 gint right_padding;
127 gint bottom_padding;
128 gint scale;
129 GSettings *settings;
130
131 priv = drw_break_window_get_instance_private (window);
132 window->priv = priv;
133
134 settings = g_settings_new (TYPING_BREAK_SCHEMA"org.mate.typing-break");
135
136 priv->break_time = 60 * g_settings_get_int (settings, "break-time");
137
138 allow_postpone = g_settings_get_boolean (settings, "allow-postpone");
139 g_object_unref (settings);
140
141 gtk_window_set_keep_above (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
, TRUE(!(0)));
142 gtk_window_fullscreen (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
);
143 gtk_window_set_modal (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
, TRUE(!(0)));
144
145 screen = gdk_screen_get_default ();
146 display = gdk_screen_get_display (screen);
147 scale = gtk_widget_get_scale_factor (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
148
149 gdk_monitor_get_geometry (gdk_display_get_monitor (display, root_monitor), &monitor);
150
151 gtk_window_set_default_size (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
,
152 WidthOfScreen (gdk_x11_screen_get_xscreen (screen))((gdk_x11_screen_get_xscreen (screen))->width) / scale,
153 HeightOfScreen (gdk_x11_screen_get_xscreen (screen))((gdk_x11_screen_get_xscreen (screen))->height) / scale);
154
155 gtk_window_set_decorated (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
, FALSE(0));
156 gtk_widget_set_app_paintable (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
, TRUE(!(0)));
157 drw_setup_background (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
158
159 right_padding = WidthOfScreen (gdk_x11_screen_get_xscreen (screen))((gdk_x11_screen_get_xscreen (screen))->width) / scale - monitor.width - monitor.x;
160 bottom_padding = HeightOfScreen (gdk_x11_screen_get_xscreen (screen))((gdk_x11_screen_get_xscreen (screen))->height) / scale - monitor.height - monitor.y;
161
162 outer_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
163 gtk_widget_set_hexpand (outer_vbox, TRUE(!(0)));
164 gtk_widget_set_vexpand (outer_vbox, TRUE(!(0)));
165 gtk_widget_set_margin_top (outer_vbox, monitor.y);
166 gtk_widget_set_margin_bottom (outer_vbox, bottom_padding);
167 gtk_widget_set_margin_start (outer_vbox, monitor.x);
168 gtk_widget_set_margin_end (outer_vbox, right_padding);
169 gtk_widget_show (outer_vbox);
170
171 gtk_container_add (GTK_CONTAINER (window)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_container_get_type ()))))))
, outer_vbox);
172
173 if (allow_postpone) {
174 button_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
175 gtk_widget_show (button_box);
176
177 gtk_container_set_border_width (GTK_CONTAINER (button_box)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((button_box)), ((gtk_container_get_type ()))))))
, 12);
178
179 priv->postpone_button = gtk_button_new_with_mnemonic (_("_Postpone Break")gettext ("_Postpone Break"));
180 gtk_widget_show (priv->postpone_button);
181
182 gtk_widget_set_sensitive (priv->postpone_button, FALSE(0));
183
184 if (priv->postpone_sensitize_id) {
185 g_source_remove (priv->postpone_sensitize_id);
186 }
187
188 priv->postpone_sensitize_id = g_timeout_add_seconds (5,
189 (GSourceFunc) postpone_sensitize_cb,
190 window);
191
192 g_signal_connect (priv->postpone_button,g_signal_connect_data ((priv->postpone_button), ("clicked"
), (((GCallback) (postpone_clicked_cb))), (window), ((void*)0
), (GConnectFlags) 0)
193 "clicked",g_signal_connect_data ((priv->postpone_button), ("clicked"
), (((GCallback) (postpone_clicked_cb))), (window), ((void*)0
), (GConnectFlags) 0)
194 G_CALLBACK (postpone_clicked_cb),g_signal_connect_data ((priv->postpone_button), ("clicked"
), (((GCallback) (postpone_clicked_cb))), (window), ((void*)0
), (GConnectFlags) 0)
195 window)g_signal_connect_data ((priv->postpone_button), ("clicked"
), (((GCallback) (postpone_clicked_cb))), (window), ((void*)0
), (GConnectFlags) 0)
;
196
197 gtk_box_pack_end (GTK_BOX (button_box)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((button_box)), ((gtk_box_get_type ()))))))
, priv->postpone_button, FALSE(0), TRUE(!(0)), 0);
198
199 priv->postpone_entry = gtk_entry_new ();
200 gtk_entry_set_has_frame (GTK_ENTRY (priv->postpone_entry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->postpone_entry)), ((gtk_entry_get_type ()))))))
, FALSE(0));
201
202 gtk_box_pack_end (GTK_BOX (button_box)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((button_box)), ((gtk_box_get_type ()))))))
, priv->postpone_entry, FALSE(0), TRUE(!(0)), 4);
203
204 gtk_box_pack_end (GTK_BOX (outer_vbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((outer_vbox)), ((gtk_box_get_type ()))))))
, button_box, FALSE(0), TRUE(!(0)), 0);
205 }
206
207 vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
208 gtk_widget_set_halign (vbox, GTK_ALIGN_CENTER);
209 gtk_widget_set_valign (vbox, GTK_ALIGN_CENTER);
210 gtk_widget_show (vbox);
211
212 gtk_box_pack_start (GTK_BOX (outer_vbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((outer_vbox)), ((gtk_box_get_type ()))))))
, vbox, TRUE(!(0)), TRUE(!(0)), 0);
213
214 hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
215 gtk_widget_show (hbox);
216 gtk_box_pack_start (GTK_BOX (vbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((vbox)), ((gtk_box_get_type ()))))))
, hbox, TRUE(!(0)), FALSE(0), 0);
217
218 priv->image = gtk_image_new_from_icon_name ("process-stop", GTK_ICON_SIZE_DIALOG);
219 gtk_widget_set_halign (priv->image, GTK_ALIGN_END);
220 gtk_widget_set_valign (priv->image, GTK_ALIGN_CENTER);
221 gtk_widget_show (priv->image);
222 gtk_box_pack_start (GTK_BOX (hbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((hbox)), ((gtk_box_get_type ()))))))
, priv->image, TRUE(!(0)), TRUE(!(0)), 8);
223
224 priv->break_label = gtk_label_new (NULL((void*)0));
225 gtk_widget_show (priv->break_label);
226
227 g_signal_connect (priv->break_label,g_signal_connect_data ((priv->break_label), ("draw"), (((GCallback
) (label_draw_event_cb))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
228 "draw",g_signal_connect_data ((priv->break_label), ("draw"), (((GCallback
) (label_draw_event_cb))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
229 G_CALLBACK (label_draw_event_cb),g_signal_connect_data ((priv->break_label), ("draw"), (((GCallback
) (label_draw_event_cb))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
230 NULL)g_signal_connect_data ((priv->break_label), ("draw"), (((GCallback
) (label_draw_event_cb))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
;
231
232 g_signal_connect_after (priv->break_label,g_signal_connect_data ((priv->break_label), ("size-allocate"
), (((GCallback) (label_size_allocate_cb))), (((void*)0)), ((
void*)0), G_CONNECT_AFTER)
233 "size-allocate",g_signal_connect_data ((priv->break_label), ("size-allocate"
), (((GCallback) (label_size_allocate_cb))), (((void*)0)), ((
void*)0), G_CONNECT_AFTER)
234 G_CALLBACK (label_size_allocate_cb),g_signal_connect_data ((priv->break_label), ("size-allocate"
), (((GCallback) (label_size_allocate_cb))), (((void*)0)), ((
void*)0), G_CONNECT_AFTER)
235 NULL)g_signal_connect_data ((priv->break_label), ("size-allocate"
), (((GCallback) (label_size_allocate_cb))), (((void*)0)), ((
void*)0), G_CONNECT_AFTER)
;
236
237 str = g_strdup_printf ("<span size=\"xx-large\" foreground=\"white\"><b>%s</b></span>",
238 _("Take a break!")gettext ("Take a break!"));
239 gtk_label_set_markup (GTK_LABEL (priv->break_label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->break_label)), ((gtk_label_get_type ()))))))
, str);
240 g_free (str);
241
242 gtk_box_pack_start (GTK_BOX (hbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((hbox)), ((gtk_box_get_type ()))))))
, priv->break_label, FALSE(0), FALSE(0), 12);
243
244 priv->clock_label = gtk_label_new (NULL((void*)0));
245 gtk_widget_show (priv->clock_label);
246 gtk_box_pack_start (GTK_BOX (vbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((vbox)), ((gtk_box_get_type ()))))))
, priv->clock_label, TRUE(!(0)), TRUE(!(0)), 8);
247
248 g_signal_connect (priv->clock_label,g_signal_connect_data ((priv->clock_label), ("draw"), (((GCallback
) (label_draw_event_cb))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
249 "draw",g_signal_connect_data ((priv->clock_label), ("draw"), (((GCallback
) (label_draw_event_cb))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
250 G_CALLBACK (label_draw_event_cb),g_signal_connect_data ((priv->clock_label), ("draw"), (((GCallback
) (label_draw_event_cb))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
251 NULL)g_signal_connect_data ((priv->clock_label), ("draw"), (((GCallback
) (label_draw_event_cb))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
;
252
253 g_signal_connect_after (priv->clock_label,g_signal_connect_data ((priv->clock_label), ("size-allocate"
), (((GCallback) (label_size_allocate_cb))), (((void*)0)), ((
void*)0), G_CONNECT_AFTER)
254 "size-allocate",g_signal_connect_data ((priv->clock_label), ("size-allocate"
), (((GCallback) (label_size_allocate_cb))), (((void*)0)), ((
void*)0), G_CONNECT_AFTER)
255 G_CALLBACK (label_size_allocate_cb),g_signal_connect_data ((priv->clock_label), ("size-allocate"
), (((GCallback) (label_size_allocate_cb))), (((void*)0)), ((
void*)0), G_CONNECT_AFTER)
256 NULL)g_signal_connect_data ((priv->clock_label), ("size-allocate"
), (((GCallback) (label_size_allocate_cb))), (((void*)0)), ((
void*)0), G_CONNECT_AFTER)
;
257
258 gtk_window_stick (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
);
259
260 priv->timer = drw_timer_new ();
261
262 /* Make sure we have a valid time label from the start. */
263 clock_timeout_cb (window);
264
265 priv->clock_timeout_id = g_timeout_add (1000,
266 (GSourceFunc) clock_timeout_cb,
267 window);
268#ifdef HAVE_CANBERRA_GTK1
269 ca_context_play (ca_gtk_context_get (), 0, CA_PROP_EVENT_ID"event.id", "desktop-screen-lock", NULL((void*)0));
270#endif
271}
272
273static void
274drw_break_window_finalize (GObject *object)
275{
276 DrwBreakWindow *window = DRW_BREAK_WINDOW (object)((((DrwBreakWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((drw_break_window_get_type ()))))))
;
277 DrwBreakWindowPrivate *priv;
278
279 priv = window->priv;
280
281 if (priv->clock_timeout_id != 0) {
282 g_source_remove (priv->clock_timeout_id);
283 }
284
285 if (priv->postpone_timeout_id != 0) {
286 g_source_remove (priv->postpone_timeout_id);
287 }
288
289 if (priv->postpone_sensitize_id != 0) {
290 g_source_remove (priv->postpone_sensitize_id);
291 }
292
293 window->priv = NULL((void*)0);
294
295 if (G_OBJECT_CLASS (drw_break_window_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((drw_break_window_parent_class)), (((GType) ((20) <<
(2))))))))
->finalize) {
296 (* G_OBJECT_CLASS (drw_break_window_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((drw_break_window_parent_class)), (((GType) ((20) <<
(2))))))))
->finalize) (object);
297 }
298}
299
300static void
301drw_break_window_dispose (GObject *object)
302{
303 DrwBreakWindow *window = DRW_BREAK_WINDOW (object)((((DrwBreakWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((drw_break_window_get_type ()))))))
;
304 DrwBreakWindowPrivate *priv;
305
306 priv = window->priv;
307
308 if (priv->timer) {
309 drw_timer_destroy (priv->timer);
310 priv->timer = NULL((void*)0);
311 }
312
313 if (priv->clock_timeout_id != 0) {
314 g_source_remove (priv->clock_timeout_id);
315 priv->clock_timeout_id = 0;
316 }
317
318 if (priv->postpone_timeout_id != 0) {
319 g_source_remove (priv->postpone_timeout_id);
320 priv->postpone_timeout_id = 0;
321 }
322
323 if (priv->postpone_sensitize_id != 0) {
324 g_source_remove (priv->postpone_sensitize_id);
325 }
326
327 if (G_OBJECT_CLASS (drw_break_window_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((drw_break_window_parent_class)), (((GType) ((20) <<
(2))))))))
->dispose) {
328 (* G_OBJECT_CLASS (drw_break_window_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((drw_break_window_parent_class)), (((GType) ((20) <<
(2))))))))
->dispose) (object);
329 }
330}
331
332GtkWidget *
333drw_break_window_new (void)
334{
335 GObject *object;
336
337 object = g_object_new (DRW_TYPE_BREAK_WINDOW(drw_break_window_get_type ()),
338 "type", GTK_WINDOW_POPUP,
339 "skip-taskbar-hint", TRUE(!(0)),
340 "skip-pager-hint", TRUE(!(0)),
341 "focus-on-map", TRUE(!(0)),
342 NULL((void*)0));
343
344 return GTK_WIDGET (object)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((gtk_widget_get_type ()))))))
;
345}
346
347static gboolean
348postpone_sensitize_cb (DrwBreakWindow *window)
349{
350 DrwBreakWindowPrivate *priv;
351
352 priv = window->priv;
353
354 gtk_widget_set_sensitive (priv->postpone_button, TRUE(!(0)));
355
356 priv->postpone_sensitize_id = 0;
357 return FALSE(0);
358}
359
360static gboolean
361clock_timeout_cb (DrwBreakWindow *window)
362{
363 DrwBreakWindowPrivate *priv;
364 gchar *txt;
365 gint minutes;
366 gint seconds;
367
368 g_return_val_if_fail (DRW_IS_BREAK_WINDOW (window), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((window)); GType __t = ((drw_break_window_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "DRW_IS_BREAK_WINDOW (window)"); return ((0));
} } while (0)
;
369
370 priv = window->priv;
371
372 seconds = 1 + priv->break_time - drw_timer_elapsed (priv->timer);
373 seconds = MAX (0, seconds)(((0)>(seconds))?(0):(seconds));
374
375 if (seconds == 0) {
376 /* Zero this out so the finalizer doesn't try to remove the
377 * source, which would be done in the timeout callback ==
378 * no-no.
379 */
380 priv->clock_timeout_id = 0;
381
382#ifdef HAVE_CANBERRA_GTK1
383 ca_context_play (ca_gtk_context_get (), 0, CA_PROP_EVENT_ID"event.id", "alarm-clock-elapsed", NULL((void*)0));
384#endif
385 g_signal_emit (window, signals[DONE], 0, NULL((void*)0));
386
387 return FALSE(0);
388 }
389
390 minutes = seconds / 60;
391 seconds -= minutes * 60;
392
393 txt = g_strdup_printf ("<span size=\"25000\" foreground=\"white\"><b>%d:%02d</b></span>",
394 minutes,
395 seconds);
396 gtk_label_set_markup (GTK_LABEL (priv->clock_label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->clock_label)), ((gtk_label_get_type ()))))))
, txt);
397 g_free (txt);
398
399 return TRUE(!(0));
400}
401
402static void
403postpone_entry_activate_cb (GtkWidget *entry,
404 DrwBreakWindow *window)
405{
406 const gchar *str;
407 gchar *phrase;
408 GSettings *settings = g_settings_new (TYPING_BREAK_SCHEMA"org.mate.typing-break");
409
410 str = gtk_entry_get_text (GTK_ENTRY (entry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((entry)), ((gtk_entry_get_type ()))))))
);
411
412 phrase = g_settings_get_string (settings, "unlock-phrase");
413 g_object_unref (settings);
414
415 if (!strcmp (str, phrase)) {
416 g_signal_emit (window, signals[POSTPONE], 0, NULL((void*)0));
417 g_free (phrase);
418 return;
419 }
420
421 g_free (phrase);
422 gtk_entry_set_text (GTK_ENTRY (entry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((entry)), ((gtk_entry_get_type ()))))))
, "");
423}
424
425static gboolean
426grab_on_window (GdkWindow *window,
427 guint32 activate_time)
428{
429 GdkDisplay *display;
430 GdkSeat *seat;
431
432 display = gdk_window_get_display (window);
433 seat = gdk_display_get_default_seat (display);
434
435 return (gdk_seat_grab (seat,
436 window,
437 GDK_SEAT_CAPABILITY_ALL,
438 TRUE(!(0)),
439 NULL((void*)0),
440 NULL((void*)0),
441 NULL((void*)0),
442 NULL((void*)0)) == GDK_GRAB_SUCCESS);
443}
444
445static gboolean
446postpone_cancel_cb (DrwBreakWindow *window)
447{
448 DrwBreakWindowPrivate *priv;
449
450 priv = window->priv;
451
452 gtk_entry_set_text (GTK_ENTRY (priv->postpone_entry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->postpone_entry)), ((gtk_entry_get_type ()))))))
, "");
453 gtk_widget_hide (priv->postpone_entry);
454
455 priv->postpone_timeout_id = 0;
456
457 return FALSE(0);
458}
459
460static gboolean
461postpone_entry_key_press_event_cb (GtkEntry *entry,
462 GdkEventKey *event,
463 DrwBreakWindow *window)
464{
465 DrwBreakWindowPrivate *priv;
466
467 priv = window->priv;
468
469 if (event->keyval == GDK_KEY_Escape0xff1b) {
470 if (priv->postpone_timeout_id) {
471 g_source_remove (priv->postpone_timeout_id);
472 }
473
474 postpone_cancel_cb (window);
475
476 return TRUE(!(0));
477 }
478
479 g_source_remove (priv->postpone_timeout_id);
480
481 priv->postpone_timeout_id = g_timeout_add_seconds (POSTPONE_CANCEL30, (GSourceFunc) postpone_cancel_cb, window);
482
483 return FALSE(0);
484}
485
486static void
487postpone_clicked_cb (GtkWidget *button,
488 GtkWidget *window)
489{
490 DrwBreakWindow *bw = DRW_BREAK_WINDOW (window)((((DrwBreakWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((drw_break_window_get_type ()))))))
;
491 DrwBreakWindowPrivate *priv = bw->priv;
492 gchar *phrase;
493
494 /* Disable the phrase for now. */
495 phrase = NULL((void*)0); /*g_settings_get_string (settings, "unlock-phrase");*/
496
497 if (!phrase || !phrase[0]) {
This statement is never executed
498 g_signal_emit (window, signals[POSTPONE], 0, NULL((void*)0));
499 return;
500 }
501
502 if (gtk_widget_get_visible (priv->postpone_entry)) {
503 gtk_widget_activate (priv->postpone_entry);
504 return;
505 }
506
507 gtk_widget_show (priv->postpone_entry);
508
509 priv->postpone_timeout_id = g_timeout_add_seconds (POSTPONE_CANCEL30, (GSourceFunc) postpone_cancel_cb, bw);
510
511 grab_on_window (gtk_widget_get_window (priv->postpone_entry), gtk_get_current_event_time ());
512
513 gtk_widget_grab_focus (priv->postpone_entry);
514
515 g_signal_connect (priv->postpone_entry,g_signal_connect_data ((priv->postpone_entry), ("activate"
), (((GCallback) (postpone_entry_activate_cb))), (bw), ((void
*)0), (GConnectFlags) 0)
516 "activate",g_signal_connect_data ((priv->postpone_entry), ("activate"
), (((GCallback) (postpone_entry_activate_cb))), (bw), ((void
*)0), (GConnectFlags) 0)
517 G_CALLBACK (postpone_entry_activate_cb),g_signal_connect_data ((priv->postpone_entry), ("activate"
), (((GCallback) (postpone_entry_activate_cb))), (bw), ((void
*)0), (GConnectFlags) 0)
518 bw)g_signal_connect_data ((priv->postpone_entry), ("activate"
), (((GCallback) (postpone_entry_activate_cb))), (bw), ((void
*)0), (GConnectFlags) 0)
;
519
520 g_signal_connect (priv->postpone_entry,g_signal_connect_data ((priv->postpone_entry), ("key_press_event"
), (((GCallback) (postpone_entry_key_press_event_cb))), (bw),
((void*)0), (GConnectFlags) 0)
521 "key_press_event",g_signal_connect_data ((priv->postpone_entry), ("key_press_event"
), (((GCallback) (postpone_entry_key_press_event_cb))), (bw),
((void*)0), (GConnectFlags) 0)
522 G_CALLBACK (postpone_entry_key_press_event_cb),g_signal_connect_data ((priv->postpone_entry), ("key_press_event"
), (((GCallback) (postpone_entry_key_press_event_cb))), (bw),
((void*)0), (GConnectFlags) 0)
523 bw)g_signal_connect_data ((priv->postpone_entry), ("key_press_event"
), (((GCallback) (postpone_entry_key_press_event_cb))), (bw),
((void*)0), (GConnectFlags) 0)
;
524}
525
526static void
527get_layout_location (GtkLabel *label,
528 gint *xp,
529 gint *yp)
530{
531 GtkWidget *widget;
532 GtkAllocation widget_allocation;
533 GtkRequisition widget_requisition;
534 gfloat xalign, yalign;
535 gint x, y;
536 gint xpad, ypad;
537 gint margin_start, margin_end, margin_top, margin_bottom;
538 gint scale;
539
540 widget = GTK_WIDGET (label)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_widget_get_type ()))))))
;
541
542 scale = gtk_widget_get_scale_factor (widget);
543 xalign = gtk_label_get_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
);
544 yalign = gtk_label_get_yalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
);
545 margin_start = gtk_widget_get_margin_start (widget);
546 margin_end = gtk_widget_get_margin_end (widget);
547 margin_top = gtk_widget_get_margin_top (widget);
548 margin_bottom = gtk_widget_get_margin_bottom (widget);
549
550 xpad = margin_start + margin_end;
551 ypad = margin_top + margin_bottom;
552
553 gtk_widget_get_allocation (widget, &widget_allocation);
554 gtk_widget_get_preferred_size (widget, &widget_requisition, NULL((void*)0));
555 widget_allocation.x /= scale;
556 widget_allocation.y /= scale;
557 widget_requisition.width /= scale;
558 widget_requisition.height /= scale;
559
560 if (gtk_widget_get_direction (widget) != GTK_TEXT_DIR_LTR)
561 xalign = 1.0 - xalign;
562
563 x = floor (widget_allocation.x + (int)xpad
564 + ((widget_allocation.width - widget_requisition.width - 1) * xalign)
565 + 0.5);
566
567 y = floor (widget_allocation.y + (int)ypad
568 + ((widget_allocation.height - widget_requisition.height - 1) * yalign)
569 + 0.5);
570
571 if (xp) {
572 *xp = x;
573 }
574
575 if (yp) {
576 *yp = y;
577 }
578}
579
580static gboolean
581label_draw_event_cb (GtkLabel *label,
582 cairo_t *cr,
583 gpointer user_data)
584{
585 gint x, y;
586 GtkWidget *widget;
587
588 get_layout_location (label, &x, &y);
589
590 widget = GTK_WIDGET (label)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_widget_get_type ()))))))
;
591
592 pango_cairo_show_layout (cr, gtk_label_get_layout (label));
593
594 gtk_render_layout (gtk_widget_get_style_context (widget),
595 cr,
596 (double)x, (double)y,
597 gtk_label_get_layout (label));
598
599 return TRUE(!(0));
600}
601
602static void
603label_size_allocate_cb (GtkLabel *label,
604 GdkRectangle *allocation,
605 gpointer user_data)
606{
607 allocation->width += 1;
608 allocation->height += 1;
609}
diff --git a/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-72d530.html b/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-72d530.html new file mode 100644 index 00000000..fe5861b4 --- /dev/null +++ b/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-72d530.html @@ -0,0 +1,1115 @@ + + + +theme-save.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:capplets/appearance/theme-save.c
Warning:line 72, column 4
Access of the heap area at index 3, while it holds only 3 'char' elements
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name theme-save.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/capplets/appearance -fcoverage-compilation-dir=/rootdir/capplets/appearance -resource-dir /usr/bin/../lib/clang/18 -D HAVE_CONFIG_H -I . -I ../.. -I /usr/include/marco-1 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/gio-unix-2.0 -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I ../../capplets/common -I /usr/include/udisks2 -I /usr/include/libgtop-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/libxml2 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/gio-unix-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/dconf -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I ../../ -D G_LOG_DOMAIN="appearance-properties" -I /usr/include/polkit-1 -I /usr/include/gio-unix-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I /usr/include/udisks2 -I /usr/include/libgtop-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/gio-unix-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/libxml2 -I /usr/include/harfbuzz -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/freetype2 -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/dconf -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libpng16 -D WITH_GZFILEOP -I /usr/include/sysprof-6 -I /usr/include/pixman-1 -D MATECC_DATA_DIR="/usr/local/share/mate-control-center" -D MATECC_PIXMAP_DIR="/usr/local/share/mate-control-center/pixmaps" -D WALLPAPER_DATADIR="/usr/local/share/mate-background-properties" -D BACKGROUND_DATADIR="/usr/local/share/backgrounds" -D MATE_DESKTOP_USE_UNSTABLE_API -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-06-07-044335-13427-1 -x c theme-save.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 * Copyright (C) 2007 The GNOME Foundation
3 * Written by Thomas Wood <thos@gnome.org>
4 * Jens Granseuer <jensgr@gmx.net>
5 * All Rights Reserved
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 */
21
22#include "appearance.h"
23
24#include <glib/gstdio.h>
25#include <glib/gi18n.h>
26#include <gio/gio.h>
27#include <string.h>
28
29#include "theme-save.h"
30#include "theme-util.h"
31#include "capplet-util.h"
32
33static GQuark error_quark;
34enum {
35 INVALID_THEME_NAME
36};
37
38/* taken from mate-desktop-item.c */
39static gchar *
40escape_string_and_dup (const gchar *s)
41{
42 gchar *return_value, *p;
43 const gchar *q;
44 int len = 0;
45
46 if (s == NULL((void*)0))
4
Assuming 's' is not equal to NULL
5
Taking false branch
47 return g_strdup("")g_strdup_inline ("");
48
49 q = s;
50 while (*q)
6
Loop condition is true. Entering loop body
9
Loop condition is true. Entering loop body
12
Loop condition is false. Execution continues on line 57
51 {
52 len++;
53 if (strchr ("\n\r\t\\", *q) != NULL((void*)0))
7
Assuming the condition is false
8
Taking false branch
10
Assuming the condition is false
11
Taking false branch
54 len++;
55 q++;
56 }
57 return_value = p = (gchar *) g_malloc (len + 1);
58 do
15
Loop condition is true. Execution continues on line 60
59 {
60 switch (*s)
13
Control jumps to 'case 92:' at line 74
16
Control jumps to 'case 13:' at line 70
61 {
62 case '\t':
63 *p++ = '\\';
64 *p++ = 't';
65 break;
66 case '\n':
67 *p++ = '\\';
68 *p++ = 'n';
69 break;
70 case '\r':
71 *p++ = '\\';
72 *p++ = 'r';
17
Access of the heap area at index 3, while it holds only 3 'char' elements
73 break;
74 case '\\':
75 *p++ = '\\';
76 *p++ = '\\';
77 break;
14
Execution continues on line 82
78 default:
79 *p++ = *s;
80 }
81 }
82 while (*s++);
83 return return_value;
84}
85
86static gboolean
87check_theme_name (const gchar *theme_name,
88 GError **error)
89{
90 if (theme_name == NULL((void*)0)) {
91 g_set_error (error,
92 error_quark,
93 INVALID_THEME_NAME,
94 _("Theme name must be present")gettext ("Theme name must be present"));
95 return FALSE(0);
96 }
97 return TRUE(!(0));
98}
99
100static gchar *
101str_remove_slash (const gchar *src)
102{
103 const gchar *i;
104 gchar *rtn;
105 gint len = 0;
106 i = src;
107
108 while (*i) {
109 if (*i != '/')
110 len++;
111 i++;
112 }
113
114 rtn = (gchar *) g_malloc (len + 1);
115 while (*src) {
116 if (*src != '/') {
117 *rtn = *src;
118 rtn++;
119 }
120 src++;
121 }
122 *rtn = '\0';
123 return rtn - len;
124}
125
126static gboolean
127setup_directory_structure (const gchar *theme_name,
128 GError **error)
129{
130 gchar *dir, *theme_name_dir;
131 gboolean retval = TRUE(!(0));
132
133 theme_name_dir = str_remove_slash (theme_name);
134
135 dir = g_build_filename (g_get_home_dir (), ".themes", NULL((void*)0));
136 if (!g_file_test (dir, G_FILE_TEST_EXISTS))
137 g_mkdirmkdir (dir, 0775);
138 g_free (dir);
139
140 dir = g_build_filename (g_get_home_dir (), ".themes", theme_name_dir, NULL((void*)0));
141 if (!g_file_test (dir, G_FILE_TEST_EXISTS))
142 g_mkdirmkdir (dir, 0775);
143 g_free (dir);
144
145 dir = g_build_filename (g_get_home_dir (), ".themes", theme_name_dir, "index.theme", NULL((void*)0));
146 g_free (theme_name_dir);
147
148 if (g_file_test (dir, G_FILE_TEST_EXISTS)) {
149 GtkDialog *dialog;
150 GtkWidget *button;
151 gint response;
152
153 dialog = (GtkDialog *) gtk_message_dialog_new (NULL((void*)0),
154 GTK_DIALOG_MODAL,
155 GTK_MESSAGE_QUESTION,
156 GTK_BUTTONS_CANCEL,
157 _("The theme already exists. Would you like to replace it?")gettext ("The theme already exists. Would you like to replace it?"
)
);
158 button = gtk_dialog_add_button (dialog, _("_Overwrite")gettext ("_Overwrite"), GTK_RESPONSE_ACCEPT);
159 gtk_button_set_image (GTK_BUTTON (button)((((GtkButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((button)), ((gtk_button_get_type ()))))))
,
160 gtk_image_new_from_icon_name ("document-save", GTK_ICON_SIZE_BUTTON));
161 response = gtk_dialog_run (dialog);
162 gtk_widget_destroy (GTK_WIDGET (dialog)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_widget_get_type ()))))))
);
163 retval = (response != GTK_RESPONSE_CANCEL);
164 }
165 g_free (dir);
166
167 return retval;
168}
169
170static gboolean
171write_theme_to_disk (MateThemeMetaInfo *theme_info,
172 const gchar *theme_name,
173 const gchar *theme_description,
174 gboolean save_background,
175 gboolean save_notification,
176 GError **error)
177{
178 gchar* dir;
179 gchar* theme_name_dir;
180 GFile* tmp_file;
181 GFile* target_file;
182 GOutputStream* output;
183
184 gchar* str;
185 gchar* current_background;
186
187 GSettings* settings;
188 const gchar* theme_header = ""
189 "[Desktop Entry]\n"
190 "Name=%s\n"
191 "Type=X-GNOME-Metatheme\n"
192 "Comment=%s\n"
193 "\n"
194 "[X-GNOME-Metatheme]\n"
195 "GtkTheme=%s\n"
196 "MetacityTheme=%s\n"
197 "IconTheme=%s\n";
198
199 theme_name_dir = str_remove_slash (theme_name);
200 dir = g_build_filename (g_get_home_dir (), ".themes", theme_name_dir, "index.theme~", NULL((void*)0));
201 g_free (theme_name_dir);
202
203 tmp_file = g_file_new_for_path (dir);
204 dir [strlen (dir) - 1] = '\000';
205 target_file = g_file_new_for_path (dir);
206 g_free (dir);
207
208 /* start making the theme file */
209 str = g_strdup_printf(theme_header, theme_name, theme_description, theme_info->gtk_theme_name, theme_info->marco_theme_name, theme_info->icon_theme_name);
210
211 output = G_OUTPUT_STREAM (g_file_replace (tmp_file, NULL, FALSE, G_FILE_CREATE_NONE, NULL, NULL))((((GOutputStream*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((g_file_replace (tmp_file, ((void*)0), (0), G_FILE_CREATE_NONE
, ((void*)0), ((void*)0)))), ((g_output_stream_get_type ())))
)))
;
212 g_output_stream_write (output, str, strlen (str), NULL((void*)0), NULL((void*)0));
213 g_free (str);
214
215 if (theme_info->gtk_color_scheme) {
216 gchar *a, *tmp;
217 tmp = g_strdup (theme_info->gtk_color_scheme)g_strdup_inline (theme_info->gtk_color_scheme);
218 for (a = tmp; *a != '\0'; a++)
219 if (*a == '\n')
220 *a = ',';
221 str = g_strdup_printf ("GtkColorScheme=%s\n", tmp);
222 g_output_stream_write (output, str, strlen (str), NULL((void*)0), NULL((void*)0));
223
224 g_free (str);
225 g_free (tmp);
226 }
227
228 if (theme_info->cursor_theme_name) {
229 str = g_strdup_printf ("CursorTheme=%s\n"
230 "CursorSize=%i\n",
231 theme_info->cursor_theme_name,
232 theme_info->cursor_size);
233 g_output_stream_write (output, str, strlen (str), NULL((void*)0), NULL((void*)0));
234 g_free (str);
235 }
236
237 if (theme_info->notification_theme_name && save_notification) {
238 str = g_strdup_printf ("NotificationTheme=%s\n", theme_info->notification_theme_name);
239 g_output_stream_write (output, str, strlen (str), NULL((void*)0), NULL((void*)0));
240 g_free (str);
241 }
242
243 if (save_background) {
244 settings = g_settings_new (WP_SCHEMA"org.mate.background");
245 current_background = g_settings_get_string (settings, WP_FILE_KEY"picture-filename");
246
247 if (current_background != NULL((void*)0)) {
248 str = g_strdup_printf ("BackgroundImage=%s\n", current_background);
249
250 g_output_stream_write (output, str, strlen (str), NULL((void*)0), NULL((void*)0));
251
252 g_free (current_background);
253 g_free (str);
254 }
255 g_object_unref (settings);
256 }
257
258 g_file_move (tmp_file, target_file, G_FILE_COPY_OVERWRITE, NULL((void*)0), NULL((void*)0), NULL((void*)0), NULL((void*)0));
259 g_output_stream_close (output, NULL((void*)0), NULL((void*)0));
260
261 g_object_unref (tmp_file);
262 g_object_unref (target_file);
263
264 return TRUE(!(0));
265}
266
267static gboolean
268save_theme_to_disk (MateThemeMetaInfo *theme_info,
269 const gchar *theme_name,
270 const gchar *theme_description,
271 gboolean save_background,
272 gboolean save_notification,
273 GError **error)
274{
275 if (!check_theme_name (theme_name, error))
276 return FALSE(0);
277
278 if (!setup_directory_structure (theme_name, error))
279 return FALSE(0);
280
281 if (!write_theme_to_disk (theme_info, theme_name, theme_description, save_background, save_notification, error))
282 return FALSE(0);
283
284 return TRUE(!(0));
285}
286
287static void
288save_dialog_response (GtkWidget *save_dialog,
289 gint response_id,
290 AppearanceData *data)
291{
292 if (response_id == GTK_RESPONSE_OK) {
1
Assuming 'response_id' is equal to GTK_RESPONSE_OK
2
Taking true branch
293 GtkWidget *entry;
294 GtkWidget *text_view;
295 GtkTextBuffer *buffer;
296 GtkTextIter start_iter;
297 GtkTextIter end_iter;
298 gchar *buffer_text;
299 MateThemeMetaInfo *theme_info;
300 gchar *theme_description = NULL((void*)0);
301 gchar *theme_name = NULL((void*)0);
302 gboolean save_background;
303 gboolean save_notification;
304 GError *error = NULL((void*)0);
305
306 entry = appearance_capplet_get_widget (data, "save_dialog_entry")(GtkWidget*) gtk_builder_get_object(data->ui, "save_dialog_entry"
)
;
307 theme_name = escape_string_and_dup (gtk_entry_get_text (GTK_ENTRY (entry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((entry)), ((gtk_entry_get_type ()))))))
))
;
3
Calling 'escape_string_and_dup'
308
309 text_view = appearance_capplet_get_widget (data, "save_dialog_textview")(GtkWidget*) gtk_builder_get_object(data->ui, "save_dialog_textview"
)
;
310 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view)((((GtkTextView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((text_view)), ((gtk_text_view_get_type ()))))))
);
311 gtk_text_buffer_get_start_iter (buffer, &start_iter);
312 gtk_text_buffer_get_end_iter (buffer, &end_iter);
313 buffer_text = gtk_text_buffer_get_text (buffer, &start_iter, &end_iter, FALSE(0));
314 theme_description = escape_string_and_dup (buffer_text);
315 g_free (buffer_text);
316 theme_info = (MateThemeMetaInfo *) g_object_get_data (G_OBJECT (save_dialog)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((save_dialog)), (((GType) ((20) << (2))))))))
, "meta-theme-info");
317 save_background = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (((((GtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (((GtkWidget*) gtk_builder_get_object(data->ui, "save_background_checkbutton"
))), ((gtk_toggle_button_get_type ()))))))
318 appearance_capplet_get_widget (data, "save_background_checkbutton"))((((GtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (((GtkWidget*) gtk_builder_get_object(data->ui, "save_background_checkbutton"
))), ((gtk_toggle_button_get_type ()))))))
);
319 save_notification = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (((((GtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (((GtkWidget*) gtk_builder_get_object(data->ui, "save_notification_checkbutton"
))), ((gtk_toggle_button_get_type ()))))))
320 appearance_capplet_get_widget (data, "save_notification_checkbutton"))((((GtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (((GtkWidget*) gtk_builder_get_object(data->ui, "save_notification_checkbutton"
))), ((gtk_toggle_button_get_type ()))))))
);
321
322 if (save_theme_to_disk (theme_info, theme_name, theme_description, save_background, save_notification, &error)) {
323 /* remove the custom theme */
324 GtkTreeIter iter;
325
326 if (theme_find_in_model (GTK_TREE_MODEL (data->theme_store)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data->theme_store)), ((gtk_tree_model_get_type ()))))
))
, "__custom__", &iter))
327 gtk_list_store_remove (data->theme_store, &iter);
328 }
329
330 g_free (theme_name);
331 g_free (theme_description);
332 g_clear_error (&error);
333 }
334
335 gtk_widget_hide (save_dialog);
336}
337
338static void
339entry_text_changed (GtkEditable *editable,
340 AppearanceData *data)
341{
342 const gchar *text;
343 GtkWidget *button;
344
345 text = gtk_entry_get_text (GTK_ENTRY (editable)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((editable)), ((gtk_entry_get_type ()))))))
);
346 button = appearance_capplet_get_widget (data, "save_dialog_save_button")(GtkWidget*) gtk_builder_get_object(data->ui, "save_dialog_save_button"
)
;
347
348 gtk_widget_set_sensitive (button, text != NULL((void*)0) && text[0] != '\000');
349}
350
351void
352theme_save_dialog_run (MateThemeMetaInfo *theme_info,
353 AppearanceData *data)
354{
355 GtkWidget *entry;
356 GtkWidget *text_view;
357 GtkTextBuffer *text_buffer;
358
359 entry = appearance_capplet_get_widget (data, "save_dialog_entry")(GtkWidget*) gtk_builder_get_object(data->ui, "save_dialog_entry"
)
;
360 text_view = appearance_capplet_get_widget (data, "save_dialog_textview")(GtkWidget*) gtk_builder_get_object(data->ui, "save_dialog_textview"
)
;
361
362 if (data->theme_save_dialog == NULL((void*)0)) {
363 data->theme_save_dialog = appearance_capplet_get_widget (data, "theme_save_dialog")(GtkWidget*) gtk_builder_get_object(data->ui, "theme_save_dialog"
)
;
364
365 g_signal_connect (data->theme_save_dialog, "response", (GCallback) save_dialog_response, data)g_signal_connect_data ((data->theme_save_dialog), ("response"
), ((GCallback) save_dialog_response), (data), ((void*)0), (GConnectFlags
) 0)
;
366 g_signal_connect (data->theme_save_dialog, "delete-event", (GCallback) gtk_true, NULL)g_signal_connect_data ((data->theme_save_dialog), ("delete-event"
), ((GCallback) gtk_true), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
;
367 g_signal_connect (entry, "changed", (GCallback) entry_text_changed, data)g_signal_connect_data ((entry), ("changed"), ((GCallback) entry_text_changed
), (data), ((void*)0), (GConnectFlags) 0)
;
368
369 error_quark = g_quark_from_string ("mate-theme-save");
370 gtk_widget_set_size_request (text_view, 300, 100);
371 }
372
373 gtk_entry_set_text (GTK_ENTRY (entry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((entry)), ((gtk_entry_get_type ()))))))
, "");
374 entry_text_changed (GTK_EDITABLE (entry)((((GtkEditable*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((entry)), ((gtk_editable_get_type ()))))))
, data);
375 gtk_widget_grab_focus (entry);
376
377 text_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view)((((GtkTextView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((text_view)), ((gtk_text_view_get_type ()))))))
);
378 gtk_text_buffer_set_text (text_buffer, "", 0);
379 g_object_set_data (G_OBJECT (data->theme_save_dialog)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data->theme_save_dialog)), (((GType) ((20) << (
2))))))))
, "meta-theme-info", theme_info);
380 gtk_window_set_transient_for (GTK_WINDOW (data->theme_save_dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data->theme_save_dialog)), ((gtk_window_get_type ()))
))))
,
381 GET_WINDOW ("appearance_window")(((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (data->ui, ("appearance_window"
)))), ((gtk_window_get_type ())))))))
);
382 gtk_widget_show (data->theme_save_dialog);
383}
diff --git a/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-77ae30.html b/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-77ae30.html new file mode 100644 index 00000000..453ce4d4 --- /dev/null +++ b/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-77ae30.html @@ -0,0 +1,1455 @@ + + + +mate-system-info.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:capplets/system-info/mate-system-info.c
Warning:line 371, column 12
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name mate-system-info.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/capplets/system-info -fcoverage-compilation-dir=/rootdir/capplets/system-info -resource-dir /usr/bin/../lib/clang/18 -D HAVE_CONFIG_H -I . -I ../.. -I ../../capplets/common -I /usr/include/udisks2 -I /usr/include/libgtop-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/libxml2 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/gio-unix-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/dconf -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I ../../ -D G_LOG_DOMAIN="system-info-properties" -I /usr/include/polkit-1 -I /usr/include/gio-unix-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -D MATECC_DATA_DIR="/usr/local/share/mate-control-center" -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-06-07-044335-13427-1 -x c mate-system-info.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
2 *
3 * Copyright (C) 2023 MATE Developers
4 * Copyright (C) 2019 Purism SPC
5 * Copyright (C) 2017 Mohammed Sadiq <sadiq@sadiqpk.org>
6 * Copyright (C) 2010 Red Hat, Inc
7 * Copyright (C) 2008 William Jon McCann <jmccann@redhat.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, see <http://www.gnu.org/licenses/>.
21 *
22 */
23#include <gtk/gtk.h>
24#include <glib.h>
25#include <glibtop/fsusage.h>
26#include <glibtop/mountlist.h>
27#include <glibtop/mem.h>
28#include <glibtop/sysinfo.h>
29#include <udisks/udisks.h>
30#include <sys/utsname.h>
31
32#ifdef GDK_WINDOWING_WAYLAND
33#include <gdk/gdkwayland.h>
34#endif
35#ifdef GDK_WINDOWING_X11
36#include <gdk/gdkx.h>
37#endif
38
39#include "info-cleanup.h"
40#include "mate-system-info.h"
41#include "mate-system-info-resources.h"
42
43struct _MateSystemInfo
44{
45 GtkDialog parent_instance;
46 GtkWidget *logo_image;
47 GtkWidget *hostname_row;
48 GtkListBox *hardware_box;
49 GtkWidget *hardware_model_row;
50 GtkWidget *memory_row;
51 GtkWidget *processor_row;
52 GtkWidget *graphics_row;
53 GtkWidget *disk_row;
54 GtkListBox *os_box;
55 GtkWidget *kernel_row;
56 GtkWidget *virtualization_row;
57 GtkWidget *windowing_system_row;
58 GtkWidget *mate_version_row;
59 GtkWidget *os_name_row;
60 GtkWidget *os_type_row;
61};
62
63G_DEFINE_TYPE (MateSystemInfo, mate_system_info, GTK_TYPE_DIALOG)static void mate_system_info_init (MateSystemInfo *self); static
void mate_system_info_class_init (MateSystemInfoClass *klass
); static GType mate_system_info_get_type_once (void); static
gpointer mate_system_info_parent_class = ((void*)0); static gint
MateSystemInfo_private_offset; static void mate_system_info_class_intern_init
(gpointer klass) { mate_system_info_parent_class = g_type_class_peek_parent
(klass); if (MateSystemInfo_private_offset != 0) g_type_class_adjust_private_offset
(klass, &MateSystemInfo_private_offset); mate_system_info_class_init
((MateSystemInfoClass*) klass); } __attribute__ ((__unused__
)) static inline gpointer mate_system_info_get_instance_private
(MateSystemInfo *self) { return (((gpointer) ((guint8*) (self
) + (glong) (MateSystemInfo_private_offset)))); } GType mate_system_info_get_type
(void) { static GType static_g_define_type_id = 0; if ((__extension__
({ _Static_assert (sizeof *(&static_g_define_type_id) ==
sizeof (gpointer), "Expression evaluates to false"); (void) (
0 ? (gpointer) * (&static_g_define_type_id) : ((void*)0))
; (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter_pointer (
&static_g_define_type_id)); })) ) { GType g_define_type_id
= mate_system_info_get_type_once (); (__extension__ ({ _Static_assert
(sizeof *(&static_g_define_type_id) == sizeof (gpointer)
, "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id
) = (g_define_type_id)) : (void) 0; g_once_init_leave_pointer
((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id
)); })) ; } return static_g_define_type_id; } __attribute__ (
(__noinline__)) static GType mate_system_info_get_type_once (
void) { GType g_define_type_id = g_type_register_static_simple
((gtk_dialog_get_type ()), g_intern_static_string ("MateSystemInfo"
), sizeof (MateSystemInfoClass), (GClassInitFunc)(void (*)(void
)) mate_system_info_class_intern_init, sizeof (MateSystemInfo
), (GInstanceInitFunc)(void (*)(void)) mate_system_info_init,
(GTypeFlags) 0); { {{};} } return g_define_type_id; }
64
65static void
66set_lable_style (GtkWidget *lable,
67 const char *color,
68 int font_szie,
69 const char *text,
70 gboolean blod)
71{
72 g_autofree__attribute__((cleanup(g_autoptr_cleanup_generic_gfree))) gchar *lable_text = NULL((void*)0);
73
74 if (color == NULL((void*)0))
75 {
76 lable_text = g_strdup_printf ("<span weight=\'light\'font_desc=\'%d\'><b>%s</b></span>", font_szie, text);
77 }
78 else
79 {
80 if(blod)
81 {
82 lable_text = g_strdup_printf ("<span foreground=\'%s\'weight=\'light\'font_desc=\'%d\'><b>%s</b></span>",
83 color,
84 font_szie,
85 text);
86 }
87 else
88 {
89 lable_text = g_strdup_printf ("<span foreground=\'%s\'weight=\'light\'font_desc=\'%d\'>%s</span>",
90 color,
91 font_szie,
92 text);
93 }
94 }
95
96 gtk_label_set_markup (GTK_LABEL(lable)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((lable)), ((gtk_label_get_type ()))))))
, lable_text);
97}
98
99static void
100mate_system_info_row_fill (GtkWidget *row,
101 const char *labelname,
102 gboolean is_separator)
103{
104 GtkWidget *vbox;
105 GtkWidget *box;
106 GtkWidget *label;
107 GtkWidget *separator;
108
109 vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
110 box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
111 gtk_box_set_spacing (GTK_BOX (box)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((box)), ((gtk_box_get_type ()))))))
, 12);
112 g_object_set (box, "margin", 12, NULL((void*)0));
113 gtk_box_pack_start (GTK_BOX (vbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((vbox)), ((gtk_box_get_type ()))))))
, box, FALSE(0), FALSE(0), 3);
114
115 label = gtk_label_new (NULL((void*)0));
116 set_lable_style (label, NULL((void*)0), 12, labelname, TRUE(!(0)));
117 gtk_label_set_ellipsize (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
, PANGO_ELLIPSIZE_END);
118 gtk_box_pack_start (GTK_BOX (box)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((box)), ((gtk_box_get_type ()))))))
, label, FALSE(0), FALSE(0), 6);
119
120 label = gtk_label_new (NULL((void*)0));
121 gtk_box_pack_end (GTK_BOX (box)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((box)), ((gtk_box_get_type ()))))))
, label, FALSE(0), FALSE(0), 6);
122 g_object_set_data (G_OBJECT (row)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((row)), (((GType) ((20) << (2))))))))
, "labelvalue", label);
123
124 separator = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
125 if (is_separator)
126 gtk_box_pack_start (GTK_BOX (vbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((vbox)), ((gtk_box_get_type ()))))))
, separator, FALSE(0), FALSE(0), 0);
127
128 gtk_container_add (GTK_CONTAINER (row)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((row)), ((gtk_container_get_type ()))))))
, vbox);
129}
130
131static void
132mate_system_info_set_row (MateSystemInfo *info)
133{
134 mate_system_info_row_fill (info->hostname_row, _("Device Name")gettext ("Device Name"), FALSE(0));
135# ifdef HAVE_SYSTEMD
136 mate_system_info_row_fill (info->hardware_model_row, _("Hardware Model")gettext ("Hardware Model"), TRUE(!(0)));
137 mate_system_info_row_fill (info->virtualization_row, _("Virtualization")gettext ("Virtualization"), TRUE(!(0)));
138# endif
139 mate_system_info_row_fill (info->memory_row, _("Memory")gettext ("Memory"), TRUE(!(0)));
140 mate_system_info_row_fill (info->processor_row, _("Processor")gettext ("Processor"), TRUE(!(0)));
141 mate_system_info_row_fill (info->graphics_row, _("Graphics")gettext ("Graphics"), TRUE(!(0)));
142 mate_system_info_row_fill (info->disk_row, _("Disk Capacity")gettext ("Disk Capacity"), FALSE(0));
143 mate_system_info_row_fill (info->kernel_row, _("Kernel Version")gettext ("Kernel Version"), FALSE(0));
144 mate_system_info_row_fill (info->windowing_system_row, _("Windowing System")gettext ("Windowing System"), TRUE(!(0)));
145 mate_system_info_row_fill (info->mate_version_row, _("MATE Version")gettext ("MATE Version"), TRUE(!(0)));
146 mate_system_info_row_fill (info->os_name_row, _("OS Name")gettext ("OS Name"), TRUE(!(0)));
147 mate_system_info_row_fill (info->os_type_row, _("OS Type")gettext ("OS Type"), TRUE(!(0)));
148
149 gtk_widget_show (info->logo_image);
150 gtk_widget_show_all (info->hostname_row);
151 gtk_widget_show_all (info->memory_row);
152 gtk_widget_show_all (info->processor_row);
153 gtk_widget_show_all (info->graphics_row);
154 gtk_widget_show_all (info->disk_row);
155 gtk_widget_show_all (info->kernel_row);
156 gtk_widget_show_all (info->windowing_system_row);
157 gtk_widget_show_all (info->mate_version_row);
158 gtk_widget_show_all (info->os_type_row);
159 gtk_widget_show_all (info->os_name_row);
160}
161
162static char *
163get_system_hostname (void)
164{
165# ifdef HAVE_SYSTEMD
166 GDBusProxy *hostnamed_proxy;
167 g_autoptr(GVariant)__attribute__((cleanup(glib_autoptr_cleanup_GVariant))) GVariant_autoptr variant = NULL((void*)0);
168 g_autoptr(GError)__attribute__((cleanup(glib_autoptr_cleanup_GError))) GError_autoptr error = NULL((void*)0);
169
170 hostnamed_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
171 G_DBUS_PROXY_FLAGS_NONE,
172 NULL((void*)0),
173 "org.freedesktop.hostname1",
174 "/org/freedesktop/hostname1",
175 "org.freedesktop.hostname1",
176 NULL((void*)0),
177 &error);
178
179 if (!hostnamed_proxy)
180 return g_strdup ("")g_strdup_inline ("");
181
182 variant = g_dbus_proxy_get_cached_property (hostnamed_proxy, "Hostname");
183 if (!variant)
184 {
185 g_autoptr(GError)__attribute__((cleanup(glib_autoptr_cleanup_GError))) GError_autoptr error = NULL((void*)0);
186 g_autoptr(GVariant)__attribute__((cleanup(glib_autoptr_cleanup_GVariant))) GVariant_autoptr inner = NULL((void*)0);
187
188 /* Work around systemd-hostname not sending us back
189 * the property value when changing values */
190 variant = g_dbus_proxy_call_sync (hostnamed_proxy,
191 "org.freedesktop.DBus.Properties.Get",
192 g_variant_new ("(ss)", "org.freedesktop.hostname1", "Hostname"),
193 G_DBUS_CALL_FLAGS_NONE,
194 -1,
195 NULL((void*)0),
196 &error);
197 if (variant == NULL((void*)0))
198 {
199 g_warning ("Failed to get property '%s': %s", "Hostname", error->message);
200 g_object_unref (hostnamed_proxy);
201 return NULL((void*)0);
202 }
203
204 g_variant_get (variant, "(v)", &inner);
205 g_object_unref (hostnamed_proxy);
206 return g_variant_dup_string (inner, NULL((void*)0));
207 }
208 else
209 {
210 g_object_unref (hostnamed_proxy);
211 return g_variant_dup_string (variant, NULL((void*)0));
212 }
213# else
214 return g_strdup (g_get_host_name ())g_strdup_inline (g_get_host_name ());
215# endif
216}
217
218# ifdef HAVE_SYSTEMD
219static char *
220get_hardware_model (void)
221{
222 g_autoptr(GDBusProxy)__attribute__((cleanup(glib_autoptr_cleanup_GDBusProxy))) GDBusProxy_autoptr hostnamed_proxy = NULL((void*)0);
223 g_autoptr(GVariant)__attribute__((cleanup(glib_autoptr_cleanup_GVariant))) GVariant_autoptr vendor_variant = NULL((void*)0);
224 g_autoptr(GVariant)__attribute__((cleanup(glib_autoptr_cleanup_GVariant))) GVariant_autoptr model_variant = NULL((void*)0);
225 const char *vendor_string, *model_string;
226 g_autoptr(GError)__attribute__((cleanup(glib_autoptr_cleanup_GError))) GError_autoptr error = NULL((void*)0);
227
228 hostnamed_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
229 G_DBUS_PROXY_FLAGS_NONE,
230 NULL((void*)0),
231 "org.freedesktop.hostname1",
232 "/org/freedesktop/hostname1",
233 "org.freedesktop.hostname1",
234 NULL((void*)0),
235 &error);
236 if (hostnamed_proxy == NULL((void*)0))
237 {
238 g_debug ("Couldn't get hostnamed to start, bailing: %s", error->message);
239 return NULL((void*)0);
240 }
241
242 vendor_variant = g_dbus_proxy_get_cached_property (hostnamed_proxy, "HardwareVendor");
243 if (!vendor_variant)
244 {
245 g_debug ("Unable to retrieve org.freedesktop.hostname1.HardwareVendor property");
246 return NULL((void*)0);
247 }
248
249 model_variant = g_dbus_proxy_get_cached_property (hostnamed_proxy, "HardwareModel");
250 if (!model_variant)
251 {
252 g_debug ("Unable to retrieve org.freedesktop.hostname1.HardwareModel property");
253 return NULL((void*)0);
254 }
255
256 vendor_string = g_variant_get_string (vendor_variant, NULL((void*)0)),
257 model_string = g_variant_get_string (model_variant, NULL((void*)0));
258
259 if (vendor_string && g_strcmp0 (vendor_string, "") != 0)
260 {
261 gchar *vendor_model = NULL((void*)0);
262
263 vendor_model = g_strdup_printf ("%s %s", vendor_string, model_string);
264 return vendor_model;
265 }
266
267 return NULL((void*)0);
268}
269# endif
270
271static char *
272get_cpu_info (void)
273{
274 g_autoptr(GHashTable)__attribute__((cleanup(glib_autoptr_cleanup_GHashTable))) GHashTable_autoptr counts = NULL((void*)0);
275 const glibtop_sysinfo *info;
276 g_autoptr(GString)__attribute__((cleanup(glib_autoptr_cleanup_GString))) GString_autoptr cpu = NULL((void*)0);
277 GHashTableIter iter;
278 gpointer key, value;
279 int i;
280 int j;
281
282 counts = g_hash_table_new (g_str_hash, g_str_equal);
283 info = glibtop_get_sysinfo ();
284
285 /* count duplicates */
286 for (i = 0; i != info->ncpu; ++i)
287 {
288 const char * const keys[] = { "model name", "cpu", "Processor" ,"Model Name"};
289 char *model;
290 int *count;
291 model = NULL((void*)0);
292
293 for (j = 0; model == NULL((void*)0) && j != G_N_ELEMENTS (keys)(sizeof (keys) / sizeof ((keys)[0])); ++j)
294 {
295 model = g_hash_table_lookup (info->cpuinfo[i].values,
296 keys[j]);
297 }
298
299 if (model == NULL((void*)0))
300 continue;
301 count = g_hash_table_lookup (counts, model);
302 if (count == NULL((void*)0))
303 g_hash_table_insert (counts, model, GINT_TO_POINTER (1)((gpointer) (glong) (1)));
304 else
305 g_hash_table_replace (counts, model, GINT_TO_POINTER (GPOINTER_TO_INT (count) + 1)((gpointer) (glong) (((gint) (glong) (count)) + 1)));
306 }
307
308 cpu = g_string_new (NULL((void*)0));
309 g_hash_table_iter_init (&iter, counts);
310 while (g_hash_table_iter_next (&iter, &key, &value))
311 {
312 g_autofree__attribute__((cleanup(g_autoptr_cleanup_generic_gfree))) char *cleanedup = NULL((void*)0);
313 int count;
314
315 count = GPOINTER_TO_INT (value)((gint) (glong) (value));
316 cleanedup = info_cleanup ((const char *) key);
317 if (count > 1)
318 g_string_append_printf (cpu, "%s \303\227 %d ", cleanedup, count);
319 else
320 g_string_append_printf (cpu, "%s ", cleanedup);
321 }
322
323 return g_strdup (cpu->str)g_strdup_inline (cpu->str);
324}
325
326static char *
327get_renderer_from_session (void)
328{
329 g_autoptr(GDBusProxy)__attribute__((cleanup(glib_autoptr_cleanup_GDBusProxy))) GDBusProxy_autoptr session_proxy = NULL((void*)0);
330 g_autoptr(GVariant)__attribute__((cleanup(glib_autoptr_cleanup_GVariant))) GVariant_autoptr renderer_variant = NULL((void*)0);
331 char *renderer;
332 g_autoptr(GError)__attribute__((cleanup(glib_autoptr_cleanup_GError))) GError_autoptr error = NULL((void*)0);
333
334 session_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
335 G_DBUS_PROXY_FLAGS_NONE,
336 NULL((void*)0),
337 "org.gnome.SessionManager",
338 "/org/gnome/SessionManager",
339 "org.gnome.SessionManager",
340 NULL((void*)0), &error);
341 if (error != NULL((void*)0))
342 {
343 g_warning ("Unable to connect to create a proxy for org.gnome.SessionManager: %s",
344 error->message);
345 return NULL((void*)0);
346 }
347
348 renderer_variant = g_dbus_proxy_get_cached_property (session_proxy, "Renderer");
349
350 if (!renderer_variant)
351 {
352 g_warning ("Unable to retrieve org.gnome.SessionManager.Renderer property");
353 return NULL((void*)0);
354 }
355
356 renderer = info_cleanup (g_variant_get_string (renderer_variant, NULL((void*)0)));
357
358 return renderer;
359}
360
361static gchar *
362get_graphics_hardware_string (void)
363{
364 g_autofree__attribute__((cleanup(g_autoptr_cleanup_generic_gfree))) char *discrete_renderer = NULL((void*)0);
365 g_autofree__attribute__((cleanup(g_autoptr_cleanup_generic_gfree))) char *renderer = NULL((void*)0);
366
367 renderer = get_renderer_from_session ();
368 if (!renderer)
369 return g_strdup ("Unknown")g_strdup_inline ("Unknown");
370
371 return g_strdup (renderer)g_strdup_inline (renderer);
This statement is never executed
372}
373
374static char *
375get_primary_disk_size (void)
376{
377 g_autoptr(UDisksClient)__attribute__((cleanup(glib_autoptr_cleanup_UDisksClient))) UDisksClient_autoptr client = NULL((void*)0);
378 GDBusObjectManager *manager;
379 g_autolist(GDBusObject)__attribute__((cleanup(glib_listautoptr_cleanup_GDBusObject))
) GDBusObject_listautoptr
objects = NULL((void*)0);
380 GList *l;
381 gchar *size;
382 guint64 total_size;
383 g_autoptr(GError)__attribute__((cleanup(glib_autoptr_cleanup_GError))) GError_autoptr error = NULL((void*)0);
384
385 total_size = 0;
386
387 client = udisks_client_new_sync (NULL((void*)0), &error);
388 if (client == NULL((void*)0))
389 {
390 g_warning ("Unable to get UDisks client: %s. Disk information will not be available.",
391 error->message);
392 return g_strdup ("Unknown")g_strdup_inline ("Unknown");
393 }
394
395 manager = udisks_client_get_object_manager (client);
396 objects = g_dbus_object_manager_get_objects (manager);
397
398 for (l = objects; l != NULL((void*)0); l = l->next)
399 {
400 UDisksDrive *drive;
401 drive = udisks_object_peek_drive (UDISKS_OBJECT (l->data)((((UDisksObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((l->data)), ((udisks_object_get_type ()))))))
);
402
403 /* Skip removable devices */
404 if (drive == NULL((void*)0) ||
405 udisks_drive_get_removable (drive) ||
406 udisks_drive_get_ejectable (drive))
407 {
408 continue;
409 }
410
411 total_size += udisks_drive_get_size (drive);
412 }
413 if (total_size > 0)
414 {
415 size = g_format_size (total_size);
416 }
417 else
418 {
419 size = g_strdup ("Unknown")g_strdup_inline ("Unknown");
420 }
421
422 return size;
423}
424
425static char *
426get_os_name (void)
427{
428 g_autofree__attribute__((cleanup(g_autoptr_cleanup_generic_gfree))) gchar *name = NULL((void*)0);
429 g_autofree__attribute__((cleanup(g_autoptr_cleanup_generic_gfree))) gchar *version_id = NULL((void*)0);
430 g_autofree__attribute__((cleanup(g_autoptr_cleanup_generic_gfree))) gchar *pretty_name = NULL((void*)0);
431 g_autofree__attribute__((cleanup(g_autoptr_cleanup_generic_gfree))) gchar *name_version = NULL((void*)0);
432 gchar *result = NULL((void*)0);
433
434 name = g_get_os_info (G_OS_INFO_KEY_NAME"NAME");
435 version_id = g_get_os_info (G_OS_INFO_KEY_VERSION_ID"VERSION_ID");
436 pretty_name = g_get_os_info (G_OS_INFO_KEY_PRETTY_NAME"PRETTY_NAME");
437
438 if (pretty_name)
439 name_version = g_strdup (pretty_name)g_strdup_inline (pretty_name);
440 else if (name && version_id)
441 name_version = g_strdup_printf ("%s %s", name, version_id);
442 else
443 name_version = g_strdup (("Unknown"))g_strdup_inline (("Unknown"));
444
445 result = g_strdup (name_version)g_strdup_inline (name_version);
446
447 return result;
448}
449
450static char *
451get_os_type (void)
452{
453 if (GLIB_SIZEOF_VOID_P8 == 8)
454 /* translators: This is the type of architecture for the OS */
455 return g_strdup_printf ("64-bit");
456 else
457 /* translators: This is the type of architecture for the OS */
458 return g_strdup_printf ("32-bit");
459}
460
461static char *
462get_windowing_system (void)
463{
464 GdkDisplay *display;
465
466 display = gdk_display_get_default ();
467
468#if defined(GDK_WINDOWING_X11)
469 if (GDK_IS_X11_DISPLAY (display)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(display)); GType __t = ((gdk_x11_display_get_type())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
)
470 return g_strdup ("X11")g_strdup_inline ("X11");
471#endif /* GDK_WINDOWING_X11 */
472#if defined(GDK_WINDOWING_WAYLAND)
473 if (GDK_IS_WAYLAND_DISPLAY (display)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(display)); GType __t = ((gdk_wayland_display_get_type())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
)
474 return g_strdup ("Wayland")g_strdup_inline ("Wayland");
475#endif /* GDK_WINDOWING_WAYLAND */
476 return g_strdup (C_("Windowing system (Wayland, X11, or Unknown)", "Unknown"))g_strdup_inline (g_dpgettext (((void*)0), "Windowing system (Wayland, X11, or Unknown)"
"\004" "Unknown", strlen ("Windowing system (Wayland, X11, or Unknown)"
) + 1))
;
477}
478
479static char *
480get_kernel_vesrion (void)
481{
482 struct utsname un;
483
484 if (uname (&un) < 0)
485 return NULL((void*)0);
486
487 return g_strdup_printf ("%s %s", un.sysname, un.release);
488}
489
490# ifdef HAVE_SYSTEMD
491static struct {
492 const char *id;
493 const char *display;
494} const virt_tech[] = {
495 { "kvm", "KVM" },
496 { "qemu", "QEmu" },
497 { "vmware", "VMware" },
498 { "microsoft", "Microsoft" },
499 { "oracle", "Oracle" },
500 { "xen", "Xen" },
501 { "bochs", "Bochs" },
502 { "chroot", "chroot" },
503 { "openvz", "OpenVZ" },
504 { "lxc", "LXC" },
505 { "lxc-libvirt", "LXC (libvirt)" },
506 { "systemd-nspawn", "systemd (nspawn)" }
507};
508
509static char *
510get_virtualization_label (const char *virt)
511{
512 const char *display_name;
513 guint i;
514
515 if (virt == NULL((void*)0) || *virt == '\0')
516 {
517 return NULL((void*)0);
518 }
519
520 display_name = NULL((void*)0);
521 for (i = 0; i < G_N_ELEMENTS (virt_tech)(sizeof (virt_tech) / sizeof ((virt_tech)[0])); i++)
522 {
523 if (g_str_equal (virt_tech[i].id, virt)(strcmp ((const char *) (virt_tech[i].id), (const char *) (virt
)) == 0)
)
524 {
525 display_name = virt_tech[i].display;
526 break;
527 }
528 }
529
530 return display_name ? g_strdup (display_name)g_strdup_inline (display_name) : g_strdup (virt)g_strdup_inline (virt);
531}
532
533static char *
534get_system_virt (void)
535{
536 g_autoptr(GError)__attribute__((cleanup(glib_autoptr_cleanup_GError))) GError_autoptr error = NULL((void*)0);
537 g_autoptr(GDBusProxy)__attribute__((cleanup(glib_autoptr_cleanup_GDBusProxy))) GDBusProxy_autoptr systemd_proxy = NULL((void*)0);
538 g_autoptr(GVariant)__attribute__((cleanup(glib_autoptr_cleanup_GVariant))) GVariant_autoptr variant = NULL((void*)0);
539 GVariant *inner;
540
541 systemd_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
542 G_DBUS_PROXY_FLAGS_NONE,
543 NULL((void*)0),
544 "org.freedesktop.systemd1",
545 "/org/freedesktop/systemd1",
546 "org.freedesktop.systemd1",
547 NULL((void*)0),
548 &error);
549
550 if (systemd_proxy == NULL((void*)0))
551 {
552 g_debug ("systemd not available, bailing: %s", error->message);
553 return NULL((void*)0);
554 }
555
556 variant = g_dbus_proxy_call_sync (systemd_proxy,
557 "org.freedesktop.DBus.Properties.Get",
558 g_variant_new ("(ss)", "org.freedesktop.systemd1.Manager", "Virtualization"),
559 G_DBUS_CALL_FLAGS_NONE,
560 -1,
561 NULL((void*)0),
562 &error);
563 if (variant == NULL((void*)0))
564 {
565 g_debug ("Failed to get property '%s': %s", "Virtualization", error->message);
566 return NULL((void*)0);
567 }
568
569 g_variant_get (variant, "(v)", &inner);
570
571 return get_virtualization_label (g_variant_get_string (inner, NULL((void*)0)));
572}
573# endif
574
575static char *
576get_mate_desktop_version ()
577{
578 int status;
579 int i = 0;
580 char *version = NULL((void*)0);
581 char *argv[] = {"/usr/bin/mate-about", "-v", NULL((void*)0)};
582 g_autoptr(GError)__attribute__((cleanup(glib_autoptr_cleanup_GError))) GError_autoptr error = NULL((void*)0);
583
584 g_debug ("About to launch '%s'", argv[0]);
585
586 if (!g_spawn_sync (NULL((void*)0), (char **) argv, NULL((void*)0), 0, NULL((void*)0), NULL((void*)0), &version, NULL((void*)0), &status, &error))
587 {
588 g_warning ("Failed to get GPU: %s", error->message);
589 return NULL((void*)0);
590 }
591#if GLIB_CHECK_VERSION(2, 70, 0)(2 > (2) || (2 == (2) && 80 > (70)) || (2 == (2
) && 80 == (70) && 2 >= (0)))
592 if (!g_spawn_check_wait_status (status, NULL((void*)0)))
593#else
594 if (!g_spawn_check_exit_status (status, NULL((void*)0)))
595#endif
596 return NULL((void*)0);
597
598 while (version[i] != '\0')
599 {
600 if (version[i] == '\n')
601 {
602 version[i] = '\0';
603 break;
604 }
605 i++;
606 }
607
608 return version;
609}
610
611static char *
612get_logo_name (void)
613{
614 char *logo_name = NULL((void*)0);
615
616 logo_name = g_get_os_info ("LOGO");
617
618 if (logo_name == NULL((void*)0))
619 logo_name = g_strdup ("mate-desktop")g_strdup_inline ("mate-desktop");
620
621 return logo_name;
622}
623
624void
625mate_system_info_setup (MateSystemInfo *info)
626{
627 g_autofree__attribute__((cleanup(g_autoptr_cleanup_generic_gfree))) char *logo_name = NULL((void*)0);
628 g_autofree__attribute__((cleanup(g_autoptr_cleanup_generic_gfree))) char *hostname_text = NULL((void*)0);
629# ifdef HAVE_SYSTEMD
630 g_autofree__attribute__((cleanup(g_autoptr_cleanup_generic_gfree))) char *hw_model_text = NULL((void*)0);
631 g_autofree__attribute__((cleanup(g_autoptr_cleanup_generic_gfree))) char *virt_text = NULL((void*)0);
632# endif
633 g_autofree__attribute__((cleanup(g_autoptr_cleanup_generic_gfree))) char *memory_text = NULL((void*)0);
634 g_autofree__attribute__((cleanup(g_autoptr_cleanup_generic_gfree))) char *cpu_text = NULL((void*)0);
635 g_autofree__attribute__((cleanup(g_autoptr_cleanup_generic_gfree))) char *os_type_text = NULL((void*)0);
636 g_autofree__attribute__((cleanup(g_autoptr_cleanup_generic_gfree))) char *os_name_text = NULL((void*)0);
637 g_autofree__attribute__((cleanup(g_autoptr_cleanup_generic_gfree))) char *disk_text = NULL((void*)0);
638 g_autofree__attribute__((cleanup(g_autoptr_cleanup_generic_gfree))) char *kernel_text = NULL((void*)0);
639 g_autofree__attribute__((cleanup(g_autoptr_cleanup_generic_gfree))) char *windowing_system_text = NULL((void*)0);
640 g_autofree__attribute__((cleanup(g_autoptr_cleanup_generic_gfree))) char *de_text = NULL((void*)0);
641 g_autofree__attribute__((cleanup(g_autoptr_cleanup_generic_gfree))) char *graphics_hardware_string = NULL((void*)0);
642
643 GtkWidget *label;
644 glibtop_mem mem;
645
646 logo_name = get_logo_name ();
647 gtk_image_set_from_icon_name (GTK_IMAGE (info->logo_image)((((GtkImage*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((info->logo_image)), ((gtk_image_get_type ()))))))
, logo_name, GTK_ICON_SIZE_INVALID);
648 gtk_image_set_pixel_size (GTK_IMAGE (info->logo_image)((((GtkImage*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((info->logo_image)), ((gtk_image_get_type ()))))))
, 128);
649
650 hostname_text = get_system_hostname ();
651 label = g_object_get_data (G_OBJECT (info->hostname_row)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((info->hostname_row)), (((GType) ((20) << (2))))
))))
, "labelvalue");
652 set_lable_style (label, "gray", 12, hostname_text, FALSE(0));
653
654# if HAVE_SYSTEMD
655 hw_model_text = get_hardware_model ();
656 if (hw_model_text != NULL((void*)0))
657 {
658 gtk_widget_show_all (info->hardware_model_row);
659 label = g_object_get_data (G_OBJECT (info->hardware_model_row)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((info->hardware_model_row)), (((GType) ((20) << (
2))))))))
, "labelvalue");
660 set_lable_style (label, "gray", 12, hw_model_text, FALSE(0));
661 }
662# endif
663 glibtop_get_mem (&mem);
664 memory_text = g_format_size_full (mem.total, G_FORMAT_SIZE_IEC_UNITS);
665 label = g_object_get_data (G_OBJECT (info->memory_row)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((info->memory_row)), (((GType) ((20) << (2))))))
))
, "labelvalue");
666 set_lable_style (label, "gray", 12, memory_text, FALSE(0));
667
668 cpu_text = get_cpu_info ();
669 label = g_object_get_data (G_OBJECT (info->processor_row)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((info->processor_row)), (((GType) ((20) << (2)))
)))))
, "labelvalue");
670 set_lable_style (label, "gray", 12, cpu_text, FALSE(0));
671
672 graphics_hardware_string = get_graphics_hardware_string ();
673 label = g_object_get_data (G_OBJECT (info->graphics_row)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((info->graphics_row)), (((GType) ((20) << (2))))
))))
, "labelvalue");
674 set_lable_style (label, "gray", 12, graphics_hardware_string, FALSE(0));
675
676 disk_text = get_primary_disk_size ();
677 label = g_object_get_data (G_OBJECT (info->disk_row)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((info->disk_row)), (((GType) ((20) << (2))))))))
, "labelvalue");
678 set_lable_style (label, "gray", 12, disk_text, FALSE(0));
679
680 kernel_text = get_kernel_vesrion ();
681 label = g_object_get_data (G_OBJECT (info->kernel_row)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((info->kernel_row)), (((GType) ((20) << (2))))))
))
, "labelvalue");
682 set_lable_style (label, "gray", 12, kernel_text, FALSE(0));
683# ifdef HAVE_SYSTEMD
684 virt_text = get_system_virt ();
685 if (virt_text != NULL((void*)0))
686 {
687 gtk_widget_show_all (info->virtualization_row);
688 label = g_object_get_data (G_OBJECT (info->virtualization_row)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((info->virtualization_row)), (((GType) ((20) << (
2))))))))
, "labelvalue");
689 set_lable_style (label, "gray", 12, virt_text, FALSE(0));
690 }
691# endif
692 windowing_system_text = get_windowing_system ();
693 label = g_object_get_data (G_OBJECT (info->windowing_system_row)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((info->windowing_system_row)), (((GType) ((20) <<
(2))))))))
, "labelvalue");
694 set_lable_style (label, "gray", 12, windowing_system_text, FALSE(0));
695
696 de_text = get_mate_desktop_version ();
697 label = g_object_get_data (G_OBJECT (info->mate_version_row)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((info->mate_version_row)), (((GType) ((20) << (2
))))))))
, "labelvalue");
698 set_lable_style (label, "gray", 12, de_text, FALSE(0));
699
700 os_type_text = get_os_type ();
701 label = g_object_get_data (G_OBJECT (info->os_type_row)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((info->os_type_row)), (((GType) ((20) << (2)))))
)))
, "labelvalue");
702 set_lable_style (label, "gray", 12, os_type_text, FALSE(0));
703
704 os_name_text = get_os_name ();
705 label = g_object_get_data (G_OBJECT (info->os_name_row)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((info->os_name_row)), (((GType) ((20) << (2)))))
)))
, "labelvalue");
706 set_lable_style (label, "gray", 12, os_name_text, FALSE(0));
707}
708
709static void
710mate_system_info_destroy (GtkWidget *widget)
711{
712 GTK_WIDGET_CLASS (mate_system_info_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((mate_system_info_parent_class)), ((gtk_widget_get_type (
)))))))
->destroy (widget);
713}
714
715static void
716mate_system_info_class_init (MateSystemInfoClass *klass)
717{
718 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((klass)), ((gtk_widget_get_type ()))))))
;
719
720 widget_class->destroy = mate_system_info_destroy;
721 gtk_widget_class_set_template_from_resource (widget_class, "/org/mate/control-center/system-info/mate-system-info.ui");
722
723 gtk_widget_class_bind_template_child (widget_class, MateSystemInfo, hostname_row)gtk_widget_class_bind_template_child_full (widget_class, "hostname_row"
, (0), ((glong) __builtin_offsetof(MateSystemInfo, hostname_row
)))
;
724# ifdef HAVE_SYSTEMD
725 gtk_widget_class_bind_template_child (widget_class, MateSystemInfo, hardware_box)gtk_widget_class_bind_template_child_full (widget_class, "hardware_box"
, (0), ((glong) __builtin_offsetof(MateSystemInfo, hardware_box
)))
;
726 gtk_widget_class_bind_template_child (widget_class, MateSystemInfo, virtualization_row)gtk_widget_class_bind_template_child_full (widget_class, "virtualization_row"
, (0), ((glong) __builtin_offsetof(MateSystemInfo, virtualization_row
)))
;
727# endif
728 gtk_widget_class_bind_template_child (widget_class, MateSystemInfo, disk_row)gtk_widget_class_bind_template_child_full (widget_class, "disk_row"
, (0), ((glong) __builtin_offsetof(MateSystemInfo, disk_row))
)
;
729 gtk_widget_class_bind_template_child (widget_class, MateSystemInfo, mate_version_row)gtk_widget_class_bind_template_child_full (widget_class, "mate_version_row"
, (0), ((glong) __builtin_offsetof(MateSystemInfo, mate_version_row
)))
;
730 gtk_widget_class_bind_template_child (widget_class, MateSystemInfo, graphics_row)gtk_widget_class_bind_template_child_full (widget_class, "graphics_row"
, (0), ((glong) __builtin_offsetof(MateSystemInfo, graphics_row
)))
;
731 gtk_widget_class_bind_template_child (widget_class, MateSystemInfo, hardware_model_row)gtk_widget_class_bind_template_child_full (widget_class, "hardware_model_row"
, (0), ((glong) __builtin_offsetof(MateSystemInfo, hardware_model_row
)))
;
732 gtk_widget_class_bind_template_child (widget_class, MateSystemInfo, memory_row)gtk_widget_class_bind_template_child_full (widget_class, "memory_row"
, (0), ((glong) __builtin_offsetof(MateSystemInfo, memory_row
)))
;
733 gtk_widget_class_bind_template_child (widget_class, MateSystemInfo, os_box)gtk_widget_class_bind_template_child_full (widget_class, "os_box"
, (0), ((glong) __builtin_offsetof(MateSystemInfo, os_box)))
;
734 gtk_widget_class_bind_template_child (widget_class, MateSystemInfo, logo_image)gtk_widget_class_bind_template_child_full (widget_class, "logo_image"
, (0), ((glong) __builtin_offsetof(MateSystemInfo, logo_image
)))
;
735 gtk_widget_class_bind_template_child (widget_class, MateSystemInfo, os_name_row)gtk_widget_class_bind_template_child_full (widget_class, "os_name_row"
, (0), ((glong) __builtin_offsetof(MateSystemInfo, os_name_row
)))
;
736 gtk_widget_class_bind_template_child (widget_class, MateSystemInfo, os_type_row)gtk_widget_class_bind_template_child_full (widget_class, "os_type_row"
, (0), ((glong) __builtin_offsetof(MateSystemInfo, os_type_row
)))
;
737 gtk_widget_class_bind_template_child (widget_class, MateSystemInfo, processor_row)gtk_widget_class_bind_template_child_full (widget_class, "processor_row"
, (0), ((glong) __builtin_offsetof(MateSystemInfo, processor_row
)))
;
738 gtk_widget_class_bind_template_child (widget_class, MateSystemInfo, kernel_row)gtk_widget_class_bind_template_child_full (widget_class, "kernel_row"
, (0), ((glong) __builtin_offsetof(MateSystemInfo, kernel_row
)))
;
739 gtk_widget_class_bind_template_child (widget_class, MateSystemInfo, windowing_system_row)gtk_widget_class_bind_template_child_full (widget_class, "windowing_system_row"
, (0), ((glong) __builtin_offsetof(MateSystemInfo, windowing_system_row
)))
;
740}
741
742static void
743mate_system_info_init (MateSystemInfo *self)
744{
745 gtk_widget_init_template (GTK_WIDGET (self)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((self)), ((gtk_widget_get_type ()))))))
);
746 g_resources_register (mate_system_info_get_resource ());
747 mate_system_info_set_row (MATE_SYSTEM_INFO (self));
748}
749
750GtkWidget *
751mate_system_info_new (void)
752{
753 GtkWidget *dialog;
754 gboolean use_header;
755 GdkDisplay *display;
756
757 g_object_get (gtk_settings_get_default (),
758 "gtk-dialogs-use-header", &use_header,
759 NULL((void*)0));
760
761 display = gdk_display_get_default ();
762#if defined(GDK_WINDOWING_WAYLAND)
763 if (GDK_IS_WAYLAND_DISPLAY (display)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(display)); GType __t = ((gdk_wayland_display_get_type())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
)
764 use_header = FALSE(0);
765#endif /* GDK_WINDOWING_WAYLAND */
766
767 dialog = g_object_new (MATE_TYPE_SYSTEM_INFO(mate_system_info_get_type ()),
768 "use-header-bar", use_header,
769 NULL((void*)0));
770 gtk_window_set_title (GTK_WINDOW (dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_window_get_type ()))))))
, _("Mate System Info")gettext ("Mate System Info"));
771 gtk_widget_set_size_request (GTK_WIDGET (dialog)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_widget_get_type ()))))))
, 600, 500);
772 gtk_window_set_resizable (GTK_WINDOW (dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_window_get_type ()))))))
, FALSE(0));
773
774 return dialog;
775}
diff --git a/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-7c28e5.html b/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-7c28e5.html new file mode 100644 index 00000000..99bf0a1a --- /dev/null +++ b/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-7c28e5.html @@ -0,0 +1,949 @@ + + + +appearance-main.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:capplets/appearance/appearance-main.c
Warning:line 188, column 12
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name appearance-main.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/capplets/appearance -fcoverage-compilation-dir=/rootdir/capplets/appearance -resource-dir /usr/bin/../lib/clang/18 -D HAVE_CONFIG_H -I . -I ../.. -I /usr/include/marco-1 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/gio-unix-2.0 -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I ../../capplets/common -I /usr/include/udisks2 -I /usr/include/libgtop-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/libxml2 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/gio-unix-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/dconf -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I ../../ -D G_LOG_DOMAIN="appearance-properties" -I /usr/include/polkit-1 -I /usr/include/gio-unix-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I /usr/include/udisks2 -I /usr/include/libgtop-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/gio-unix-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/libxml2 -I /usr/include/harfbuzz -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/freetype2 -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/dconf -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libpng16 -D WITH_GZFILEOP -I /usr/include/sysprof-6 -I /usr/include/pixman-1 -D MATECC_DATA_DIR="/usr/local/share/mate-control-center" -D MATECC_PIXMAP_DIR="/usr/local/share/mate-control-center/pixmaps" -D WALLPAPER_DATADIR="/usr/local/share/mate-background-properties" -D BACKGROUND_DATADIR="/usr/local/share/backgrounds" -D MATE_DESKTOP_USE_UNSTABLE_API -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-06-07-044335-13427-1 -x c appearance-main.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 * Copyright (C) 2007 The GNOME Foundation
3 * Written by Thomas Wood <thos@gnome.org>
4 * All Rights Reserved
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 */
20
21#include <glib/gi18n.h>
22#include <libmate-desktop/mate-gsettings.h>
23#include "appearance.h"
24#include "appearance-desktop.h"
25#include "appearance-font.h"
26#include "appearance-themes.h"
27#include "appearance-style.h"
28#include "appearance-ui.h"
29#include "appearance-support.h"
30#include "theme-installer.h"
31#include "theme-thumbnail.h"
32#include "activate-settings-daemon.h"
33#include "capplet-util.h"
34#include <gdk/gdkx.h>
35
36static AppearanceData *
37init_appearance_data (int *argc, char ***argv, GOptionContext *context)
38{
39 AppearanceData *data = NULL((void*)0);
40 GtkBuilder *ui;
41
42 theme_thumbnail_factory_init (*argc, *argv);
43 capplet_init (context, argc, argv);
44 activate_settings_daemon ();
45
46 /* set up the data */
47 ui = gtk_builder_new_from_resource ("/org/mate/mcc/appearance/data/appearance.ui");
48
49 data = g_new (AppearanceData, 1)((AppearanceData *) g_malloc_n ((1), sizeof (AppearanceData))
)
;
50 data->settings = g_settings_new (APPEARANCE_SCHEMA"org.mate.control-center.appearance");
51 data->wp_settings = g_settings_new (WP_SCHEMA"org.mate.background");
52
53 if (mate_gsettings_schema_exists (CAJA_SCHEMA"org.mate.caja.desktop"))
54 data->caja_settings = g_settings_new (CAJA_SCHEMA"org.mate.caja.desktop");
55 else
56 data->caja_settings = NULL((void*)0);
57
58 data->filechooser_settings = g_settings_new (FILECHOOSER_SCHEMA"org.gtk.Settings.FileChooser");
59 data->interface_settings = g_settings_new (INTERFACE_SCHEMA"org.mate.interface");
60
61 data->interface_gnome_settings = NULL((void*)0);
62 /*Load the gnome interface schema if we are running under wayland and it is present*/
63 if (!(GDK_IS_X11_DISPLAY (gdk_display_get_default())(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(gdk_display_get_default())); GType __t = ((gdk_x11_display_get_type
())); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
))
64 {
65 GSettingsSchemaSource *source = g_settings_schema_source_get_default ();
66
67 if (source)
68 {
69 GSettingsSchema *schema = g_settings_schema_source_lookup (source, INTERFACE_GNOME_SCHEMA"org.gnome.desktop.interface", TRUE(!(0)));
70
71 if (schema)
72 data->interface_gnome_settings = g_settings_new_full (schema, NULL((void*)0), NULL((void*)0));
73 }
74 }
75 data->marco_settings = g_settings_new (MARCO_SCHEMA"org.mate.Marco.general");
76 data->mouse_settings = g_settings_new (MOUSE_SCHEMA"org.mate.peripherals-mouse");
77 data->font_settings = g_settings_new (FONT_RENDER_SCHEMA"org.mate.font-rendering");
78 data->ui = ui;
79 data->thumb_factory = mate_desktop_thumbnail_factory_new (MATE_DESKTOP_THUMBNAIL_SIZE_NORMAL);
80
81 return data;
82}
83
84static void
85main_window_response (GtkWidget *widget,
86 gint response_id,
87 AppearanceData *data)
88{
89 if (response_id == GTK_RESPONSE_CLOSE ||
90 response_id == GTK_RESPONSE_DELETE_EVENT)
91 {
92 gtk_main_quit ();
93
94 themes_shutdown (data);
95 style_shutdown (data);
96 desktop_shutdown (data);
97 font_shutdown (data);
98 support_shutdown (data);
99
100 g_object_unref (data->thumb_factory);
101 g_object_unref (data->settings);
102 g_object_unref (data->wp_settings);
103
104 if (data->caja_settings)
105 g_object_unref (data->caja_settings);
106
107 g_object_unref (data->filechooser_settings);
108 g_object_unref (data->interface_settings);
109 g_object_unref (data->marco_settings);
110 g_object_unref (data->mouse_settings);
111 g_object_unref (data->font_settings);
112 g_object_unref (data->ui);
113 }
114 else if (response_id == GTK_RESPONSE_HELP)
115 {
116 GtkNotebook *nb;
117 gint pindex;
118
119 nb = GTK_NOTEBOOK (appearance_capplet_get_widget (data, "main_notebook"))((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (((GtkWidget*) gtk_builder_get_object(data->ui, "main_notebook"
))), ((gtk_notebook_get_type ()))))))
;
120 pindex = gtk_notebook_get_current_page (nb);
121
122 switch (pindex)
123 {
124 case 0: /* theme */
125 capplet_help (GTK_WINDOW (widget)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_window_get_type ()))))))
, "goscustdesk-12");
126 break;
127 case 1: /* background */
128 capplet_help (GTK_WINDOW (widget)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_window_get_type ()))))))
, "goscustdesk-7");
129 break;
130 case 2: /* fonts */
131 capplet_help (GTK_WINDOW (widget)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_window_get_type ()))))))
, "goscustdesk-38");
132 break;
133 case 3: /* interface */
134 capplet_help (GTK_WINDOW (widget)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_window_get_type ()))))))
, "goscustuserinter-2");
135 break;
136 default:
137 capplet_help (GTK_WINDOW (widget)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_window_get_type ()))))))
, "prefs-look-and-feel");
138 break;
139 }
140 }
141}
142
143int
144main (int argc, char **argv)
145{
146 AppearanceData *data;
147 GtkWidget *w;
148 GtkWidget *nb;
149 GtkWidget *nb_custom_theme;
150 GtkStyleContext *context;
151
152 gchar *install_filename = NULL((void*)0);
153 gchar *start_page = NULL((void*)0);
154 gchar **wallpaper_files = NULL((void*)0);
155 GOptionContext *option_context;
156 GOptionEntry option_entries[] = {
157 { "install-theme",
158 'i',
159 G_OPTION_FLAG_IN_MAIN,
160 G_OPTION_ARG_FILENAME,
161 &install_filename,
162 N_("Specify the filename of a theme to install")("Specify the filename of a theme to install"),
163 N_("filename")("filename") },
164 { "show-page",
165 'p',
166 G_OPTION_FLAG_IN_MAIN,
167 G_OPTION_ARG_STRING,
168 &start_page,
169 /* TRANSLATORS: don't translate the terms in brackets */
170 N_("Specify the name of the page to show (theme|background|fonts|interface)")("Specify the name of the page to show (theme|background|fonts|interface)"
)
,
171 N_("page")("page") },
172 { G_OPTION_REMAINING"",
173 0,
174 G_OPTION_FLAG_IN_MAIN,
175 G_OPTION_ARG_FILENAME_ARRAY,
176 &wallpaper_files,
177 NULL((void*)0),
178 N_("[WALLPAPER...]")("[WALLPAPER...]") },
179 { NULL((void*)0), 0, 0, G_OPTION_ARG_NONE, NULL((void*)0), NULL((void*)0), NULL((void*)0) }
180 };
181
182 option_context = g_option_context_new (NULL((void*)0));
183 g_option_context_add_main_entries (option_context, option_entries, GETTEXT_PACKAGE"mate-control-center");
184
185 /* init */
186 data = init_appearance_data (&argc, &argv, option_context);
187 if (!data)
188 return 1;
This statement is never executed
189
190 /* init tabs */
191 themes_init (data);
192 style_init (data);
193 desktop_init (data, (const gchar **) wallpaper_files);
194 g_strfreev (wallpaper_files);
195 font_init (data);
196 ui_init (data);
197
198 /* init support for other window managers */
199 support_init (data);
200
201 /* prepare the main window */
202 w = appearance_capplet_get_widget (data, "appearance_window")(GtkWidget*) gtk_builder_get_object(data->ui, "appearance_window"
)
;
203 context = gtk_widget_get_style_context (w);
204 gtk_style_context_add_class (context, "appearance-window");
205
206 capplet_set_icon (w, "preferences-desktop-theme");
207 gtk_widget_show_all (w);
208
209#if !GTK_CHECK_VERSION(3, 24, 12)((3) > (3) || ((3) == (3) && (24) > (24)) || ((
3) == (3) && (24) == (24) && (42) >= (12))
)
210 gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (data->ui, "filechooser_type_column_toggle"))((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (data->ui, "filechooser_type_column_toggle"
))), ((gtk_widget_get_type ()))))))
);
211#endif /* !GTK_CHECK_VERSION(3, 24, 12) */
212
213 g_signal_connect_after (w, "response",g_signal_connect_data ((w), ("response"), ((GCallback) main_window_response
), (data), ((void*)0), G_CONNECT_AFTER)
214 (GCallback) main_window_response, data)g_signal_connect_data ((w), ("response"), ((GCallback) main_window_response
), (data), ((void*)0), G_CONNECT_AFTER)
;
215
216 /* default to background page if files were given on the command line */
217 if (wallpaper_files && !install_filename && !start_page)
218 start_page = g_strdup ("background")g_strdup_inline ("background");
219
220 nb = appearance_capplet_get_widget (data, "main_notebook")(GtkWidget*) gtk_builder_get_object(data->ui, "main_notebook"
)
;
221 gtk_widget_add_events (nb, GDK_SCROLL_MASK);
222 g_signal_connect (nb,g_signal_connect_data ((nb), ("scroll-event"), (((GCallback) (
capplet_notebook_scroll_event_cb))), (((void*)0)), ((void*)0)
, (GConnectFlags) 0)
223 "scroll-event",g_signal_connect_data ((nb), ("scroll-event"), (((GCallback) (
capplet_notebook_scroll_event_cb))), (((void*)0)), ((void*)0)
, (GConnectFlags) 0)
224 G_CALLBACK (capplet_notebook_scroll_event_cb),g_signal_connect_data ((nb), ("scroll-event"), (((GCallback) (
capplet_notebook_scroll_event_cb))), (((void*)0)), ((void*)0)
, (GConnectFlags) 0)
225 NULL)g_signal_connect_data ((nb), ("scroll-event"), (((GCallback) (
capplet_notebook_scroll_event_cb))), (((void*)0)), ((void*)0)
, (GConnectFlags) 0)
;
226
227 if (start_page != NULL((void*)0)) {
228 gchar *page_name;
229
230 page_name = g_strconcat (start_page, "_vbox", NULL((void*)0));
231 g_free (start_page);
232
233 w = appearance_capplet_get_widget (data, page_name)(GtkWidget*) gtk_builder_get_object(data->ui, page_name);
234 if (w != NULL((void*)0)) {
235 gint pindex;
236 GtkNotebook *notebook;
237
238 notebook = GTK_NOTEBOOK (nb)((((GtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((nb)), ((gtk_notebook_get_type ()))))))
;
239 pindex = gtk_notebook_page_num (notebook, w);
240 if (pindex != -1)
241 gtk_notebook_set_current_page (notebook, pindex);
242 }
243 g_free (page_name);
244 }
245
246 if (install_filename != NULL((void*)0)) {
247 GFile *inst = g_file_new_for_commandline_arg (install_filename);
248 g_free (install_filename);
249 mate_theme_install (inst, GTK_WINDOW (w)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((w)), ((gtk_window_get_type ()))))))
);
250 g_object_unref (inst);
251 }
252
253 g_option_context_free (option_context);
254
255 nb_custom_theme = appearance_capplet_get_widget (data, "notebook2")(GtkWidget*) gtk_builder_get_object(data->ui, "notebook2");
256 gtk_widget_add_events (nb_custom_theme, GDK_SCROLL_MASK);
257 g_signal_connect (nb_custom_theme,g_signal_connect_data ((nb_custom_theme), ("scroll-event"), (
((GCallback) (capplet_notebook_scroll_event_cb))), (((void*)0
)), ((void*)0), (GConnectFlags) 0)
258 "scroll-event",g_signal_connect_data ((nb_custom_theme), ("scroll-event"), (
((GCallback) (capplet_notebook_scroll_event_cb))), (((void*)0
)), ((void*)0), (GConnectFlags) 0)
259 G_CALLBACK (capplet_notebook_scroll_event_cb),g_signal_connect_data ((nb_custom_theme), ("scroll-event"), (
((GCallback) (capplet_notebook_scroll_event_cb))), (((void*)0
)), ((void*)0), (GConnectFlags) 0)
260 NULL)g_signal_connect_data ((nb_custom_theme), ("scroll-event"), (
((GCallback) (capplet_notebook_scroll_event_cb))), (((void*)0
)), ((void*)0), (GConnectFlags) 0)
;
261
262 /* start the mainloop */
263 gtk_main ();
264
265 /* free stuff */
266 g_free (data);
267
268 return 0;
269}
diff --git a/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-83aba4.html b/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-83aba4.html new file mode 100644 index 00000000..0f349c0c --- /dev/null +++ b/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-83aba4.html @@ -0,0 +1,1070 @@ + + + +font-thumbnailer.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:font-viewer/font-thumbnailer.c
Warning:line 96, column 3
Undefined or garbage value returned to caller
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name font-thumbnailer.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/font-viewer -fcoverage-compilation-dir=/rootdir/font-viewer -resource-dir /usr/bin/../lib/clang/18 -D HAVE_CONFIG_H -I . -I .. -I /usr/include/udisks2 -I /usr/include/libgtop-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/libxml2 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/gio-unix-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/dconf -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I ../capplets/common -I /usr/include/udisks2 -I /usr/include/libgtop-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/libxml2 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/gio-unix-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/dconf -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I ../ -D G_LOG_DOMAIN="-properties" -I /usr/include/polkit-1 -I /usr/include/gio-unix-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -D DIRECTORY_DIR="" -D MATELOCALEDIR="/usr/local/share/locale" -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-06-07-044335-13427-1 -x c font-thumbnailer.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* -*- mode: C; c-basic-offset: 4 -*- */
2/*
3 * font-thumbnailer: a thumbnailer for font files, using FreeType
4 *
5 * Copyright (C) 2002-2003 James Henstridge <james@daa.com.au>
6 * Copyright (C) 2012 Cosimo Cecchi <cosimoc@gnome.org>
7 * Copyright (C) 2013-2021 MATE Developers
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
24#ifdef HAVE_CONFIG_H1
25#include <config.h>
26#endif
27
28#include <stdio.h>
29#ifdef ENABLE_NLS1
30#include <locale.h>
31#endif /* ENABLE_NLS */
32#include <ft2build.h>
33#include <math.h>
34#include FT_FREETYPE_H<freetype/freetype.h>
35
36#include <gdk/gdk.h>
37#include <gdk-pixbuf/gdk-pixbuf.h>
38#include <gio/gio.h>
39#include <glib/gi18n.h>
40
41#include <cairo/cairo-ft.h>
42
43#include "sushi-font-loader.h"
44#include "totem-resources.h"
45
46static const gchar *
47get_ft_error (FT_Error error)
48{
49#undef __FTERRORS_H__
50#define FT_ERRORDEF(e,v,s) case e: return s;
51#define FT_ERROR_START_LIST
52#define FT_ERROR_END_LIST
53 switch (error) {
54#include FT_ERRORS_H<freetype/fterrors.h>
55 default:
56 return "unknown";
57 }
58}
59
60#define THUMB_SIZE128 128
61#define PADDING_VERTICAL2 2
62#define PADDING_HORIZONTAL4 4
63
64static gboolean
65check_font_contain_text (FT_Face face,
66 const gchar *text)
67{
68 gunichar *string;
69 glong len, idx, map;
70 FT_CharMap charmap;
71 gboolean retval;
15
'retval' declared without an initial value
72
73 string = g_utf8_to_ucs4_fast (text, -1, &len);
74
75 for (map = 0; map < face->num_charmaps; map++) {
16
Assuming 'map' is >= field 'num_charmaps'
17
Loop condition is false. Execution continues on line 94
76 charmap = face->charmaps[map];
77 FT_Set_Charmap (face, charmap);
78
79 retval = TRUE(!(0));
80
81 for (idx = 0; idx < len; idx++) {
82 gunichar c = string[idx];
83
84 if (!FT_Get_Char_Index (face, c)) {
85 retval = FALSE(0);
86 break;
87 }
88 }
89
90 if (retval)
91 break;
92 }
93
94 g_free (string);
95
96 return retval;
18
Undefined or garbage value returned to caller
97}
98
99static gchar *
100check_for_ascii_glyph_numbers (FT_Face face,
101 gboolean *found_ascii)
102{
103 GString *ascii_string, *string;
104 gulong c;
105 guint glyph, found = 0;
106
107 string = g_string_new (NULL((void*)0));
108 ascii_string = g_string_new (NULL((void*)0));
109 *found_ascii = FALSE(0);
110
111 c = FT_Get_First_Char (face, &glyph);
112
113 do {
114 if (glyph == 65 || glyph == 97) {
115 g_string_append_unichar (ascii_string, (gunichar) c);
116 found++;
117 }
118
119 if (found == 2)
120 break;
121
122 g_string_append_unichar (string, (gunichar) c);
123 c = FT_Get_Next_Char (face, c, &glyph);
124 } while (glyph != 0);
125
126 if (found == 2) {
127 *found_ascii = TRUE(!(0));
128 g_string_free (string, TRUE)(__builtin_constant_p ((!(0))) ? (((!(0))) ? (g_string_free) (
(string), ((!(0)))) : g_string_free_and_steal (string)) : (g_string_free
) ((string), ((!(0)))))
;
129 return g_string_free (ascii_string, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((ascii_string
), ((0))) : g_string_free_and_steal (ascii_string)) : (g_string_free
) ((ascii_string), ((0))))
;
130 } else {
131 g_string_free (ascii_string, TRUE)(__builtin_constant_p ((!(0))) ? (((!(0))) ? (g_string_free) (
(ascii_string), ((!(0)))) : g_string_free_and_steal (ascii_string
)) : (g_string_free) ((ascii_string), ((!(0)))))
;
132 return g_string_free (string, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((string
), ((0))) : g_string_free_and_steal (string)) : (g_string_free
) ((string), ((0))))
;
133 }
134}
135
136static gchar *
137build_fallback_thumbstr (FT_Face face)
138{
139 gchar *chars;
140 gint idx, total_chars;
141 GString *retval;
142 gchar *ptr, *end;
143 gboolean found_ascii;
144
145 chars = check_for_ascii_glyph_numbers (face, &found_ascii);
146
147 if (found_ascii)
148 return chars;
149
150 idx = 0;
151 retval = g_string_new (NULL((void*)0));
152 total_chars = g_utf8_strlen (chars, -1);
153
154 while (idx < 2) {
155 total_chars = total_chars / 2;
156 ptr = g_utf8_offset_to_pointer (chars, total_chars);
157 end = g_utf8_find_next_char (ptr, NULL((void*)0));
158
159 g_string_append_len (retval, ptr, end - ptr)g_string_append_len_inline (retval, ptr, end - ptr);
160 idx++;
161 }
162
163 return g_string_free (retval, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((retval
), ((0))) : g_string_free_and_steal (retval)) : (g_string_free
) ((retval), ((0))))
;
164}
165
166int
167main (int argc,
168 char **argv)
169{
170 FT_Error error;
171 FT_Library library;
172 FT_Face face;
173 GFile *file;
174 gint font_size, thumb_size = THUMB_SIZE128;
175 gchar *thumbstr_utf8 = NULL((void*)0), *help, *uri;
176 gchar **arguments = NULL((void*)0);
177 GOptionContext *context;
178 GError *gerror = NULL((void*)0);
179 gchar *contents = NULL((void*)0);
180 gboolean retval, default_thumbstr = TRUE(!(0));
181 gint rv = 1;
182 GdkRGBA black = { 0.0, 0.0, 0.0, 1.0 };
183 cairo_surface_t *surface;
184 cairo_t *cr;
185 cairo_text_extents_t text_extents;
186 cairo_font_face_t *font;
187 gchar *str = NULL((void*)0);
188 gdouble scale, scale_x, scale_y;
189 gint face_index = 0;
190 gchar *fragment;
191
192 const GOptionEntry options[] = {
193 { "text", 't', 0, G_OPTION_ARG_STRING, &thumbstr_utf8,
194 N_("Text to thumbnail (default: Aa)")("Text to thumbnail (default: Aa)"), N_("TEXT")("TEXT") },
195 { "size", 's', 0, G_OPTION_ARG_INT, &thumb_size,
196 N_("Thumbnail size (default: 128)")("Thumbnail size (default: 128)"), N_("SIZE")("SIZE") },
197 { G_OPTION_REMAINING"", 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &arguments,
198 NULL((void*)0), N_("FONT-FILE OUTPUT-FILE")("FONT-FILE OUTPUT-FILE") },
199 { NULL((void*)0), 0, 0, G_OPTION_ARG_NONE, NULL((void*)0), NULL((void*)0), NULL((void*)0) }
200 };
201
202#ifdef ENABLE_NLS1
203 setlocale (LC_ALL6, "");
204 bindtextdomain (GETTEXT_PACKAGE"mate-control-center", MATELOCALEDIR"/usr/local/share/locale");
205 bind_textdomain_codeset (GETTEXT_PACKAGE"mate-control-center", "UTF-8");
206 textdomain (GETTEXT_PACKAGE"mate-control-center");
207#endif /* ENABLE_NLS */
208
209 context = g_option_context_new (NULL((void*)0));
210 g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE"mate-control-center");
211
212 retval = g_option_context_parse (context, &argc, &argv, &gerror);
213 if (!retval) {
1
Assuming 'retval' is not equal to 0
214 g_printerr ("Error parsing arguments: %s\n", gerror->message);
215
216 g_option_context_free (context);
217 g_error_free (gerror);
218 return 1;
219 }
220
221 if (!arguments || g_strv_length (arguments) != 2) {
2
Assuming 'arguments' is non-null
3
Assuming the condition is false
4
Taking false branch
222 help = g_option_context_get_help (context, TRUE(!(0)), NULL((void*)0));
223 g_printerr ("%s", help);
224
225 g_option_context_free (context);
226 goto out;
227 }
228
229 g_option_context_free (context);
230
231 if (thumbstr_utf8 != NULL((void*)0))
5
Assuming 'thumbstr_utf8' is equal to NULL
6
Taking false branch
232 default_thumbstr = FALSE(0);
233
234 error = FT_Init_FreeType (&library);
235 if (error) {
7
Assuming 'error' is 0
8
Taking false branch
236 g_printerr("Could not initialise freetype: %s\n", get_ft_error (error));
237 goto out;
238 }
239
240 totem_resources_monitor_start (arguments[0], 30 * G_USEC_PER_SEC1000000);
241
242 fragment = strrchr (arguments[0], '#');
243 if (fragment)
9
Assuming 'fragment' is null
10
Taking false branch
244 face_index = strtol (fragment + 1, NULL((void*)0), 0);
245
246 file = g_file_new_for_commandline_arg (arguments[0]);
247 uri = g_file_get_uri (file);
248 g_object_unref (file);
249
250 face = sushi_new_ft_face_from_uri (library, uri, face_index, &contents, &gerror);
251 if (gerror) {
11
Assuming 'gerror' is null
12
Taking false branch
252 g_printerr ("Could not load face '%s': %s\n", uri,
253 gerror->message);
254 g_free (uri);
255 g_error_free (gerror);
256 goto out;
257 }
258
259 g_free (uri);
260
261 if (default_thumbstr
12.1
'default_thumbstr' is 1
) {
13
Taking true branch
262 if (check_font_contain_text (face, "Aa"))
14
Calling 'check_font_contain_text'
263 str = g_strdup ("Aa")g_strdup_inline ("Aa");
264 else
265 str = build_fallback_thumbstr (face);
266 } else {
267 str = thumbstr_utf8;
268 }
269
270 surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
271 thumb_size, thumb_size);
272 cr = cairo_create (surface);
273
274 font = cairo_ft_font_face_create_for_ft_face (face, 0);
275 cairo_set_font_face (cr, font);
276 cairo_font_face_destroy (font);
277
278 font_size = thumb_size - 2 * PADDING_VERTICAL2;
279 cairo_set_font_size (cr, font_size);
280 cairo_text_extents (cr, str, &text_extents);
281
282 if ((text_extents.width) > (thumb_size - 2 * PADDING_HORIZONTAL4)) {
283 scale_x = (gdouble) (thumb_size - 2 * PADDING_HORIZONTAL4) / (text_extents.width);
284 } else {
285 scale_x = 1.0;
286 }
287
288 if ((text_extents.height) > (thumb_size - 2 * PADDING_VERTICAL2)) {
289 scale_y = (gdouble) (thumb_size - 2 * PADDING_VERTICAL2) / (text_extents.height);
290 } else {
291 scale_y = 1.0;
292 }
293
294 scale = MIN (scale_x, scale_y)(((scale_x) < (scale_y)) ? (scale_x) : (scale_y));
295 cairo_scale (cr, scale, scale);
296 cairo_translate (cr,
297 PADDING_HORIZONTAL4 - text_extents.x_bearing + (thumb_size - scale * text_extents.width) / 2.0,
298 PADDING_VERTICAL2 - text_extents.y_bearing + (thumb_size - scale * text_extents.height) / 2.0);
299
300 gdk_cairo_set_source_rgba (cr, &black);
301 cairo_show_text (cr, str);
302 cairo_destroy (cr);
303
304 cairo_surface_write_to_png (surface, arguments[1]);
305 cairo_surface_destroy (surface);
306
307 totem_resources_monitor_stop ();
308
309 error = FT_Done_Face (face);
310 if (error) {
311 g_printerr("Could not unload face: %s\n", get_ft_error (error));
312 goto out;
313 }
314
315 error = FT_Done_FreeType (library);
316 if (error) {
317 g_printerr ("Could not finalize freetype library: %s\n",
318 get_ft_error (error));
319 goto out;
320 }
321
322 rv = 0; /* success */
323
324 out:
325
326 g_strfreev (arguments);
327 g_free (str);
328 g_free (contents);
329
330 return rv;
331}
332
diff --git a/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-850291.html b/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-850291.html new file mode 100644 index 00000000..251a0ae9 --- /dev/null +++ b/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-850291.html @@ -0,0 +1,3339 @@ + + + +xrandr-capplet.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:capplets/display/xrandr-capplet.c
Warning:line 1098, column 17
3rd function call argument is an uninitialized value
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name xrandr-capplet.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/capplets/display -fcoverage-compilation-dir=/rootdir/capplets/display -resource-dir /usr/bin/../lib/clang/18 -D HAVE_CONFIG_H -I . -I ../.. -I /usr/include/udisks2 -I /usr/include/libgtop-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/libxml2 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/gio-unix-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/dconf -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I ../../capplets/common -I /usr/include/udisks2 -I /usr/include/libgtop-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/libxml2 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/gio-unix-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/dconf -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I ../../ -D G_LOG_DOMAIN="display-properties" -I /usr/include/polkit-1 -I /usr/include/gio-unix-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -D SBINDIR="/usr/local/sbin" -D MATELOCALEDIR="/usr/local/share/locale" -D MATECC_DATA_DIR="/usr/local/share/mate-control-center" -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-06-07-044335-13427-1 -x c xrandr-capplet.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* Monitor Settings. A preference panel for configuring monitors
2 *
3 * Copyright (C) 2007, 2008 Red Hat, Inc.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 *
19 * Author: Soren Sandmann <sandmann@redhat.com>
20 */
21
22#include <config.h>
23#include <string.h>
24#include <stdlib.h>
25#include <sys/wait.h>
26
27#include <gtk/gtk.h>
28#include "scrollarea.h"
29#define MATE_DESKTOP_USE_UNSTABLE_API
30#include <libmate-desktop/mate-desktop-utils.h>
31#include <libmate-desktop/mate-rr.h>
32#include <libmate-desktop/mate-rr-config.h>
33#include <libmate-desktop/mate-rr-labeler.h>
34#include <gdk/gdkx.h>
35#include <X11/Xlib.h>
36#include <glib/gi18n.h>
37#include <gio/gio.h>
38
39#include "capplet-util.h"
40
41#define MATE_INTERFACE_SCHEMA"org.mate.interface" "org.mate.interface"
42#define WINDOW_SCALE_KEY"window-scaling-factor" "window-scaling-factor"
43
44typedef struct App App;
45typedef struct GrabInfo GrabInfo;
46
47struct App
48{
49 MateRRScreen *screen;
50 MateRRConfig *current_configuration;
51 MateRRLabeler *labeler;
52 MateRROutputInfo *current_output;
53
54 GtkWidget *dialog;
55 GtkWidget *current_monitor_event_box;
56 GtkWidget *current_monitor_label;
57 GtkWidget *monitor_on_radio;
58 GtkWidget *monitor_off_radio;
59 GtkListStore *resolution_store;
60 GtkWidget *resolution_combo;
61 GtkWidget *refresh_combo;
62 GtkWidget *rotation_combo;
63 GtkWidget *panel_checkbox;
64 GtkWidget *scale_vbox;
65 GtkWidget *scale_bbox;
66 GtkWidget *clone_checkbox;
67 GtkWidget *show_icon_checkbox;
68 GtkWidget *primary_button;
69
70 /* We store the event timestamp when the Apply button is clicked */
71 GtkWidget *apply_button;
72 guint32 apply_button_clicked_timestamp;
73
74 GtkWidget *area;
75 gboolean ignore_gui_changes;
76 GSettings *settings;
77 GSettings *scale_settings;
78
79 /* These are used while we are waiting for the ApplyConfiguration method to be executed over D-bus */
80 GDBusConnection *connection;
81 GDBusProxy *proxy;
82
83 enum {
84 APPLYING_VERSION_1,
85 APPLYING_VERSION_2
86 } apply_configuration_state;
87};
88
89/* Response codes for custom buttons in the main dialog */
90enum {
91 RESPONSE_MAKE_DEFAULT = 1
92};
93
94static void rebuild_gui (App *app);
95static void on_clone_changed (GtkWidget *box, gpointer data);
96static void on_rate_changed (GtkComboBox *box, gpointer data);
97static gboolean output_overlaps (MateRROutputInfo *output, MateRRConfig *config);
98static void select_current_output_from_dialog_position (App *app);
99static void monitor_on_off_toggled_cb (GtkToggleButton *toggle, gpointer data);
100static void apply_configuration_returned_cb (GObject *source_object, GAsyncResult *res, gpointer data);
101
102static void
103error_message (App *app, const char *primary_text, const char *secondary_text)
104{
105 GtkWidget *dialog;
106
107 dialog = gtk_message_dialog_new ((app && app->dialog) ? GTK_WINDOW (app->dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((app->dialog)), ((gtk_window_get_type ()))))))
: NULL((void*)0),
108 GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
109 GTK_MESSAGE_ERROR,
110 GTK_BUTTONS_CLOSE,
111 "%s", primary_text);
112
113 if (secondary_text)
114 gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog)((((GtkMessageDialog*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((dialog)), ((gtk_message_dialog_get_type ())
)))))
, "%s", secondary_text);
115
116 gtk_dialog_run (GTK_DIALOG (dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_dialog_get_type ()))))))
);
117 gtk_widget_destroy (dialog);
118}
119
120static gboolean
121do_free (gpointer data)
122{
123 g_free (data);
124 return FALSE(0);
125}
126
127static gchar *
128idle_free (gchar *s)
129{
130 g_idle_add (do_free, s);
131
132 return s;
133}
134
135static void
136on_screen_changed (MateRRScreen *scr,
137 gpointer data)
138{
139 MateRRConfig *current;
140 App *app = data;
141
142 current = mate_rr_config_new_current (app->screen, NULL((void*)0));
143
144 if (app->current_configuration)
145 g_object_unref (app->current_configuration);
146
147 app->current_configuration = current;
148 app->current_output = NULL((void*)0);
149
150 if (app->labeler) {
151 mate_rr_labeler_hide (app->labeler);
152 g_object_unref (app->labeler);
153 }
154
155 app->labeler = mate_rr_labeler_new (app->current_configuration);
156
157 select_current_output_from_dialog_position (app);
158}
159
160static void
161on_viewport_changed (FooScrollArea *scroll_area,
162 GdkRectangle *old_viewport,
163 GdkRectangle *new_viewport)
164{
165 foo_scroll_area_set_size (scroll_area,
166 new_viewport->width,
167 new_viewport->height);
168
169 foo_scroll_area_invalidate (scroll_area);
170}
171
172static void
173layout_set_font (PangoLayout *layout, const char *font)
174{
175 PangoFontDescription *desc =
176 pango_font_description_from_string (font);
177
178 if (desc)
179 {
180 pango_layout_set_font_description (layout, desc);
181
182 pango_font_description_free (desc);
183 }
184}
185
186static void
187clear_combo (GtkWidget *widget)
188{
189 GtkComboBox *box = GTK_COMBO_BOX (widget)((((GtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_combo_box_get_type ()))))))
;
190 GtkTreeModel *model = gtk_combo_box_get_model (box);
191 GtkListStore *store = GTK_LIST_STORE (model)((((GtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_list_store_get_type ()))))))
;
192
193 gtk_list_store_clear (store);
194}
195
196typedef struct
197{
198 const char *text;
199 gboolean found;
200 GtkTreeIter iter;
201} ForeachInfo;
202
203static gboolean
204foreach (GtkTreeModel *model,
205 GtkTreePath *path,
206 GtkTreeIter *iter,
207 gpointer data)
208{
209 ForeachInfo *info = data;
210 char *text = NULL((void*)0);
211
212 gtk_tree_model_get (model, iter, 0, &text, -1);
213
214 g_assert (text != NULL)do { if (text != ((void*)0)) ; else g_assertion_message_expr (
"display-properties", "xrandr-capplet.c", 214, ((const char*)
(__func__)), "text != NULL"); } while (0)
;
215
216 if (strcmp (info->text, text) == 0)
217 {
218 info->found = TRUE(!(0));
219 info->iter = *iter;
220 return TRUE(!(0));
221 }
222
223 return FALSE(0);
224}
225
226static void
227add_key (GtkWidget *widget,
228 const char *text,
229 guint width,
230 guint height,
231 int rate,
232 MateRRRotation rotation)
233{
234 ForeachInfo info;
235 GtkComboBox *box = GTK_COMBO_BOX (widget)((((GtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_combo_box_get_type ()))))))
;
236 GtkTreeModel *model = gtk_combo_box_get_model (box);
237 GtkListStore *store = GTK_LIST_STORE (model)((((GtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_list_store_get_type ()))))))
;
238
239 info.text = text;
240 info.found = FALSE(0);
241
242 gtk_tree_model_foreach (model, foreach, &info);
243
244 if (!info.found)
245 {
246 GtkTreeIter iter;
247 gtk_list_store_insert_with_values (store, &iter, -1,
248 0, text,
249 1, width,
250 2, height,
251 3, rate,
252 4, width * height,
253 5, rotation,
254 -1);
255 }
256}
257
258static gboolean
259combo_select (GtkWidget *widget, const char *text)
260{
261 GtkComboBox *box = GTK_COMBO_BOX (widget)((((GtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_combo_box_get_type ()))))))
;
262 GtkTreeModel *model = gtk_combo_box_get_model (box);
263 ForeachInfo info;
264
265 info.text = text;
266 info.found = FALSE(0);
267
268 gtk_tree_model_foreach (model, foreach, &info);
269
270 if (!info.found)
271 return FALSE(0);
272
273 gtk_combo_box_set_active_iter (box, &info.iter);
274 return TRUE(!(0));
275}
276
277static MateRRMode **
278get_current_modes (App *app)
279{
280 MateRROutput *output;
281
282 if (mate_rr_config_get_clone (app->current_configuration))
283 {
284 return mate_rr_screen_list_clone_modes (app->screen);
285 }
286 else
287 {
288 if (!app->current_output)
289 return NULL((void*)0);
290
291 output = mate_rr_screen_get_output_by_name (app->screen,
292 mate_rr_output_info_get_name (app->current_output));
293
294 if (!output)
295 return NULL((void*)0);
296
297 return mate_rr_output_list_modes (output);
298 }
299}
300
301static void
302rebuild_rotation_combo (App *app)
303{
304 typedef struct
305 {
306 MateRRRotation rotation;
307 const char * name;
308 } RotationInfo;
309 static const RotationInfo rotations[] = {
310 { MATE_RR_ROTATION_0, N_("Normal")("Normal") },
311 { MATE_RR_ROTATION_90, N_("Left")("Left") },
312 { MATE_RR_ROTATION_270, N_("Right")("Right") },
313 { MATE_RR_ROTATION_180, N_("Upside Down")("Upside Down") },
314 };
315 const char *selection;
316 MateRRRotation current;
317 unsigned int i;
318
319 clear_combo (app->rotation_combo);
320
321 gtk_widget_set_sensitive (app->rotation_combo,
322 app->current_output && mate_rr_output_info_is_active (app->current_output));
323
324 if (!app->current_output)
325 return;
326
327 current = mate_rr_output_info_get_rotation (app->current_output);
328
329 selection = NULL((void*)0);
330 for (i = 0; i < G_N_ELEMENTS (rotations)(sizeof (rotations) / sizeof ((rotations)[0])); ++i)
331 {
332 const RotationInfo *info = &(rotations[i]);
333
334 mate_rr_output_info_set_rotation (app->current_output, info->rotation);
335
336 /* NULL-GError --- FIXME: we should say why this rotation is not available! */
337 if (mate_rr_config_applicable (app->current_configuration, app->screen, NULL((void*)0)))
338 {
339 add_key (app->rotation_combo, _(info->name)gettext (info->name), 0, 0, 0, info->rotation);
340
341 if (info->rotation == current)
342 selection = _(info->name)gettext (info->name);
343 }
344 }
345
346 mate_rr_output_info_set_rotation (app->current_output, current);
347
348 if (!(selection && combo_select (app->rotation_combo, selection)))
349 combo_select (app->rotation_combo, _("Normal")gettext ("Normal"));
350}
351
352static char *
353make_rate_string (int hz)
354{
355 return g_strdup_printf (_("%d Hz")gettext ("%d Hz"), hz);
356}
357
358static void
359rebuild_rate_combo (App *app)
360{
361 MateRRMode **modes;
362 int best;
363 int i;
364
365 clear_combo (app->refresh_combo);
366
367 gtk_widget_set_sensitive (
368 app->refresh_combo, app->current_output && mate_rr_output_info_is_active (app->current_output));
369
370 if (!app->current_output
371 || !(modes = get_current_modes (app)))
372 return;
373
374 best = -1;
375 for (i = 0; modes[i] != NULL((void*)0); ++i)
376 {
377 MateRRMode *mode = modes[i];
378 guint width;
379 guint height;
380 int rate;
381 int output_width;
382 int output_height;
383
384 mate_rr_output_info_get_geometry (app->current_output, NULL((void*)0), NULL((void*)0),
385 &output_width,
386 &output_height);
387
388 width = mate_rr_mode_get_width (mode);
389 height = mate_rr_mode_get_height (mode);
390 rate = mate_rr_mode_get_freq (mode);
391
392 if ((width == (guint) output_width) &&
393 (height == (guint) output_height))
394 {
395 add_key (app->refresh_combo,
396 idle_free (make_rate_string (rate)),
397 0, 0, rate, -1);
398
399 if (rate > best)
400 best = rate;
401 }
402 }
403
404 if (!combo_select (app->refresh_combo, idle_free (make_rate_string (mate_rr_output_info_get_refresh_rate (app->current_output)))))
405 combo_select (app->refresh_combo, idle_free (make_rate_string (best)));
406}
407
408static int
409count_active_outputs (App *app)
410{
411 int i, count = 0;
412 MateRROutputInfo **outputs = mate_rr_config_get_outputs (app->current_configuration);
413
414 for (i = 0; outputs[i] != NULL((void*)0); ++i)
415 {
416 if (mate_rr_output_info_is_active (outputs[i]))
417 count++;
418 }
419
420 return count;
421}
422
423/* FIXME: this function is copied from mate-settings-daemon/plugins/xrandr/gsd-xrandr-manager.c.
424 * Do we need to put this function in mate-desktop for public use?
425 */
426static gboolean
427get_clone_size (MateRRScreen *screen,
428 guint *width,
429 guint *height)
430{
431 MateRRMode **modes = mate_rr_screen_list_clone_modes (screen);
432 guint best_w = 0;
433 guint best_h = 0;
434 guint i;
435
436 for (i = 0; modes[i] != NULL((void*)0); ++i) {
8
Assuming the condition is false
437 MateRRMode *mode = modes[i];
438 guint w, h;
439
440 w = mate_rr_mode_get_width (mode);
441 h = mate_rr_mode_get_height (mode);
442
443 if (w * h > best_w * best_h) {
444 best_w = w;
445 best_h = h;
446 }
447 }
448
449 if (best_w
8.1
'best_w' is <= 0
> 0 && best_h > 0) {
450 if (width)
451 *width = best_w;
452 if (height)
453 *height = best_h;
454
455 return TRUE(!(0));
456 }
457
458 return FALSE(0);
9
Returning without writing to '*width'
459}
460
461static gboolean
462output_info_supports_mode (App *app,
463 MateRROutputInfo *info,
464 guint width,
465 guint height)
466{
467 MateRROutput *output;
468 MateRRMode **modes;
469 guint i;
470
471 if (!mate_rr_output_info_is_connected (info))
472 return FALSE(0);
473
474 output = mate_rr_screen_get_output_by_name (app->screen, mate_rr_output_info_get_name (info));
475 if (!output)
476 return FALSE(0);
477
478 modes = mate_rr_output_list_modes (output);
479
480 for (i = 0; modes[i]; i++) {
481 if ((mate_rr_mode_get_width (modes[i]) == width) &&
482 (mate_rr_mode_get_height (modes[i]) == height))
483 {
484 return TRUE(!(0));
485 }
486 }
487
488 return FALSE(0);
489}
490
491/* Computes whether "Mirror Screens" (clone mode) is supported based on these criteria:
492 *
493 * 1. There is an available size for cloning.
494 *
495 * 2. There are 2 or more connected outputs that support that size.
496 */
497static gboolean
498mirror_screens_is_supported (App *app)
499{
500 guint clone_width;
501 guint clone_height;
502 gboolean have_clone_size;
503 gboolean mirror_is_supported;
504
505 mirror_is_supported = FALSE(0);
506
507 have_clone_size = get_clone_size (app->screen, &clone_width, &clone_height);
508
509 if (have_clone_size) {
510 guint i;
511 guint num_outputs_with_clone_size = 0;
512 MateRROutputInfo **outputs = mate_rr_config_get_outputs (app->current_configuration);
513
514 for (i = 0; outputs[i] != NULL((void*)0); i++)
515 {
516 /* We count the connected outputs that support the clone size. It
517 * doesn't matter if those outputs aren't actually On currently; we
518 * will turn them on in on_clone_changed().
519 */
520 if (mate_rr_output_info_is_connected (outputs[i]) &&
521 output_info_supports_mode (app, outputs[i], clone_width, clone_height))
522 {
523 num_outputs_with_clone_size++;
524 }
525 }
526
527 if (num_outputs_with_clone_size >= 2)
528 mirror_is_supported = TRUE(!(0));
529 }
530
531 return mirror_is_supported;
532}
533
534static void
535on_scale_btn_active_changed_cb (GtkWidget *widget,
536 App *app)
537{
538 gint scale;
539
540 if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)((((GtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_toggle_button_get_type ()))))))
))
541 return;
542
543 scale = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "scale"))((gint) (glong) (g_object_get_data (((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((widget)), (((GType) ((20) << (2)))
))))), "scale")))
;
544 g_settings_set_int (app->scale_settings, WINDOW_SCALE_KEY"window-scaling-factor", scale);
545}
546
547static void
548rebuild_scale_window (App *app)
549{
550 GtkRadioButton *group = NULL((void*)0);
551 gint32 scale;
552 int i;
553 const char *button_label[] = {_("auto detect")gettext ("auto detect"), _("100%")gettext ("100%"), _("200%")gettext ("200%"), NULL((void*)0)};
554
555 if (app->scale_bbox != NULL((void*)0))
556 return;
557
558 app->scale_bbox = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL);
559 gtk_container_set_border_width (GTK_CONTAINER (app->scale_bbox)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((app->scale_bbox)), ((gtk_container_get_type ()))))))
, 6);
560 gtk_container_add (GTK_CONTAINER (app->scale_vbox)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((app->scale_vbox)), ((gtk_container_get_type ()))))))
, app->scale_bbox);
561
562 scale = g_settings_get_int (app->scale_settings, WINDOW_SCALE_KEY"window-scaling-factor");
563
564 for (i = 0; button_label[i] != NULL((void*)0); i++)
565 {
566 GtkWidget *scale_btn;
567 scale_btn = gtk_radio_button_new_with_label_from_widget (group, button_label[i]);
568 if (!group)
569 group = GTK_RADIO_BUTTON (scale_btn)((((GtkRadioButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((scale_btn)), ((gtk_radio_button_get_type ()))))))
;
570 if (i == scale)
571 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (scale_btn)((((GtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((scale_btn)), ((gtk_toggle_button_get_type ()))))))
, TRUE(!(0)));
572
573 g_object_set_data (G_OBJECT (scale_btn)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((scale_btn)), (((GType) ((20) << (2))))))))
,
574 "scale",
575 GINT_TO_POINTER (i)((gpointer) (glong) (i)));
576
577 g_signal_connect (scale_btn,g_signal_connect_data ((scale_btn), ("toggled"), (((GCallback
) (on_scale_btn_active_changed_cb))), (app), ((void*)0), (GConnectFlags
) 0)
578 "toggled",g_signal_connect_data ((scale_btn), ("toggled"), (((GCallback
) (on_scale_btn_active_changed_cb))), (app), ((void*)0), (GConnectFlags
) 0)
579 G_CALLBACK (on_scale_btn_active_changed_cb),g_signal_connect_data ((scale_btn), ("toggled"), (((GCallback
) (on_scale_btn_active_changed_cb))), (app), ((void*)0), (GConnectFlags
) 0)
580 app)g_signal_connect_data ((scale_btn), ("toggled"), (((GCallback
) (on_scale_btn_active_changed_cb))), (app), ((void*)0), (GConnectFlags
) 0)
;
581 gtk_container_add (GTK_CONTAINER (app->scale_bbox)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((app->scale_bbox)), ((gtk_container_get_type ()))))))
, scale_btn);
582 }
583 gtk_widget_show_all (app->scale_bbox);
584}
585
586static void
587rebuild_mirror_screens (App *app)
588{
589 gboolean mirror_is_active;
590 gboolean mirror_is_supported;
591
592 g_signal_handlers_block_by_func (app->clone_checkbox, G_CALLBACK (on_clone_changed), app)g_signal_handlers_block_matched ((app->clone_checkbox), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (on_clone_changed))), (app))
;
593
594 mirror_is_active = app->current_configuration && mate_rr_config_get_clone (app->current_configuration);
595
596 /* If mirror_is_active, then it *must* be possible to turn mirroring off */
597 mirror_is_supported = mirror_is_active || mirror_screens_is_supported (app);
598
599 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (app->clone_checkbox)((((GtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((app->clone_checkbox)), ((gtk_toggle_button_get_type (
)))))))
, mirror_is_active);
600 gtk_widget_set_sensitive (app->clone_checkbox, mirror_is_supported);
601
602 g_signal_handlers_unblock_by_func (app->clone_checkbox, G_CALLBACK (on_clone_changed), app)g_signal_handlers_unblock_matched ((app->clone_checkbox), (
GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA)
, 0, 0, ((void*)0), (((GCallback) (on_clone_changed))), (app)
)
;
603}
604
605static void
606set_override_color (GtkWidget *widget,
607 const char *style,
608 GdkRGBA *rgba)
609{
610 gchar *css;
611 GtkCssProvider *provider;
612
613 provider = gtk_css_provider_new ();
614
615 css = g_strdup_printf ("* { %s: %s;}",
616 style,
617 gdk_rgba_to_string (rgba));
618 gtk_css_provider_load_from_data (provider, css, -1, NULL((void*)0));
619 g_free (css);
620
621 gtk_style_context_add_provider (gtk_widget_get_style_context (widget),
622 GTK_STYLE_PROVIDER (provider)((((GtkStyleProvider*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((provider)), ((gtk_style_provider_get_type (
)))))))
,
623 GTK_STYLE_PROVIDER_PRIORITY_APPLICATION600);
624 g_object_unref (provider);
625}
626
627static void
628rebuild_current_monitor_label (App *app)
629{
630 char *str, *tmp;
631 GdkRGBA color;
632 gboolean use_color;
633
634 if (app->current_output)
635 {
636 if (mate_rr_config_get_clone (app->current_configuration))
637 tmp = g_strdup (_("Mirror Screens"))g_strdup_inline (gettext ("Mirror Screens"));
638 else
639 tmp = g_strdup_printf (_("Monitor: %s")gettext ("Monitor: %s"), mate_rr_output_info_get_display_name (app->current_output));
640
641 str = g_strdup_printf ("<b>%s</b>", tmp);
642 mate_rr_labeler_get_rgba_for_output (app->labeler, app->current_output, &color);
643 use_color = TRUE(!(0));
644 g_free (tmp);
645 }
646 else
647 {
648 str = g_strdup_printf ("<b>%s</b>", _("Monitor")gettext ("Monitor"));
649 use_color = FALSE(0);
650 }
651
652 gtk_label_set_markup (GTK_LABEL (app->current_monitor_label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((app->current_monitor_label)), ((gtk_label_get_type ()
))))))
, str);
653 g_free (str);
654
655 if (use_color)
656 {
657 GdkRGBA black = { 0, 0, 0, 1.0 };
658
659 set_override_color (app->current_monitor_event_box, "background-color", &color);
660 set_override_color (app->current_monitor_label, "color", &black);
661 }
662
663 gtk_event_box_set_visible_window (GTK_EVENT_BOX (app->current_monitor_event_box)((((GtkEventBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((app->current_monitor_event_box)), ((gtk_event_box_get_type
()))))))
, use_color);
664}
665
666static void
667rebuild_on_off_radios (App *app)
668{
669 gboolean sensitive;
670 gboolean on_active;
671 gboolean off_active;
672
673 g_signal_handlers_block_by_func (app->monitor_on_radio, G_CALLBACK (monitor_on_off_toggled_cb), app)g_signal_handlers_block_matched ((app->monitor_on_radio), (
GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA)
, 0, 0, ((void*)0), (((GCallback) (monitor_on_off_toggled_cb)
)), (app))
;
674 g_signal_handlers_block_by_func (app->monitor_off_radio, G_CALLBACK (monitor_on_off_toggled_cb), app)g_signal_handlers_block_matched ((app->monitor_off_radio),
(GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (monitor_on_off_toggled_cb
))), (app))
;
675
676 sensitive = FALSE(0);
677 on_active = FALSE(0);
678 off_active = FALSE(0);
679
680 if (!mate_rr_config_get_clone (app->current_configuration) && app->current_output)
681 {
682 if (count_active_outputs (app) > 1 || !mate_rr_output_info_is_active (app->current_output))
683 sensitive = TRUE(!(0));
684 else
685 sensitive = FALSE(0);
686
687 on_active = mate_rr_output_info_is_active (app->current_output);
688 off_active = !on_active;
689 }
690
691 gtk_widget_set_sensitive (app->monitor_on_radio, sensitive);
692 gtk_widget_set_sensitive (app->monitor_off_radio, sensitive);
693
694 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (app->monitor_on_radio)((((GtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((app->monitor_on_radio)), ((gtk_toggle_button_get_type
()))))))
, on_active);
695 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (app->monitor_off_radio)((((GtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((app->monitor_off_radio)), ((gtk_toggle_button_get_type
()))))))
, off_active);
696
697 g_signal_handlers_unblock_by_func (app->monitor_on_radio, G_CALLBACK (monitor_on_off_toggled_cb), app)g_signal_handlers_unblock_matched ((app->monitor_on_radio)
, (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (monitor_on_off_toggled_cb
))), (app))
;
698 g_signal_handlers_unblock_by_func (app->monitor_off_radio, G_CALLBACK (monitor_on_off_toggled_cb), app)g_signal_handlers_unblock_matched ((app->monitor_off_radio
), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (monitor_on_off_toggled_cb
))), (app))
;
699}
700
701static char *
702make_resolution_string (guint width,
703 guint height)
704{
705 return g_strdup_printf (_("%u x %u")gettext ("%u x %u"), width, height);
706}
707
708static void
709find_best_mode (MateRRMode **modes,
710 guint *out_width,
711 guint *out_height)
712{
713 guint i;
714
715 *out_width = 0;
716 *out_height = 0;
717
718 for (i = 0; modes[i] != NULL((void*)0); i++)
719 {
720 guint w, h;
721
722 w = mate_rr_mode_get_width (modes[i]);
723 h = mate_rr_mode_get_height (modes[i]);
724
725 if ((w * h) > ((*out_width) * (*out_height)))
726 {
727 *out_width = w;
728 *out_height = h;
729 }
730 }
731}
732
733static void
734rebuild_resolution_combo (App *app)
735{
736 guint i;
737 MateRRMode **modes;
738 const char *current;
739 int output_width, output_height;
740
741 clear_combo (app->resolution_combo);
742
743 if (!(modes = get_current_modes (app))
744 || !app->current_output
745 || !mate_rr_output_info_is_active (app->current_output))
746 {
747 gtk_widget_set_sensitive (app->resolution_combo, FALSE(0));
748 return;
749 }
750
751 g_assert (app->current_output != NULL)do { if (app->current_output != ((void*)0)) ; else g_assertion_message_expr
("display-properties", "xrandr-capplet.c", 751, ((const char
*) (__func__)), "app->current_output != NULL"); } while (0
)
;
752
753 mate_rr_output_info_get_geometry (app->current_output, NULL((void*)0), NULL((void*)0), &output_width, &output_height);
754 g_assert (output_width != 0 && output_height != 0)do { if (output_width != 0 && output_height != 0) ; else
g_assertion_message_expr ("display-properties", "xrandr-capplet.c"
, 754, ((const char*) (__func__)), "output_width != 0 && output_height != 0"
); } while (0)
;
755
756 gtk_widget_set_sensitive (app->resolution_combo, TRUE(!(0)));
757
758 for (i = 0; modes[i] != NULL((void*)0); ++i)
759 {
760 guint width, height;
761
762 width = mate_rr_mode_get_width (modes[i]);
763 height = mate_rr_mode_get_height (modes[i]);
764
765 add_key (app->resolution_combo,
766 idle_free (make_resolution_string (width, height)),
767 width, height, 0, -1);
768 }
769
770 current = idle_free (make_resolution_string ((guint) output_width, (guint) output_height));
771
772 if (!combo_select (app->resolution_combo, current))
773 {
774 guint best_w, best_h;
775
776 find_best_mode (modes, &best_w, &best_h);
777 combo_select (app->resolution_combo, idle_free (make_resolution_string (best_w, best_h)));
778 }
779}
780
781static void
782rebuild_gui (App *app)
783{
784 gboolean sensitive;
785
786 /* We would break spectacularly if we recursed, so
787 * just assert if that happens
788 */
789 g_assert (app->ignore_gui_changes == FALSE)do { if (app->ignore_gui_changes == (0)) ; else g_assertion_message_expr
("display-properties", "xrandr-capplet.c", 789, ((const char
*) (__func__)), "app->ignore_gui_changes == FALSE"); } while
(0)
;
790
791 app->ignore_gui_changes = TRUE(!(0));
792
793 sensitive = app->current_output ? TRUE(!(0)) : FALSE(0);
794
795#if 0
796 g_debug ("rebuild gui, is on: %d", mate_rr_output_info_is_active (app->current_output));
797#endif
798
799 rebuild_mirror_screens (app);
800 rebuild_scale_window (app);
801 rebuild_current_monitor_label (app);
802 rebuild_on_off_radios (app);
803 rebuild_resolution_combo (app);
804 rebuild_rate_combo (app);
805 rebuild_rotation_combo (app);
806
807#if 0
808 g_debug ("sensitive: %d, on: %d", sensitive, mate_rr_output_info_is_active (app->current_output));
809#endif
810 gtk_widget_set_sensitive (app->panel_checkbox, sensitive);
811
812 gtk_widget_set_sensitive (app->primary_button, app->current_output && !mate_rr_output_info_get_primary(app->current_output));
813
814 app->ignore_gui_changes = FALSE(0);
815}
816
817static gboolean
818get_mode (GtkWidget *widget, int *width, int *height, int *freq, MateRRRotation *rot)
819{
820 GtkTreeIter iter;
821 GtkTreeModel *model;
822 GtkComboBox *box = GTK_COMBO_BOX (widget)((((GtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_combo_box_get_type ()))))))
;
823 int dummy;
824
825 if (!gtk_combo_box_get_active_iter (box, &iter))
826 return FALSE(0);
827
828 if (!width)
829 width = &dummy;
830
831 if (!height)
832 height = &dummy;
833
834 if (!freq)
835 freq = &dummy;
836
837 if (!rot)
838 rot = (MateRRRotation *)&dummy;
839
840 model = gtk_combo_box_get_model (box);
841 gtk_tree_model_get (model, &iter,
842 1, width,
843 2, height,
844 3, freq,
845 5, rot,
846 -1);
847
848 return TRUE(!(0));
849
850}
851
852static void
853on_rotation_changed (GtkComboBox *box, gpointer data)
854{
855 App *app = data;
856 MateRRRotation rotation;
857
858 if (!app->current_output)
859 return;
860
861 if (get_mode (app->rotation_combo, NULL((void*)0), NULL((void*)0), NULL((void*)0), &rotation))
862 mate_rr_output_info_set_rotation (app->current_output, rotation);
863
864 foo_scroll_area_invalidate (FOO_SCROLL_AREA (app->area)((((FooScrollArea*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((app->area)), ((foo_scroll_area_get_type ()))))))
);
865}
866
867static void
868on_rate_changed (GtkComboBox *box, gpointer data)
869{
870 App *app = data;
871 int rate;
872
873 if (!app->current_output)
874 return;
875
876 if (get_mode (app->refresh_combo, NULL((void*)0), NULL((void*)0), &rate, NULL((void*)0)))
877 mate_rr_output_info_set_refresh_rate (app->current_output, rate);
878
879 foo_scroll_area_invalidate (FOO_SCROLL_AREA (app->area)((((FooScrollArea*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((app->area)), ((foo_scroll_area_get_type ()))))))
);
880}
881
882static void
883select_resolution_for_current_output (App *app)
884{
885 MateRRMode **modes;
886 int width, height;
887 guint best_w, best_h;
888 int x, y;
889
890 mate_rr_output_info_get_geometry (app->current_output, &x, &y, NULL((void*)0), NULL((void*)0));
891
892 width = mate_rr_output_info_get_preferred_width (app->current_output);
893 height = mate_rr_output_info_get_preferred_height (app->current_output);
894
895 if (width != 0 && height != 0)
896 {
897 mate_rr_output_info_set_geometry (app->current_output, x, y, width, height);
898 return;
899 }
900
901 modes = get_current_modes (app);
902 if (!modes)
903 return;
904
905 find_best_mode (modes, &best_w, &best_h);
906 mate_rr_output_info_set_geometry (app->current_output, x, y, (int) best_w, (int) best_w);
907}
908
909static void
910monitor_on_off_toggled_cb (GtkToggleButton *toggle, gpointer data)
911{
912 App *app = data;
913 gboolean is_on;
914
915 if (!app->current_output)
916 return;
917
918 if (!gtk_toggle_button_get_active (toggle))
919 return;
920
921 if (GTK_WIDGET (toggle)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toggle)), ((gtk_widget_get_type ()))))))
== app->monitor_on_radio)
922 is_on = TRUE(!(0));
923 else if (GTK_WIDGET (toggle)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toggle)), ((gtk_widget_get_type ()))))))
== app->monitor_off_radio)
924 is_on = FALSE(0);
925 else
926 {
927 g_assert_not_reached ()do { g_assertion_message_expr ("display-properties", "xrandr-capplet.c"
, 927, ((const char*) (__func__)), ((void*)0)); } while (0)
;
928 return;
929 }
930
931 mate_rr_output_info_set_active (app->current_output, is_on);
932
933 if (is_on)
934 select_resolution_for_current_output (app); /* The refresh rate will be picked in rebuild_rate_combo() */
935
936 rebuild_gui (app);
937 foo_scroll_area_invalidate (FOO_SCROLL_AREA (app->area)((((FooScrollArea*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((app->area)), ((foo_scroll_area_get_type ()))))))
);
938}
939
940static void
941realign_outputs_after_resolution_change (App *app, MateRROutputInfo *output_that_changed, int old_width, int old_height)
942{
943 /* We find the outputs that were below or to the right of the output that
944 * changed, and realign them; we also do that for outputs that shared the
945 * right/bottom edges with the output that changed. The outputs that are
946 * above or to the left of that output don't need to change.
947 */
948
949 int i;
950 int old_right_edge, old_bottom_edge;
951 int dx, dy;
952 int x, y, width, height;
953 MateRROutputInfo **outputs;
954
955 g_assert (app->current_configuration != NULL)do { if (app->current_configuration != ((void*)0)) ; else g_assertion_message_expr
("display-properties", "xrandr-capplet.c", 955, ((const char
*) (__func__)), "app->current_configuration != NULL"); } while
(0)
;
956
957 mate_rr_output_info_get_geometry (output_that_changed, &x, &y, &width, &height);
958 if (width == old_width && height == old_height)
959 return;
960
961 old_right_edge = x + old_width;
962 old_bottom_edge = y + old_height;
963
964 dx = width - old_width;
965 dy = height - old_height;
966
967 outputs = mate_rr_config_get_outputs (app->current_configuration);
968
969 for (i = 0; outputs[i] != NULL((void*)0); i++)
970 {
971 int output_x, output_y;
972 int output_width, output_height;
973
974 if (outputs[i] == output_that_changed || mate_rr_output_info_is_connected (outputs[i]))
975 continue;
976
977 mate_rr_output_info_get_geometry (outputs[i], &output_x, &output_y, &output_width, &output_height);
978
979 if (output_x >= old_right_edge)
980 output_x += dx;
981 else if (output_x + output_width == old_right_edge)
982 output_x = x + width - output_width;
983
984 if (output_y >= old_bottom_edge)
985 output_y += dy;
986 else if (output_y + output_height == old_bottom_edge)
987 output_y = y + height - output_height;
988
989 mate_rr_output_info_set_geometry (outputs[i], output_x, output_y, output_width, output_height);
990 }
991}
992
993static void
994on_resolution_changed (GtkComboBox *box, gpointer data)
995{
996 App *app = data;
997 int old_width, old_height;
998 int x, y;
999 int width;
1000 int height;
1001
1002 if (!app->current_output)
1003 return;
1004
1005 mate_rr_output_info_get_geometry (app->current_output, &x, &y, &old_width, &old_height);
1006
1007 if (get_mode (app->resolution_combo, &width, &height, NULL((void*)0), NULL((void*)0)))
1008 {
1009 mate_rr_output_info_set_geometry (app->current_output, x, y, width, height);
1010
1011 if (width == 0 || height == 0)
1012 mate_rr_output_info_set_active (app->current_output, FALSE(0));
1013 else
1014 mate_rr_output_info_set_active (app->current_output, TRUE(!(0)));
1015 }
1016
1017 realign_outputs_after_resolution_change (app, app->current_output, old_width, old_height);
1018
1019 rebuild_rate_combo (app);
1020 rebuild_rotation_combo (app);
1021
1022 foo_scroll_area_invalidate (FOO_SCROLL_AREA (app->area)((((FooScrollArea*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((app->area)), ((foo_scroll_area_get_type ()))))))
);
1023}
1024
1025static void
1026lay_out_outputs_horizontally (App *app)
1027{
1028 int i;
1029 int x;
1030 MateRROutputInfo **outputs;
1031
1032 /* Lay out all the monitors horizontally when "mirror screens" is turned
1033 * off, to avoid having all of them overlapped initially. We put the
1034 * outputs turned off on the right-hand side.
1035 */
1036
1037 x = 0;
1038
1039 /* First pass, all "on" outputs */
1040 outputs = mate_rr_config_get_outputs (app->current_configuration);
1041
1042 for (i = 0; outputs[i]; ++i)
1043 {
1044 int width, height;
1045 if (mate_rr_output_info_is_connected (outputs[i]) &&mate_rr_output_info_is_active (outputs[i]))
1046 {
1047 mate_rr_output_info_get_geometry (outputs[i], NULL((void*)0), NULL((void*)0), &width, &height);
1048 mate_rr_output_info_set_geometry (outputs[i], x, 0, width, height);
1049 x += width;
1050 }
1051 }
1052
1053 /* Second pass, all the black screens */
1054
1055 for (i = 0; outputs[i]; ++i)
1056 {
1057 int width, height;
1058 if (!(mate_rr_output_info_is_connected (outputs[i]) && mate_rr_output_info_is_active (outputs[i])))
1059 {
1060 mate_rr_output_info_get_geometry (outputs[i], NULL((void*)0), NULL((void*)0), &width, &height);
1061 mate_rr_output_info_set_geometry (outputs[i], x, 0, width, height);
1062 x += width;
1063 }
1064 }
1065
1066}
1067
1068static void
1069on_clone_changed (GtkWidget *box, gpointer data)
1070{
1071 App *app = data;
1072
1073 mate_rr_config_set_clone (app->current_configuration, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (app->clone_checkbox)((((GtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((app->clone_checkbox)), ((gtk_toggle_button_get_type (
)))))))
));
1074
1075 if (mate_rr_config_get_clone (app->current_configuration)) {
1
Assuming the condition is true
2
Taking true branch
1076 guint i;
1077 guint width;
3
'width' declared without an initial value
1078 guint height;
1079 MateRROutputInfo **outputs = mate_rr_config_get_outputs (app->current_configuration);
1080
1081 for (i = 0; outputs[i]; ++i) {
4
Loop condition is true. Entering loop body
1082 if (mate_rr_output_info_is_connected(outputs[i])) {
5
Assuming the condition is true
6
Taking true branch
1083 app->current_output = outputs[i];
1084 break;
1085 }
1086 }
1087
1088 /* Turn on all the connected screens that support the best clone mode.
1089 * The user may hit "Mirror Screens", but he shouldn't have to turn on
1090 * all the required outputs as well.
1091 */
1092
1093 get_clone_size (app->screen, &width, &height);
7
Calling 'get_clone_size'
10
Returning from 'get_clone_size'
1094
1095 for (i = 0; outputs[i]; i++) {
11
Loop condition is true. Entering loop body
1096 int x, y;
1097
1098 if (output_info_supports_mode (app, outputs[i], width, height)) {
12
3rd function call argument is an uninitialized value
1099 mate_rr_output_info_set_active (outputs[i], TRUE(!(0)));
1100 mate_rr_output_info_get_geometry (outputs[i], &x, &y, NULL((void*)0), NULL((void*)0));
1101 mate_rr_output_info_set_geometry (outputs[i], x, y, (int) width, (int) height);
1102 }
1103 }
1104 } else {
1105 if (output_overlaps (app->current_output, app->current_configuration))
1106 lay_out_outputs_horizontally (app);
1107 }
1108
1109 rebuild_gui (app);
1110}
1111
1112#define SPACE15 15
1113#define MARGIN15 15
1114
1115static void
1116get_geometry (MateRROutputInfo *output,
1117 int *w,
1118 int *h)
1119{
1120 MateRRRotation rotation;
1121
1122 if (mate_rr_output_info_is_active (output)) {
1123 mate_rr_output_info_get_geometry (output, NULL((void*)0), NULL((void*)0), w, h);
1124 } else {
1125 *h = mate_rr_output_info_get_preferred_height (output);
1126 *w = mate_rr_output_info_get_preferred_width (output);
1127 }
1128 rotation = mate_rr_output_info_get_rotation (output);
1129 if ((rotation & MATE_RR_ROTATION_90) ||
1130 (rotation & MATE_RR_ROTATION_270)) {
1131 int tmp;
1132 tmp = *h;
1133 *h = *w;
1134 *w = tmp;
1135 }
1136}
1137
1138static GList *
1139list_connected_outputs (App *app,
1140 int *total_w,
1141 int *total_h)
1142{
1143 guint i;
1144 int dummy;
1145 GList *result = NULL((void*)0);
1146 MateRROutputInfo **outputs;
1147
1148 if (!total_w)
1149 total_w = &dummy;
1150 if (!total_h)
1151 total_h = &dummy;
1152
1153 *total_w = 0;
1154 *total_h = 0;
1155
1156 outputs = mate_rr_config_get_outputs(app->current_configuration);
1157 for (i = 0; outputs[i] != NULL((void*)0); ++i) {
1158 if (mate_rr_output_info_is_connected (outputs[i])) {
1159 int w, h;
1160
1161 result = g_list_prepend (result, outputs[i]);
1162
1163 get_geometry (outputs[i], &w, &h);
1164
1165 *total_w += w;
1166 *total_h += h;
1167 }
1168 }
1169
1170 return g_list_reverse (result);
1171}
1172
1173static guint
1174get_n_connected (App *app)
1175{
1176 GList *connected_outputs = list_connected_outputs (app, NULL((void*)0), NULL((void*)0));
1177 guint n = g_list_length (connected_outputs);
1178
1179 g_list_free (connected_outputs);
1180
1181 return n;
1182}
1183
1184static double
1185compute_scale (App *app)
1186{
1187 int available_w, available_h;
1188 int total_w, total_h;
1189 guint n_monitors;
1190 GdkRectangle viewport;
1191 GList *connected_outputs;
1192
1193 foo_scroll_area_get_viewport (FOO_SCROLL_AREA (app->area)((((FooScrollArea*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((app->area)), ((foo_scroll_area_get_type ()))))))
, &viewport);
1194
1195 connected_outputs = list_connected_outputs (app, &total_w, &total_h);
1196
1197 n_monitors = g_list_length (connected_outputs);
1198
1199 g_list_free (connected_outputs);
1200
1201 available_w = viewport.width - 2 * MARGIN15 - ((int) n_monitors - 1) * SPACE15;
1202 available_h = viewport.height - 2 * MARGIN15 - ((int) n_monitors - 1) * SPACE15;
1203
1204 return MIN ((double)available_w / total_w, (double)available_h / total_h)((((double)available_w / total_w) < ((double)available_h /
total_h)) ? ((double)available_w / total_w) : ((double)available_h
/ total_h))
;
1205}
1206
1207typedef struct Edge
1208{
1209 MateRROutputInfo *output;
1210 int x1, y1;
1211 int x2, y2;
1212} Edge;
1213
1214typedef struct Snap
1215{
1216 Edge *snapper; /* Edge that should be snapped */
1217 Edge *snappee;
1218 int dy, dx;
1219} Snap;
1220
1221static void
1222add_edge (MateRROutputInfo *output, int x1, int y1, int x2, int y2, GArray *edges)
1223{
1224 Edge e;
1225
1226 e.x1 = x1;
1227 e.x2 = x2;
1228 e.y1 = y1;
1229 e.y2 = y2;
1230 e.output = output;
1231
1232 g_array_append_val (edges, e)g_array_append_vals (edges, &(e), 1);
1233}
1234
1235static void
1236list_edges_for_output (MateRROutputInfo *output, GArray *edges)
1237{
1238 int x, y, w, h;
1239
1240 mate_rr_output_info_get_geometry (output, &x, &y, &w, &h);
1241 get_geometry (output, &w, &h); /* accounts for rotation */
1242
1243 /* Top, Bottom, Left, Right */
1244 add_edge (output, x, y, x + w, y, edges);
1245 add_edge (output, x, y + h, x + w, y + h, edges);
1246 add_edge (output, x, y, x, y + h, edges);
1247 add_edge (output, x + w, y, x + w, y + h, edges);
1248}
1249
1250static void
1251list_edges (MateRRConfig *config, GArray *edges)
1252{
1253 int i;
1254 MateRROutputInfo **outputs = mate_rr_config_get_outputs (config);
1255
1256 for (i = 0; outputs[i]; ++i)
1257 {
1258 if (mate_rr_output_info_is_connected (outputs[i]))
1259 list_edges_for_output (outputs[i], edges);
1260 }
1261}
1262
1263static gboolean
1264overlap (int s1, int e1, int s2, int e2)
1265{
1266 return (!(e1 < s2 || s1 >= e2));
1267}
1268
1269static gboolean
1270horizontal_overlap (Edge *snapper, Edge *snappee)
1271{
1272 if (snapper->y1 != snapper->y2 || snappee->y1 != snappee->y2)
1273 return FALSE(0);
1274
1275 return overlap (snapper->x1, snapper->x2, snappee->x1, snappee->x2);
1276}
1277
1278static gboolean
1279vertical_overlap (Edge *snapper, Edge *snappee)
1280{
1281 if (snapper->x1 != snapper->x2 || snappee->x1 != snappee->x2)
1282 return FALSE(0);
1283
1284 return overlap (snapper->y1, snapper->y2, snappee->y1, snappee->y2);
1285}
1286
1287static void
1288add_snap (GArray *snaps, Snap snap)
1289{
1290 if (ABS (snap.dx)(((snap.dx) < 0) ? -(snap.dx) : (snap.dx)) <= 200 || ABS (snap.dy)(((snap.dy) < 0) ? -(snap.dy) : (snap.dy)) <= 200)
1291 g_array_append_val (snaps, snap)g_array_append_vals (snaps, &(snap), 1);
1292}
1293
1294static void
1295add_edge_snaps (Edge *snapper, Edge *snappee, GArray *snaps)
1296{
1297 Snap snap;
1298
1299 snap.snapper = snapper;
1300 snap.snappee = snappee;
1301
1302 if (horizontal_overlap (snapper, snappee))
1303 {
1304 snap.dx = 0;
1305 snap.dy = snappee->y1 - snapper->y1;
1306
1307 add_snap (snaps, snap);
1308 }
1309 else if (vertical_overlap (snapper, snappee))
1310 {
1311 snap.dy = 0;
1312 snap.dx = snappee->x1 - snapper->x1;
1313
1314 add_snap (snaps, snap);
1315 }
1316
1317 /* Corner snaps */
1318 /* 1->1 */
1319 snap.dx = snappee->x1 - snapper->x1;
1320 snap.dy = snappee->y1 - snapper->y1;
1321
1322 add_snap (snaps, snap);
1323
1324 /* 1->2 */
1325 snap.dx = snappee->x2 - snapper->x1;
1326 snap.dy = snappee->y2 - snapper->y1;
1327
1328 add_snap (snaps, snap);
1329
1330 /* 2->2 */
1331 snap.dx = snappee->x2 - snapper->x2;
1332 snap.dy = snappee->y2 - snapper->y2;
1333
1334 add_snap (snaps, snap);
1335
1336 /* 2->1 */
1337 snap.dx = snappee->x1 - snapper->x2;
1338 snap.dy = snappee->y1 - snapper->y2;
1339
1340 add_snap (snaps, snap);
1341}
1342
1343static void
1344list_snaps (MateRROutputInfo *output, GArray *edges, GArray *snaps)
1345{
1346 guint i;
1347
1348 for (i = 0; i < edges->len; ++i) {
1349 Edge *output_edge = &(g_array_index (edges, Edge, i)(((Edge*) (void *) (edges)->data) [(i)]));
1350
1351 if (output_edge->output == output) {
1352 guint j;
1353
1354 for (j = 0; j < edges->len; ++j) {
1355 Edge *edge = &(g_array_index (edges, Edge, j)(((Edge*) (void *) (edges)->data) [(j)]));
1356
1357 if (edge->output != output)
1358 add_edge_snaps (output_edge, edge, snaps);
1359 }
1360 }
1361 }
1362}
1363
1364#if 0
1365static void
1366print_edge (Edge *edge)
1367{
1368 g_debug ("(%d %d %d %d)", edge->x1, edge->y1, edge->x2, edge->y2);
1369}
1370#endif
1371
1372static gboolean
1373corner_on_edge (int x, int y, Edge *e)
1374{
1375 if (x == e->x1 && x == e->x2 && y >= e->y1 && y <= e->y2)
1376 return TRUE(!(0));
1377
1378 if (y == e->y1 && y == e->y2 && x >= e->x1 && x <= e->x2)
1379 return TRUE(!(0));
1380
1381 return FALSE(0);
1382}
1383
1384static gboolean
1385edges_align (Edge *e1, Edge *e2)
1386{
1387 if (corner_on_edge (e1->x1, e1->y1, e2))
1388 return TRUE(!(0));
1389
1390 if (corner_on_edge (e2->x1, e2->y1, e1))
1391 return TRUE(!(0));
1392
1393 return FALSE(0);
1394}
1395
1396static gboolean
1397output_is_aligned (MateRROutputInfo *output, GArray *edges)
1398{
1399 gboolean result = FALSE(0);
1400 guint i;
1401
1402 for (i = 0; i < edges->len; ++i) {
1403 Edge *output_edge = &(g_array_index (edges, Edge, i)(((Edge*) (void *) (edges)->data) [(i)]));
1404
1405 if (output_edge->output == output) {
1406 guint j;
1407
1408 for (j = 0; j < edges->len; ++j) {
1409 Edge *edge = &(g_array_index (edges, Edge, j)(((Edge*) (void *) (edges)->data) [(j)]));
1410
1411 /* We are aligned if an output edge matches
1412 * an edge of another output
1413 */
1414 if ((edge->output != output_edge->output) &&
1415 edges_align (output_edge, edge)) {
1416 result = TRUE(!(0));
1417 goto done;
1418 }
1419 }
1420 }
1421 }
1422done:
1423
1424 return result;
1425}
1426
1427static void
1428get_output_rect (MateRROutputInfo *output, GdkRectangle *rect)
1429{
1430 mate_rr_output_info_get_geometry (output, &rect->x, &rect->y, &rect->width, &rect->height);
1431 get_geometry (output, &rect->width, &rect->height); /* accounts for rotation */
1432}
1433
1434static gboolean
1435output_overlaps (MateRROutputInfo *output, MateRRConfig *config)
1436{
1437 int i;
1438 GdkRectangle output_rect;
1439 MateRROutputInfo **outputs;
1440
1441 get_output_rect (output, &output_rect);
1442
1443 outputs = mate_rr_config_get_outputs (config);
1444 for (i = 0; outputs[i]; ++i)
1445 {
1446 if (outputs[i] != output && mate_rr_output_info_is_connected (outputs[i]))
1447 {
1448 GdkRectangle other_rect;
1449
1450 get_output_rect (outputs[i], &other_rect);
1451 if (gdk_rectangle_intersect (&output_rect, &other_rect, NULL((void*)0)))
1452 return TRUE(!(0));
1453 }
1454 }
1455
1456 return FALSE(0);
1457}
1458
1459static gboolean
1460mate_rr_config_is_aligned (MateRRConfig *config, GArray *edges)
1461{
1462 int i;
1463 gboolean result = TRUE(!(0));
1464 MateRROutputInfo **outputs;
1465
1466 outputs = mate_rr_config_get_outputs(config);
1467 for (i = 0; outputs[i]; ++i)
1468 {
1469 if (mate_rr_output_info_is_connected (outputs[i]))
1470 {
1471 if (!output_is_aligned (outputs[i], edges))
1472 return FALSE(0);
1473
1474 if (output_overlaps (outputs[i], config))
1475 return FALSE(0);
1476 }
1477 }
1478
1479 return result;
1480}
1481
1482struct GrabInfo
1483{
1484 int grab_x;
1485 int grab_y;
1486 int output_x;
1487 int output_y;
1488};
1489
1490static gboolean
1491is_corner_snap (const Snap *s)
1492{
1493 return s->dx != 0 && s->dy != 0;
1494}
1495
1496static int
1497compare_snaps (gconstpointer v1, gconstpointer v2)
1498{
1499 const Snap *s1 = v1;
1500 const Snap *s2 = v2;
1501 int sv1 = MAX (ABS (s1->dx), ABS (s1->dy))((((((s1->dx) < 0) ? -(s1->dx) : (s1->dx))) > (
(((s1->dy) < 0) ? -(s1->dy) : (s1->dy)))) ? ((((s1
->dx) < 0) ? -(s1->dx) : (s1->dx))) : ((((s1->
dy) < 0) ? -(s1->dy) : (s1->dy))))
;
1502 int sv2 = MAX (ABS (s2->dx), ABS (s2->dy))((((((s2->dx) < 0) ? -(s2->dx) : (s2->dx))) > (
(((s2->dy) < 0) ? -(s2->dy) : (s2->dy)))) ? ((((s2
->dx) < 0) ? -(s2->dx) : (s2->dx))) : ((((s2->
dy) < 0) ? -(s2->dy) : (s2->dy))))
;
1503 int d;
1504
1505 d = sv1 - sv2;
1506
1507 /* This snapping algorithm is good enough for rock'n'roll, but
1508 * this is probably a better:
1509 *
1510 * First do a horizontal/vertical snap, then
1511 * with the new coordinates from that snap,
1512 * do a corner snap.
1513 *
1514 * Right now, it's confusing that corner snapping
1515 * depends on the distance in an axis that you can't actually see.
1516 *
1517 */
1518 if (d == 0)
1519 {
1520 if (is_corner_snap (s1) && !is_corner_snap (s2))
1521 return -1;
1522 else if (is_corner_snap (s2) && !is_corner_snap (s1))
1523 return 1;
1524 else
1525 return 0;
1526 }
1527 else
1528 {
1529 return d;
1530 }
1531}
1532
1533/* Sets a mouse cursor for a widget's window. As a hack, you can pass
1534 * GDK_BLANK_CURSOR to mean "set the cursor to NULL" (i.e. reset the widget's
1535 * window's cursor to its default).
1536 */
1537static void
1538set_cursor (GtkWidget *widget, GdkCursorType type)
1539{
1540 GdkCursor *cursor;
1541 GdkWindow *window;
1542
1543 if (type == GDK_BLANK_CURSOR)
1544 cursor = NULL((void*)0);
1545 else
1546 cursor = gdk_cursor_new_for_display (gtk_widget_get_display (widget), type);
1547
1548 window = gtk_widget_get_window (widget);
1549
1550 if (window)
1551 gdk_window_set_cursor (window, cursor);
1552
1553 if (cursor)
1554 g_object_unref (cursor);
1555}
1556
1557static void
1558set_monitors_tooltip (App *app, gboolean is_dragging)
1559{
1560 const char *text;
1561
1562 if (is_dragging)
1563 text = NULL((void*)0);
1564 else
1565 text = _("Select a monitor to change its properties; drag it to rearrange its placement.")gettext ("Select a monitor to change its properties; drag it to rearrange its placement."
)
;
1566
1567 gtk_widget_set_tooltip_text (app->area, text);
1568}
1569
1570static void
1571on_output_event (FooScrollArea *area,
1572 FooScrollAreaEvent *event,
1573 gpointer data)
1574{
1575 MateRROutputInfo *output = data;
1576 App *app = g_object_get_data (G_OBJECT (area)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((area)), (((GType) ((20) << (2))))))))
, "app");
1577
1578 /* If the mouse is inside the outputs, set the cursor to "you can move me". See
1579 * on_canvas_event() for where we reset the cursor to the default if it
1580 * exits the outputs' area.
1581 */
1582 if (!mate_rr_config_get_clone (app->current_configuration) && get_n_connected (app) > 1)
1583 set_cursor (GTK_WIDGET (area)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((area)), ((gtk_widget_get_type ()))))))
, GDK_FLEUR);
1584
1585 if (event->type == FOO_BUTTON_PRESS)
1586 {
1587 GrabInfo *info;
1588
1589 app->current_output = output;
1590
1591 rebuild_gui (app);
1592 set_monitors_tooltip (app, TRUE(!(0)));
1593
1594 if (!mate_rr_config_get_clone (app->current_configuration) && get_n_connected (app) > 1)
1595 {
1596 int output_x, output_y;
1597 mate_rr_output_info_get_geometry (output, &output_x, &output_y, NULL((void*)0), NULL((void*)0));
1598
1599 foo_scroll_area_begin_grab (area, on_output_event, data);
1600
1601 info = g_new0 (GrabInfo, 1)((GrabInfo *) g_malloc0_n ((1), sizeof (GrabInfo)));
1602 info->grab_x = event->x;
1603 info->grab_y = event->y;
1604 info->output_x = output_x;
1605 info->output_y = output_y;
1606
1607 g_object_set_data (G_OBJECT (output)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((output)), (((GType) ((20) << (2))))))))
, "grab-info", info);
1608 }
1609
1610 foo_scroll_area_invalidate (area);
1611 }
1612 else
1613 {
1614 if (foo_scroll_area_is_grabbed (area))
1615 {
1616 GrabInfo *info = g_object_get_data (G_OBJECT (output)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((output)), (((GType) ((20) << (2))))))))
, "grab-info");
1617 double scale = compute_scale (app);
1618 int old_x, old_y;
1619 int width, height;
1620 int new_x, new_y;
1621 guint i;
1622 GArray *edges, *snaps, *new_edges;
1623
1624 mate_rr_output_info_get_geometry (output, &old_x, &old_y, &width, &height);
1625 new_x = info->output_x + (int) ((double)(event->x - info->grab_x) / scale);
1626 new_y = info->output_y + (int) ((double)(event->y - info->grab_y) / scale);
1627
1628 mate_rr_output_info_set_geometry (output, new_x, new_y, width, height);
1629
1630 edges = g_array_new (TRUE(!(0)), TRUE(!(0)), sizeof (Edge));
1631 snaps = g_array_new (TRUE(!(0)), TRUE(!(0)), sizeof (Snap));
1632 new_edges = g_array_new (TRUE(!(0)), TRUE(!(0)), sizeof (Edge));
1633
1634 list_edges (app->current_configuration, edges);
1635 list_snaps (output, edges, snaps);
1636
1637 g_array_sort (snaps, compare_snaps);
1638
1639 mate_rr_output_info_set_geometry (output, new_x, new_y, width, height);
1640
1641 for (i = 0; i < snaps->len; ++i)
1642 {
1643 Snap *snap = &(g_array_index (snaps, Snap, i)(((Snap*) (void *) (snaps)->data) [(i)]));
1644 GArray *new_edges = g_array_new (TRUE(!(0)), TRUE(!(0)), sizeof (Edge));
1645
1646 mate_rr_output_info_set_geometry (output, new_x + snap->dx, new_y + snap->dy, width, height);
1647
1648 g_array_set_size (new_edges, 0);
1649 list_edges (app->current_configuration, new_edges);
1650
1651 if (mate_rr_config_is_aligned (app->current_configuration, new_edges))
1652 {
1653 g_array_free (new_edges, TRUE(!(0)));
1654 break;
1655 }
1656 else
1657 {
1658 mate_rr_output_info_set_geometry (output, info->output_x, info->output_y, width, height);
1659 }
1660 }
1661
1662 g_array_free (new_edges, TRUE(!(0)));
1663 g_array_free (snaps, TRUE(!(0)));
1664 g_array_free (edges, TRUE(!(0)));
1665
1666 if (event->type == FOO_BUTTON_RELEASE)
1667 {
1668 foo_scroll_area_end_grab (area);
1669 set_monitors_tooltip (app, FALSE(0));
1670
1671 g_free (g_object_get_data (G_OBJECT (output)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((output)), (((GType) ((20) << (2))))))))
, "grab-info"));
1672 g_object_set_data (G_OBJECT (output)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((output)), (((GType) ((20) << (2))))))))
, "grab-info", NULL((void*)0));
1673
1674#if 0
1675 g_debug ("new position: %d %d %d %d", output->x, output->y, output->width, output->height);
1676#endif
1677 }
1678
1679 foo_scroll_area_invalidate (area);
1680 }
1681 }
1682}
1683
1684static void
1685on_canvas_event (FooScrollArea *area,
1686 FooScrollAreaEvent *event,
1687 gpointer data)
1688{
1689 /* If the mouse exits the outputs, reset the cursor to the default. See
1690 * on_output_event() for where we set the cursor to the movement cursor if
1691 * it is over one of the outputs.
1692 */
1693 set_cursor (GTK_WIDGET (area)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((area)), ((gtk_widget_get_type ()))))))
, GDK_BLANK_CURSOR);
1694}
1695
1696static PangoLayout *
1697get_display_name (App *app,
1698 MateRROutputInfo *output)
1699{
1700 char *text;
1701 PangoLayout * layout;
1702
1703 if (mate_rr_config_get_clone (app->current_configuration)) {
1704 /* Translators: this is the feature where what you see on your laptop's
1705 * screen is the same as your external monitor. Here, "Mirror" is being
1706 * used as an adjective, not as a verb. For example, the Spanish
1707 * translation could be "Pantallas en Espejo", *not* "Espejar Pantallas".
1708 */
1709 text = g_strdup_printf (_("Mirror Screens")gettext ("Mirror Screens"));
1710 }
1711 else {
1712 text = 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));
1713 }
1714 layout = gtk_widget_create_pango_layout (GTK_WIDGET (app->area)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((app->area)), ((gtk_widget_get_type ()))))))
, text);
1715 pango_layout_set_markup (layout, text, -1);
1716 g_free (text);
1717 pango_layout_set_alignment (layout, PANGO_ALIGN_CENTER);
1718 return layout;
1719}
1720
1721static void
1722paint_background (FooScrollArea *area,
1723 cairo_t *cr)
1724{
1725 GdkRectangle viewport;
1726 GtkWidget *widget;
1727 GtkStyleContext *widget_style;
1728 GdkRGBA *base_color = NULL((void*)0);
1729 GdkRGBA dark_color;
1730
1731 widget = GTK_WIDGET (area)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((area)), ((gtk_widget_get_type ()))))))
;
1732
1733 foo_scroll_area_get_viewport (area, &viewport);
1734
1735 widget_style = gtk_widget_get_style_context (widget);
1736
1737 gtk_style_context_save (widget_style);
1738 gtk_style_context_set_state (widget_style, GTK_STATE_FLAG_SELECTED);
1739 gtk_style_context_get (widget_style,
1740 gtk_style_context_get_state (widget_style),
1741 GTK_STYLE_PROPERTY_BACKGROUND_COLOR"background-color", &base_color,
1742 NULL((void*)0));
1743 gtk_style_context_restore (widget_style);
1744 gdk_cairo_set_source_rgba(cr, base_color);
1745 gdk_rgba_free (base_color);
1746
1747 cairo_rectangle (cr,
1748 viewport.x, viewport.y,
1749 viewport.width, viewport.height);
1750
1751 cairo_fill_preserve (cr);
1752
1753 foo_scroll_area_add_input_from_fill (area, cr, on_canvas_event, NULL((void*)0));
1754
1755 gtk_style_context_save (widget_style);
1756 gtk_style_context_set_state (widget_style, GTK_STATE_FLAG_SELECTED);
1757 mate_desktop_gtk_style_get_dark_color (widget_style,
1758 gtk_style_context_get_state (widget_style),
1759 &dark_color);
1760 gtk_style_context_restore (widget_style);
1761 gdk_cairo_set_source_rgba (cr, &dark_color);
1762
1763 cairo_stroke (cr);
1764}
1765
1766static void
1767paint_output (App *app,
1768 cairo_t *cr,
1769 guint i)
1770{
1771 int w, h;
1772 double scale = compute_scale (app);
1773 double x, y;
1774 int output_x, output_y;
1775 MateRRRotation rotation;
1776 int total_w, total_h;
1777 GList *connected_outputs = list_connected_outputs (app, &total_w, &total_h);
1778 MateRROutputInfo *output = g_list_nth_data (connected_outputs, i);
1779 PangoLayout *layout = get_display_name (app, output);
1780 PangoRectangle ink_extent, log_extent;
1781 GdkRectangle viewport;
1782 GdkRGBA output_color;
1783 double r, g, b;
1784 double available_w;
1785 double factor;
1786
1787 cairo_save (cr);
1788
1789 foo_scroll_area_get_viewport (FOO_SCROLL_AREA (app->area)((((FooScrollArea*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((app->area)), ((foo_scroll_area_get_type ()))))))
, &viewport);
1790
1791 get_geometry (output, &w, &h);
1792
1793#if 0
1794 g_debug ("%s (%p) geometry %d %d %d", output->name, output,
1795 w, h, output->rate);
1796#endif
1797
1798 viewport.height -= 2 * MARGIN15;
1799 viewport.width -= 2 * MARGIN15;
1800
1801 mate_rr_output_info_get_geometry (output, &output_x, &output_y, NULL((void*)0), NULL((void*)0));
1802 x = output_x * scale + MARGIN15 + (viewport.width - total_w * scale) / 2.0;
1803 y = output_y * scale + MARGIN15 + (viewport.height - total_h * scale) / 2.0;
1804
1805#if 0
1806 g_debug ("scaled: %f %f", x, y);
1807
1808 g_debug ("scale: %f", scale);
1809
1810 g_debug ("%f %f %f %f", x, y, w * scale + 0.5, h * scale + 0.5);
1811#endif
1812
1813 cairo_translate (cr,
1814 x + (w * scale + 0.5) / 2,
1815 y + (h * scale + 0.5) / 2);
1816
1817 /* rotation is already applied in get_geometry */
1818
1819 rotation = mate_rr_output_info_get_rotation (output);
1820 if (rotation & MATE_RR_REFLECT_X)
1821 cairo_scale (cr, -1, 1);
1822
1823 if (rotation & MATE_RR_REFLECT_Y)
1824 cairo_scale (cr, 1, -1);
1825
1826 cairo_translate (cr,
1827 - x - (w * scale + 0.5) / 2,
1828 - y - (h * scale + 0.5) / 2);
1829
1830 cairo_rectangle (cr, x, y, w * scale + 0.5, h * scale + 0.5);
1831 cairo_clip_preserve (cr);
1832
1833 mate_rr_labeler_get_rgba_for_output (app->labeler, output, &output_color);
1834 r = output_color.red;
1835 g = output_color.green;
1836 b = output_color.blue;
1837
1838 if (!mate_rr_output_info_is_active (output))
1839 {
1840 /* If the output is turned off, just darken the selected color */
1841 r *= 0.2;
1842 g *= 0.2;
1843 b *= 0.2;
1844 }
1845
1846 cairo_set_source_rgba (cr, r, g, b, 1.0);
1847
1848 foo_scroll_area_add_input_from_fill (FOO_SCROLL_AREA (app->area)((((FooScrollArea*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((app->area)), ((foo_scroll_area_get_type ()))))))
,
1849 cr, on_output_event, output);
1850 cairo_fill (cr);
1851
1852 if (output == app->current_output)
1853 {
1854 cairo_rectangle (cr, x + 2, y + 2, w * scale + 0.5 - 4, h * scale + 0.5 - 4);
1855
1856 cairo_set_line_width (cr, 4);
1857 cairo_set_source_rgba (cr, 0.33, 0.43, 0.57, 1.0);
1858 cairo_stroke (cr);
1859 }
1860
1861 cairo_rectangle (cr, x + 0.5, y + 0.5, w * scale + 0.5 - 1, h * scale + 0.5 - 1);
1862
1863 cairo_set_line_width (cr, 1);
1864 cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, 1.0);
1865
1866 cairo_stroke (cr);
1867 cairo_set_line_width (cr, 2);
1868
1869 layout_set_font (layout, "Sans 12");
1870 pango_layout_get_pixel_extents (layout, &ink_extent, &log_extent);
1871
1872 available_w = w * scale + 0.5 - 6; /* Same as the inner rectangle's width, minus 1 pixel of padding on each side */
1873 if (available_w < ink_extent.width)
1874 factor = available_w / ink_extent.width;
1875 else
1876 factor = 1.0;
1877
1878 cairo_move_to (cr,
1879 x + ((w * scale + 0.5) - factor * log_extent.width) / 2,
1880 y + ((h * scale + 0.5) - factor * log_extent.height) / 2);
1881
1882 cairo_scale (cr, factor, factor);
1883
1884 if (mate_rr_output_info_is_active (output))
1885 cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
1886 else
1887 cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
1888
1889 pango_cairo_show_layout (cr, layout);
1890
1891 cairo_restore (cr);
1892
1893 g_object_unref (layout);
1894}
1895
1896static void
1897on_area_paint (FooScrollArea *area,
1898 cairo_t *cr,
1899 gpointer data)
1900{
1901 App *app = data;
1902 GList *connected_outputs = NULL((void*)0);
1903 GList *list;
1904
1905 paint_background (area, cr);
1906
1907 if (!app->current_configuration)
1908 return;
1909
1910 connected_outputs = list_connected_outputs (app, NULL((void*)0), NULL((void*)0));
1911
1912#if 0
1913 double scale;
1914 scale = compute_scale (app);
1915 g_debug ("scale: %f", scale);
1916#endif
1917
1918 for (list = connected_outputs; list != NULL((void*)0); list = list->next)
1919 {
1920 int pos;
1921
1922 if ((pos = g_list_position (connected_outputs, list)) != -1)
1923 paint_output (app, cr, (guint) pos);
1924
1925 if (mate_rr_config_get_clone (app->current_configuration))
1926 break;
1927 }
1928}
1929
1930static void
1931make_text_combo (GtkWidget *widget, int sort_column)
1932{
1933 GtkComboBox *box = GTK_COMBO_BOX (widget)((((GtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_combo_box_get_type ()))))))
;
1934 GtkListStore *store = gtk_list_store_new (
1935 6,
1936 G_TYPE_STRING((GType) ((16) << (2))), /* Text */
1937 G_TYPE_INT((GType) ((6) << (2))), /* Width */
1938 G_TYPE_INT((GType) ((6) << (2))), /* Height */
1939 G_TYPE_INT((GType) ((6) << (2))), /* Frequency */
1940 G_TYPE_INT((GType) ((6) << (2))), /* Width * Height */
1941 G_TYPE_INT((GType) ((6) << (2)))); /* Rotation */
1942
1943 GtkCellRenderer *cell;
1944
1945 gtk_cell_layout_clear (GTK_CELL_LAYOUT (widget)((((GtkCellLayout*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_cell_layout_get_type ()))))))
);
1946
1947 gtk_combo_box_set_model (box, GTK_TREE_MODEL (store)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((store)), ((gtk_tree_model_get_type ()))))))
);
1948
1949 cell = gtk_cell_renderer_text_new ();
1950 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (box)((((GtkCellLayout*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((box)), ((gtk_cell_layout_get_type ()))))))
, cell, TRUE(!(0)));
1951 gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (box)((((GtkCellLayout*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((box)), ((gtk_cell_layout_get_type ()))))))
, cell,
1952 "text", 0,
1953 NULL((void*)0));
1954
1955 if (sort_column != -1)
1956 {
1957 gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store)((((GtkTreeSortable*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((store)), ((gtk_tree_sortable_get_type ()))))))
,
1958 sort_column,
1959 GTK_SORT_DESCENDING);
1960 }
1961}
1962
1963static void
1964compute_virtual_size_for_configuration (MateRRConfig *config, int *ret_width, int *ret_height)
1965{
1966 int i;
1967 int width, height;
1968 int output_x, output_y, output_width, output_height;
1969 MateRROutputInfo **outputs;
1970
1971 width = height = 0;
1972
1973 outputs = mate_rr_config_get_outputs (config);
1974 for (i = 0; outputs[i] != NULL((void*)0); i++)
1975 {
1976 if (mate_rr_output_info_is_active (outputs[i]))
1977 {
1978 mate_rr_output_info_get_geometry (outputs[i], &output_x, &output_y, &output_width, &output_height);
1979 width = MAX (width, output_x + output_width)(((width) > (output_x + output_width)) ? (width) : (output_x
+ output_width))
;
1980 height = MAX (height, output_y + output_height)(((height) > (output_y + output_height)) ? (height) : (output_y
+ output_height))
;
1981 }
1982 }
1983
1984 *ret_width = width;
1985 *ret_height = height;
1986}
1987
1988static void
1989check_required_virtual_size (App *app)
1990{
1991 int req_width, req_height;
1992 int min_width, max_width;
1993 int min_height, max_height;
1994
1995 compute_virtual_size_for_configuration (app->current_configuration, &req_width, &req_height);
1996
1997 mate_rr_screen_get_ranges (app->screen, &min_width, &max_width, &min_height, &max_height);
1998
1999#if 0
2000 g_debug ("X Server supports:");
2001 g_debug ("min_width = %d, max_width = %d", min_width, max_width);
2002 g_debug ("min_height = %d, max_height = %d", min_height, max_height);
2003
2004 g_debug ("Requesting size of %dx%d", req_width, req_height);
2005#endif
2006
2007 if (!(min_width <= req_width && req_width <= max_width
2008 && min_height <= req_height && req_height <= max_height))
2009 {
2010 /* FIXME: present a useful dialog, maybe even before the user tries to Apply */
2011#if 0
2012 g_debug ("Your X server needs a larger Virtual size!");
2013#endif
2014 }
2015}
2016
2017static void
2018begin_version2_apply_configuration (App *app, GdkWindow *parent_window, guint32 timestamp)
2019{
2020 XID parent_window_xid;
2021 GError *error = NULL((void*)0);
2022
2023 parent_window_xid = GDK_WINDOW_XID (parent_window)(gdk_x11_window_get_xid (parent_window));
2024
2025 app->proxy = g_dbus_proxy_new_sync (app->connection,
2026 G_DBUS_PROXY_FLAGS_NONE,
2027 NULL((void*)0),
2028 "org.mate.SettingsDaemon",
2029 "/org/mate/SettingsDaemon/XRANDR",
2030 "org.mate.SettingsDaemon.XRANDR_2",
2031 NULL((void*)0),
2032 &error);
2033 if (app->proxy == NULL((void*)0)) {
2034 g_warning ("Failed to get dbus connection: %s", error->message);
2035 g_error_free (error);
2036 } else {
2037 app->apply_configuration_state = APPLYING_VERSION_2;
2038 g_dbus_proxy_call (app->proxy,
2039 "ApplyConfiguration",
2040 g_variant_new ("(xx)", parent_window_xid, timestamp),
2041 G_DBUS_CALL_FLAGS_NONE,
2042 -1,
2043 NULL((void*)0),
2044 (GAsyncReadyCallback) apply_configuration_returned_cb,
2045 app);
2046 }
2047}
2048
2049static void
2050begin_version1_apply_configuration (App *app)
2051{
2052 GError *error = NULL((void*)0);
2053
2054 app->proxy = g_dbus_proxy_new_sync (app->connection,
2055 G_DBUS_PROXY_FLAGS_NONE,
2056 NULL((void*)0),
2057 "org.mate.SettingsDaemon",
2058 "/org/mate/SettingsDaemon/XRANDR",
2059 "org.mate.SettingsDaemon.XRANDR",
2060 NULL((void*)0),
2061 &error);
2062 if (app->proxy == NULL((void*)0)) {
2063 g_warning ("Failed to get dbus connection: %s", error->message);
2064 g_error_free (error);
2065 } else {
2066 app->apply_configuration_state = APPLYING_VERSION_1;
2067 g_dbus_proxy_call (app->proxy,
2068 "ApplyConfiguration",
2069 g_variant_new ("()"),
2070 G_DBUS_CALL_FLAGS_NONE,
2071 -1,
2072 NULL((void*)0),
2073 (GAsyncReadyCallback) apply_configuration_returned_cb,
2074 app);
2075 }
2076}
2077
2078static void
2079ensure_current_configuration_is_saved (void)
2080{
2081 MateRRScreen *rr_screen;
2082 MateRRConfig *rr_config;
2083
2084 /* Normally, mate_rr_config_save() creates a backup file based on the
2085 * old monitors.xml. However, if *that* file didn't exist, there is
2086 * nothing from which to create a backup. So, here we'll save the
2087 * current/unchanged configuration and then let our caller call
2088 * mate_rr_config_save() again with the new/changed configuration, so
2089 * that there *will* be a backup file in the end.
2090 */
2091
2092 rr_screen = mate_rr_screen_new (gdk_screen_get_default (), NULL((void*)0)); /* NULL-GError */
2093 if (!rr_screen)
2094 return;
2095
2096 rr_config = mate_rr_config_new_current (rr_screen, NULL((void*)0));
2097 mate_rr_config_save (rr_config, NULL((void*)0)); /* NULL-GError */
2098
2099 g_object_unref (rr_config);
2100 g_object_unref (rr_screen);
2101}
2102
2103/* Callback for g_dbus_proxy_call() */
2104static void
2105apply_configuration_returned_cb (GObject *source_object,
2106 GAsyncResult *res,
2107 gpointer data)
2108{
2109 GVariant *variant;
2110 GError *error;
2111 App *app = data;
2112
2113 error = NULL((void*)0);
2114
2115 if (app->proxy == NULL((void*)0))
2116 return;
2117
2118 variant = g_dbus_proxy_call_finish (app->proxy, res, &error);
2119 if (variant == NULL((void*)0)) {
2120 if (app->apply_configuration_state == APPLYING_VERSION_2
2121 && g_error_matches (error, G_DBUS_ERRORg_dbus_error_quark(), G_DBUS_ERROR_UNKNOWN_METHOD)) {
2122 g_error_free (error);
2123
2124 g_object_unref (app->proxy);
2125 app->proxy = NULL((void*)0);
2126
2127 begin_version1_apply_configuration (app);
2128 return;
2129 } else {
2130 /* We don't pop up an error message; mate-settings-daemon already does that
2131 * in case the selected RANDR configuration could not be applied.
2132 */
2133 g_error_free (error);
2134 }
2135 }
2136
2137 g_object_unref (app->proxy);
2138 app->proxy = NULL((void*)0);
2139
2140 g_object_unref (app->connection);
2141 app->connection = NULL((void*)0);
2142
2143 gtk_widget_set_sensitive (app->dialog, TRUE(!(0)));
2144}
2145
2146static gboolean
2147sanitize_and_save_configuration (App *app)
2148{
2149 GError *error;
2150
2151 mate_rr_config_sanitize (app->current_configuration);
2152
2153 check_required_virtual_size (app);
2154
2155 foo_scroll_area_invalidate (FOO_SCROLL_AREA (app->area)((((FooScrollArea*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((app->area)), ((foo_scroll_area_get_type ()))))))
);
2156
2157 ensure_current_configuration_is_saved ();
2158
2159 error = NULL((void*)0);
2160 if (!mate_rr_config_save (app->current_configuration, &error))
2161 {
2162 error_message (app, _("Could not save the monitor configuration")gettext ("Could not save the monitor configuration"), error->message);
2163 g_error_free (error);
2164 return FALSE(0);
2165 }
2166
2167 return TRUE(!(0));
2168}
2169
2170static void
2171apply (App *app)
2172{
2173 GError *error = NULL((void*)0);
2174
2175 if (!sanitize_and_save_configuration (app))
2176 return;
2177
2178 g_assert (app->connection == NULL)do { if (app->connection == ((void*)0)) ; else g_assertion_message_expr
("display-properties", "xrandr-capplet.c", 2178, ((const char
*) (__func__)), "app->connection == NULL"); } while (0)
;
2179 g_assert (app->proxy == NULL)do { if (app->proxy == ((void*)0)) ; else g_assertion_message_expr
("display-properties", "xrandr-capplet.c", 2179, ((const char
*) (__func__)), "app->proxy == NULL"); } while (0)
;
2180
2181 app->connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL((void*)0), &error);
2182 if (app->connection == NULL((void*)0)) {
2183 error_message (app, _("Could not get session bus while applying display configuration")gettext ("Could not get session bus while applying display configuration"
)
, error->message);
2184 g_error_free (error);
2185 return;
2186 }
2187
2188 gtk_widget_set_sensitive (app->dialog, FALSE(0));
2189
2190 begin_version2_apply_configuration (app, gtk_widget_get_window (app->dialog), app->apply_button_clicked_timestamp);
2191}
2192
2193static void
2194on_detect_displays (GtkWidget *widget, gpointer data)
2195{
2196 App *app = data;
2197 GError *error;
2198
2199 error = NULL((void*)0);
2200 if (!mate_rr_screen_refresh (app->screen, &error)) {
2201 if (error) {
2202 error_message (app, _("Could not detect displays")gettext ("Could not detect displays"), error->message);
2203 g_error_free (error);
2204 }
2205 }
2206}
2207
2208static void
2209set_primary (GtkWidget *widget, gpointer data)
2210{
2211 App *app = data;
2212 int i;
2213 MateRROutputInfo **outputs;
2214
2215 if (!app->current_output)
2216 return;
2217
2218 outputs = mate_rr_config_get_outputs (app->current_configuration);
2219 for (i=0; outputs[i]!=NULL((void*)0); i++) {
2220 mate_rr_output_info_set_primary (outputs[i], outputs[i] == app->current_output);
2221 }
2222
2223 gtk_widget_set_sensitive (app->primary_button, !mate_rr_output_info_get_primary(app->current_output));
2224}
2225
2226#define MSD_XRANDR_SCHEMA"org.mate.SettingsDaemon.plugins.xrandr" "org.mate.SettingsDaemon.plugins.xrandr"
2227#define SHOW_ICON_KEY"show-notification-icon" "show-notification-icon"
2228#define DEFAULT_CONFIGURATION_FILE_KEY"default-configuration-file" "default-configuration-file"
2229
2230static void
2231on_show_icon_toggled (GtkWidget *widget, gpointer data)
2232{
2233 GtkToggleButton *tb = GTK_TOGGLE_BUTTON (widget)((((GtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_toggle_button_get_type ()))))))
;
2234 App *app = data;
2235
2236 g_settings_set_boolean (app->settings, SHOW_ICON_KEY"show-notification-icon",
2237 gtk_toggle_button_get_active (tb));
2238}
2239
2240static MateRROutputInfo *
2241get_nearest_output (MateRRConfig *configuration, int x, int y)
2242{
2243 int i;
2244 int nearest_index;
2245 int nearest_dist;
2246 MateRROutputInfo **outputs;
2247
2248 nearest_index = -1;
2249 nearest_dist = G_MAXINT2147483647;
2250
2251 outputs = mate_rr_config_get_outputs (configuration);
2252 for (i = 0; outputs[i] != NULL((void*)0); i++)
2253 {
2254 int dist_x, dist_y;
2255 int output_x, output_y, output_width, output_height;
2256
2257 if (!(mate_rr_output_info_is_connected(outputs[i]) && mate_rr_output_info_is_active (outputs[i])))
2258 continue;
2259
2260 mate_rr_output_info_get_geometry (outputs[i], &output_x, &output_y, &output_width, &output_height);
2261 if (x < output_x)
2262 dist_x = output_x - x;
2263 else if (x >= output_x + output_width)
2264 dist_x = x - (output_x + output_width) + 1;
2265 else
2266 dist_x = 0;
2267
2268 if (y < output_y)
2269 dist_y = output_y - y;
2270 else if (y >= output_y + output_height)
2271 dist_y = y - (output_y + output_height) + 1;
2272 else
2273 dist_y = 0;
2274
2275 if (MIN (dist_x, dist_y)(((dist_x) < (dist_y)) ? (dist_x) : (dist_y)) < nearest_dist)
2276 {
2277 nearest_dist = MIN (dist_x, dist_y)(((dist_x) < (dist_y)) ? (dist_x) : (dist_y));
2278 nearest_index = i;
2279 }
2280 }
2281
2282 if (nearest_index != -1)
2283 return outputs[nearest_index];
2284 else
2285 return NULL((void*)0);
2286
2287}
2288
2289/* Gets the output that contains the largest intersection with the window.
2290 * Logic stolen from gdk_screen_get_monitor_at_window().
2291 */
2292static MateRROutputInfo *
2293get_output_for_window (MateRRConfig *configuration, GdkWindow *window)
2294{
2295 GdkRectangle win_rect;
2296 int i;
2297 int largest_area;
2298 int largest_index;
2299 MateRROutputInfo **outputs;
2300
2301 gdk_window_get_geometry (window, &win_rect.x, &win_rect.y, &win_rect.width, &win_rect.height);
2302 gdk_window_get_origin (window, &win_rect.x, &win_rect.y);
2303
2304 largest_area = 0;
2305 largest_index = -1;
2306
2307 outputs = mate_rr_config_get_outputs (configuration);
2308 for (i = 0; outputs[i] != NULL((void*)0); i++)
2309 {
2310 GdkRectangle output_rect, intersection;
2311
2312 mate_rr_output_info_get_geometry (outputs[i], &output_rect.x, &output_rect.y, &output_rect.width, &output_rect.height);
2313
2314 if (mate_rr_output_info_is_connected (outputs[i]) && gdk_rectangle_intersect (&win_rect, &output_rect, &intersection))
2315 {
2316 int area;
2317
2318 area = intersection.width * intersection.height;
2319 if (area > largest_area)
2320 {
2321 largest_area = area;
2322 largest_index = i;
2323 }
2324 }
2325 }
2326
2327 if (largest_index != -1)
2328 return outputs[largest_index];
2329 else
2330 return get_nearest_output (configuration,
2331 win_rect.x + win_rect.width / 2,
2332 win_rect.y + win_rect.height / 2);
2333}
2334
2335/* We select the current output, i.e. select the one being edited, based on
2336 * which output is showing the configuration dialog.
2337 */
2338static void
2339select_current_output_from_dialog_position (App *app)
2340{
2341 if (gtk_widget_get_realized (app->dialog))
2342 app->current_output = get_output_for_window (app->current_configuration, gtk_widget_get_window (app->dialog));
2343 else
2344 app->current_output = NULL((void*)0);
2345
2346 rebuild_gui (app);
2347}
2348
2349/* This is a GtkWidget::map-event handler. We wait for the display-properties
2350 * dialog to be mapped, and then we select the output which corresponds to the
2351 * monitor on which the dialog is being shown.
2352 */
2353static gboolean
2354dialog_map_event_cb (GtkWidget *widget, GdkEventAny *event, gpointer data)
2355{
2356 App *app = data;
2357
2358 select_current_output_from_dialog_position (app);
2359 return FALSE(0);
2360}
2361
2362static void
2363apply_button_clicked_cb (GtkButton *button, gpointer data)
2364{
2365 App *app = data;
2366
2367 /* We simply store the timestamp at which the Apply button was clicked.
2368 * We'll just wait for the dialog to return from gtk_dialog_run(), and
2369 * *then* use the timestamp when applying the RANDR configuration.
2370 */
2371
2372 app->apply_button_clicked_timestamp = gtk_get_current_event_time ();
2373}
2374
2375static void
2376success_dialog_for_make_default (App *app)
2377{
2378 GtkWidget *dialog;
2379
2380 dialog = gtk_message_dialog_new (GTK_WINDOW (app->dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((app->dialog)), ((gtk_window_get_type ()))))))
,
2381 GTK_DIALOG_MODAL,
2382 GTK_MESSAGE_INFO,
2383 GTK_BUTTONS_OK,
2384 _("The monitor configuration has been saved")gettext ("The monitor configuration has been saved"));
2385 gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog)((((GtkMessageDialog*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((dialog)), ((gtk_message_dialog_get_type ())
)))))
,
2386 _("This configuration will be used the next time someone logs in.")gettext ("This configuration will be used the next time someone logs in."
)
);
2387
2388 gtk_dialog_run (GTK_DIALOG (dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_dialog_get_type ()))))))
);
2389 gtk_widget_destroy (dialog);
2390}
2391
2392static void
2393error_dialog_for_make_default (App *app, const char *error_text)
2394{
2395 error_message (app, _("Could not set the default configuration for monitors")gettext ("Could not set the default configuration for monitors"
)
, error_text);
2396}
2397
2398static void
2399make_default (App *app)
2400{
2401 char *command_line;
2402 char *source_filename;
2403 char *dest_filename;
2404 char *dest_basename;
2405 char *std_error;
2406 gint exit_status;
2407 GError *error;
2408
2409 if (!sanitize_and_save_configuration (app))
2410 return;
2411
2412 dest_filename = g_settings_get_string (app->settings, DEFAULT_CONFIGURATION_FILE_KEY"default-configuration-file");
2413 if (!dest_filename)
2414 return; /* FIXME: present an error? */
2415
2416 dest_basename = g_path_get_basename (dest_filename);
2417
2418 source_filename = mate_rr_config_get_intended_filename ();
2419
2420 command_line = g_strdup_printf ("pkexec %s/mate-display-properties-install-systemwide %s %s",
2421 SBINDIR"/usr/local/sbin",
2422 source_filename,
2423 dest_basename);
2424
2425 error = NULL((void*)0);
2426 if (!g_spawn_command_line_sync (command_line, NULL((void*)0), &std_error, &exit_status, &error))
2427 {
2428 error_dialog_for_make_default (app, error->message);
2429 g_error_free (error);
2430 }
2431 else if (!WIFEXITED (exit_status)(((exit_status) & 0x7f) == 0) || WEXITSTATUS (exit_status)(((exit_status) & 0xff00) >> 8) != 0)
2432 {
2433 error_dialog_for_make_default (app, std_error);
2434 }
2435 else
2436 {
2437 success_dialog_for_make_default (app);
2438 }
2439
2440 g_free (std_error);
2441 g_free (dest_filename);
2442 g_free (dest_basename);
2443 g_free (source_filename);
2444 g_free (command_line);
2445}
2446
2447static GtkWidget*
2448_gtk_builder_get_widget (GtkBuilder *builder, const gchar *name)
2449{
2450 return GTK_WIDGET (gtk_builder_get_object (builder, name))((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, name))), ((gtk_widget_get_type
()))))))
;
2451}
2452
2453static void
2454run_application (App *app)
2455{
2456 GtkBuilder *builder;
2457 GtkWidget *align;
2458 GError *error = NULL((void*)0);
2459
2460 builder = gtk_builder_new_from_resource ("/org/mate/mcc/display/display-capplet.ui");
2461
2462 app->screen = mate_rr_screen_new (gdk_screen_get_default (), &error);
2463 g_signal_connect (app->screen, "changed", G_CALLBACK (on_screen_changed), app)g_signal_connect_data ((app->screen), ("changed"), (((GCallback
) (on_screen_changed))), (app), ((void*)0), (GConnectFlags) 0
)
;
2464 if (!app->screen)
2465 {
2466 error_message (NULL((void*)0), _("Could not get screen information")gettext ("Could not get screen information"), error->message);
2467 g_error_free (error);
2468 g_object_unref (builder);
2469 return;
2470 }
2471
2472 app->settings = g_settings_new (MSD_XRANDR_SCHEMA"org.mate.SettingsDaemon.plugins.xrandr");
2473 app->scale_settings = g_settings_new (MATE_INTERFACE_SCHEMA"org.mate.interface");
2474
2475 app->dialog = _gtk_builder_get_widget (builder, "dialog");
2476 g_signal_connect_after (app->dialog, "map-event",g_signal_connect_data ((app->dialog), ("map-event"), (((GCallback
) (dialog_map_event_cb))), (app), ((void*)0), G_CONNECT_AFTER
)
2477 G_CALLBACK (dialog_map_event_cb), app)g_signal_connect_data ((app->dialog), ("map-event"), (((GCallback
) (dialog_map_event_cb))), (app), ((void*)0), G_CONNECT_AFTER
)
;
2478
2479 gtk_window_set_default_icon_name ("preferences-desktop-display");
2480 gtk_window_set_icon_name (GTK_WINDOW (app->dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((app->dialog)), ((gtk_window_get_type ()))))))
,
2481 "preferences-desktop-display");
2482
2483 app->current_monitor_event_box = _gtk_builder_get_widget (builder,
2484 "current_monitor_event_box");
2485 app->current_monitor_label = _gtk_builder_get_widget (builder,
2486 "current_monitor_label");
2487
2488 app->monitor_on_radio = _gtk_builder_get_widget (builder,
2489 "monitor_on_radio");
2490 app->monitor_off_radio = _gtk_builder_get_widget (builder,
2491 "monitor_off_radio");
2492 g_signal_connect (app->monitor_on_radio, "toggled",g_signal_connect_data ((app->monitor_on_radio), ("toggled"
), (((GCallback) (monitor_on_off_toggled_cb))), (app), ((void
*)0), (GConnectFlags) 0)
2493 G_CALLBACK (monitor_on_off_toggled_cb), app)g_signal_connect_data ((app->monitor_on_radio), ("toggled"
), (((GCallback) (monitor_on_off_toggled_cb))), (app), ((void
*)0), (GConnectFlags) 0)
;
2494 g_signal_connect (app->monitor_off_radio, "toggled",g_signal_connect_data ((app->monitor_off_radio), ("toggled"
), (((GCallback) (monitor_on_off_toggled_cb))), (app), ((void
*)0), (GConnectFlags) 0)
2495 G_CALLBACK (monitor_on_off_toggled_cb), app)g_signal_connect_data ((app->monitor_off_radio), ("toggled"
), (((GCallback) (monitor_on_off_toggled_cb))), (app), ((void
*)0), (GConnectFlags) 0)
;
2496
2497 app->resolution_combo = _gtk_builder_get_widget (builder,
2498 "resolution_combo");
2499 g_signal_connect (app->resolution_combo, "changed",g_signal_connect_data ((app->resolution_combo), ("changed"
), (((GCallback) (on_resolution_changed))), (app), ((void*)0)
, (GConnectFlags) 0)
2500 G_CALLBACK (on_resolution_changed), app)g_signal_connect_data ((app->resolution_combo), ("changed"
), (((GCallback) (on_resolution_changed))), (app), ((void*)0)
, (GConnectFlags) 0)
;
2501
2502 app->refresh_combo = _gtk_builder_get_widget (builder, "refresh_combo");
2503 g_signal_connect (app->refresh_combo, "changed",g_signal_connect_data ((app->refresh_combo), ("changed"), (
((GCallback) (on_rate_changed))), (app), ((void*)0), (GConnectFlags
) 0)
2504 G_CALLBACK (on_rate_changed), app)g_signal_connect_data ((app->refresh_combo), ("changed"), (
((GCallback) (on_rate_changed))), (app), ((void*)0), (GConnectFlags
) 0)
;
2505
2506 app->rotation_combo = _gtk_builder_get_widget (builder, "rotation_combo");
2507 g_signal_connect (app->rotation_combo, "changed",g_signal_connect_data ((app->rotation_combo), ("changed"),
(((GCallback) (on_rotation_changed))), (app), ((void*)0), (GConnectFlags
) 0)
2508 G_CALLBACK (on_rotation_changed), app)g_signal_connect_data ((app->rotation_combo), ("changed"),
(((GCallback) (on_rotation_changed))), (app), ((void*)0), (GConnectFlags
) 0)
;
2509
2510 app->scale_vbox = _gtk_builder_get_widget (builder, "scale_vbox");
2511
2512 app->clone_checkbox = _gtk_builder_get_widget (builder, "clone_checkbox");
2513 g_signal_connect (app->clone_checkbox, "toggled",g_signal_connect_data ((app->clone_checkbox), ("toggled"),
(((GCallback) (on_clone_changed))), (app), ((void*)0), (GConnectFlags
) 0)
2514 G_CALLBACK (on_clone_changed), app)g_signal_connect_data ((app->clone_checkbox), ("toggled"),
(((GCallback) (on_clone_changed))), (app), ((void*)0), (GConnectFlags
) 0)
;
2515
2516 g_signal_connect (_gtk_builder_get_widget (builder, "detect_displays_button"),g_signal_connect_data ((_gtk_builder_get_widget (builder, "detect_displays_button"
)), ("clicked"), (((GCallback) (on_detect_displays))), (app),
((void*)0), (GConnectFlags) 0)
2517 "clicked", G_CALLBACK (on_detect_displays), app)g_signal_connect_data ((_gtk_builder_get_widget (builder, "detect_displays_button"
)), ("clicked"), (((GCallback) (on_detect_displays))), (app),
((void*)0), (GConnectFlags) 0)
;
2518
2519 app->primary_button = _gtk_builder_get_widget (builder, "primary_button");
2520
2521 g_signal_connect (app->primary_button, "clicked", G_CALLBACK (set_primary), app)g_signal_connect_data ((app->primary_button), ("clicked"),
(((GCallback) (set_primary))), (app), ((void*)0), (GConnectFlags
) 0)
;
2522
2523 app->show_icon_checkbox = _gtk_builder_get_widget (builder,
2524 "show_notification_icon");
2525
2526 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (app->show_icon_checkbox)((((GtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((app->show_icon_checkbox)), ((gtk_toggle_button_get_type
()))))))
,
2527 g_settings_get_boolean (app->settings, SHOW_ICON_KEY"show-notification-icon"));
2528
2529 g_signal_connect (app->show_icon_checkbox, "toggled", G_CALLBACK (on_show_icon_toggled), app)g_signal_connect_data ((app->show_icon_checkbox), ("toggled"
), (((GCallback) (on_show_icon_toggled))), (app), ((void*)0),
(GConnectFlags) 0)
;
2530
2531 app->panel_checkbox = _gtk_builder_get_widget (builder, "panel_checkbox");
2532
2533 make_text_combo (app->resolution_combo, 4);
2534 make_text_combo (app->refresh_combo, 3);
2535 make_text_combo (app->rotation_combo, -1);
2536
2537 g_assert (app->panel_checkbox)do { if (app->panel_checkbox) ; else g_assertion_message_expr
("display-properties", "xrandr-capplet.c", 2537, ((const char
*) (__func__)), "app->panel_checkbox"); } while (0)
;
2538
2539 /* Scroll Area */
2540 app->area = (GtkWidget *)foo_scroll_area_new ();
2541
2542 g_object_set_data (G_OBJECT (app->area)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((app->area)), (((GType) ((20) << (2))))))))
, "app", app);
2543
2544 set_monitors_tooltip (app, FALSE(0));
2545
2546 /* FIXME: this should be computed dynamically */
2547 foo_scroll_area_set_min_size (FOO_SCROLL_AREA (app->area)((((FooScrollArea*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((app->area)), ((foo_scroll_area_get_type ()))))))
, -1, 200);
2548 gtk_widget_show (app->area);
2549 g_signal_connect (app->area, "paint",g_signal_connect_data ((app->area), ("paint"), (((GCallback
) (on_area_paint))), (app), ((void*)0), (GConnectFlags) 0)
2550 G_CALLBACK (on_area_paint), app)g_signal_connect_data ((app->area), ("paint"), (((GCallback
) (on_area_paint))), (app), ((void*)0), (GConnectFlags) 0)
;
2551 g_signal_connect (app->area, "viewport_changed",g_signal_connect_data ((app->area), ("viewport_changed"), (
((GCallback) (on_viewport_changed))), (app), ((void*)0), (GConnectFlags
) 0)
2552 G_CALLBACK (on_viewport_changed), app)g_signal_connect_data ((app->area), ("viewport_changed"), (
((GCallback) (on_viewport_changed))), (app), ((void*)0), (GConnectFlags
) 0)
;
2553
2554 align = _gtk_builder_get_widget (builder, "align");
2555
2556 gtk_container_add (GTK_CONTAINER (align)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((align)), ((gtk_container_get_type ()))))))
, app->area);
2557
2558 app->apply_button = _gtk_builder_get_widget (builder, "apply_button");
2559 g_signal_connect (app->apply_button, "clicked",g_signal_connect_data ((app->apply_button), ("clicked"), (
((GCallback) (apply_button_clicked_cb))), (app), ((void*)0), (
GConnectFlags) 0)
2560 G_CALLBACK (apply_button_clicked_cb), app)g_signal_connect_data ((app->apply_button), ("clicked"), (
((GCallback) (apply_button_clicked_cb))), (app), ((void*)0), (
GConnectFlags) 0)
;
2561
2562 on_screen_changed (app->screen, app);
2563
2564 g_object_unref (builder);
2565
2566restart:
2567 switch (gtk_dialog_run (GTK_DIALOG (app->dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((app->dialog)), ((gtk_dialog_get_type ()))))))
))
2568 {
2569 default:
2570 /* Fall Through */
2571 case GTK_RESPONSE_DELETE_EVENT:
2572 case GTK_RESPONSE_CLOSE:
2573#if 0
2574 g_debug ("Close");
2575#endif
2576 break;
2577
2578 case GTK_RESPONSE_HELP:
2579 gtk_show_uri_on_window (GTK_WINDOW (app->dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((app->dialog)), ((gtk_window_get_type ()))))))
,
2580 "help:mate-user-guide/goscustdesk-70",
2581 gtk_get_current_event_time (),
2582 &error);
2583 if (error)
2584 {
2585 error_message (app, _("Could not open help content")gettext ("Could not open help content"), error->message);
2586 g_error_free (error);
2587 }
2588 goto restart;
2589 break;
2590
2591 case GTK_RESPONSE_APPLY:
2592 apply (app);
2593 goto restart;
2594 break;
2595
2596 case RESPONSE_MAKE_DEFAULT:
2597 make_default (app);
2598 goto restart;
2599 break;
2600 }
2601
2602 gtk_widget_destroy (app->dialog);
2603 g_object_unref (app->screen);
2604 g_object_unref (app->settings);
2605 g_object_unref (app->scale_settings);
2606}
2607
2608int
2609main (int argc, char **argv)
2610{
2611 App *app;
2612
2613 capplet_init (NULL((void*)0), &argc, &argv);
2614
2615 app = g_new0 (App, 1)((App *) g_malloc0_n ((1), sizeof (App)));
2616
2617 run_application (app);
2618
2619 g_free (app);
2620
2621 return 0;
2622}
diff --git a/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-894cd0.html b/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-894cd0.html new file mode 100644 index 00000000..475b9d33 --- /dev/null +++ b/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-894cd0.html @@ -0,0 +1,1029 @@ + + + +mate-wp-item.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:capplets/appearance/mate-wp-item.c
Warning:line 60, column 7
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name mate-wp-item.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/capplets/appearance -fcoverage-compilation-dir=/rootdir/capplets/appearance -resource-dir /usr/bin/../lib/clang/18 -D HAVE_CONFIG_H -I . -I ../.. -I /usr/include/marco-1 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/gio-unix-2.0 -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I ../../capplets/common -I /usr/include/udisks2 -I /usr/include/libgtop-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/libxml2 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/gio-unix-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/dconf -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I ../../ -D G_LOG_DOMAIN="appearance-properties" -I /usr/include/polkit-1 -I /usr/include/gio-unix-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I /usr/include/udisks2 -I /usr/include/libgtop-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/gio-unix-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/libxml2 -I /usr/include/harfbuzz -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/freetype2 -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/dconf -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libpng16 -D WITH_GZFILEOP -I /usr/include/sysprof-6 -I /usr/include/pixman-1 -D MATECC_DATA_DIR="/usr/local/share/mate-control-center" -D MATECC_PIXMAP_DIR="/usr/local/share/mate-control-center/pixmaps" -D WALLPAPER_DATADIR="/usr/local/share/mate-background-properties" -D BACKGROUND_DATADIR="/usr/local/share/backgrounds" -D MATE_DESKTOP_USE_UNSTABLE_API -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-06-07-044335-13427-1 -x c mate-wp-item.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 * Authors: Rodney Dawes <dobey@ximian.com>
3 *
4 * Copyright 2003-2006 Novell, Inc. (www.novell.com)
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of version 2 of the GNU General Public License
8 * as published by the Free Software Foundation
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Street #330, Boston, MA 02110-1301, USA.
18 *
19 */
20
21#include <config.h>
22
23#include <glib/gi18n.h>
24#include <gio/gio.h>
25#include <string.h>
26#include "appearance.h"
27#include "mate-wp-item.h"
28
29const gchar *wp_item_option_to_string (MateBGPlacement type)
30{
31 switch (type)
32 {
33 case MATE_BG_PLACEMENT_CENTERED:
34 return "centered";
35 break;
36 case MATE_BG_PLACEMENT_FILL_SCREEN:
37 return "stretched";
38 break;
39 case MATE_BG_PLACEMENT_SCALED:
40 return "scaled";
41 break;
42 case MATE_BG_PLACEMENT_ZOOMED:
43 return "zoom";
44 break;
45 case MATE_BG_PLACEMENT_TILED:
46 return "wallpaper";
47 break;
48 case MATE_BG_PLACEMENT_SPANNED:
49 return "spanned";
50 break;
51 }
52 return "";
53}
54
55const gchar *wp_item_shading_to_string (MateBGColorType type)
56{
57 switch (type) {
58 case MATE_BG_COLOR_SOLID:
59 return "solid";
60 break;
This statement is never executed
61 case MATE_BG_COLOR_H_GRADIENT:
62 return "horizontal-gradient";
63 break;
64 case MATE_BG_COLOR_V_GRADIENT:
65 return "vertical-gradient";
66 break;
67 }
68 return "";
69}
70
71MateBGPlacement wp_item_string_to_option (const gchar *option)
72{
73 if (!g_strcmp0(option, "centered"))
74 return MATE_BG_PLACEMENT_CENTERED;
75 else if (!g_strcmp0(option, "stretched"))
76 return MATE_BG_PLACEMENT_FILL_SCREEN;
77 else if (!g_strcmp0(option, "scaled"))
78 return MATE_BG_PLACEMENT_SCALED;
79 else if (!g_strcmp0(option, "zoom"))
80 return MATE_BG_PLACEMENT_ZOOMED;
81 else if (!g_strcmp0(option, "wallpaper"))
82 return MATE_BG_PLACEMENT_TILED;
83 else if (!g_strcmp0(option, "spanned"))
84 return MATE_BG_PLACEMENT_SPANNED;
85 else
86 return MATE_BG_PLACEMENT_SCALED;
87}
88
89MateBGColorType wp_item_string_to_shading (const gchar *shade_type)
90{
91 if (!g_strcmp0(shade_type, "solid"))
92 return MATE_BG_COLOR_SOLID;
93 else if (!g_strcmp0(shade_type, "horizontal-gradient"))
94 return MATE_BG_COLOR_H_GRADIENT;
95 else if (!g_strcmp0(shade_type, "vertical-gradient"))
96 return MATE_BG_COLOR_V_GRADIENT;
97 else
98 return MATE_BG_COLOR_SOLID;
99}
100
101static void set_bg_properties (MateWPItem *item)
102{
103 if (item->filename)
104 mate_bg_set_filename (item->bg, item->filename);
105
106 mate_bg_set_color (item->bg, item->shade_type, item->pcolor, item->scolor);
107 mate_bg_set_placement (item->bg, item->options);
108}
109
110void mate_wp_item_ensure_mate_bg (MateWPItem *item)
111{
112 if (!item->bg) {
113 item->bg = mate_bg_new ();
114
115 set_bg_properties (item);
116 }
117}
118
119void mate_wp_item_update (MateWPItem *item) {
120 GSettings *settings;
121 GdkRGBA color1 = { 0, 0, 0, 1.0 }, color2 = { 0, 0, 0, 1.0 };
122 gchar *s;
123
124 settings = g_settings_new (WP_SCHEMA"org.mate.background");
125
126 item->options = g_settings_get_enum (settings, WP_OPTIONS_KEY"picture-options");
127
128 item->shade_type = g_settings_get_enum (settings, WP_SHADING_KEY"color-shading-type");
129
130 s = g_settings_get_string (settings, WP_PCOLOR_KEY"primary-color");
131 if (s != NULL((void*)0)) {
132 gdk_rgba_parse (&color1, s);
133 g_free (s);
134 }
135
136 s = g_settings_get_string (settings, WP_SCOLOR_KEY"secondary-color");
137 if (s != NULL((void*)0)) {
138 gdk_rgba_parse (&color2, s);
139 g_free (s);
140 }
141
142 g_object_unref (settings);
143
144 if (item->pcolor != NULL((void*)0))
145 gdk_rgba_free (item->pcolor);
146
147 if (item->scolor != NULL((void*)0))
148 gdk_rgba_free (item->scolor);
149
150 item->pcolor = gdk_rgba_copy (&color1);
151 item->scolor = gdk_rgba_copy (&color2);
152}
153
154MateWPItem * mate_wp_item_new (const gchar * filename,
155 GHashTable * wallpapers,
156 MateDesktopThumbnailFactory * thumbnails) {
157 MateWPItem *item = g_new0 (MateWPItem, 1)((MateWPItem *) g_malloc0_n ((1), sizeof (MateWPItem)));
158
159 item->filename = g_strdup (filename)g_strdup_inline (filename);
160 item->fileinfo = mate_wp_info_new (filename, thumbnails);
161
162 if (item->fileinfo != NULL((void*)0) && item->fileinfo->mime_type != NULL((void*)0) &&
163 (g_str_has_prefix (item->fileinfo->mime_type, "image/")(__builtin_constant_p ("image/")? __extension__ ({ const char
* const __str = (item->fileinfo->mime_type); const char
* const __prefix = ("image/"); gboolean __result = (0); if (
__str == ((void*)0) || __prefix == ((void*)0)) __result = (g_str_has_prefix
) (__str, __prefix); else { const size_t __str_len = strlen (
((__str) + !(__str))); const size_t __prefix_len = strlen (((
__prefix) + !(__prefix))); if (__str_len >= __prefix_len) __result
= memcmp (((__str) + !(__str)), ((__prefix) + !(__prefix)), __prefix_len
) == 0; } __result; }) : (g_str_has_prefix) (item->fileinfo
->mime_type, "image/") )
||
164 strcmp (item->fileinfo->mime_type, "application/xml") == 0)) {
165
166 if (g_utf8_validate (item->fileinfo->name, -1, NULL((void*)0)))
167 item->name = g_strdup (item->fileinfo->name)g_strdup_inline (item->fileinfo->name);
168 else
169 item->name = g_filename_to_utf8 (item->fileinfo->name, -1, NULL((void*)0),
170 NULL((void*)0), NULL((void*)0));
171
172 mate_wp_item_update (item);
173 mate_wp_item_ensure_mate_bg (item);
174 mate_wp_item_update_description (item);
175
176 g_hash_table_insert (wallpapers, item->filename, item);
177 } else {
178 mate_wp_item_free (item);
179 item = NULL((void*)0);
180 }
181
182 return item;
183}
184
185void mate_wp_item_free (MateWPItem * item) {
186 if (item == NULL((void*)0)) {
187 return;
188 }
189
190 g_free (item->name);
191 g_free (item->filename);
192 g_free (item->description);
193 g_free (item->artist);
194
195 if (item->pcolor != NULL((void*)0))
196 gdk_rgba_free (item->pcolor);
197
198 if (item->scolor != NULL((void*)0))
199 gdk_rgba_free (item->scolor);
200
201 mate_wp_info_free (item->fileinfo);
202 if (item->bg)
203 g_object_unref (item->bg);
204
205 gtk_tree_row_reference_free (item->rowref);
206
207 g_free (item);
208}
209
210static GdkPixbuf *
211add_slideshow_frame (GdkPixbuf *pixbuf)
212{
213 GdkPixbuf *sheet, *sheet2;
214 GdkPixbuf *tmp;
215 gint w, h;
216
217 w = gdk_pixbuf_get_width (pixbuf);
218 h = gdk_pixbuf_get_height (pixbuf);
219
220 sheet = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE(0), 8, w, h);
221 gdk_pixbuf_fill (sheet, 0x00000000);
222 sheet2 = gdk_pixbuf_new_subpixbuf (sheet, 1, 1, w - 2, h - 2);
223 gdk_pixbuf_fill (sheet2, 0xffffffff);
224 g_object_unref (sheet2);
225
226 tmp = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE(!(0)), 8, w + 6, h + 6);
227
228 gdk_pixbuf_fill (tmp, 0x00000000);
229 gdk_pixbuf_composite (sheet, tmp, 6, 6, w, h, 6.0, 6.0, 1.0, 1.0, GDK_INTERP_NEAREST, 255);
230 gdk_pixbuf_composite (sheet, tmp, 3, 3, w, h, 3.0, 3.0, 1.0, 1.0, GDK_INTERP_NEAREST, 255);
231 gdk_pixbuf_composite (pixbuf, tmp, 0, 0, w, h, 0.0, 0.0, 1.0, 1.0, GDK_INTERP_NEAREST, 255);
232
233 g_object_unref (sheet);
234
235 return tmp;
236}
237
238GdkPixbuf * mate_wp_item_get_frame_thumbnail (MateWPItem * item,
239 MateDesktopThumbnailFactory * thumbs,
240 int width,
241 int height,
242 gint frame) {
243 GdkPixbuf *pixbuf = NULL((void*)0);
244
245 set_bg_properties (item);
246
247 if (frame != -1)
248 pixbuf = mate_bg_create_frame_thumbnail (item->bg, thumbs, gdk_screen_get_default (), width, height, frame);
249 else
250 pixbuf = mate_bg_create_thumbnail (item->bg, thumbs, gdk_screen_get_default(), width, height);
251
252 if (pixbuf && mate_bg_changes_with_time (item->bg))
253 {
254 GdkPixbuf *tmp;
255
256 tmp = add_slideshow_frame (pixbuf);
257 g_object_unref (pixbuf);
258 pixbuf = tmp;
259 }
260
261 mate_bg_get_image_size (item->bg, thumbs, width, height, &item->width, &item->height);
262
263 return pixbuf;
264}
265
266GdkPixbuf * mate_wp_item_get_thumbnail (MateWPItem * item,
267 MateDesktopThumbnailFactory * thumbs,
268 gint width,
269 gint height) {
270 return mate_wp_item_get_frame_thumbnail (item, thumbs, width, height, -1);
271}
272
273void mate_wp_item_update_description (MateWPItem * item) {
274 g_free (item->description);
275
276 if (!strcmp (item->filename, "(none)")) {
277 item->description = g_strdup (item->name)g_strdup_inline (item->name);
278 } else {
279 gchar *description;
280 gchar *size;
281 gchar *dirname = g_path_get_dirname (item->filename);
282 gchar *artist;
283
284 description = NULL((void*)0);
285 size = NULL((void*)0);
286
287 if (!item->artist || item->artist[0] == 0 || !g_strcmp0(item->artist, "(none)"))
288 artist = g_strdup (_("unknown"))g_strdup_inline (gettext ("unknown"));
289 else
290 artist = g_strdup (item->artist)g_strdup_inline (item->artist);
291
292 if (strcmp (item->fileinfo->mime_type, "application/xml") == 0)
293 {
294 if (mate_bg_changes_with_time (item->bg))
295 description = g_strdup (_("Slide Show"))g_strdup_inline (gettext ("Slide Show"));
296 else if (item->width > 0 && item->height > 0)
297 description = g_strdup (_("Image"))g_strdup_inline (gettext ("Image"));
298 }
299 else
300 description = g_content_type_get_description (item->fileinfo->mime_type);
301
302 if (mate_bg_has_multiple_sizes (item->bg))
303 size = g_strdup (_("multiple sizes"))g_strdup_inline (gettext ("multiple sizes"));
304 else if (item->width > 0 && item->height > 0) {
305 /* translators: x pixel(s) by y pixel(s) */
306 size = g_strdup_printf (_("%d %s by %d %s")gettext ("%d %s by %d %s"),
307 item->width,
308 ngettext ("pixel", "pixels", item->width),
309 item->height,
310 ngettext ("pixel", "pixels", item->height));
311 }
312
313 if (description && size) {
314 /* translators: <b>wallpaper name</b>
315 * mime type, size
316 * Folder: /path/to/file
317 * Artist: wallpaper author
318 */
319 item->description = g_markup_printf_escaped (_("<b>%s</b>\n"gettext ("<b>%s</b>\n" "%s, %s\n" "Folder: %s\n" "Artist: %s"
)
320 "%s, %s\n"gettext ("<b>%s</b>\n" "%s, %s\n" "Folder: %s\n" "Artist: %s"
)
321 "Folder: %s\n"gettext ("<b>%s</b>\n" "%s, %s\n" "Folder: %s\n" "Artist: %s"
)
322 "Artist: %s")gettext ("<b>%s</b>\n" "%s, %s\n" "Folder: %s\n" "Artist: %s"
)
,
323 item->name,
324 description,
325 size,
326 dirname,
327 artist);
328 } else {
329 /* translators: <b>wallpaper name</b>
330 * Image missing
331 * Folder: /path/to/file
332 * Artist: wallpaper author
333 */
334 item->description = g_markup_printf_escaped (_("<b>%s</b>\n"gettext ("<b>%s</b>\n" "%s\n" "Folder: %s\n" "Artist: %s"
)
335 "%s\n"gettext ("<b>%s</b>\n" "%s\n" "Folder: %s\n" "Artist: %s"
)
336 "Folder: %s\n"gettext ("<b>%s</b>\n" "%s\n" "Folder: %s\n" "Artist: %s"
)
337 "Artist: %s")gettext ("<b>%s</b>\n" "%s\n" "Folder: %s\n" "Artist: %s"
)
,
338 item->name,
339 _("Image missing")gettext ("Image missing"),
340 dirname,
341 artist);
342 }
343
344 g_free (size);
345 g_free (dirname);
346 g_free (artist);
347 g_free (description);
348 }
349}
diff --git a/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-8c7773.html b/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-8c7773.html new file mode 100644 index 00000000..92526ad5 --- /dev/null +++ b/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-8c7773.html @@ -0,0 +1,1995 @@ + + + +bookmark-agent.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:shell/bookmark-agent.c
Warning:line 707, column 48
Access of 'char *' element in the heap area at index 1
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name bookmark-agent.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/shell -fcoverage-compilation-dir=/rootdir/shell -resource-dir /usr/bin/../lib/clang/18 -D HAVE_CONFIG_H -I . -I .. -I .. -I /usr/include/udisks2 -I /usr/include/libgtop-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/atk-1.0 -I /usr/include/startup-notification-1.0 -I /usr/include/mate-menus -I /usr/include/gio-unix-2.0 -I /usr/include/librsvg-2.0 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/libxml2 -I /usr/include/harfbuzz -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/freetype2 -I /usr/include/cloudproviders -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/dconf -I /usr/include/webp -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libpng16 -D WITH_GZFILEOP -I /usr/include/sysprof-6 -I /usr/include/pixman-1 -D MATELOCALEDIR="/usr/local/share/locale" -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-06-07-044335-13427-1 -x c bookmark-agent.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 * This file is part of the Main Menu.
3 *
4 * Copyright (c) 2007 Novell, Inc.
5 *
6 * The Main Menu is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free
8 * Software Foundation; either version 2 of the License, or (at your option)
9 * any later version.
10 *
11 * The Main Menu is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * more details.
15 *
16 * You should have received a copy of the GNU General Public License along with
17 * the Main Menu; if not, write to the Free Software Foundation, Inc., 51
18 * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#include "bookmark-agent.h"
22
23#ifdef HAVE_CONFIG_H1
24# include <config.h>
25#else
26# define PACKAGE"mate-control-center" "mate-main-menu"
27#endif
28
29#include <gtk/gtk.h>
30
31#include <string.h>
32#include <stdlib.h>
33#include <glib/gi18n-lib.h>
34#include <glib/gstdio.h>
35#include <gio/gio.h>
36
37#include "libslab-utils.h"
38
39#define USER_APPS_STORE_FILE_NAME"applications.xbel" "applications.xbel"
40#define USER_DOCS_STORE_FILE_NAME"documents.xbel" "documents.xbel"
41#define USER_DIRS_STORE_FILE_NAME"places.xbel" "places.xbel"
42#define SYSTEM_STORE_FILE_NAME"system-items.xbel" "system-items.xbel"
43#define CALC_TEMPLATE_FILE_NAME"empty.ots" "empty.ots"
44#define WRITER_TEMPLATE_FILE_NAME"empty.ott" "empty.ott"
45
46#define GTK_BOOKMARKS_FILE"bookmarks" "bookmarks"
47
48#define TYPE_IS_RECENT(type)((type) == BOOKMARK_STORE_RECENT_APPS || (type) == BOOKMARK_STORE_RECENT_DOCS
)
((type) == BOOKMARK_STORE_RECENT_APPS || (type) == BOOKMARK_STORE_RECENT_DOCS)
49
50typedef struct {
51 BookmarkStoreType type;
52
53 BookmarkItem **items;
54 gint n_items;
55 BookmarkStoreStatus status;
56
57 GBookmarkFile *store;
58 gboolean needs_sync;
59
60 gchar *store_path;
61 gchar *user_store_path;
62 gboolean user_modifiable;
63 gboolean reorderable;
64 const gchar *store_filename;
65
66 GFileMonitor *store_monitor;
67 GFileMonitor *user_store_monitor;
68
69 void (* update_path) (BookmarkAgent *);
70 void (* load_store) (BookmarkAgent *);
71 void (* save_store) (BookmarkAgent *);
72 void (* create_item) (BookmarkAgent *, const gchar *);
73
74 gchar *gtk_store_path;
75 GFileMonitor *gtk_store_monitor;
76} BookmarkAgentPrivate;
77
78enum {
79 PROP_0,
80 PROP_ITEMS,
81 PROP_STATUS
82};
83
84static BookmarkAgent *instances [BOOKMARK_STORE_N_TYPES];
85
86static BookmarkAgentClass *bookmark_agent_parent_class = NULL((void*)0);
87
88static void bookmark_agent_base_init (BookmarkAgentClass *);
89static void bookmark_agent_class_init (BookmarkAgentClass *);
90static void bookmark_agent_init (BookmarkAgent *);
91static BookmarkAgent *bookmark_agent_new (BookmarkStoreType );
92
93static void get_property (GObject *, guint, GValue *, GParamSpec *);
94static void set_property (GObject *, guint, const GValue *, GParamSpec *);
95static void finalize (GObject *);
96
97static void update_agent (BookmarkAgent *);
98static void update_items (BookmarkAgent *);
99static void save_store (BookmarkAgent *);
100static gint get_rank (BookmarkAgent *, const gchar *);
101static void set_rank (BookmarkAgent *, const gchar *, gint);
102
103static void load_xbel_store (BookmarkAgent *);
104static void load_places_store (BookmarkAgent *);
105static void update_user_spec_path (BookmarkAgent *);
106static void save_xbel_store (BookmarkAgent *);
107static void create_app_item (BookmarkAgent *, const gchar *);
108static void create_doc_item (BookmarkAgent *, const gchar *);
109static void create_dir_item (BookmarkAgent *, const gchar *);
110
111static void store_monitor_cb (GFileMonitor *, GFile *, GFile *,
112 GFileMonitorEvent, gpointer);
113static void weak_destroy_cb (gpointer, GObject *);
114
115static gchar *find_package_data_file (const gchar *filename);
116
117static gint BookmarkAgent_private_offset;
118
119static inline gpointer bookmark_agent_get_instance_private (BookmarkAgent *this)
120{
121 return (G_STRUCT_MEMBER_P (this, BookmarkAgent_private_offset)((gpointer) ((guint8*) (this) + (glong) (BookmarkAgent_private_offset
)))
);
122}
123
124GType
125bookmark_agent_get_type ()
126{
127 static GType g_define_type_id = 0;
128
129 if (G_UNLIKELY (g_define_type_id == 0)(g_define_type_id == 0)) {
130 static const GTypeInfo info = {
131 sizeof (BookmarkAgentClass),
132 (GBaseInitFunc) bookmark_agent_base_init,
133 NULL((void*)0),
134 (GClassInitFunc) bookmark_agent_class_init,
135 NULL((void*)0), NULL((void*)0),
136 sizeof (BookmarkAgent), 0,
137 (GInstanceInitFunc) bookmark_agent_init,
138 NULL((void*)0)
139 };
140
141 g_define_type_id = g_type_register_static (
142 G_TYPE_OBJECT((GType) ((20) << (2))), "BookmarkAgent", & info, 0);
143 G_ADD_PRIVATE (BookmarkAgent){ BookmarkAgent_private_offset = g_type_add_instance_private (
g_define_type_id, sizeof (BookmarkAgentPrivate)); }
;
144 }
145
146 return g_define_type_id;
147}
148
149gboolean
150bookmark_agent_has_item (BookmarkAgent *this, const gchar *uri)
151{
152 BookmarkAgentPrivate *priv = bookmark_agent_get_instance_private (this);
153 return g_bookmark_file_has_item (priv->store, uri);
154}
155
156void
157bookmark_agent_add_item (BookmarkAgent *this, const BookmarkItem *item)
158{
159 BookmarkAgentPrivate *priv = bookmark_agent_get_instance_private (this);
160
161 if (! item)
162 return;
163
164 g_return_if_fail (priv->user_modifiable)do { if ((priv->user_modifiable)) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "priv->user_modifiable"
); return; } } while (0)
;
165 g_return_if_fail (item->uri)do { if ((item->uri)) { } else { g_return_if_fail_warning (
((gchar*) 0), ((const char*) (__func__)), "item->uri"); return
; } } while (0)
;
166 g_return_if_fail (item->mime_type)do { if ((item->mime_type)) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "item->mime_type"
); return; } } while (0)
;
167
168 g_bookmark_file_set_mime_type (priv->store, item->uri, item->mime_type);
169
170 if (item->mtime)
171#if GLIB_CHECK_VERSION(2,66,0)(2 > (2) || (2 == (2) && 80 > (66)) || (2 == (2
) && 80 == (66) && 2 >= (0)))
172 g_bookmark_file_set_modified_date_time (priv->store, item->uri, item->mtime);
173#else
174 g_bookmark_file_set_modified (priv->store, item->uri, item->mtime);
175#endif
176
177 if (item->title)
178 g_bookmark_file_set_title (priv->store, item->uri, item->title);
179
180 g_bookmark_file_add_application (priv->store, item->uri, item->app_name, item->app_exec);
181
182 set_rank (this, item->uri, g_bookmark_file_get_size (priv->store) - 1);
183
184 save_store (this);
185}
186
187void
188bookmark_agent_move_item (BookmarkAgent *this, const gchar *uri, const gchar *uri_new)
189{
190 BookmarkAgentPrivate *priv = bookmark_agent_get_instance_private (this);
191
192 GError *error = NULL((void*)0);
193
194 if (! TYPE_IS_RECENT (priv->type)((priv->type) == BOOKMARK_STORE_RECENT_APPS || (priv->type
) == BOOKMARK_STORE_RECENT_DOCS)
)
195 return;
196
197 gtk_recent_manager_move_item (gtk_recent_manager_get_default (), uri, uri_new, &error);
198 if (error) {
199 g_warning ("Unable to update %s with renamed file, [%s] -> [%s]: %s",
200 priv->store_path, uri, uri_new, error->message);
201 g_error_free (error);
202 }
203}
204
205void
206bookmark_agent_purge_items (BookmarkAgent *this)
207{
208 BookmarkAgentPrivate *priv = bookmark_agent_get_instance_private (this);
209
210 GError *error = NULL((void*)0);
211
212 gchar **uris = NULL((void*)0);
213 gsize uris_len;
214 gint i;
215 g_return_if_fail (priv->user_modifiable)do { if ((priv->user_modifiable)) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "priv->user_modifiable"
); return; } } while (0)
;
216
217 uris = g_bookmark_file_get_uris (priv->store, &uris_len);
218 if (TYPE_IS_RECENT (priv->type)((priv->type) == BOOKMARK_STORE_RECENT_APPS || (priv->type
) == BOOKMARK_STORE_RECENT_DOCS)
) {
219 for (i = 0; i < uris_len; i++) {
220 gtk_recent_manager_remove_item (gtk_recent_manager_get_default (), uris [i], &error);
221 if (error) {
222 g_warning ("Unable to remove [%s] from %s: %s",
223 priv->store_path, uris [i], error->message);
224 g_error_free (error);
225 }
226 }
227 } else {
228 for (i = 0; i < uris_len; i++) {
229 g_bookmark_file_remove_item (priv->store, uris [i], NULL((void*)0));
230 }
231 save_store (this);
232 }
233 g_strfreev (uris);
234}
235
236void
237bookmark_agent_remove_item (BookmarkAgent *this, const gchar *uri)
238{
239 BookmarkAgentPrivate *priv = bookmark_agent_get_instance_private (this);
240 gint rank;
241
242 GError *error = NULL((void*)0);
243
244 gchar **uris = NULL((void*)0);
245 gint rank_i;
246 gint i;
247
248 g_return_if_fail (priv->user_modifiable)do { if ((priv->user_modifiable)) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "priv->user_modifiable"
); return; } } while (0)
;
249
250 if (! bookmark_agent_has_item (this, uri))
251 return;
252
253 if (TYPE_IS_RECENT (priv->type)((priv->type) == BOOKMARK_STORE_RECENT_APPS || (priv->type
) == BOOKMARK_STORE_RECENT_DOCS)
) {
254 gtk_recent_manager_remove_item (gtk_recent_manager_get_default (), uri, &error);
255 if (error) {
256 g_warning ("Unable to remove [%s] from %s: %s", priv->store_path, uri, error->message);
257 g_error_free (error);
258 }
259 }
260 else {
261 rank = get_rank (this, uri);
262
263 g_bookmark_file_remove_item (priv->store, uri, NULL((void*)0));
264
265 if (rank >= 0) {
266 uris = g_bookmark_file_get_uris (priv->store, NULL((void*)0));
267
268 for (i = 0; uris && uris [i]; ++i) {
269 rank_i = get_rank (this, uris [i]);
270
271 if (rank_i > rank)
272 set_rank (this, uris [i], rank_i - 1);
273 }
274
275 g_strfreev (uris);
276 }
277
278 save_store (this);
279 }
280}
281
282void
283bookmark_agent_reorder_items (BookmarkAgent *this, const gchar **uris)
284{
285 BookmarkAgentPrivate *priv = bookmark_agent_get_instance_private (this);
286
287 gint i;
288
289 g_return_if_fail (priv->reorderable)do { if ((priv->reorderable)) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "priv->reorderable"
); return; } } while (0)
;
290
291 for (i = 0; uris && uris [i]; ++i)
292 set_rank (this, uris [i], i);
293
294 save_store (this);
295}
296
297#if !GLIB_CHECK_VERSION(2,66,0)(2 > (2) || (2 == (2) && 80 > (66)) || (2 == (2
) && 80 == (66) && 2 >= (0)))
298static gint
299recent_item_mru_comp_func (gconstpointer a, gconstpointer b)
300{
301 return ((BookmarkItem *) b)->mtime - ((BookmarkItem *) a)->mtime;
302}
303#endif
304
305static GList *
306make_items_from_bookmark_file (BookmarkAgent *this, GBookmarkFile *store)
307{
308 BookmarkAgentPrivate *priv = bookmark_agent_get_instance_private (this);
309 gchar **uris;
310 gint i;
311 GList *items_ordered;
312
313 if (!store)
314 return NULL((void*)0);
315
316 uris = g_bookmark_file_get_uris (store, NULL((void*)0));
317 items_ordered = NULL((void*)0);
318
319 for (i = 0; uris && uris [i]; ++i) {
320 gboolean include;
321
322 if (priv->type == BOOKMARK_STORE_RECENT_APPS)
323 include = g_bookmark_file_has_group (store, uris [i], "recently-used-apps", NULL((void*)0));
324 else
325 include = ! g_bookmark_file_get_is_private (store, uris [i], NULL((void*)0));
326
327 if (include) {
328 BookmarkItem *item;
329
330 item = g_new0 (BookmarkItem, 1)((BookmarkItem *) g_malloc0_n ((1), sizeof (BookmarkItem)));
331
332 item->uri = g_strdup (uris [i])g_strdup_inline (uris [i]);
333 item->mime_type = g_bookmark_file_get_mime_type (store, uris [i], NULL((void*)0));
334#if GLIB_CHECK_VERSION(2,66,0)(2 > (2) || (2 == (2) && 80 > (66)) || (2 == (2
) && 80 == (66) && 2 >= (0)))
335 item->mtime = g_bookmark_file_get_modified_date_time (store, uris [i], NULL((void*)0));
336#else
337 item->mtime = g_bookmark_file_get_modified (store, uris [i], NULL((void*)0));
338#endif
339
340 items_ordered = g_list_prepend (items_ordered, item);
341 }
342 }
343
344#if GLIB_CHECK_VERSION(2,66,0)(2 > (2) || (2 == (2) && 80 > (66)) || (2 == (2
) && 80 == (66) && 2 >= (0)))
345 items_ordered = g_list_sort (items_ordered, g_date_time_compare);
346#else
347 items_ordered = g_list_sort (items_ordered, recent_item_mru_comp_func);
348#endif
349 g_strfreev (uris);
350
351 return items_ordered;
352}
353
354void
355bookmark_agent_update_from_bookmark_file (BookmarkAgent *this, GBookmarkFile *store)
356{
357 BookmarkAgentPrivate *priv;
358 GList *items_ordered;
359 GList *node;
360
361 g_return_if_fail (IS_BOOKMARK_AGENT (this))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((this)); GType __t = ((bookmark_agent_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "IS_BOOKMARK_AGENT (this)"); return; } } while
(0)
;
362
363 priv = bookmark_agent_get_instance_private (this);
364
365 items_ordered = make_items_from_bookmark_file (this, store);
366
367 g_bookmark_file_free (priv->store);
368 priv->store = g_bookmark_file_new ();
369
370 for (node = items_ordered; node; node = node->next) {
371 BookmarkItem *item;
372
373 item = (BookmarkItem *) node->data;
374
375 g_bookmark_file_set_mime_type (priv->store, item->uri, item->mime_type);
376 #if GLIB_CHECK_VERSION(2,66,0)(2 > (2) || (2 == (2) && 80 > (66)) || (2 == (2
) && 80 == (66) && 2 >= (0)))
377 g_bookmark_file_set_modified_date_time (priv->store, item->uri, item->mtime);
378 #else
379 g_bookmark_file_set_modified (priv->store, item->uri, item->mtime);
380 #endif
381
382 bookmark_item_free (item);
383 }
384
385 g_list_free (items_ordered);
386
387 update_items (this);
388}
389
390void
391bookmark_item_free (BookmarkItem *item)
392{
393 if (! item)
394 return;
395
396 g_free (item->uri);
397 g_free (item->title);
398 g_free (item->mime_type);
399 g_free (item->icon);
400 g_free (item->app_name);
401 g_free (item->app_exec);
402 g_free (item);
403}
404
405static void
406bookmark_agent_base_init (BookmarkAgentClass *this_class)
407{
408 gint i;
409
410 for (i = 0; i < BOOKMARK_STORE_N_TYPES; ++i)
411 instances [i] = NULL((void*)0);
412}
413
414static void
415bookmark_agent_class_init (BookmarkAgentClass *this_class)
416{
417 GObjectClass *g_obj_class = G_OBJECT_CLASS (this_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((this_class)), (((GType) ((20) << (2))))))))
;
418
419 GParamSpec *items_pspec;
420 GParamSpec *status_pspec;
421
422 if (BookmarkAgent_private_offset != 0)
423 g_type_class_adjust_private_offset (this_class, &BookmarkAgent_private_offset);
424
425 g_obj_class->get_property = get_property;
426 g_obj_class->set_property = set_property;
427 g_obj_class->finalize = finalize;
428
429 items_pspec = g_param_spec_pointer (
430 BOOKMARK_AGENT_ITEMS_PROP"items", BOOKMARK_AGENT_ITEMS_PROP"items",
431 "the null-terminated list which contains the bookmark items in this store",
432 G_PARAM_READABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB);
433
434 status_pspec = g_param_spec_int (
435 BOOKMARK_AGENT_STORE_STATUS_PROP"store-status", BOOKMARK_AGENT_STORE_STATUS_PROP"store-status", "the status of the store",
436 BOOKMARK_STORE_DEFAULT_ONLY, BOOKMARK_STORE_USER, BOOKMARK_STORE_DEFAULT,
437 G_PARAM_READABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB);
438
439 g_object_class_install_property (g_obj_class, PROP_ITEMS, items_pspec);
440 g_object_class_install_property (g_obj_class, PROP_STATUS, status_pspec);
441
442 bookmark_agent_parent_class = g_type_class_peek_parent (this_class);
443}
444
445static void
446bookmark_agent_init (BookmarkAgent *this)
447{
448 BookmarkAgentPrivate *priv = bookmark_agent_get_instance_private (this);
449
450 priv->type = -1;
451
452 priv->items = NULL((void*)0);
453 priv->n_items = 0;
454 priv->status = BOOKMARK_STORE_ABSENT;
455
456 priv->store = NULL((void*)0);
457 priv->needs_sync = FALSE(0);
458
459 priv->store_path = NULL((void*)0);
460 priv->user_store_path = NULL((void*)0);
461 priv->user_modifiable = FALSE(0);
462 priv->reorderable = FALSE(0);
463 priv->store_filename = NULL((void*)0);
464
465 priv->store_monitor = NULL((void*)0);
466 priv->user_store_monitor = NULL((void*)0);
467
468 priv->update_path = NULL((void*)0);
469 priv->load_store = NULL((void*)0);
470 priv->save_store = NULL((void*)0);
471 priv->create_item = NULL((void*)0);
472
473 priv->gtk_store_path = NULL((void*)0);
474 priv->gtk_store_monitor = NULL((void*)0);
475}
476
477static BookmarkAgent *
478bookmark_agent_new (BookmarkStoreType type)
479{
480 BookmarkAgent *this;
481 BookmarkAgentPrivate *priv;
482 GFile *gtk_store_file;
483
484 this = g_object_new (BOOKMARK_AGENT_TYPE(bookmark_agent_get_type ()), NULL((void*)0));
485 priv = bookmark_agent_get_instance_private (this);
486
487 priv->type = type;
488 priv->store = g_bookmark_file_new ();
489
490 switch (type) {
491 case BOOKMARK_STORE_USER_APPS:
492 priv->store_filename = USER_APPS_STORE_FILE_NAME"applications.xbel";
493 priv->create_item = create_app_item;
494
495 break;
496
497 case BOOKMARK_STORE_USER_DOCS:
498 priv->store_filename = USER_DOCS_STORE_FILE_NAME"documents.xbel";
499 priv->create_item = create_doc_item;
500
501 break;
502
503 case BOOKMARK_STORE_USER_DIRS:
504 priv->store_filename = USER_DIRS_STORE_FILE_NAME"places.xbel";
505 priv->create_item = create_dir_item;
506
507 priv->user_modifiable = TRUE(!(0));
508 priv->reorderable = FALSE(0);
509
510 priv->load_store = load_places_store;
511
512 priv->gtk_store_path = g_build_filename (g_get_user_config_dir (),
513 "gtk-3.0", GTK_BOOKMARKS_FILE"bookmarks", NULL((void*)0));
514 gtk_store_file = g_file_new_for_path (priv->gtk_store_path);
515 priv->gtk_store_monitor = g_file_monitor_file (gtk_store_file,
516 0, NULL((void*)0), NULL((void*)0));
517 if (priv->gtk_store_monitor) {
518 g_signal_connect (priv->gtk_store_monitor, "changed",g_signal_connect_data ((priv->gtk_store_monitor), ("changed"
), (((GCallback) (store_monitor_cb))), (this), ((void*)0), (GConnectFlags
) 0)
519 G_CALLBACK (store_monitor_cb), this)g_signal_connect_data ((priv->gtk_store_monitor), ("changed"
), (((GCallback) (store_monitor_cb))), (this), ((void*)0), (GConnectFlags
) 0)
;
520 }
521
522 g_object_unref (gtk_store_file);
523
524 break;
525
526 case BOOKMARK_STORE_RECENT_APPS:
527 case BOOKMARK_STORE_RECENT_DOCS:
528 priv->user_modifiable = TRUE(!(0));
529 priv->reorderable = FALSE(0);
530
531 priv->store_path = g_build_filename (g_get_user_data_dir (), "recently-used.xbel", NULL((void*)0));
532
533 break;
534
535 case BOOKMARK_STORE_SYSTEM:
536 priv->store_filename = SYSTEM_STORE_FILE_NAME"system-items.xbel";
537 priv->create_item = create_app_item;
538
539 break;
540
541 default:
542 break;
543 }
544
545 if (
546 type == BOOKMARK_STORE_USER_APPS || type == BOOKMARK_STORE_USER_DOCS ||
547 type == BOOKMARK_STORE_USER_DIRS || type == BOOKMARK_STORE_SYSTEM)
548 {
549 priv->user_modifiable = TRUE(!(0));
550
551 priv->user_store_path = g_build_filename (
552 g_get_user_data_dir (), PACKAGE"mate-control-center", priv->store_filename, NULL((void*)0));
553
554 priv->update_path = update_user_spec_path;
555 }
556
557 if (type == BOOKMARK_STORE_USER_APPS || type == BOOKMARK_STORE_USER_DOCS || type == BOOKMARK_STORE_SYSTEM) {
558 priv->reorderable = TRUE(!(0));
559 priv->load_store = load_xbel_store;
560 priv->save_store = save_xbel_store;
561 }
562
563 update_agent (this);
564
565 return this;
566}
567
568BookmarkAgent *
569bookmark_agent_get_instance (BookmarkStoreType type)
570{
571 g_return_val_if_fail (0 <= type, NULL)do { if ((0 <= type)) { } else { g_return_if_fail_warning (
((gchar*) 0), ((const char*) (__func__)), "0 <= type"); return
(((void*)0)); } } while (0)
;
572 g_return_val_if_fail (type < BOOKMARK_STORE_N_TYPES, NULL)do { if ((type < BOOKMARK_STORE_N_TYPES)) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "type < BOOKMARK_STORE_N_TYPES"
); return (((void*)0)); } } while (0)
;
573
574 if (! instances [type]) {
575 instances [type] = bookmark_agent_new (type);
576 g_object_weak_ref (G_OBJECT (instances [type])((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((instances [type])), (((GType) ((20) << (2))))))))
, weak_destroy_cb, GINT_TO_POINTER (type)((gpointer) (glong) (type)));
577 }
578 else
579 g_object_ref (G_OBJECT (instances [type]))((__typeof__ (((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((instances [type])), (((GType) ((20) <<
(2)))))))))) (g_object_ref) (((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((instances [type])), (((GType) ((20) <<
(2))))))))))
;
580
581 return instances [type];
582}
583
584static void
585get_property (GObject *g_obj, guint prop_id, GValue *value, GParamSpec *pspec)
586{
587 BookmarkAgent *this = BOOKMARK_AGENT (g_obj)((((BookmarkAgent*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((g_obj)), ((bookmark_agent_get_type ()))))))
;
588 BookmarkAgentPrivate *priv = bookmark_agent_get_instance_private (this);
589
590 switch (prop_id) {
591 case PROP_ITEMS:
592 g_value_set_pointer (value, priv->items);
593 break;
594
595 case PROP_STATUS:
596 g_value_set_int (value, priv->status);
597 break;
598 }
599}
600
601static void
602set_property (GObject *g_obj, guint prop_id, const GValue *value, GParamSpec *pspec)
603{
604 /* no writeable properties */
605}
606
607static void
608finalize (GObject *g_obj)
609{
610 BookmarkAgent *this = BOOKMARK_AGENT (g_obj)((((BookmarkAgent*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((g_obj)), ((bookmark_agent_get_type ()))))))
;
611 BookmarkAgentPrivate *priv = bookmark_agent_get_instance_private (this);
612
613 gint i;
614
615 for (i = 0; priv->items && priv->items [i]; ++i)
616 bookmark_item_free (priv->items [i]);
617
618 g_free (priv->items);
619 g_free (priv->store_path);
620 g_free (priv->user_store_path);
621 g_free (priv->gtk_store_path);
622
623 if (priv->store_monitor) {
624 g_signal_handlers_disconnect_by_func (priv->store_monitor, store_monitor_cb, this)g_signal_handlers_disconnect_matched ((priv->store_monitor
), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (store_monitor_cb), (this))
;
625 g_file_monitor_cancel (priv->store_monitor);
626 g_object_unref (priv->store_monitor);
627 }
628
629 if (priv->user_store_monitor) {
630 g_signal_handlers_disconnect_by_func (priv->user_store_monitor, store_monitor_cb, this)g_signal_handlers_disconnect_matched ((priv->user_store_monitor
), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (store_monitor_cb), (this))
;
631 g_file_monitor_cancel (priv->user_store_monitor);
632 g_object_unref (priv->user_store_monitor);
633 }
634
635 if (priv->gtk_store_monitor) {
636 g_signal_handlers_disconnect_by_func (priv->gtk_store_monitor, store_monitor_cb, this)g_signal_handlers_disconnect_matched ((priv->gtk_store_monitor
), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (store_monitor_cb), (this))
;
637 g_file_monitor_cancel (priv->gtk_store_monitor);
638 g_object_unref (priv->gtk_store_monitor);
639 }
640
641 g_bookmark_file_free (priv->store);
642
643 G_OBJECT_CLASS (bookmark_agent_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((bookmark_agent_parent_class)), (((GType) ((20) << (
2))))))))
->finalize (g_obj);
644}
645
646static void
647update_agent (BookmarkAgent *this)
648{
649 BookmarkAgentPrivate *priv = bookmark_agent_get_instance_private (this);
650
651 if (priv->update_path)
2
Assuming field 'update_path' is null
3
Taking false branch
652 priv->update_path (this);
653
654 if (priv->load_store)
4
Assuming field 'load_store' is null
5
Taking false branch
655 priv->load_store (this);
656
657 update_items (this);
6
Calling 'update_items'
658}
659
660static void
661update_items (BookmarkAgent *this)
662{
663 BookmarkAgentPrivate *priv = bookmark_agent_get_instance_private (this);
664
665 gchar **uris = NULL((void*)0);
666 gchar **uris_ordered = NULL((void*)0);
667 gsize n_uris = 0;
668 gint rank = -1;
669 gint rank_corr = -1;
670 gboolean needs_update = FALSE(0);
671 gboolean store_corrupted = FALSE(0);
672 gchar *new_title, *old_title;
673
674 gint i;
675
676 uris = g_bookmark_file_get_uris (priv->store, & n_uris);
677 uris_ordered = g_new0 (gchar *, n_uris + 1)((gchar * *) g_malloc0_n ((n_uris + 1), sizeof (gchar *)));
678 uris_ordered [n_uris] = NULL((void*)0);
679
680 for (i = 0; uris
12.1
'uris' is non-null
&& uris [i]; ++i) {
7
Assuming 'uris' is non-null
8
Loop condition is true. Entering loop body
13
Loop condition is false. Execution continues on line 704
681 rank = get_rank (this, uris [i]);
682
683 if (rank
8.1
'rank' is < 0
< 0 || rank >= n_uris)
684 rank = i;
685
686 if (uris_ordered [rank]) {
9
Assuming the condition is true
10
Taking true branch
687 store_corrupted = TRUE(!(0));
688 rank_corr = rank;
689
690 for (rank = 0; rank < n_uris; ++rank)
11
Assuming 'rank' is >= 'n_uris'
12
Loop condition is false. Execution continues on line 694
691 if (! uris_ordered [rank])
692 break;
693
694 g_warning (
695 "store corruption [%s] - multiple uris with same rank (%d): [%s] [%s], moving latter to %d",
696 priv->store_path, rank_corr, uris_ordered [rank_corr], uris [i], rank);
697 }
698
699 set_rank (this, uris [i], rank);
700
701 uris_ordered [rank] = uris [i];
702 }
703
704 if (priv->n_items != n_uris)
14
Assuming 'n_uris' is equal to field 'n_items'
15
Taking false branch
705 needs_update = TRUE(!(0));
706
707 for (i = 0; ! needs_update
15.1
'needs_update' is 0
20.1
'needs_update' is 0
&& uris_ordered
15.2
'uris_ordered' is non-null
20.2
'uris_ordered' is non-null
&& uris_ordered [i]; ++i) {
16
Loop condition is true. Entering loop body
21
Access of 'char *' element in the heap area at index 1
708 if (priv->type == BOOKMARK_STORE_USER_DIRS) {
17
Assuming field 'type' is not equal to BOOKMARK_STORE_USER_DIRS
18
Taking false branch
709 new_title = g_bookmark_file_get_title (priv->store, uris_ordered [i], NULL((void*)0));
710 old_title = priv->items [i]->title;
711 if (!new_title && !old_title) {
712 if (strcmp (priv->items [i]->uri, uris_ordered [i]))
713 needs_update = TRUE(!(0));
714 }
715 else if ((new_title && !old_title) || (!new_title && old_title))
716 needs_update = TRUE(!(0));
717 else if (strcmp (old_title, new_title))
718 needs_update = TRUE(!(0));
719 g_free (new_title);
720 }
721 else if (strcmp (priv->items [i]->uri, uris_ordered [i]))
19
Assuming the condition is false
20
Taking false branch
722 needs_update = TRUE(!(0));
723 }
724
725 if (needs_update) {
726 for (i = 0; priv->items && priv->items [i]; ++i)
727 bookmark_item_free (priv->items [i]);
728
729 g_free (priv->items);
730
731 priv->n_items = n_uris;
732 priv->items = g_new0 (BookmarkItem *, priv->n_items + 1)((BookmarkItem * *) g_malloc0_n ((priv->n_items + 1), sizeof
(BookmarkItem *)))
;
733
734 for (i = 0; uris_ordered && uris_ordered [i]; ++i) {
735 priv->items [i] = g_new0 (BookmarkItem, 1)((BookmarkItem *) g_malloc0_n ((1), sizeof (BookmarkItem)));
736 priv->items [i]->uri = g_strdup (uris_ordered [i])g_strdup_inline (uris_ordered [i]);
737 priv->items [i]->title = g_bookmark_file_get_title (priv->store, uris_ordered [i], NULL((void*)0));
738 priv->items [i]->mime_type = g_bookmark_file_get_mime_type (priv->store, uris_ordered [i], NULL((void*)0));
739 #if GLIB_CHECK_VERSION(2,66,0)(2 > (2) || (2 == (2) && 80 > (66)) || (2 == (2
) && 80 == (66) && 2 >= (0)))
740 priv->items [i]->mtime = g_bookmark_file_get_modified_date_time (priv->store, uris_ordered [i], NULL((void*)0));
741 #else
742 priv->items [i]->mtime = g_bookmark_file_get_modified (priv->store, uris_ordered [i], NULL((void*)0));
743 #endif
744 priv->items [i]->app_name = NULL((void*)0);
745 priv->items [i]->app_exec = NULL((void*)0);
746
747 g_bookmark_file_get_icon (priv->store, uris_ordered [i], & priv->items [i]->icon, NULL((void*)0), NULL((void*)0));
748 }
749
750 /* Since the bookmark store for recently-used items is updated by the caller of BookmarkAgent,
751 * we don't emit notifications in that case. The caller will know when to update itself.
752 */
753 if (!TYPE_IS_RECENT (priv->type)((priv->type) == BOOKMARK_STORE_RECENT_APPS || (priv->type
) == BOOKMARK_STORE_RECENT_DOCS)
)
754 g_object_notify (G_OBJECT (this)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((this)), (((GType) ((20) << (2))))))))
, BOOKMARK_AGENT_ITEMS_PROP"items");
755 }
756
757 if (store_corrupted)
758 save_store (this);
759
760 g_strfreev (uris);
761 g_free (uris_ordered);
762}
763
764static void
765save_store (BookmarkAgent *this)
766{
767 BookmarkAgentPrivate *priv = bookmark_agent_get_instance_private (this);
768
769 gchar *dir;
770
771 g_return_if_fail (priv->user_modifiable)do { if ((priv->user_modifiable)) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "priv->user_modifiable"
); return; } } while (0)
;
772
773 priv->needs_sync = TRUE(!(0));
774 priv->update_path (this);
775
776 dir = g_path_get_dirname (priv->store_path);
777 g_mkdir_with_parents (dir, 0700);
778 g_free (dir);
779
780 priv->save_store (this);
781 update_items (this);
782}
783
784static gint
785get_rank (BookmarkAgent *this, const gchar *uri)
786{
787 BookmarkAgentPrivate *priv = bookmark_agent_get_instance_private (this);
788
789 gchar **groups;
790 gint rank;
791
792 gint i;
793
794 if (! priv->reorderable)
795 return -1;
796
797 groups = g_bookmark_file_get_groups (priv->store, uri, NULL((void*)0), NULL((void*)0));
798 rank = -1;
799
800 for (i = 0; groups && groups [i]; ++i) {
801 if (g_str_has_prefix (groups [i], "rank-")(__builtin_constant_p ("rank-")? __extension__ ({ const char *
const __str = (groups [i]); const char * const __prefix = ("rank-"
); gboolean __result = (0); if (__str == ((void*)0) || __prefix
== ((void*)0)) __result = (g_str_has_prefix) (__str, __prefix
); else { const size_t __str_len = strlen (((__str) + !(__str
))); const size_t __prefix_len = strlen (((__prefix) + !(__prefix
))); if (__str_len >= __prefix_len) __result = memcmp (((__str
) + !(__str)), ((__prefix) + !(__prefix)), __prefix_len) == 0
; } __result; }) : (g_str_has_prefix) (groups [i], "rank-") )
) {
802 if (rank >= 0)
803 g_warning (
804 "store corruption - multiple ranks for same uri: [%s] [%s]",
805 priv->store_path, uri);
806
807 rank = atoi (& groups [i] [5]);
808 }
809 }
810
811 g_strfreev (groups);
812
813 return rank;
814}
815
816static void
817set_rank (BookmarkAgent *this, const gchar *uri, gint rank)
818{
819 BookmarkAgentPrivate *priv = bookmark_agent_get_instance_private (this);
820
821 gchar **groups;
822 gchar *group;
823
824 gint i;
825
826 if (! (priv->reorderable && bookmark_agent_has_item (this, uri)))
827 return;
828
829 groups = g_bookmark_file_get_groups (priv->store, uri, NULL((void*)0), NULL((void*)0));
830
831 for (i = 0; groups && groups [i]; ++i)
832 if (g_str_has_prefix (groups [i], "rank-")(__builtin_constant_p ("rank-")? __extension__ ({ const char *
const __str = (groups [i]); const char * const __prefix = ("rank-"
); gboolean __result = (0); if (__str == ((void*)0) || __prefix
== ((void*)0)) __result = (g_str_has_prefix) (__str, __prefix
); else { const size_t __str_len = strlen (((__str) + !(__str
))); const size_t __prefix_len = strlen (((__prefix) + !(__prefix
))); if (__str_len >= __prefix_len) __result = memcmp (((__str
) + !(__str)), ((__prefix) + !(__prefix)), __prefix_len) == 0
; } __result; }) : (g_str_has_prefix) (groups [i], "rank-") )
)
833 g_bookmark_file_remove_group (priv->store, uri, groups [i], NULL((void*)0));
834
835 g_strfreev (groups);
836
837 group = g_strdup_printf ("rank-%d", rank);
838 g_bookmark_file_add_group (priv->store, uri, group);
839 g_free (group);
840}
841
842static void
843load_xbel_store (BookmarkAgent *this)
844{
845 BookmarkAgentPrivate *priv = bookmark_agent_get_instance_private (this);
846
847 gchar **uris = NULL((void*)0);
848
849 GError *error = NULL((void*)0);
850
851 gint i;
852 gboolean success;
853
854 if (!priv->store_path)
855 success = FALSE(0);
856 else {
857 success = g_bookmark_file_load_from_file (priv->store, priv->store_path, & error);
858 }
859
860 if (!success) {
861 g_bookmark_file_free (priv->store);
862 priv->store = g_bookmark_file_new ();
863
864 if (error) {
865 g_debug ("Couldn't load bookmark file [%s]: %s", priv->store_path, error->message);
866 g_error_free (error);
867 } else {
868 g_debug ("Couldn't load bookmark file [NULL]");
869 }
870 return;
871 }
872
873 uris = g_bookmark_file_get_uris (priv->store, NULL((void*)0));
874
875 for (i = 0; uris && uris [i]; ++i)
876 priv->create_item (this, uris [i]);
877
878 g_strfreev (uris);
879}
880
881static void
882load_places_store (BookmarkAgent *this)
883{
884 BookmarkAgentPrivate *priv = bookmark_agent_get_instance_private (this);
885
886 gchar **uris;
887 gchar **groups;
888 gchar **bookmarks = NULL((void*)0);
889
890 gchar *buf, *label, *uri;
891
892 gint i, j, bookmark_len;
893
894 load_xbel_store (this);
895
896 uris = g_bookmark_file_get_uris (priv->store, NULL((void*)0));
897
898 for (i = 0; uris && uris [i]; ++i) {
899 groups = g_bookmark_file_get_groups (priv->store, uris [i], NULL((void*)0), NULL((void*)0));
900
901 for (j = 0; groups && groups [j]; ++j) {
902 if (! strcmp (groups [j], "gtk-bookmarks")) {
903 g_bookmark_file_remove_item (priv->store, uris [i], NULL((void*)0));
904
905 break;
906 }
907 }
908
909 g_strfreev (groups);
910 }
911
912 g_strfreev (uris);
913
914 g_file_get_contents (priv->gtk_store_path, & buf, NULL((void*)0), NULL((void*)0));
915
916 if (buf) {
917 bookmarks = g_strsplit (buf, "\n", -1);
918 g_free (buf);
919 }
920
921 for (i = 0; bookmarks && bookmarks [i]; ++i) {
922 bookmark_len = strlen (bookmarks [i]);
923 if (bookmark_len > 0) {
924 label = strstr (bookmarks[i], " ");
925 if (label != NULL((void*)0))
926 uri = g_strndup (bookmarks [i], bookmark_len - strlen (label));
927 else
928 uri = bookmarks [i];
929 g_bookmark_file_add_group (priv->store, uri, "gtk-bookmarks");
930 priv->create_item (this, uri);
931 if (label != NULL((void*)0)) {
932 label++;
933 if (strlen (label) > 0)
934 g_bookmark_file_set_title (priv->store, uri, label);
935 g_free (uri);
936 }
937 }
938 }
939
940 g_strfreev (bookmarks);
941}
942
943static gchar *
944find_package_data_file (const gchar *filename)
945{
946 const gchar * const *dirs = NULL((void*)0);
947 gchar *path = NULL((void*)0);
948 gint i;
949
950 dirs = g_get_system_data_dirs ();
951
952 for (i = 0; ! path && dirs && dirs [i]; ++i) {
953 path = g_build_filename (dirs [i], PACKAGE"mate-control-center", filename, NULL((void*)0));
954
955 if (! g_file_test (path, G_FILE_TEST_EXISTS)) {
956 g_free (path);
957 path = NULL((void*)0);
958 }
959 }
960
961 return path;
962}
963
964static void
965update_user_spec_path (BookmarkAgent *this)
966{
967 BookmarkAgentPrivate *priv = bookmark_agent_get_instance_private (this);
968
969 gboolean use_user_path;
970 gchar *path = NULL((void*)0);
971
972 BookmarkStoreStatus status;
973
974 use_user_path = priv->user_modifiable &&
975 (priv->needs_sync || g_file_test (priv->user_store_path, G_FILE_TEST_EXISTS));
976
977 if (use_user_path)
978 path = g_strdup (priv->user_store_path)g_strdup_inline (priv->user_store_path);
979 else
980 path = find_package_data_file (priv->store_filename);
981
982 if (use_user_path)
983 status = BOOKMARK_STORE_USER;
984 else if (path && priv->user_modifiable)
985 status = BOOKMARK_STORE_DEFAULT;
986 else if (path)
987 status = BOOKMARK_STORE_DEFAULT_ONLY;
988 else
989 status = BOOKMARK_STORE_ABSENT;
990
991 if (priv->status != status) {
992 priv->status = status;
993 g_object_notify (G_OBJECT (this)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((this)), (((GType) ((20) << (2))))))))
, BOOKMARK_AGENT_STORE_STATUS_PROP"store-status");
994
995 if (priv->user_store_monitor) {
996 g_file_monitor_cancel (priv->user_store_monitor);
997 g_object_unref (priv->user_store_monitor);
998 priv->user_store_monitor = NULL((void*)0);
999 }
1000
1001 if (priv->status == BOOKMARK_STORE_DEFAULT) {
1002 GFile *user_store_file;
1003
1004 user_store_file = g_file_new_for_path (priv->user_store_path);
1005 priv->user_store_monitor = g_file_monitor_file (user_store_file,
1006 0, NULL((void*)0), NULL((void*)0));
1007 if (priv->user_store_monitor) {
1008 g_signal_connect (priv->user_store_monitor, "changed",g_signal_connect_data ((priv->user_store_monitor), ("changed"
), (((GCallback) (store_monitor_cb))), (this), ((void*)0), (GConnectFlags
) 0)
1009 G_CALLBACK (store_monitor_cb), this)g_signal_connect_data ((priv->user_store_monitor), ("changed"
), (((GCallback) (store_monitor_cb))), (this), ((void*)0), (GConnectFlags
) 0)
;
1010 }
1011
1012 g_object_unref (user_store_file);
1013 }
1014 }
1015
1016 if (g_strcmp0 (priv->store_path, path)) {
1017 g_free (priv->store_path);
1018 priv->store_path = path;
1019
1020 if (priv->store_monitor) {
1021 g_file_monitor_cancel (priv->store_monitor);
1022 g_object_unref (priv->store_monitor);
1023 }
1024
1025 if (priv->store_path) {
1026 GFile *store_file;
1027
1028 store_file = g_file_new_for_path (priv->store_path);
1029 priv->store_monitor = g_file_monitor_file (store_file,
1030 0, NULL((void*)0), NULL((void*)0));
1031 if (priv->store_monitor) {
1032 g_signal_connect (priv->store_monitor, "changed",g_signal_connect_data ((priv->store_monitor), ("changed"),
(((GCallback) (store_monitor_cb))), (this), ((void*)0), (GConnectFlags
) 0)
1033 G_CALLBACK (store_monitor_cb), this)g_signal_connect_data ((priv->store_monitor), ("changed"),
(((GCallback) (store_monitor_cb))), (this), ((void*)0), (GConnectFlags
) 0)
;
1034 }
1035
1036 g_object_unref (store_file);
1037 }
1038 }
1039 else
1040 g_free (path);
1041}
1042
1043static void
1044save_xbel_store (BookmarkAgent *this)
1045{
1046 BookmarkAgentPrivate *priv = bookmark_agent_get_instance_private (this);
1047
1048 GError *error = NULL((void*)0);
1049
1050 if (g_bookmark_file_to_file (priv->store, priv->store_path, &error))
1051 return;
1052
1053 if (error) {
1054 g_warning ("Couldn't save bookmark file [%s]: %s", priv->store_path, error->message);
1055 g_error_free (error);
1056 } else {
1057 g_warning ("Couldn't save bookmark file [%s]", priv->store_path);
1058 }
1059}
1060
1061static void
1062create_app_item (BookmarkAgent *this, const gchar *uri)
1063{
1064 BookmarkAgentPrivate *priv = bookmark_agent_get_instance_private (this);
1065
1066 MateDesktopItem *ditem;
1067 gchar *uri_new = NULL((void*)0);
1068
1069 ditem = libslab_mate_desktop_item_new_from_unknown_id (uri);
1070
1071 if (ditem) {
1072 uri_new = g_strdup (mate_desktop_item_get_location (ditem))g_strdup_inline (mate_desktop_item_get_location (ditem));
1073 mate_desktop_item_unref (ditem);
1074 }
1075
1076 if (! uri_new)
1077 return;
1078
1079 if (g_strcmp0 (uri, uri_new))
1080 g_bookmark_file_move_item (priv->store, uri, uri_new, NULL((void*)0));
1081
1082 g_free (uri_new);
1083}
1084
1085static void
1086create_doc_item (BookmarkAgent *this, const gchar *uri)
1087{
1088 BookmarkAgentPrivate *priv = bookmark_agent_get_instance_private (this);
1089
1090 gchar *uri_new = NULL((void*)0);
1091
1092 if ((strcmp (uri, "BLANK_SPREADSHEET") == 0) || (strcmp (uri, "BLANK_DOCUMENT") == 0)) {
1093 gchar *template = NULL((void*)0);
1094 gchar *file;
1095
1096 gchar *dir = g_strdup (g_get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS))g_strdup_inline (g_get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS
))
;
1097 if (!dir)
1098 dir = g_build_filename (g_get_home_dir (), "Documents", NULL((void*)0));
1099
1100 if (strcmp (uri, "BLANK_SPREADSHEET") == 0) {
1101 g_bookmark_file_set_title (priv->store, uri, "BLANK_SPREADSHEET");
1102 file = g_strconcat (_("New Spreadsheet")((char *) g_dgettext ("mate-control-center", "New Spreadsheet"
))
, ".ots", NULL((void*)0));
1103 template = find_package_data_file (CALC_TEMPLATE_FILE_NAME"empty.ots");
1104 } else {
1105 g_bookmark_file_set_title (priv->store, uri, "BLANK_DOCUMENT");
1106 file = g_strconcat (_("New Document")((char *) g_dgettext ("mate-control-center", "New Document")), ".ott", NULL((void*)0));
1107 template = find_package_data_file (WRITER_TEMPLATE_FILE_NAME"empty.ott");
1108 }
1109
1110 gchar *path = g_build_filename (dir, file, NULL((void*)0));
1111 if (!g_file_test (path, G_FILE_TEST_EXISTS)) {
1112 g_mkdir_with_parents (dir, 0700);
1113
1114 if (template != NULL((void*)0)) {
1115 gchar *contents;
1116 gsize length;
1117
1118 if (g_file_get_contents (template, &contents, &length, NULL((void*)0)))
1119 g_file_set_contents (path, contents, length, NULL((void*)0));
1120
1121 g_free (contents);
1122 } else {
1123 fclose (g_fopenfopen (path, "w"));
1124 }
1125 }
1126
1127 uri_new = g_filename_to_uri (path, NULL((void*)0), NULL((void*)0));
1128
1129 g_free (dir);
1130 g_free (file);
1131 g_free (path);
1132 g_free (template);
1133 }
1134
1135 if (!uri_new)
1136 return;
1137
1138 if (g_strcmp0 (uri, uri_new))
1139 g_bookmark_file_move_item (priv->store, uri, uri_new, NULL((void*)0));
1140
1141 g_free (uri_new);
1142}
1143
1144static void
1145create_dir_item (BookmarkAgent *this, const gchar *uri)
1146{
1147 BookmarkAgentPrivate *priv = bookmark_agent_get_instance_private (this);
1148
1149 gchar *uri_new = NULL((void*)0);
1150 gchar *path = NULL((void*)0);
1151 gchar *name = NULL((void*)0);
1152 gchar *icon = NULL((void*)0);
1153
1154 gchar *search_string = NULL((void*)0);
1155
1156 gboolean gotta_free_name = FALSE(0);
1157
1158 if (strcmp (uri, "HOME") == 0) {
1159 uri_new = g_filename_to_uri (g_get_home_dir (), NULL((void*)0), NULL((void*)0));
1160 name = g_strdup (C_("Home folder", "Home"))g_strdup_inline (g_dpgettext ("mate-control-center", "Home folder"
"\004" "Home", strlen ("Home folder") + 1))
;
1161 gotta_free_name = TRUE(!(0));
1162 icon = "user-home";
1163 } else if (strcmp (uri, "DOCUMENTS") == 0) {
1164 path = g_strdup (g_get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS))g_strdup_inline (g_get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS
))
;
1165 if (!path)
1166 path = g_build_filename (g_get_home_dir (), "Documents", NULL((void*)0));
1167 name = _("Documents")((char *) g_dgettext ("mate-control-center", "Documents"));
1168 uri_new = g_filename_to_uri (path, NULL((void*)0), NULL((void*)0));
1169 } else if (strcmp (uri, "DESKTOP") == 0) {
1170 path = g_strdup (g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP))g_strdup_inline (g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP
))
;
1171 if (!path)
1172 path = g_build_filename (g_get_home_dir (), "Desktop", NULL((void*)0));
1173 name = _("Desktop")((char *) g_dgettext ("mate-control-center", "Desktop"));
1174 uri_new = g_filename_to_uri (path, NULL((void*)0), NULL((void*)0));
1175 icon = "user-desktop";
1176 } else if (strcmp (uri, "file:///") == 0) {
1177 icon = "drive-harddisk";
1178 name = _("File System")((char *) g_dgettext ("mate-control-center", "File System"));
1179 } else if (strcmp (uri, "network:") == 0) {
1180 icon = "network-workgroup";
1181 name = _("Network Servers")((char *) g_dgettext ("mate-control-center", "Network Servers"
))
;
1182 } else if (g_str_has_prefix (uri, "x-caja-search")(__builtin_constant_p ("x-caja-search")? __extension__ ({ const
char * const __str = (uri); const char * const __prefix = ("x-caja-search"
); gboolean __result = (0); if (__str == ((void*)0) || __prefix
== ((void*)0)) __result = (g_str_has_prefix) (__str, __prefix
); else { const size_t __str_len = strlen (((__str) + !(__str
))); const size_t __prefix_len = strlen (((__prefix) + !(__prefix
))); if (__str_len >= __prefix_len) __result = memcmp (((__str
) + !(__str)), ((__prefix) + !(__prefix)), __prefix_len) == 0
; } __result; }) : (g_str_has_prefix) (uri, "x-caja-search") )
) {
1183 icon = "system-search";
1184
1185 path = g_build_filename (g_get_user_data_dir (), "caja", "searches", & uri [21], NULL((void*)0));
1186
1187 if (g_file_test (path, G_FILE_TEST_EXISTS)) {
1188 gchar *buf = NULL((void*)0);
1189 g_file_get_contents (path, &buf, NULL((void*)0), NULL((void*)0));
1190
1191 gchar *tag_open_ptr = NULL((void*)0);
1192 gchar *tag_close_ptr = NULL((void*)0);
1193
1194 if (buf) {
1195 tag_open_ptr = strstr (buf, "<text>");
1196 tag_close_ptr = strstr (buf, "</text>");
1197 }
1198
1199 if (tag_open_ptr && tag_close_ptr) {
1200 tag_close_ptr [0] = '\0';
1201 tag_close_ptr [0] = 'a';
1202 search_string = g_strdup_printf ("\"%s\"", &tag_open_ptr[6]);
1203 }
1204
1205 g_free (buf);
1206 }
1207
1208 if (search_string) {
1209 name = search_string;
1210 gotta_free_name = TRUE(!(0));
1211 } else {
1212 name = _("Search")((char *) g_dgettext ("mate-control-center", "Search"));
1213 }
1214 }
1215
1216 if (icon)
1217 g_bookmark_file_set_icon (priv->store, uri, icon, "image/png");
1218
1219 if (name)
1220 g_bookmark_file_set_title (priv->store, uri, name);
1221
1222 if (uri_new && g_strcmp0 (uri, uri_new))
1223 g_bookmark_file_move_item (priv->store, uri, uri_new, NULL((void*)0));
1224
1225 if (gotta_free_name) {
1226 g_free (name);
1227 }
1228
1229 g_free (path);
1230 g_free (uri_new);
1231}
1232
1233static void
1234store_monitor_cb (GFileMonitor *mon, GFile *f1, GFile *f2,
1235 GFileMonitorEvent event_type, gpointer user_data)
1236{
1237 update_agent (BOOKMARK_AGENT (user_data)((((BookmarkAgent*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((bookmark_agent_get_type ()))))))
)
;
1
Calling 'update_agent'
1238}
1239
1240static void
1241weak_destroy_cb (gpointer data, GObject *g_obj)
1242{
1243 instances [GPOINTER_TO_INT (data)((gint) (glong) (data))] = NULL((void*)0);
1244}
diff --git a/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-8e9a5f.html b/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-8e9a5f.html new file mode 100644 index 00000000..12c2af87 --- /dev/null +++ b/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-8e9a5f.html @@ -0,0 +1,816 @@ + + + +mate-keyboard-properties-xkbpv.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:capplets/keyboard/mate-keyboard-properties-xkbpv.c
Warning:line 96, column 10
Although the value stored to 'p' is used in the enclosing expression, the value is never actually read from 'p'
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name mate-keyboard-properties-xkbpv.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/capplets/keyboard -fcoverage-compilation-dir=/rootdir/capplets/keyboard -resource-dir /usr/bin/../lib/clang/18 -D HAVE_CONFIG_H -I . -I ../.. -I ../../capplets/common -I /usr/include/udisks2 -I /usr/include/libgtop-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/libxml2 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/gio-unix-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/dconf -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I ../../ -D G_LOG_DOMAIN="keyboard-properties" -I /usr/include/polkit-1 -I /usr/include/gio-unix-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/cairo -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/webp -I /usr/include/gio-unix-2.0 -I /usr/include/libpng16 -I /usr/include/pixman-1 -I /usr/include/cloudproviders -I /usr/include/fribidi -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I /usr/include/libxml2 -D WITH_GZFILEOP -D MATECC_DATA_DIR="/usr/local/share/mate-control-center" -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-06-07-044335-13427-1 -x c mate-keyboard-properties-xkbpv.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* -*- mode: c; style: linux -*- */
2
3/* mate-keyboard-properties-xkbpv.c
4 * Copyright (C) 2003-2007 Sergey V. Udaltsov
5 *
6 * Written by: Sergey V. Udaltsov <svu@gnome.org>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2, or (at your option)
11 * any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21 * 02110-1301, USA.
22 */
23
24#ifdef HAVE_CONFIG_H1
25# include <config.h>
26#endif
27
28#include <libmatekbd/matekbd-keyboard-drawing.h>
29
30#include "capplet-util.h"
31#include "mate-keyboard-properties-xkb.h"
32
33#ifdef HAVE_X11_EXTENSIONS_XKB_H1
34#include "X11/XKBlib.h"
35/**
36 * BAD STYLE: Taken from xklavier_private_xkb.h
37 * Any ideas on architectural improvements are WELCOME
38 */
39extern gboolean xkl_xkb_config_native_prepare (XklEngine * engine,
40 const XklConfigRec * data,
41 XkbComponentNamesPtr
42 component_names);
43
44extern void xkl_xkb_config_native_cleanup (XklEngine * engine,
45 XkbComponentNamesPtr
46 component_names);
47
48/* */
49#endif
50
51static MatekbdKeyboardDrawingGroupLevel groupsLevels[] =
52 { {0, 1}, {0, 3}, {0, 0}, {0, 2} };
53static MatekbdKeyboardDrawingGroupLevel *pGroupsLevels[] = {
54 groupsLevels, groupsLevels + 1, groupsLevels + 2, groupsLevels + 3
55};
56
57GtkWidget *
58xkb_layout_preview_create_widget (GtkBuilder * chooserDialog)
59{
60 GtkWidget *kbdraw = matekbd_keyboard_drawing_new ();
61
62 matekbd_keyboard_drawing_set_groups_levels (MATEKBD_KEYBOARD_DRAWING((((MatekbdKeyboardDrawing*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((kbdraw)), (matekbd_keyboard_drawing_get_type
())))))
63 (kbdraw)((((MatekbdKeyboardDrawing*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((kbdraw)), (matekbd_keyboard_drawing_get_type
())))))
, pGroupsLevels);
64 return kbdraw;
65}
66
67void
68xkb_layout_preview_update (GtkBuilder * chooser_dialog)
69{
70#ifdef HAVE_X11_EXTENSIONS_XKB_H1
71 GtkWidget *chooser = CWID ("xkb_layout_chooser")((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (chooser_dialog, "xkb_layout_chooser"
))), ((gtk_widget_get_type ()))))))
;
72 GtkWidget *kbdraw =
73 GTK_WIDGET (g_object_get_data (G_OBJECT (chooser), "kbdraw"))((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((g_object_get_data (((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((chooser)), (((GType) ((20) << (2))
)))))), "kbdraw"))), ((gtk_widget_get_type ()))))))
;
74 gchar *id = xkb_layout_chooser_get_selected_id (chooser_dialog);
75 xkb_layout_preview_set_drawing_layout (kbdraw, id);
76 g_free (id);
77#endif
78}
79
80void
81xkb_layout_preview_set_drawing_layout (GtkWidget * kbdraw,
82 const gchar * id)
83{
84#ifdef HAVE_X11_EXTENSIONS_XKB_H1
85 if (kbdraw != NULL((void*)0)) {
86 if (id != NULL((void*)0)) {
87 XklConfigRec *data;
88 char **p, *layout, *variant;
89 XkbComponentNamesRec component_names;
90
91 data = xkl_config_rec_new ();
92 if (xkl_config_rec_get_from_server (data, engine)) {
93 if ((p = data->layouts) != NULL((void*)0))
94 g_strfreev (data->layouts);
95
96 if ((p = data->variants) != NULL((void*)0))
Although the value stored to 'p' is used in the enclosing expression, the value is never actually read from 'p'
97 g_strfreev (data->variants);
98
99 data->layouts = g_new0 (char *, 2)((char * *) g_malloc0_n ((2), sizeof (char *)));
100 data->variants = g_new0 (char *, 2)((char * *) g_malloc0_n ((2), sizeof (char *)));
101 if (matekbd_keyboard_config_split_items
102 (id, &layout, &variant)
103 && variant != NULL((void*)0)) {
104 data->layouts[0] =
105 (layout ==
106 NULL((void*)0)) ? NULL((void*)0) :
107 g_strdup (layout)g_strdup_inline (layout);
108 data->variants[0] =
109 (variant ==
110 NULL((void*)0)) ? NULL((void*)0) :
111 g_strdup (variant)g_strdup_inline (variant);
112 } else {
113 data->layouts[0] =
114 (id ==
115 NULL((void*)0)) ? NULL((void*)0) : g_strdup (id)g_strdup_inline (id);
116 data->variants[0] = NULL((void*)0);
117 }
118
119 if (xkl_xkb_config_native_prepare
120 (engine, data, &component_names)) {
121 matekbd_keyboard_drawing_set_keyboard
122 (MATEKBD_KEYBOARD_DRAWING((((MatekbdKeyboardDrawing*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((kbdraw)), (matekbd_keyboard_drawing_get_type
())))))
123 (kbdraw)((((MatekbdKeyboardDrawing*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((kbdraw)), (matekbd_keyboard_drawing_get_type
())))))
, &component_names);
124
125 xkl_xkb_config_native_cleanup
126 (engine, &component_names);
127 }
128 }
129 g_object_unref (G_OBJECT (data)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data)), (((GType) ((20) << (2))))))))
);
130 } else
131 matekbd_keyboard_drawing_set_keyboard
132 (MATEKBD_KEYBOARD_DRAWING (kbdraw)((((MatekbdKeyboardDrawing*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((kbdraw)), (matekbd_keyboard_drawing_get_type
())))))
, NULL((void*)0));
133
134 }
135#endif
136}
diff --git a/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-a6bd27.html b/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-a6bd27.html new file mode 100644 index 00000000..3e90a512 --- /dev/null +++ b/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-a6bd27.html @@ -0,0 +1,816 @@ + + + +mate-keyboard-properties-xkbpv.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:capplets/keyboard/mate-keyboard-properties-xkbpv.c
Warning:line 93, column 10
Although the value stored to 'p' is used in the enclosing expression, the value is never actually read from 'p'
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name mate-keyboard-properties-xkbpv.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/capplets/keyboard -fcoverage-compilation-dir=/rootdir/capplets/keyboard -resource-dir /usr/bin/../lib/clang/18 -D HAVE_CONFIG_H -I . -I ../.. -I ../../capplets/common -I /usr/include/udisks2 -I /usr/include/libgtop-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/libxml2 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/gio-unix-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/dconf -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I ../../ -D G_LOG_DOMAIN="keyboard-properties" -I /usr/include/polkit-1 -I /usr/include/gio-unix-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/cairo -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/webp -I /usr/include/gio-unix-2.0 -I /usr/include/libpng16 -I /usr/include/pixman-1 -I /usr/include/cloudproviders -I /usr/include/fribidi -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I /usr/include/libxml2 -D WITH_GZFILEOP -D MATECC_DATA_DIR="/usr/local/share/mate-control-center" -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-06-07-044335-13427-1 -x c mate-keyboard-properties-xkbpv.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* -*- mode: c; style: linux -*- */
2
3/* mate-keyboard-properties-xkbpv.c
4 * Copyright (C) 2003-2007 Sergey V. Udaltsov
5 *
6 * Written by: Sergey V. Udaltsov <svu@gnome.org>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2, or (at your option)
11 * any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21 * 02110-1301, USA.
22 */
23
24#ifdef HAVE_CONFIG_H1
25# include <config.h>
26#endif
27
28#include <libmatekbd/matekbd-keyboard-drawing.h>
29
30#include "capplet-util.h"
31#include "mate-keyboard-properties-xkb.h"
32
33#ifdef HAVE_X11_EXTENSIONS_XKB_H1
34#include "X11/XKBlib.h"
35/**
36 * BAD STYLE: Taken from xklavier_private_xkb.h
37 * Any ideas on architectural improvements are WELCOME
38 */
39extern gboolean xkl_xkb_config_native_prepare (XklEngine * engine,
40 const XklConfigRec * data,
41 XkbComponentNamesPtr
42 component_names);
43
44extern void xkl_xkb_config_native_cleanup (XklEngine * engine,
45 XkbComponentNamesPtr
46 component_names);
47
48/* */
49#endif
50
51static MatekbdKeyboardDrawingGroupLevel groupsLevels[] =
52 { {0, 1}, {0, 3}, {0, 0}, {0, 2} };
53static MatekbdKeyboardDrawingGroupLevel *pGroupsLevels[] = {
54 groupsLevels, groupsLevels + 1, groupsLevels + 2, groupsLevels + 3
55};
56
57GtkWidget *
58xkb_layout_preview_create_widget (GtkBuilder * chooserDialog)
59{
60 GtkWidget *kbdraw = matekbd_keyboard_drawing_new ();
61
62 matekbd_keyboard_drawing_set_groups_levels (MATEKBD_KEYBOARD_DRAWING((((MatekbdKeyboardDrawing*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((kbdraw)), (matekbd_keyboard_drawing_get_type
())))))
63 (kbdraw)((((MatekbdKeyboardDrawing*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((kbdraw)), (matekbd_keyboard_drawing_get_type
())))))
, pGroupsLevels);
64 return kbdraw;
65}
66
67void
68xkb_layout_preview_update (GtkBuilder * chooser_dialog)
69{
70#ifdef HAVE_X11_EXTENSIONS_XKB_H1
71 GtkWidget *chooser = CWID ("xkb_layout_chooser")((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (chooser_dialog, "xkb_layout_chooser"
))), ((gtk_widget_get_type ()))))))
;
72 GtkWidget *kbdraw =
73 GTK_WIDGET (g_object_get_data (G_OBJECT (chooser), "kbdraw"))((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((g_object_get_data (((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((chooser)), (((GType) ((20) << (2))
)))))), "kbdraw"))), ((gtk_widget_get_type ()))))))
;
74 gchar *id = xkb_layout_chooser_get_selected_id (chooser_dialog);
75 xkb_layout_preview_set_drawing_layout (kbdraw, id);
76 g_free (id);
77#endif
78}
79
80void
81xkb_layout_preview_set_drawing_layout (GtkWidget * kbdraw,
82 const gchar * id)
83{
84#ifdef HAVE_X11_EXTENSIONS_XKB_H1
85 if (kbdraw != NULL((void*)0)) {
86 if (id != NULL((void*)0)) {
87 XklConfigRec *data;
88 char **p, *layout, *variant;
89 XkbComponentNamesRec component_names;
90
91 data = xkl_config_rec_new ();
92 if (xkl_config_rec_get_from_server (data, engine)) {
93 if ((p = data->layouts) != NULL((void*)0))
Although the value stored to 'p' is used in the enclosing expression, the value is never actually read from 'p'
94 g_strfreev (data->layouts);
95
96 if ((p = data->variants) != NULL((void*)0))
97 g_strfreev (data->variants);
98
99 data->layouts = g_new0 (char *, 2)((char * *) g_malloc0_n ((2), sizeof (char *)));
100 data->variants = g_new0 (char *, 2)((char * *) g_malloc0_n ((2), sizeof (char *)));
101 if (matekbd_keyboard_config_split_items
102 (id, &layout, &variant)
103 && variant != NULL((void*)0)) {
104 data->layouts[0] =
105 (layout ==
106 NULL((void*)0)) ? NULL((void*)0) :
107 g_strdup (layout)g_strdup_inline (layout);
108 data->variants[0] =
109 (variant ==
110 NULL((void*)0)) ? NULL((void*)0) :
111 g_strdup (variant)g_strdup_inline (variant);
112 } else {
113 data->layouts[0] =
114 (id ==
115 NULL((void*)0)) ? NULL((void*)0) : g_strdup (id)g_strdup_inline (id);
116 data->variants[0] = NULL((void*)0);
117 }
118
119 if (xkl_xkb_config_native_prepare
120 (engine, data, &component_names)) {
121 matekbd_keyboard_drawing_set_keyboard
122 (MATEKBD_KEYBOARD_DRAWING((((MatekbdKeyboardDrawing*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((kbdraw)), (matekbd_keyboard_drawing_get_type
())))))
123 (kbdraw)((((MatekbdKeyboardDrawing*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((kbdraw)), (matekbd_keyboard_drawing_get_type
())))))
, &component_names);
124
125 xkl_xkb_config_native_cleanup
126 (engine, &component_names);
127 }
128 }
129 g_object_unref (G_OBJECT (data)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data)), (((GType) ((20) << (2))))))))
);
130 } else
131 matekbd_keyboard_drawing_set_keyboard
132 (MATEKBD_KEYBOARD_DRAWING (kbdraw)((((MatekbdKeyboardDrawing*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((kbdraw)), (matekbd_keyboard_drawing_get_type
())))))
, NULL((void*)0));
133
134 }
135#endif
136}
diff --git a/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-b1744c.html b/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-b1744c.html new file mode 100644 index 00000000..e39adb81 --- /dev/null +++ b/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-b1744c.html @@ -0,0 +1,1289 @@ + + + +drw-break-window.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:typing-break/drw-break-window.c
Warning:line 503, column 3
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name drw-break-window.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/typing-break -fcoverage-compilation-dir=/rootdir/typing-break -resource-dir /usr/bin/../lib/clang/18 -D HAVE_CONFIG_H -I . -I .. -D MATELOCALEDIR="/usr/local/share/locale" -D IMAGEDIR="/usr/local/share/mate-control-center/pixmaps" -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/gio-unix-2.0 -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I /usr/include/libappindicator3-0.1 -I /usr/include/libdbusmenu-glib-0.4 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/gio-unix-2.0 -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/startup-notification-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/gio-unix-2.0 -I /usr/include/dconf -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -D HAVE_CANBERRA_GTK -D _REENTRANT -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/gio-unix-2.0 -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-06-07-044335-13427-1 -x c drw-break-window.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2/*
3 * Copyright (C) 2002 CodeFactory AB
4 * Copyright (C) 2002-2003 Richard Hult <richard@imendio.com>
5
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of the
10 * License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public
18 * License along with this program; if not, write to the
19 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
21 */
22
23#include <config.h>
24#include <string.h>
25#include <math.h>
26#include <glib/gi18n.h>
27#include <gtk/gtk.h>
28#include <gdk/gdkx.h>
29#include <gdk/gdkkeysyms.h>
30#include <gio/gio.h>
31
32#ifdef HAVE_CANBERRA_GTK1
33#include <canberra-gtk.h>
34#endif
35
36#include "drwright.h"
37#include "drw-utils.h"
38#include "drw-break-window.h"
39#include "drw-timer.h"
40
41struct _DrwBreakWindowPrivate {
42 GtkWidget *clock_label;
43 GtkWidget *break_label;
44 GtkWidget *image;
45
46 GtkWidget *postpone_entry;
47 GtkWidget *postpone_button;
48
49 DrwTimer *timer;
50
51 gint break_time;
52 gchar *break_text;
53 guint clock_timeout_id;
54 guint postpone_timeout_id;
55 guint postpone_sensitize_id;
56};
57
58#define POSTPONE_CANCEL30 30
59
60/* Signals */
61enum {
62 DONE,
63 POSTPONE,
64 LAST_SIGNAL
65};
66
67static void drw_break_window_finalize (GObject *object);
68static void drw_break_window_dispose (GObject *object);
69static gboolean postpone_sensitize_cb (DrwBreakWindow *window);
70static gboolean clock_timeout_cb (DrwBreakWindow *window);
71static void postpone_clicked_cb (GtkWidget *button,
72 GtkWidget *window);
73static gboolean label_draw_event_cb (GtkLabel *label,
74 cairo_t *cr,
75 gpointer user_data);
76static void label_size_allocate_cb (GtkLabel *label,
77 GdkRectangle *allocation,
78 gpointer user_data);
79
80G_DEFINE_TYPE_WITH_PRIVATE (DrwBreakWindow, drw_break_window, GTK_TYPE_WINDOW)static void drw_break_window_init (DrwBreakWindow *self); static
void drw_break_window_class_init (DrwBreakWindowClass *klass
); static GType drw_break_window_get_type_once (void); static
gpointer drw_break_window_parent_class = ((void*)0); static gint
DrwBreakWindow_private_offset; static void drw_break_window_class_intern_init
(gpointer klass) { drw_break_window_parent_class = g_type_class_peek_parent
(klass); if (DrwBreakWindow_private_offset != 0) g_type_class_adjust_private_offset
(klass, &DrwBreakWindow_private_offset); drw_break_window_class_init
((DrwBreakWindowClass*) klass); } __attribute__ ((__unused__
)) static inline gpointer drw_break_window_get_instance_private
(DrwBreakWindow *self) { return (((gpointer) ((guint8*) (self
) + (glong) (DrwBreakWindow_private_offset)))); } GType drw_break_window_get_type
(void) { static GType static_g_define_type_id = 0; if ((__extension__
({ _Static_assert (sizeof *(&static_g_define_type_id) ==
sizeof (gpointer), "Expression evaluates to false"); (void) (
0 ? (gpointer) * (&static_g_define_type_id) : ((void*)0))
; (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter_pointer (
&static_g_define_type_id)); })) ) { GType g_define_type_id
= drw_break_window_get_type_once (); (__extension__ ({ _Static_assert
(sizeof *(&static_g_define_type_id) == sizeof (gpointer)
, "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id
) = (g_define_type_id)) : (void) 0; g_once_init_leave_pointer
((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id
)); })) ; } return static_g_define_type_id; } __attribute__ (
(__noinline__)) static GType drw_break_window_get_type_once (
void) { GType g_define_type_id = g_type_register_static_simple
((gtk_window_get_type ()), g_intern_static_string ("DrwBreakWindow"
), sizeof (DrwBreakWindowClass), (GClassInitFunc)(void (*)(void
)) drw_break_window_class_intern_init, sizeof (DrwBreakWindow
), (GInstanceInitFunc)(void (*)(void)) drw_break_window_init,
(GTypeFlags) 0); { {{ DrwBreakWindow_private_offset = g_type_add_instance_private
(g_define_type_id, sizeof (DrwBreakWindowPrivate)); };} } return
g_define_type_id; }
81
82static guint signals[LAST_SIGNAL] = { 0 };
83
84static void
85drw_break_window_class_init (DrwBreakWindowClass *klass)
86{
87 GObjectClass *object_class = G_OBJECT_CLASS (klass)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((klass)), (((GType) ((20) << (2))))))))
;
88
89 object_class->finalize = drw_break_window_finalize;
90 object_class->dispose = drw_break_window_dispose;
91
92 signals[POSTPONE] =
93 g_signal_new ("postpone",
94 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
95 G_SIGNAL_RUN_LAST,
96 0,
97 NULL((void*)0), NULL((void*)0),
98 g_cclosure_marshal_VOID__VOID,
99 G_TYPE_NONE((GType) ((1) << (2))), 0);
100
101 signals[DONE] =
102 g_signal_new ("done",
103 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
104 G_SIGNAL_RUN_LAST,
105 0,
106 NULL((void*)0), NULL((void*)0),
107 g_cclosure_marshal_VOID__VOID,
108 G_TYPE_NONE((GType) ((1) << (2))), 0);
109}
110
111static void
112drw_break_window_init (DrwBreakWindow *window)
113{
114 DrwBreakWindowPrivate *priv;
115 GtkWidget *vbox;
116 GtkWidget *hbox;
117 gchar *str;
118 GtkWidget *outer_vbox;
119 GtkWidget *button_box;
120 gboolean allow_postpone;
121
122 gint root_monitor = 0;
123 GdkScreen *screen = NULL((void*)0);
124 GdkDisplay *display;
125 GdkRectangle monitor;
126 gint right_padding;
127 gint bottom_padding;
128 gint scale;
129 GSettings *settings;
130
131 priv = drw_break_window_get_instance_private (window);
132 window->priv = priv;
133
134 settings = g_settings_new (TYPING_BREAK_SCHEMA"org.mate.typing-break");
135
136 priv->break_time = 60 * g_settings_get_int (settings, "break-time");
137
138 allow_postpone = g_settings_get_boolean (settings, "allow-postpone");
139 g_object_unref (settings);
140
141 gtk_window_set_keep_above (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
, TRUE(!(0)));
142 gtk_window_fullscreen (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
);
143 gtk_window_set_modal (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
, TRUE(!(0)));
144
145 screen = gdk_screen_get_default ();
146 display = gdk_screen_get_display (screen);
147 scale = gtk_widget_get_scale_factor (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
148
149 gdk_monitor_get_geometry (gdk_display_get_monitor (display, root_monitor), &monitor);
150
151 gtk_window_set_default_size (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
,
152 WidthOfScreen (gdk_x11_screen_get_xscreen (screen))((gdk_x11_screen_get_xscreen (screen))->width) / scale,
153 HeightOfScreen (gdk_x11_screen_get_xscreen (screen))((gdk_x11_screen_get_xscreen (screen))->height) / scale);
154
155 gtk_window_set_decorated (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
, FALSE(0));
156 gtk_widget_set_app_paintable (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
, TRUE(!(0)));
157 drw_setup_background (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
158
159 right_padding = WidthOfScreen (gdk_x11_screen_get_xscreen (screen))((gdk_x11_screen_get_xscreen (screen))->width) / scale - monitor.width - monitor.x;
160 bottom_padding = HeightOfScreen (gdk_x11_screen_get_xscreen (screen))((gdk_x11_screen_get_xscreen (screen))->height) / scale - monitor.height - monitor.y;
161
162 outer_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
163 gtk_widget_set_hexpand (outer_vbox, TRUE(!(0)));
164 gtk_widget_set_vexpand (outer_vbox, TRUE(!(0)));
165 gtk_widget_set_margin_top (outer_vbox, monitor.y);
166 gtk_widget_set_margin_bottom (outer_vbox, bottom_padding);
167 gtk_widget_set_margin_start (outer_vbox, monitor.x);
168 gtk_widget_set_margin_end (outer_vbox, right_padding);
169 gtk_widget_show (outer_vbox);
170
171 gtk_container_add (GTK_CONTAINER (window)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_container_get_type ()))))))
, outer_vbox);
172
173 if (allow_postpone) {
174 button_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
175 gtk_widget_show (button_box);
176
177 gtk_container_set_border_width (GTK_CONTAINER (button_box)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((button_box)), ((gtk_container_get_type ()))))))
, 12);
178
179 priv->postpone_button = gtk_button_new_with_mnemonic (_("_Postpone Break")gettext ("_Postpone Break"));
180 gtk_widget_show (priv->postpone_button);
181
182 gtk_widget_set_sensitive (priv->postpone_button, FALSE(0));
183
184 if (priv->postpone_sensitize_id) {
185 g_source_remove (priv->postpone_sensitize_id);
186 }
187
188 priv->postpone_sensitize_id = g_timeout_add_seconds (5,
189 (GSourceFunc) postpone_sensitize_cb,
190 window);
191
192 g_signal_connect (priv->postpone_button,g_signal_connect_data ((priv->postpone_button), ("clicked"
), (((GCallback) (postpone_clicked_cb))), (window), ((void*)0
), (GConnectFlags) 0)
193 "clicked",g_signal_connect_data ((priv->postpone_button), ("clicked"
), (((GCallback) (postpone_clicked_cb))), (window), ((void*)0
), (GConnectFlags) 0)
194 G_CALLBACK (postpone_clicked_cb),g_signal_connect_data ((priv->postpone_button), ("clicked"
), (((GCallback) (postpone_clicked_cb))), (window), ((void*)0
), (GConnectFlags) 0)
195 window)g_signal_connect_data ((priv->postpone_button), ("clicked"
), (((GCallback) (postpone_clicked_cb))), (window), ((void*)0
), (GConnectFlags) 0)
;
196
197 gtk_box_pack_end (GTK_BOX (button_box)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((button_box)), ((gtk_box_get_type ()))))))
, priv->postpone_button, FALSE(0), TRUE(!(0)), 0);
198
199 priv->postpone_entry = gtk_entry_new ();
200 gtk_entry_set_has_frame (GTK_ENTRY (priv->postpone_entry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->postpone_entry)), ((gtk_entry_get_type ()))))))
, FALSE(0));
201
202 gtk_box_pack_end (GTK_BOX (button_box)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((button_box)), ((gtk_box_get_type ()))))))
, priv->postpone_entry, FALSE(0), TRUE(!(0)), 4);
203
204 gtk_box_pack_end (GTK_BOX (outer_vbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((outer_vbox)), ((gtk_box_get_type ()))))))
, button_box, FALSE(0), TRUE(!(0)), 0);
205 }
206
207 vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
208 gtk_widget_set_halign (vbox, GTK_ALIGN_CENTER);
209 gtk_widget_set_valign (vbox, GTK_ALIGN_CENTER);
210 gtk_widget_show (vbox);
211
212 gtk_box_pack_start (GTK_BOX (outer_vbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((outer_vbox)), ((gtk_box_get_type ()))))))
, vbox, TRUE(!(0)), TRUE(!(0)), 0);
213
214 hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
215 gtk_widget_show (hbox);
216 gtk_box_pack_start (GTK_BOX (vbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((vbox)), ((gtk_box_get_type ()))))))
, hbox, TRUE(!(0)), FALSE(0), 0);
217
218 priv->image = gtk_image_new_from_icon_name ("process-stop", GTK_ICON_SIZE_DIALOG);
219 gtk_widget_set_halign (priv->image, GTK_ALIGN_END);
220 gtk_widget_set_valign (priv->image, GTK_ALIGN_CENTER);
221 gtk_widget_show (priv->image);
222 gtk_box_pack_start (GTK_BOX (hbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((hbox)), ((gtk_box_get_type ()))))))
, priv->image, TRUE(!(0)), TRUE(!(0)), 8);
223
224 priv->break_label = gtk_label_new (NULL((void*)0));
225 gtk_widget_show (priv->break_label);
226
227 g_signal_connect (priv->break_label,g_signal_connect_data ((priv->break_label), ("draw"), (((GCallback
) (label_draw_event_cb))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
228 "draw",g_signal_connect_data ((priv->break_label), ("draw"), (((GCallback
) (label_draw_event_cb))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
229 G_CALLBACK (label_draw_event_cb),g_signal_connect_data ((priv->break_label), ("draw"), (((GCallback
) (label_draw_event_cb))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
230 NULL)g_signal_connect_data ((priv->break_label), ("draw"), (((GCallback
) (label_draw_event_cb))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
;
231
232 g_signal_connect_after (priv->break_label,g_signal_connect_data ((priv->break_label), ("size-allocate"
), (((GCallback) (label_size_allocate_cb))), (((void*)0)), ((
void*)0), G_CONNECT_AFTER)
233 "size-allocate",g_signal_connect_data ((priv->break_label), ("size-allocate"
), (((GCallback) (label_size_allocate_cb))), (((void*)0)), ((
void*)0), G_CONNECT_AFTER)
234 G_CALLBACK (label_size_allocate_cb),g_signal_connect_data ((priv->break_label), ("size-allocate"
), (((GCallback) (label_size_allocate_cb))), (((void*)0)), ((
void*)0), G_CONNECT_AFTER)
235 NULL)g_signal_connect_data ((priv->break_label), ("size-allocate"
), (((GCallback) (label_size_allocate_cb))), (((void*)0)), ((
void*)0), G_CONNECT_AFTER)
;
236
237 str = g_strdup_printf ("<span size=\"xx-large\" foreground=\"white\"><b>%s</b></span>",
238 _("Take a break!")gettext ("Take a break!"));
239 gtk_label_set_markup (GTK_LABEL (priv->break_label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->break_label)), ((gtk_label_get_type ()))))))
, str);
240 g_free (str);
241
242 gtk_box_pack_start (GTK_BOX (hbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((hbox)), ((gtk_box_get_type ()))))))
, priv->break_label, FALSE(0), FALSE(0), 12);
243
244 priv->clock_label = gtk_label_new (NULL((void*)0));
245 gtk_widget_show (priv->clock_label);
246 gtk_box_pack_start (GTK_BOX (vbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((vbox)), ((gtk_box_get_type ()))))))
, priv->clock_label, TRUE(!(0)), TRUE(!(0)), 8);
247
248 g_signal_connect (priv->clock_label,g_signal_connect_data ((priv->clock_label), ("draw"), (((GCallback
) (label_draw_event_cb))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
249 "draw",g_signal_connect_data ((priv->clock_label), ("draw"), (((GCallback
) (label_draw_event_cb))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
250 G_CALLBACK (label_draw_event_cb),g_signal_connect_data ((priv->clock_label), ("draw"), (((GCallback
) (label_draw_event_cb))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
251 NULL)g_signal_connect_data ((priv->clock_label), ("draw"), (((GCallback
) (label_draw_event_cb))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
;
252
253 g_signal_connect_after (priv->clock_label,g_signal_connect_data ((priv->clock_label), ("size-allocate"
), (((GCallback) (label_size_allocate_cb))), (((void*)0)), ((
void*)0), G_CONNECT_AFTER)
254 "size-allocate",g_signal_connect_data ((priv->clock_label), ("size-allocate"
), (((GCallback) (label_size_allocate_cb))), (((void*)0)), ((
void*)0), G_CONNECT_AFTER)
255 G_CALLBACK (label_size_allocate_cb),g_signal_connect_data ((priv->clock_label), ("size-allocate"
), (((GCallback) (label_size_allocate_cb))), (((void*)0)), ((
void*)0), G_CONNECT_AFTER)
256 NULL)g_signal_connect_data ((priv->clock_label), ("size-allocate"
), (((GCallback) (label_size_allocate_cb))), (((void*)0)), ((
void*)0), G_CONNECT_AFTER)
;
257
258 gtk_window_stick (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
);
259
260 priv->timer = drw_timer_new ();
261
262 /* Make sure we have a valid time label from the start. */
263 clock_timeout_cb (window);
264
265 priv->clock_timeout_id = g_timeout_add (1000,
266 (GSourceFunc) clock_timeout_cb,
267 window);
268#ifdef HAVE_CANBERRA_GTK1
269 ca_context_play (ca_gtk_context_get (), 0, CA_PROP_EVENT_ID"event.id", "desktop-screen-lock", NULL((void*)0));
270#endif
271}
272
273static void
274drw_break_window_finalize (GObject *object)
275{
276 DrwBreakWindow *window = DRW_BREAK_WINDOW (object)((((DrwBreakWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((drw_break_window_get_type ()))))))
;
277 DrwBreakWindowPrivate *priv;
278
279 priv = window->priv;
280
281 if (priv->clock_timeout_id != 0) {
282 g_source_remove (priv->clock_timeout_id);
283 }
284
285 if (priv->postpone_timeout_id != 0) {
286 g_source_remove (priv->postpone_timeout_id);
287 }
288
289 if (priv->postpone_sensitize_id != 0) {
290 g_source_remove (priv->postpone_sensitize_id);
291 }
292
293 window->priv = NULL((void*)0);
294
295 if (G_OBJECT_CLASS (drw_break_window_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((drw_break_window_parent_class)), (((GType) ((20) <<
(2))))))))
->finalize) {
296 (* G_OBJECT_CLASS (drw_break_window_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((drw_break_window_parent_class)), (((GType) ((20) <<
(2))))))))
->finalize) (object);
297 }
298}
299
300static void
301drw_break_window_dispose (GObject *object)
302{
303 DrwBreakWindow *window = DRW_BREAK_WINDOW (object)((((DrwBreakWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((drw_break_window_get_type ()))))))
;
304 DrwBreakWindowPrivate *priv;
305
306 priv = window->priv;
307
308 if (priv->timer) {
309 drw_timer_destroy (priv->timer);
310 priv->timer = NULL((void*)0);
311 }
312
313 if (priv->clock_timeout_id != 0) {
314 g_source_remove (priv->clock_timeout_id);
315 priv->clock_timeout_id = 0;
316 }
317
318 if (priv->postpone_timeout_id != 0) {
319 g_source_remove (priv->postpone_timeout_id);
320 priv->postpone_timeout_id = 0;
321 }
322
323 if (priv->postpone_sensitize_id != 0) {
324 g_source_remove (priv->postpone_sensitize_id);
325 }
326
327 if (G_OBJECT_CLASS (drw_break_window_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((drw_break_window_parent_class)), (((GType) ((20) <<
(2))))))))
->dispose) {
328 (* G_OBJECT_CLASS (drw_break_window_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((drw_break_window_parent_class)), (((GType) ((20) <<
(2))))))))
->dispose) (object);
329 }
330}
331
332GtkWidget *
333drw_break_window_new (void)
334{
335 GObject *object;
336
337 object = g_object_new (DRW_TYPE_BREAK_WINDOW(drw_break_window_get_type ()),
338 "type", GTK_WINDOW_POPUP,
339 "skip-taskbar-hint", TRUE(!(0)),
340 "skip-pager-hint", TRUE(!(0)),
341 "focus-on-map", TRUE(!(0)),
342 NULL((void*)0));
343
344 return GTK_WIDGET (object)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((gtk_widget_get_type ()))))))
;
345}
346
347static gboolean
348postpone_sensitize_cb (DrwBreakWindow *window)
349{
350 DrwBreakWindowPrivate *priv;
351
352 priv = window->priv;
353
354 gtk_widget_set_sensitive (priv->postpone_button, TRUE(!(0)));
355
356 priv->postpone_sensitize_id = 0;
357 return FALSE(0);
358}
359
360static gboolean
361clock_timeout_cb (DrwBreakWindow *window)
362{
363 DrwBreakWindowPrivate *priv;
364 gchar *txt;
365 gint minutes;
366 gint seconds;
367
368 g_return_val_if_fail (DRW_IS_BREAK_WINDOW (window), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((window)); GType __t = ((drw_break_window_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "DRW_IS_BREAK_WINDOW (window)"); return ((0));
} } while (0)
;
369
370 priv = window->priv;
371
372 seconds = 1 + priv->break_time - drw_timer_elapsed (priv->timer);
373 seconds = MAX (0, seconds)(((0)>(seconds))?(0):(seconds));
374
375 if (seconds == 0) {
376 /* Zero this out so the finalizer doesn't try to remove the
377 * source, which would be done in the timeout callback ==
378 * no-no.
379 */
380 priv->clock_timeout_id = 0;
381
382#ifdef HAVE_CANBERRA_GTK1
383 ca_context_play (ca_gtk_context_get (), 0, CA_PROP_EVENT_ID"event.id", "alarm-clock-elapsed", NULL((void*)0));
384#endif
385 g_signal_emit (window, signals[DONE], 0, NULL((void*)0));
386
387 return FALSE(0);
388 }
389
390 minutes = seconds / 60;
391 seconds -= minutes * 60;
392
393 txt = g_strdup_printf ("<span size=\"25000\" foreground=\"white\"><b>%d:%02d</b></span>",
394 minutes,
395 seconds);
396 gtk_label_set_markup (GTK_LABEL (priv->clock_label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->clock_label)), ((gtk_label_get_type ()))))))
, txt);
397 g_free (txt);
398
399 return TRUE(!(0));
400}
401
402static void
403postpone_entry_activate_cb (GtkWidget *entry,
404 DrwBreakWindow *window)
405{
406 const gchar *str;
407 gchar *phrase;
408 GSettings *settings = g_settings_new (TYPING_BREAK_SCHEMA"org.mate.typing-break");
409
410 str = gtk_entry_get_text (GTK_ENTRY (entry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((entry)), ((gtk_entry_get_type ()))))))
);
411
412 phrase = g_settings_get_string (settings, "unlock-phrase");
413 g_object_unref (settings);
414
415 if (!strcmp (str, phrase)) {
416 g_signal_emit (window, signals[POSTPONE], 0, NULL((void*)0));
417 g_free (phrase);
418 return;
419 }
420
421 g_free (phrase);
422 gtk_entry_set_text (GTK_ENTRY (entry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((entry)), ((gtk_entry_get_type ()))))))
, "");
423}
424
425static gboolean
426grab_on_window (GdkWindow *window,
427 guint32 activate_time)
428{
429 GdkDisplay *display;
430 GdkSeat *seat;
431
432 display = gdk_window_get_display (window);
433 seat = gdk_display_get_default_seat (display);
434
435 return (gdk_seat_grab (seat,
436 window,
437 GDK_SEAT_CAPABILITY_ALL,
438 TRUE(!(0)),
439 NULL((void*)0),
440 NULL((void*)0),
441 NULL((void*)0),
442 NULL((void*)0)) == GDK_GRAB_SUCCESS);
443}
444
445static gboolean
446postpone_cancel_cb (DrwBreakWindow *window)
447{
448 DrwBreakWindowPrivate *priv;
449
450 priv = window->priv;
451
452 gtk_entry_set_text (GTK_ENTRY (priv->postpone_entry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((priv->postpone_entry)), ((gtk_entry_get_type ()))))))
, "");
453 gtk_widget_hide (priv->postpone_entry);
454
455 priv->postpone_timeout_id = 0;
456
457 return FALSE(0);
458}
459
460static gboolean
461postpone_entry_key_press_event_cb (GtkEntry *entry,
462 GdkEventKey *event,
463 DrwBreakWindow *window)
464{
465 DrwBreakWindowPrivate *priv;
466
467 priv = window->priv;
468
469 if (event->keyval == GDK_KEY_Escape0xff1b) {
470 if (priv->postpone_timeout_id) {
471 g_source_remove (priv->postpone_timeout_id);
472 }
473
474 postpone_cancel_cb (window);
475
476 return TRUE(!(0));
477 }
478
479 g_source_remove (priv->postpone_timeout_id);
480
481 priv->postpone_timeout_id = g_timeout_add_seconds (POSTPONE_CANCEL30, (GSourceFunc) postpone_cancel_cb, window);
482
483 return FALSE(0);
484}
485
486static void
487postpone_clicked_cb (GtkWidget *button,
488 GtkWidget *window)
489{
490 DrwBreakWindow *bw = DRW_BREAK_WINDOW (window)((((DrwBreakWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((drw_break_window_get_type ()))))))
;
491 DrwBreakWindowPrivate *priv = bw->priv;
492 gchar *phrase;
493
494 /* Disable the phrase for now. */
495 phrase = NULL((void*)0); /*g_settings_get_string (settings, "unlock-phrase");*/
496
497 if (!phrase || !phrase[0]) {
498 g_signal_emit (window, signals[POSTPONE], 0, NULL((void*)0));
499 return;
500 }
501
502 if (gtk_widget_get_visible (priv->postpone_entry)) {
503 gtk_widget_activate (priv->postpone_entry);
This statement is never executed
504 return;
505 }
506
507 gtk_widget_show (priv->postpone_entry);
508
509 priv->postpone_timeout_id = g_timeout_add_seconds (POSTPONE_CANCEL30, (GSourceFunc) postpone_cancel_cb, bw);
510
511 grab_on_window (gtk_widget_get_window (priv->postpone_entry), gtk_get_current_event_time ());
512
513 gtk_widget_grab_focus (priv->postpone_entry);
514
515 g_signal_connect (priv->postpone_entry,g_signal_connect_data ((priv->postpone_entry), ("activate"
), (((GCallback) (postpone_entry_activate_cb))), (bw), ((void
*)0), (GConnectFlags) 0)
516 "activate",g_signal_connect_data ((priv->postpone_entry), ("activate"
), (((GCallback) (postpone_entry_activate_cb))), (bw), ((void
*)0), (GConnectFlags) 0)
517 G_CALLBACK (postpone_entry_activate_cb),g_signal_connect_data ((priv->postpone_entry), ("activate"
), (((GCallback) (postpone_entry_activate_cb))), (bw), ((void
*)0), (GConnectFlags) 0)
518 bw)g_signal_connect_data ((priv->postpone_entry), ("activate"
), (((GCallback) (postpone_entry_activate_cb))), (bw), ((void
*)0), (GConnectFlags) 0)
;
519
520 g_signal_connect (priv->postpone_entry,g_signal_connect_data ((priv->postpone_entry), ("key_press_event"
), (((GCallback) (postpone_entry_key_press_event_cb))), (bw),
((void*)0), (GConnectFlags) 0)
521 "key_press_event",g_signal_connect_data ((priv->postpone_entry), ("key_press_event"
), (((GCallback) (postpone_entry_key_press_event_cb))), (bw),
((void*)0), (GConnectFlags) 0)
522 G_CALLBACK (postpone_entry_key_press_event_cb),g_signal_connect_data ((priv->postpone_entry), ("key_press_event"
), (((GCallback) (postpone_entry_key_press_event_cb))), (bw),
((void*)0), (GConnectFlags) 0)
523 bw)g_signal_connect_data ((priv->postpone_entry), ("key_press_event"
), (((GCallback) (postpone_entry_key_press_event_cb))), (bw),
((void*)0), (GConnectFlags) 0)
;
524}
525
526static void
527get_layout_location (GtkLabel *label,
528 gint *xp,
529 gint *yp)
530{
531 GtkWidget *widget;
532 GtkAllocation widget_allocation;
533 GtkRequisition widget_requisition;
534 gfloat xalign, yalign;
535 gint x, y;
536 gint xpad, ypad;
537 gint margin_start, margin_end, margin_top, margin_bottom;
538 gint scale;
539
540 widget = GTK_WIDGET (label)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_widget_get_type ()))))))
;
541
542 scale = gtk_widget_get_scale_factor (widget);
543 xalign = gtk_label_get_xalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
);
544 yalign = gtk_label_get_yalign (GTK_LABEL (label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_label_get_type ()))))))
);
545 margin_start = gtk_widget_get_margin_start (widget);
546 margin_end = gtk_widget_get_margin_end (widget);
547 margin_top = gtk_widget_get_margin_top (widget);
548 margin_bottom = gtk_widget_get_margin_bottom (widget);
549
550 xpad = margin_start + margin_end;
551 ypad = margin_top + margin_bottom;
552
553 gtk_widget_get_allocation (widget, &widget_allocation);
554 gtk_widget_get_preferred_size (widget, &widget_requisition, NULL((void*)0));
555 widget_allocation.x /= scale;
556 widget_allocation.y /= scale;
557 widget_requisition.width /= scale;
558 widget_requisition.height /= scale;
559
560 if (gtk_widget_get_direction (widget) != GTK_TEXT_DIR_LTR)
561 xalign = 1.0 - xalign;
562
563 x = floor (widget_allocation.x + (int)xpad
564 + ((widget_allocation.width - widget_requisition.width - 1) * xalign)
565 + 0.5);
566
567 y = floor (widget_allocation.y + (int)ypad
568 + ((widget_allocation.height - widget_requisition.height - 1) * yalign)
569 + 0.5);
570
571 if (xp) {
572 *xp = x;
573 }
574
575 if (yp) {
576 *yp = y;
577 }
578}
579
580static gboolean
581label_draw_event_cb (GtkLabel *label,
582 cairo_t *cr,
583 gpointer user_data)
584{
585 gint x, y;
586 GtkWidget *widget;
587
588 get_layout_location (label, &x, &y);
589
590 widget = GTK_WIDGET (label)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((gtk_widget_get_type ()))))))
;
591
592 pango_cairo_show_layout (cr, gtk_label_get_layout (label));
593
594 gtk_render_layout (gtk_widget_get_style_context (widget),
595 cr,
596 (double)x, (double)y,
597 gtk_label_get_layout (label));
598
599 return TRUE(!(0));
600}
601
602static void
603label_size_allocate_cb (GtkLabel *label,
604 GdkRectangle *allocation,
605 gpointer user_data)
606{
607 allocation->width += 1;
608 allocation->height += 1;
609}
diff --git a/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-b47749.html b/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-b47749.html new file mode 100644 index 00000000..7cf7804d --- /dev/null +++ b/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-b47749.html @@ -0,0 +1,1462 @@ + + + +sushi-font-widget.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:font-viewer/sushi-font-widget.c
Warning:line 507, column 5
2nd function call argument is an uninitialized value
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name sushi-font-widget.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/font-viewer -fcoverage-compilation-dir=/rootdir/font-viewer -resource-dir /usr/bin/../lib/clang/18 -D HAVE_CONFIG_H -I . -I .. -I /usr/include/udisks2 -I /usr/include/libgtop-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/libxml2 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/gio-unix-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/dconf -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I ../capplets/common -I /usr/include/udisks2 -I /usr/include/libgtop-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/libxml2 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/gio-unix-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/dconf -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I ../ -D G_LOG_DOMAIN="-properties" -I /usr/include/polkit-1 -I /usr/include/gio-unix-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -D DIRECTORY_DIR="" -D MATELOCALEDIR="/usr/local/share/locale" -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-06-07-044335-13427-1 -x c sushi-font-widget.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 * Copyright (C) 2011 Red Hat, Inc.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of the
7 * License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
17 * 02111-1307, USA.
18 *
19 * The Sushi project hereby grant permission for non-gpl compatible GStreamer
20 * plugins to be used and distributed together with GStreamer and Sushi. This
21 * permission is above and beyond the permissions granted by the GPL license
22 * Sushi is covered by.
23 *
24 * Authors: Cosimo Cecchi <cosimoc@redhat.com>
25 *
26 */
27
28#include "sushi-font-widget.h"
29#include "sushi-font-loader.h"
30
31#include <math.h>
32
33enum {
34 PROP_URI = 1,
35 PROP_FACE_INDEX,
36 NUM_PROPERTIES
37};
38
39enum {
40 LOADED,
41 ERROR,
42 NUM_SIGNALS
43};
44
45struct _SushiFontWidgetPrivate {
46 gchar *uri;
47 gint face_index;
48
49 FT_Library library;
50 FT_Face face;
51 gchar *face_contents;
52
53 const gchar *lowercase_text;
54 const gchar *uppercase_text;
55 const gchar *punctuation_text;
56
57 gchar *sample_string;
58
59 gchar *font_name;
60};
61
62static GParamSpec *properties[NUM_PROPERTIES] = { NULL((void*)0), };
63static guint signals[NUM_SIGNALS] = { 0, };
64
65G_DEFINE_TYPE_WITH_PRIVATE (SushiFontWidget, sushi_font_widget, GTK_TYPE_DRAWING_AREA)static void sushi_font_widget_init (SushiFontWidget *self); static
void sushi_font_widget_class_init (SushiFontWidgetClass *klass
); static GType sushi_font_widget_get_type_once (void); static
gpointer sushi_font_widget_parent_class = ((void*)0); static
gint SushiFontWidget_private_offset; static void sushi_font_widget_class_intern_init
(gpointer klass) { sushi_font_widget_parent_class = g_type_class_peek_parent
(klass); if (SushiFontWidget_private_offset != 0) g_type_class_adjust_private_offset
(klass, &SushiFontWidget_private_offset); sushi_font_widget_class_init
((SushiFontWidgetClass*) klass); } __attribute__ ((__unused__
)) static inline gpointer sushi_font_widget_get_instance_private
(SushiFontWidget *self) { return (((gpointer) ((guint8*) (self
) + (glong) (SushiFontWidget_private_offset)))); } GType sushi_font_widget_get_type
(void) { static GType static_g_define_type_id = 0; if ((__extension__
({ _Static_assert (sizeof *(&static_g_define_type_id) ==
sizeof (gpointer), "Expression evaluates to false"); (void) (
0 ? (gpointer) * (&static_g_define_type_id) : ((void*)0))
; (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter_pointer (
&static_g_define_type_id)); })) ) { GType g_define_type_id
= sushi_font_widget_get_type_once (); (__extension__ ({ _Static_assert
(sizeof *(&static_g_define_type_id) == sizeof (gpointer)
, "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id
) = (g_define_type_id)) : (void) 0; g_once_init_leave_pointer
((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id
)); })) ; } return static_g_define_type_id; } __attribute__ (
(__noinline__)) static GType sushi_font_widget_get_type_once (
void) { GType g_define_type_id = g_type_register_static_simple
((gtk_drawing_area_get_type ()), g_intern_static_string ("SushiFontWidget"
), sizeof (SushiFontWidgetClass), (GClassInitFunc)(void (*)(void
)) sushi_font_widget_class_intern_init, sizeof (SushiFontWidget
), (GInstanceInitFunc)(void (*)(void)) sushi_font_widget_init
, (GTypeFlags) 0); { {{ SushiFontWidget_private_offset = g_type_add_instance_private
(g_define_type_id, sizeof (SushiFontWidgetPrivate)); };} } return
g_define_type_id; }
;
66
67#define SURFACE_SIZE4 4
68#define SECTION_SPACING16 16
69#define LINE_SPACING2 2
70
71static const gchar lowercase_text_stock[] = "abcdefghijklmnopqrstuvwxyz";
72static const gchar uppercase_text_stock[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
73static const gchar punctuation_text_stock[] = "0123456789.:,;(*!?')";
74
75/* adapted from gnome-utils:font-viewer/font-view.c
76 *
77 * Copyright (C) 2002-2003 James Henstridge <james@daa.com.au>
78 * Copyright (C) 2010 Cosimo Cecchi <cosimoc@gnome.org>
79 *
80 * License: GPLv2+
81 */
82static void
83draw_string (SushiFontWidget *self,
84 cairo_t *cr,
85 GtkBorder padding,
86 const gchar *text,
87 gint *pos_y)
88{
89 cairo_font_extents_t font_extents;
90 cairo_text_extents_t extents;
91 GtkTextDirection text_dir;
92 gint pos_x;
93
94 text_dir = gtk_widget_get_direction (GTK_WIDGET (self)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((self)), ((gtk_widget_get_type ()))))))
);
95
96 cairo_font_extents (cr, &font_extents);
97 cairo_text_extents (cr, text, &extents);
98
99 if (pos_y != NULL((void*)0))
100 *pos_y += font_extents.ascent + font_extents.descent +
101 extents.y_advance + LINE_SPACING2 / 2;
102 if (text_dir == GTK_TEXT_DIR_LTR)
103 pos_x = padding.left;
104 else {
105 pos_x = gtk_widget_get_allocated_width (GTK_WIDGET (self)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((self)), ((gtk_widget_get_type ()))))))
) -
106 extents.x_advance - padding.right;
107 }
108
109 cairo_move_to (cr, pos_x, *pos_y);
110 cairo_show_text (cr, text);
111
112 *pos_y += LINE_SPACING2 / 2;
113}
114
115static gboolean
116check_font_contain_text (FT_Face face,
117 const gchar *text)
118{
119 gunichar *string;
120 glong len, idx, map;
121 FT_CharMap charmap;
122 gboolean retval = FALSE(0);
123
124 string = g_utf8_to_ucs4_fast (text, -1, &len);
125
126 for (map = 0; map < face->num_charmaps; map++) {
127 charmap = face->charmaps[map];
128 FT_Set_Charmap (face, charmap);
129
130 retval = TRUE(!(0));
131
132 for (idx = 0; idx < len; idx++) {
133 gunichar c = string[idx];
134
135 if (!FT_Get_Char_Index (face, c)) {
136 retval = FALSE(0);
137 break;
138 }
139 }
140
141 if (retval)
142 break;
143 }
144
145 g_free (string);
146
147 return retval;
148}
149
150static gchar *
151build_charlist_for_face (FT_Face face,
152 gint *length)
153{
154 GString *string;
155 gulong c;
156 guint glyph;
157 gint total_chars = 0;
158
159 string = g_string_new (NULL((void*)0));
160
161 c = FT_Get_First_Char (face, &glyph);
162
163 while (glyph != 0) {
164 g_string_append_unichar (string, (gunichar) c);
165 c = FT_Get_Next_Char (face, c, &glyph);
166 total_chars++;
167 }
168
169 if (length)
170 *length = total_chars;
171
172 return g_string_free (string, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((string
), ((0))) : g_string_free_and_steal (string)) : (g_string_free
) ((string), ((0))))
;
173}
174
175static gchar *
176random_string_from_available_chars (FT_Face face,
177 gint n_chars)
178{
179 gchar *chars;
180 gint idx, rand, total_chars;
181 GString *retval;
182 gchar *ptr, *end;
183
184 idx = 0;
185 chars = build_charlist_for_face (face, &total_chars);
186
187 if (total_chars == 0)
188 return NULL((void*)0);
189
190 retval = g_string_new (NULL((void*)0));
191
192 while (idx < n_chars) {
193 rand = g_random_int_range (0, total_chars);
194
195 ptr = g_utf8_offset_to_pointer (chars, rand);
196 end = g_utf8_find_next_char (ptr, NULL((void*)0));
197
198 g_string_append_len (retval, ptr, end - ptr)g_string_append_len_inline (retval, ptr, end - ptr);
199 idx++;
200 }
201
202 return g_string_free (retval, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((retval
), ((0))) : g_string_free_and_steal (retval)) : (g_string_free
) ((retval), ((0))))
;
203}
204
205static gboolean
206set_pango_sample_string (SushiFontWidget *self)
207{
208 const gchar *sample_string;
209 gboolean retval = FALSE(0);
210
211 sample_string = pango_language_get_sample_string (pango_language_from_string (NULL((void*)0)));
212 if (check_font_contain_text (self->priv->face, sample_string))
213 retval = TRUE(!(0));
214
215 if (!retval) {
216 sample_string = pango_language_get_sample_string (pango_language_from_string ("C"));
217 if (check_font_contain_text (self->priv->face, sample_string))
218 retval = TRUE(!(0));
219 }
220
221 if (retval) {
222 g_free (self->priv->sample_string);
223 self->priv->sample_string = g_strdup (sample_string)g_strdup_inline (sample_string);
224 }
225
226 return retval;
227}
228
229static void
230build_strings_for_face (SushiFontWidget *self)
231{
232 /* if we don't have lowercase/uppercase/punctuation text in the face,
233 * we omit it directly, and render a random text below.
234 */
235 if (check_font_contain_text (self->priv->face, lowercase_text_stock))
236 self->priv->lowercase_text = lowercase_text_stock;
237 else
238 self->priv->lowercase_text = NULL((void*)0);
239
240 if (check_font_contain_text (self->priv->face, uppercase_text_stock))
241 self->priv->uppercase_text = uppercase_text_stock;
242 else
243 self->priv->uppercase_text = NULL((void*)0);
244
245 if (check_font_contain_text (self->priv->face, punctuation_text_stock))
246 self->priv->punctuation_text = punctuation_text_stock;
247 else
248 self->priv->punctuation_text = NULL((void*)0);
249
250 if (!set_pango_sample_string (self))
251 self->priv->sample_string = random_string_from_available_chars (self->priv->face, 36);
252
253 g_free (self->priv->font_name);
254 self->priv->font_name = NULL((void*)0);
255
256 if (self->priv->face->family_name != NULL((void*)0)) {
257 gchar *font_name =
258 g_strconcat (self->priv->face->family_name, " ",
259 self->priv->face->style_name, NULL((void*)0));
260
261 if (check_font_contain_text (self->priv->face, font_name))
262 self->priv->font_name = font_name;
263 else
264 g_free (font_name);
265 }
266}
267
268static gint *
269build_sizes_table (FT_Face face,
270 gint *n_sizes,
271 gint *alpha_size,
272 gint *title_size)
273{
274 gint *sizes = NULL((void*)0);
275 gint i;
276
277 /* work out what sizes to render */
278 if (FT_IS_SCALABLE (face)( !!( (face)->face_flags & ( 1L << 0 ) ) )) {
5
Assuming the condition is true
6
Taking false branch
279 *n_sizes = 14;
280 sizes = g_new (gint, *n_sizes)((gint *) g_malloc_n ((*n_sizes), sizeof (gint)));
281 sizes[0] = 8;
282 sizes[1] = 10;
283 sizes[2] = 12;
284 sizes[3] = 18;
285 sizes[4] = 24;
286 sizes[5] = 36;
287 sizes[6] = 48;
288 sizes[7] = 72;
289 sizes[8] = 96;
290 sizes[9] = 120;
291 sizes[10] = 144;
292 sizes[11] = 168;
293 sizes[12] = 192;
294 sizes[13] = 216;
295
296 *alpha_size = 24;
297 *title_size = 48;
298 } else {
299 gint alpha_diff = G_MAXINT2147483647;
300 gint title_diff = G_MAXINT2147483647;
301
302 /* use fixed sizes */
303 *n_sizes = face->num_fixed_sizes;
304 sizes = g_new (gint, *n_sizes)((gint *) g_malloc_n ((*n_sizes), sizeof (gint)));
305 *alpha_size = 0;
306
307 for (i = 0; i < face->num_fixed_sizes; i++) {
7
Assuming 'i' is >= field 'num_fixed_sizes'
8
Loop condition is false. Execution continues on line 321
308 sizes[i] = face->available_sizes[i].height;
309
310 if ((gint) (abs (sizes[i] - 24)) < alpha_diff) {
311 alpha_diff = (gint) abs (sizes[i] - 24);
312 *alpha_size = sizes[i];
313 }
314 if ((gint) (abs (sizes[i] - 24)) < title_diff) {
315 title_diff = (gint) abs (sizes[i] - 24);
316 *title_size = sizes[i];
317 }
318 }
319 }
320
321 return sizes;
9
Returning without writing to '*title_size'
322}
323
324static void
325sushi_font_widget_size_request (GtkWidget *drawing_area,
326 gint *width,
327 gint *height,
328 gint *min_height)
329{
330 SushiFontWidget *self = SUSHI_FONT_WIDGET (drawing_area)((((SushiFontWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((drawing_area)), ((sushi_font_widget_get_type ()))))))
;
331 SushiFontWidgetPrivate *priv = self->priv;
332 gint i, pixmap_width, pixmap_height;
333 cairo_text_extents_t extents;
334 cairo_font_extents_t font_extents;
335 cairo_font_face_t *font;
336 gint *sizes = NULL((void*)0), n_sizes, alpha_size, title_size;
337 cairo_t *cr;
338 cairo_surface_t *surface;
339 FT_Face face = priv->face;
340 GtkStyleContext *context;
341 GtkStateFlags state;
342 GtkBorder padding;
343
344 if (face == NULL((void*)0)) {
345 if (width != NULL((void*)0))
346 *width = 1;
347 if (height != NULL((void*)0))
348 *height = 1;
349 if (min_height != NULL((void*)0))
350 *min_height = 1;
351
352 return;
353 }
354
355 if (min_height != NULL((void*)0))
356 *min_height = -1;
357
358 surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
359 SURFACE_SIZE4, SURFACE_SIZE4);
360 cr = cairo_create (surface);
361 context = gtk_widget_get_style_context (drawing_area);
362 state = gtk_style_context_get_state (context);
363 gtk_style_context_get_padding (context, state, &padding);
364
365 sizes = build_sizes_table (face, &n_sizes, &alpha_size, &title_size);
366
367 /* calculate size of pixmap to use */
368 pixmap_width = padding.left + padding.right;
369 pixmap_height = padding.top + padding.bottom;
370
371 font = cairo_ft_font_face_create_for_ft_face (face, 0);
372 cairo_set_font_face (cr, font);
373 cairo_font_face_destroy (font);
374
375 if (self->priv->font_name != NULL((void*)0)) {
376 cairo_set_font_size (cr, title_size);
377 cairo_font_extents (cr, &font_extents);
378 cairo_text_extents (cr, self->priv->font_name, &extents);
379 pixmap_height += font_extents.ascent + font_extents.descent +
380 extents.y_advance + LINE_SPACING2;
381 pixmap_width = MAX (pixmap_width, extents.width + padding.left + padding.right)(((pixmap_width) > (extents.width + padding.left + padding
.right)) ? (pixmap_width) : (extents.width + padding.left + padding
.right))
;
382 }
383
384 pixmap_height += SECTION_SPACING16 / 2;
385 cairo_set_font_size (cr, alpha_size);
386 cairo_font_extents (cr, &font_extents);
387
388 if (self->priv->lowercase_text != NULL((void*)0)) {
389 cairo_text_extents (cr, self->priv->lowercase_text, &extents);
390 pixmap_height += font_extents.ascent + font_extents.descent +
391 extents.y_advance + LINE_SPACING2;
392 pixmap_width = MAX (pixmap_width, extents.width + padding.left + padding.right)(((pixmap_width) > (extents.width + padding.left + padding
.right)) ? (pixmap_width) : (extents.width + padding.left + padding
.right))
;
393 }
394
395 if (self->priv->uppercase_text != NULL((void*)0)) {
396 cairo_text_extents (cr, self->priv->uppercase_text, &extents);
397 pixmap_height += font_extents.ascent + font_extents.descent +
398 extents.y_advance + LINE_SPACING2;
399 pixmap_width = MAX (pixmap_width, extents.width + padding.left + padding.right)(((pixmap_width) > (extents.width + padding.left + padding
.right)) ? (pixmap_width) : (extents.width + padding.left + padding
.right))
;
400 }
401
402 if (self->priv->punctuation_text != NULL((void*)0)) {
403 cairo_text_extents (cr, self->priv->punctuation_text, &extents);
404 pixmap_height += font_extents.ascent + font_extents.descent +
405 extents.y_advance + LINE_SPACING2;
406 pixmap_width = MAX (pixmap_width, extents.width + padding.left + padding.right)(((pixmap_width) > (extents.width + padding.left + padding
.right)) ? (pixmap_width) : (extents.width + padding.left + padding
.right))
;
407 }
408
409 if (self->priv->sample_string != NULL((void*)0)) {
410 pixmap_height += SECTION_SPACING16;
411
412 for (i = 0; i < n_sizes; i++) {
413 cairo_set_font_size (cr, sizes[i]);
414 cairo_font_extents (cr, &font_extents);
415 cairo_text_extents (cr, self->priv->sample_string, &extents);
416 pixmap_height += font_extents.ascent + font_extents.descent +
417 extents.y_advance + LINE_SPACING2;
418 pixmap_width = MAX (pixmap_width, extents.width + padding.left + padding.right)(((pixmap_width) > (extents.width + padding.left + padding
.right)) ? (pixmap_width) : (extents.width + padding.left + padding
.right))
;
419
420 if ((i == 7) && (min_height != NULL((void*)0)))
421 *min_height = pixmap_height;
422 }
423 }
424
425 pixmap_height += padding.bottom + SECTION_SPACING16;
426
427 if (min_height != NULL((void*)0) && *min_height == -1)
428 *min_height = pixmap_height;
429
430 if (width != NULL((void*)0))
431 *width = pixmap_width;
432
433 if (height != NULL((void*)0))
434 *height = pixmap_height;
435
436 cairo_destroy (cr);
437 cairo_surface_destroy (surface);
438 g_free (sizes);
439}
440
441static void
442sushi_font_widget_get_preferred_width (GtkWidget *drawing_area,
443 gint *minimum_width,
444 gint *natural_width)
445{
446 gint width;
447
448 sushi_font_widget_size_request (drawing_area, &width, NULL((void*)0), NULL((void*)0));
449
450 *minimum_width = *natural_width = width;
451}
452
453static void
454sushi_font_widget_get_preferred_height (GtkWidget *drawing_area,
455 gint *minimum_height,
456 gint *natural_height)
457{
458 gint height, min_height;
459
460 sushi_font_widget_size_request (drawing_area, NULL((void*)0), &height, &min_height);
461
462 *minimum_height = min_height;
463 *natural_height = height;
464}
465
466static gboolean
467sushi_font_widget_draw (GtkWidget *drawing_area,
468 cairo_t *cr)
469{
470 SushiFontWidget *self = SUSHI_FONT_WIDGET (drawing_area)((((SushiFontWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((drawing_area)), ((sushi_font_widget_get_type ()))))))
;
471 SushiFontWidgetPrivate *priv = self->priv;
472 gint *sizes = NULL((void*)0), n_sizes, alpha_size, title_size, pos_y = 0, i;
1
'title_size' declared without an initial value
473 cairo_font_face_t *font;
474 FT_Face face = priv->face;
475 GtkStyleContext *context;
476 GdkRGBA color;
477 GtkBorder padding;
478 GtkStateFlags state;
479 gint allocated_width, allocated_height;
480
481 if (face == NULL((void*)0))
2
Assuming 'face' is not equal to NULL
3
Taking false branch
482 goto end;
483
484 context = gtk_widget_get_style_context (drawing_area);
485 state = gtk_style_context_get_state (context);
486
487 allocated_width = gtk_widget_get_allocated_width (drawing_area);
488 allocated_height = gtk_widget_get_allocated_height (drawing_area);
489
490 gtk_render_background (context, cr,
491 0, 0, allocated_width, allocated_height);
492
493 gtk_style_context_get_color (context, state, &color);
494 gtk_style_context_get_padding (context, state, &padding);
495
496 gdk_cairo_set_source_rgba (cr, &color);
497
498 sizes = build_sizes_table (face, &n_sizes, &alpha_size, &title_size);
4
Calling 'build_sizes_table'
10
Returning from 'build_sizes_table'
499
500 font = cairo_ft_font_face_create_for_ft_face (face, 0);
501 cairo_set_font_face (cr, font);
502 cairo_font_face_destroy (font);
503
504 /* draw text */
505
506 if (self->priv->font_name != NULL((void*)0)) {
11
Assuming field 'font_name' is not equal to NULL
12
Taking true branch
507 cairo_set_font_size (cr, title_size);
13
2nd function call argument is an uninitialized value
508 draw_string (self, cr, padding, self->priv->font_name, &pos_y);
509 }
510
511 if (pos_y > allocated_height)
512 goto end;
513
514 pos_y += SECTION_SPACING16 / 2;
515 cairo_set_font_size (cr, alpha_size);
516
517 if (self->priv->lowercase_text != NULL((void*)0))
518 draw_string (self, cr, padding, self->priv->lowercase_text, &pos_y);
519 if (pos_y > allocated_height)
520 goto end;
521
522 if (self->priv->uppercase_text != NULL((void*)0))
523 draw_string (self, cr, padding, self->priv->uppercase_text, &pos_y);
524 if (pos_y > allocated_height)
525 goto end;
526
527 if (self->priv->punctuation_text != NULL((void*)0))
528 draw_string (self, cr, padding, self->priv->punctuation_text, &pos_y);
529 if (pos_y > allocated_height)
530 goto end;
531
532 pos_y += SECTION_SPACING16;
533
534 for (i = 0; i < n_sizes; i++) {
535 cairo_set_font_size (cr, sizes[i]);
536 draw_string (self, cr, padding, self->priv->sample_string, &pos_y);
537 if (pos_y > allocated_height)
538 break;
539 }
540
541 end:
542 g_free (sizes);
543
544 return FALSE(0);
545}
546
547static void
548font_face_async_ready_cb (GObject *object,
549 GAsyncResult *result,
550 gpointer user_data)
551{
552 SushiFontWidget *self = user_data;
553 GError *error = NULL((void*)0);
554
555 self->priv->face =
556 sushi_new_ft_face_from_uri_finish (result,
557 &self->priv->face_contents,
558 &error);
559
560 if (error != NULL((void*)0)) {
561 g_signal_emit (self, signals[ERROR], 0, error->message);
562 g_print ("Can't load the font face: %s\n", error->message);
563 g_error_free (error);
564
565 return;
566 }
567
568 build_strings_for_face (self);
569
570 gtk_widget_queue_resize (GTK_WIDGET (self)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((self)), ((gtk_widget_get_type ()))))))
);
571 g_signal_emit (self, signals[LOADED], 0);
572}
573
574void
575sushi_font_widget_load (SushiFontWidget *self)
576{
577 sushi_new_ft_face_from_uri_async (self->priv->library,
578 self->priv->uri,
579 self->priv->face_index,
580 font_face_async_ready_cb,
581 self);
582}
583
584static void
585sushi_font_widget_init (SushiFontWidget *self)
586{
587 FT_Error err;
588
589 self->priv = sushi_font_widget_get_instance_private (self);
590
591 self->priv->face = NULL((void*)0);
592 err = FT_Init_FreeType (&self->priv->library);
593
594 if (err != FT_Err_Ok)
595 g_error ("Unable to initialize FreeType");
596
597 gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (self)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((self)), ((gtk_widget_get_type ()))))))
),
598 GTK_STYLE_CLASS_VIEW"view");
599}
600
601static void
602sushi_font_widget_get_property (GObject *object,
603 guint prop_id,
604 GValue *value,
605 GParamSpec *pspec)
606{
607 SushiFontWidget *self = SUSHI_FONT_WIDGET (object)((((SushiFontWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((sushi_font_widget_get_type ()))))))
;
608
609 switch (prop_id) {
610 case PROP_URI:
611 g_value_set_string (value, self->priv->uri);
612 break;
613 case PROP_FACE_INDEX:
614 g_value_set_int (value, self->priv->face_index);
615 break;
616 default:
617 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "sushi-font-widget.c", 617, ("property"), _glib__property_id
, _glib__pspec->name, g_type_name ((((((GTypeClass*) (((GTypeInstance
*) (_glib__pspec))->g_class))->g_type)))), (g_type_name
((((((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class
))->g_type)))))); } while (0)
;
618 break;
619 }
620}
621
622static void
623sushi_font_widget_set_property (GObject *object,
624 guint prop_id,
625 const GValue *value,
626 GParamSpec *pspec)
627{
628 SushiFontWidget *self = SUSHI_FONT_WIDGET (object)((((SushiFontWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((sushi_font_widget_get_type ()))))))
;
629
630 switch (prop_id) {
631 case PROP_URI:
632 self->priv->uri = g_value_dup_string (value);
633 break;
634 case PROP_FACE_INDEX:
635 self->priv->face_index = g_value_get_int (value);
636 break;
637 default:
638 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "sushi-font-widget.c", 638, ("property"), _glib__property_id
, _glib__pspec->name, g_type_name ((((((GTypeClass*) (((GTypeInstance
*) (_glib__pspec))->g_class))->g_type)))), (g_type_name
((((((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class
))->g_type)))))); } while (0)
;
639 break;
640 }
641}
642
643static void
644sushi_font_widget_finalize (GObject *object)
645{
646 SushiFontWidget *self = SUSHI_FONT_WIDGET (object)((((SushiFontWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((sushi_font_widget_get_type ()))))))
;
647
648 g_free (self->priv->uri);
649
650 if (self->priv->face != NULL((void*)0)) {
651 FT_Done_Face (self->priv->face);
652 self->priv->face = NULL((void*)0);
653 }
654
655 g_free (self->priv->font_name);
656 g_free (self->priv->sample_string);
657 g_free (self->priv->face_contents);
658
659 if (self->priv->library != NULL((void*)0)) {
660 FT_Done_FreeType (self->priv->library);
661 self->priv->library = NULL((void*)0);
662 }
663
664 G_OBJECT_CLASS (sushi_font_widget_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((sushi_font_widget_parent_class)), (((GType) ((20) <<
(2))))))))
->finalize (object);
665}
666
667static void
668sushi_font_widget_constructed (GObject *object)
669{
670 SushiFontWidget *self = SUSHI_FONT_WIDGET (object)((((SushiFontWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((sushi_font_widget_get_type ()))))))
;
671
672 sushi_font_widget_load (self);
673
674 G_OBJECT_CLASS (sushi_font_widget_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((sushi_font_widget_parent_class)), (((GType) ((20) <<
(2))))))))
->constructed (object);
675}
676
677static void
678sushi_font_widget_class_init (SushiFontWidgetClass *klass)
679{
680 GObjectClass *oclass = G_OBJECT_CLASS (klass)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((klass)), (((GType) ((20) << (2))))))))
;
681 GtkWidgetClass *wclass = GTK_WIDGET_CLASS (klass)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((klass)), ((gtk_widget_get_type ()))))))
;
682
683 oclass->finalize = sushi_font_widget_finalize;
684 oclass->set_property = sushi_font_widget_set_property;
685 oclass->get_property = sushi_font_widget_get_property;
686 oclass->constructed = sushi_font_widget_constructed;
687
688 wclass->draw = sushi_font_widget_draw;
689 wclass->get_preferred_width = sushi_font_widget_get_preferred_width;
690 wclass->get_preferred_height = sushi_font_widget_get_preferred_height;
691
692 properties[PROP_URI] =
693 g_param_spec_string ("uri",
694 "Uri", "Uri",
695 NULL((void*)0), G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
696 properties[PROP_FACE_INDEX] =
697 g_param_spec_int ("face-index",
698 "Face index", "Face index",
699 0, G_MAXINT2147483647,
700 0, G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
701
702 signals[LOADED] =
703 g_signal_new ("loaded",
704 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
705 G_SIGNAL_RUN_FIRST,
706 0, NULL((void*)0), NULL((void*)0),
707 g_cclosure_marshal_VOID__VOID,
708 G_TYPE_NONE((GType) ((1) << (2))), 0);
709 signals[ERROR] =
710 g_signal_new ("error",
711 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
712 G_SIGNAL_RUN_FIRST,
713 0, NULL((void*)0), NULL((void*)0),
714 g_cclosure_marshal_VOID__STRING,
715 G_TYPE_NONE((GType) ((1) << (2))), 1, G_TYPE_STRING((GType) ((16) << (2))));
716
717 g_object_class_install_properties (oclass, NUM_PROPERTIES, properties);
718}
719
720SushiFontWidget *
721sushi_font_widget_new (const gchar *uri, gint face_index)
722{
723 return g_object_new (SUSHI_TYPE_FONT_WIDGET(sushi_font_widget_get_type ()),
724 "uri", uri,
725 "face-index", face_index,
726 NULL((void*)0));
727}
728
729/**
730 * sushi_font_widget_get_ft_face: (skip)
731 *
732 */
733FT_Face
734sushi_font_widget_get_ft_face (SushiFontWidget *self)
735{
736 return self->priv->face;
737}
738
739const gchar *
740sushi_font_widget_get_uri (SushiFontWidget *self)
741{
742 return self->priv->uri;
743}
744
diff --git a/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-c9434f.html b/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-c9434f.html new file mode 100644 index 00000000..378f6e25 --- /dev/null +++ b/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-c9434f.html @@ -0,0 +1,1115 @@ + + + +theme-save.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:capplets/appearance/theme-save.c
Warning:line 68, column 4
Access of the heap area at index 3, while it holds only 3 'char' elements
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name theme-save.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/capplets/appearance -fcoverage-compilation-dir=/rootdir/capplets/appearance -resource-dir /usr/bin/../lib/clang/18 -D HAVE_CONFIG_H -I . -I ../.. -I /usr/include/marco-1 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/gio-unix-2.0 -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I ../../capplets/common -I /usr/include/udisks2 -I /usr/include/libgtop-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/libxml2 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/gio-unix-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/dconf -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I ../../ -D G_LOG_DOMAIN="appearance-properties" -I /usr/include/polkit-1 -I /usr/include/gio-unix-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I /usr/include/udisks2 -I /usr/include/libgtop-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/gio-unix-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/libxml2 -I /usr/include/harfbuzz -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/freetype2 -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/dconf -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libpng16 -D WITH_GZFILEOP -I /usr/include/sysprof-6 -I /usr/include/pixman-1 -D MATECC_DATA_DIR="/usr/local/share/mate-control-center" -D MATECC_PIXMAP_DIR="/usr/local/share/mate-control-center/pixmaps" -D WALLPAPER_DATADIR="/usr/local/share/mate-background-properties" -D BACKGROUND_DATADIR="/usr/local/share/backgrounds" -D MATE_DESKTOP_USE_UNSTABLE_API -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-06-07-044335-13427-1 -x c theme-save.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 * Copyright (C) 2007 The GNOME Foundation
3 * Written by Thomas Wood <thos@gnome.org>
4 * Jens Granseuer <jensgr@gmx.net>
5 * All Rights Reserved
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 */
21
22#include "appearance.h"
23
24#include <glib/gstdio.h>
25#include <glib/gi18n.h>
26#include <gio/gio.h>
27#include <string.h>
28
29#include "theme-save.h"
30#include "theme-util.h"
31#include "capplet-util.h"
32
33static GQuark error_quark;
34enum {
35 INVALID_THEME_NAME
36};
37
38/* taken from mate-desktop-item.c */
39static gchar *
40escape_string_and_dup (const gchar *s)
41{
42 gchar *return_value, *p;
43 const gchar *q;
44 int len = 0;
45
46 if (s == NULL((void*)0))
4
Assuming 's' is not equal to NULL
5
Taking false branch
47 return g_strdup("")g_strdup_inline ("");
48
49 q = s;
50 while (*q)
6
Loop condition is true. Entering loop body
9
Loop condition is true. Entering loop body
12
Loop condition is false. Execution continues on line 57
51 {
52 len++;
53 if (strchr ("\n\r\t\\", *q) != NULL((void*)0))
7
Assuming the condition is false
8
Taking false branch
10
Assuming the condition is false
11
Taking false branch
54 len++;
55 q++;
56 }
57 return_value = p = (gchar *) g_malloc (len + 1);
58 do
15
Loop condition is true. Execution continues on line 60
59 {
60 switch (*s)
13
Control jumps to 'case 92:' at line 74
16
Control jumps to 'case 10:' at line 66
61 {
62 case '\t':
63 *p++ = '\\';
64 *p++ = 't';
65 break;
66 case '\n':
67 *p++ = '\\';
68 *p++ = 'n';
17
Access of the heap area at index 3, while it holds only 3 'char' elements
69 break;
70 case '\r':
71 *p++ = '\\';
72 *p++ = 'r';
73 break;
74 case '\\':
75 *p++ = '\\';
76 *p++ = '\\';
77 break;
14
Execution continues on line 82
78 default:
79 *p++ = *s;
80 }
81 }
82 while (*s++);
83 return return_value;
84}
85
86static gboolean
87check_theme_name (const gchar *theme_name,
88 GError **error)
89{
90 if (theme_name == NULL((void*)0)) {
91 g_set_error (error,
92 error_quark,
93 INVALID_THEME_NAME,
94 _("Theme name must be present")gettext ("Theme name must be present"));
95 return FALSE(0);
96 }
97 return TRUE(!(0));
98}
99
100static gchar *
101str_remove_slash (const gchar *src)
102{
103 const gchar *i;
104 gchar *rtn;
105 gint len = 0;
106 i = src;
107
108 while (*i) {
109 if (*i != '/')
110 len++;
111 i++;
112 }
113
114 rtn = (gchar *) g_malloc (len + 1);
115 while (*src) {
116 if (*src != '/') {
117 *rtn = *src;
118 rtn++;
119 }
120 src++;
121 }
122 *rtn = '\0';
123 return rtn - len;
124}
125
126static gboolean
127setup_directory_structure (const gchar *theme_name,
128 GError **error)
129{
130 gchar *dir, *theme_name_dir;
131 gboolean retval = TRUE(!(0));
132
133 theme_name_dir = str_remove_slash (theme_name);
134
135 dir = g_build_filename (g_get_home_dir (), ".themes", NULL((void*)0));
136 if (!g_file_test (dir, G_FILE_TEST_EXISTS))
137 g_mkdirmkdir (dir, 0775);
138 g_free (dir);
139
140 dir = g_build_filename (g_get_home_dir (), ".themes", theme_name_dir, NULL((void*)0));
141 if (!g_file_test (dir, G_FILE_TEST_EXISTS))
142 g_mkdirmkdir (dir, 0775);
143 g_free (dir);
144
145 dir = g_build_filename (g_get_home_dir (), ".themes", theme_name_dir, "index.theme", NULL((void*)0));
146 g_free (theme_name_dir);
147
148 if (g_file_test (dir, G_FILE_TEST_EXISTS)) {
149 GtkDialog *dialog;
150 GtkWidget *button;
151 gint response;
152
153 dialog = (GtkDialog *) gtk_message_dialog_new (NULL((void*)0),
154 GTK_DIALOG_MODAL,
155 GTK_MESSAGE_QUESTION,
156 GTK_BUTTONS_CANCEL,
157 _("The theme already exists. Would you like to replace it?")gettext ("The theme already exists. Would you like to replace it?"
)
);
158 button = gtk_dialog_add_button (dialog, _("_Overwrite")gettext ("_Overwrite"), GTK_RESPONSE_ACCEPT);
159 gtk_button_set_image (GTK_BUTTON (button)((((GtkButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((button)), ((gtk_button_get_type ()))))))
,
160 gtk_image_new_from_icon_name ("document-save", GTK_ICON_SIZE_BUTTON));
161 response = gtk_dialog_run (dialog);
162 gtk_widget_destroy (GTK_WIDGET (dialog)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_widget_get_type ()))))))
);
163 retval = (response != GTK_RESPONSE_CANCEL);
164 }
165 g_free (dir);
166
167 return retval;
168}
169
170static gboolean
171write_theme_to_disk (MateThemeMetaInfo *theme_info,
172 const gchar *theme_name,
173 const gchar *theme_description,
174 gboolean save_background,
175 gboolean save_notification,
176 GError **error)
177{
178 gchar* dir;
179 gchar* theme_name_dir;
180 GFile* tmp_file;
181 GFile* target_file;
182 GOutputStream* output;
183
184 gchar* str;
185 gchar* current_background;
186
187 GSettings* settings;
188 const gchar* theme_header = ""
189 "[Desktop Entry]\n"
190 "Name=%s\n"
191 "Type=X-GNOME-Metatheme\n"
192 "Comment=%s\n"
193 "\n"
194 "[X-GNOME-Metatheme]\n"
195 "GtkTheme=%s\n"
196 "MetacityTheme=%s\n"
197 "IconTheme=%s\n";
198
199 theme_name_dir = str_remove_slash (theme_name);
200 dir = g_build_filename (g_get_home_dir (), ".themes", theme_name_dir, "index.theme~", NULL((void*)0));
201 g_free (theme_name_dir);
202
203 tmp_file = g_file_new_for_path (dir);
204 dir [strlen (dir) - 1] = '\000';
205 target_file = g_file_new_for_path (dir);
206 g_free (dir);
207
208 /* start making the theme file */
209 str = g_strdup_printf(theme_header, theme_name, theme_description, theme_info->gtk_theme_name, theme_info->marco_theme_name, theme_info->icon_theme_name);
210
211 output = G_OUTPUT_STREAM (g_file_replace (tmp_file, NULL, FALSE, G_FILE_CREATE_NONE, NULL, NULL))((((GOutputStream*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((g_file_replace (tmp_file, ((void*)0), (0), G_FILE_CREATE_NONE
, ((void*)0), ((void*)0)))), ((g_output_stream_get_type ())))
)))
;
212 g_output_stream_write (output, str, strlen (str), NULL((void*)0), NULL((void*)0));
213 g_free (str);
214
215 if (theme_info->gtk_color_scheme) {
216 gchar *a, *tmp;
217 tmp = g_strdup (theme_info->gtk_color_scheme)g_strdup_inline (theme_info->gtk_color_scheme);
218 for (a = tmp; *a != '\0'; a++)
219 if (*a == '\n')
220 *a = ',';
221 str = g_strdup_printf ("GtkColorScheme=%s\n", tmp);
222 g_output_stream_write (output, str, strlen (str), NULL((void*)0), NULL((void*)0));
223
224 g_free (str);
225 g_free (tmp);
226 }
227
228 if (theme_info->cursor_theme_name) {
229 str = g_strdup_printf ("CursorTheme=%s\n"
230 "CursorSize=%i\n",
231 theme_info->cursor_theme_name,
232 theme_info->cursor_size);
233 g_output_stream_write (output, str, strlen (str), NULL((void*)0), NULL((void*)0));
234 g_free (str);
235 }
236
237 if (theme_info->notification_theme_name && save_notification) {
238 str = g_strdup_printf ("NotificationTheme=%s\n", theme_info->notification_theme_name);
239 g_output_stream_write (output, str, strlen (str), NULL((void*)0), NULL((void*)0));
240 g_free (str);
241 }
242
243 if (save_background) {
244 settings = g_settings_new (WP_SCHEMA"org.mate.background");
245 current_background = g_settings_get_string (settings, WP_FILE_KEY"picture-filename");
246
247 if (current_background != NULL((void*)0)) {
248 str = g_strdup_printf ("BackgroundImage=%s\n", current_background);
249
250 g_output_stream_write (output, str, strlen (str), NULL((void*)0), NULL((void*)0));
251
252 g_free (current_background);
253 g_free (str);
254 }
255 g_object_unref (settings);
256 }
257
258 g_file_move (tmp_file, target_file, G_FILE_COPY_OVERWRITE, NULL((void*)0), NULL((void*)0), NULL((void*)0), NULL((void*)0));
259 g_output_stream_close (output, NULL((void*)0), NULL((void*)0));
260
261 g_object_unref (tmp_file);
262 g_object_unref (target_file);
263
264 return TRUE(!(0));
265}
266
267static gboolean
268save_theme_to_disk (MateThemeMetaInfo *theme_info,
269 const gchar *theme_name,
270 const gchar *theme_description,
271 gboolean save_background,
272 gboolean save_notification,
273 GError **error)
274{
275 if (!check_theme_name (theme_name, error))
276 return FALSE(0);
277
278 if (!setup_directory_structure (theme_name, error))
279 return FALSE(0);
280
281 if (!write_theme_to_disk (theme_info, theme_name, theme_description, save_background, save_notification, error))
282 return FALSE(0);
283
284 return TRUE(!(0));
285}
286
287static void
288save_dialog_response (GtkWidget *save_dialog,
289 gint response_id,
290 AppearanceData *data)
291{
292 if (response_id == GTK_RESPONSE_OK) {
1
Assuming 'response_id' is equal to GTK_RESPONSE_OK
2
Taking true branch
293 GtkWidget *entry;
294 GtkWidget *text_view;
295 GtkTextBuffer *buffer;
296 GtkTextIter start_iter;
297 GtkTextIter end_iter;
298 gchar *buffer_text;
299 MateThemeMetaInfo *theme_info;
300 gchar *theme_description = NULL((void*)0);
301 gchar *theme_name = NULL((void*)0);
302 gboolean save_background;
303 gboolean save_notification;
304 GError *error = NULL((void*)0);
305
306 entry = appearance_capplet_get_widget (data, "save_dialog_entry")(GtkWidget*) gtk_builder_get_object(data->ui, "save_dialog_entry"
)
;
307 theme_name = escape_string_and_dup (gtk_entry_get_text (GTK_ENTRY (entry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((entry)), ((gtk_entry_get_type ()))))))
))
;
3
Calling 'escape_string_and_dup'
308
309 text_view = appearance_capplet_get_widget (data, "save_dialog_textview")(GtkWidget*) gtk_builder_get_object(data->ui, "save_dialog_textview"
)
;
310 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view)((((GtkTextView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((text_view)), ((gtk_text_view_get_type ()))))))
);
311 gtk_text_buffer_get_start_iter (buffer, &start_iter);
312 gtk_text_buffer_get_end_iter (buffer, &end_iter);
313 buffer_text = gtk_text_buffer_get_text (buffer, &start_iter, &end_iter, FALSE(0));
314 theme_description = escape_string_and_dup (buffer_text);
315 g_free (buffer_text);
316 theme_info = (MateThemeMetaInfo *) g_object_get_data (G_OBJECT (save_dialog)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((save_dialog)), (((GType) ((20) << (2))))))))
, "meta-theme-info");
317 save_background = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (((((GtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (((GtkWidget*) gtk_builder_get_object(data->ui, "save_background_checkbutton"
))), ((gtk_toggle_button_get_type ()))))))
318 appearance_capplet_get_widget (data, "save_background_checkbutton"))((((GtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (((GtkWidget*) gtk_builder_get_object(data->ui, "save_background_checkbutton"
))), ((gtk_toggle_button_get_type ()))))))
);
319 save_notification = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (((((GtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (((GtkWidget*) gtk_builder_get_object(data->ui, "save_notification_checkbutton"
))), ((gtk_toggle_button_get_type ()))))))
320 appearance_capplet_get_widget (data, "save_notification_checkbutton"))((((GtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (((GtkWidget*) gtk_builder_get_object(data->ui, "save_notification_checkbutton"
))), ((gtk_toggle_button_get_type ()))))))
);
321
322 if (save_theme_to_disk (theme_info, theme_name, theme_description, save_background, save_notification, &error)) {
323 /* remove the custom theme */
324 GtkTreeIter iter;
325
326 if (theme_find_in_model (GTK_TREE_MODEL (data->theme_store)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data->theme_store)), ((gtk_tree_model_get_type ()))))
))
, "__custom__", &iter))
327 gtk_list_store_remove (data->theme_store, &iter);
328 }
329
330 g_free (theme_name);
331 g_free (theme_description);
332 g_clear_error (&error);
333 }
334
335 gtk_widget_hide (save_dialog);
336}
337
338static void
339entry_text_changed (GtkEditable *editable,
340 AppearanceData *data)
341{
342 const gchar *text;
343 GtkWidget *button;
344
345 text = gtk_entry_get_text (GTK_ENTRY (editable)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((editable)), ((gtk_entry_get_type ()))))))
);
346 button = appearance_capplet_get_widget (data, "save_dialog_save_button")(GtkWidget*) gtk_builder_get_object(data->ui, "save_dialog_save_button"
)
;
347
348 gtk_widget_set_sensitive (button, text != NULL((void*)0) && text[0] != '\000');
349}
350
351void
352theme_save_dialog_run (MateThemeMetaInfo *theme_info,
353 AppearanceData *data)
354{
355 GtkWidget *entry;
356 GtkWidget *text_view;
357 GtkTextBuffer *text_buffer;
358
359 entry = appearance_capplet_get_widget (data, "save_dialog_entry")(GtkWidget*) gtk_builder_get_object(data->ui, "save_dialog_entry"
)
;
360 text_view = appearance_capplet_get_widget (data, "save_dialog_textview")(GtkWidget*) gtk_builder_get_object(data->ui, "save_dialog_textview"
)
;
361
362 if (data->theme_save_dialog == NULL((void*)0)) {
363 data->theme_save_dialog = appearance_capplet_get_widget (data, "theme_save_dialog")(GtkWidget*) gtk_builder_get_object(data->ui, "theme_save_dialog"
)
;
364
365 g_signal_connect (data->theme_save_dialog, "response", (GCallback) save_dialog_response, data)g_signal_connect_data ((data->theme_save_dialog), ("response"
), ((GCallback) save_dialog_response), (data), ((void*)0), (GConnectFlags
) 0)
;
366 g_signal_connect (data->theme_save_dialog, "delete-event", (GCallback) gtk_true, NULL)g_signal_connect_data ((data->theme_save_dialog), ("delete-event"
), ((GCallback) gtk_true), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
;
367 g_signal_connect (entry, "changed", (GCallback) entry_text_changed, data)g_signal_connect_data ((entry), ("changed"), ((GCallback) entry_text_changed
), (data), ((void*)0), (GConnectFlags) 0)
;
368
369 error_quark = g_quark_from_string ("mate-theme-save");
370 gtk_widget_set_size_request (text_view, 300, 100);
371 }
372
373 gtk_entry_set_text (GTK_ENTRY (entry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((entry)), ((gtk_entry_get_type ()))))))
, "");
374 entry_text_changed (GTK_EDITABLE (entry)((((GtkEditable*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((entry)), ((gtk_editable_get_type ()))))))
, data);
375 gtk_widget_grab_focus (entry);
376
377 text_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view)((((GtkTextView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((text_view)), ((gtk_text_view_get_type ()))))))
);
378 gtk_text_buffer_set_text (text_buffer, "", 0);
379 g_object_set_data (G_OBJECT (data->theme_save_dialog)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data->theme_save_dialog)), (((GType) ((20) << (
2))))))))
, "meta-theme-info", theme_info);
380 gtk_window_set_transient_for (GTK_WINDOW (data->theme_save_dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data->theme_save_dialog)), ((gtk_window_get_type ()))
))))
,
381 GET_WINDOW ("appearance_window")(((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (data->ui, ("appearance_window"
)))), ((gtk_window_get_type ())))))))
);
382 gtk_widget_show (data->theme_save_dialog);
383}
diff --git a/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-d85912.html b/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-d85912.html new file mode 100644 index 00000000..cd32265c --- /dev/null +++ b/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-d85912.html @@ -0,0 +1,2735 @@ + + + +mate-keybinding-properties.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:capplets/keybindings/mate-keybinding-properties.c
Warning:line 1206, column 51
Access to field 'message' results in a dereference of a null pointer (loaded from variable 'err')
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name mate-keybinding-properties.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/capplets/keybindings -fcoverage-compilation-dir=/rootdir/capplets/keybindings -resource-dir /usr/bin/../lib/clang/18 -D HAVE_CONFIG_H -I . -I ../.. -I ../../capplets/common -I /usr/include/udisks2 -I /usr/include/libgtop-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/libxml2 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/gio-unix-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/dconf -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I ../../ -D G_LOG_DOMAIN="keybinding-properties" -I /usr/include/polkit-1 -I /usr/include/gio-unix-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -D MATECC_DATA_DIR="/usr/local/share/mate-control-center" -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-06-07-044335-13427-1 -x c mate-keybinding-properties.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* This program was written with lots of love under the GPL by Jonathan
2 * Blandford <jrb@gnome.org>
3 */
4
5#include <config.h>
6
7#include <stdlib.h>
8#include <string.h>
9#include <gtk/gtk.h>
10#include <gio/gio.h>
11#include <gdk/gdkx.h>
12#include <X11/Xatom.h>
13#include <glib/gi18n.h>
14#include <gdk/gdkkeysyms.h>
15
16#include "wm-common.h"
17#include "capplet-util.h"
18#include "eggcellrendererkeys.h"
19#include "activate-settings-daemon.h"
20#include "dconf-util.h"
21
22#define GSETTINGS_KEYBINDINGS_DIR"/org/mate/desktop/keybindings/" "/org/mate/desktop/keybindings/"
23#define CUSTOM_KEYBINDING_SCHEMA"org.mate.control-center.keybinding" "org.mate.control-center.keybinding"
24
25#define MAX_ELEMENTS_BEFORE_SCROLLING10 10
26#define MAX_CUSTOM_SHORTCUTS1000 1000
27#define RESPONSE_ADD0 0
28#define RESPONSE_REMOVE1 1
29
30typedef struct {
31 /* The untranslated name, combine with ->package to translate */
32 char *name;
33 /* The gettext package to use to translate the section title */
34 char *package;
35 /* Name of the window manager the keys would apply to */
36 char *wm_name;
37 /* The GSettings schema for the whole file */
38 char *schema;
39 /* an array of KeyListEntry */
40 GArray *entries;
41} KeyList;
42
43typedef enum {
44 COMPARISON_NONE = 0,
45 COMPARISON_GT,
46 COMPARISON_LT,
47 COMPARISON_EQ
48} Comparison;
49
50typedef struct
51{
52 char *gsettings_path;
53 char *schema;
54 char *name;
55 int value;
56 char *value_schema; /* gsettings schema for key/value */
57 char *value_key;
58 char *description;
59 char *description_key;
60 char *cmd_key;
61 Comparison comparison;
62} KeyListEntry;
63
64enum
65{
66 DESCRIPTION_COLUMN,
67 KEYENTRY_COLUMN,
68 N_COLUMNS
69};
70
71typedef struct
72{
73 GSettings *settings;
74 char *gsettings_path;
75 char *gsettings_key;
76 guint keyval;
77 guint keycode;
78 EggVirtualModifierType mask;
79 gboolean editable;
80 GtkTreeModel *model;
81 char *description;
82 char *desc_gsettings_key;
83 gboolean desc_editable;
84 char *command;
85 char *cmd_gsettings_key;
86 gboolean cmd_editable;
87 gulong gsettings_cnxn;
88 gulong gsettings_cnxn_desc;
89 gulong gsettings_cnxn_cmd;
90} KeyEntry;
91
92static gboolean block_accels = FALSE(0);
93static GtkWidget *custom_shortcut_dialog = NULL((void*)0);
94static GtkWidget *custom_shortcut_name_entry = NULL((void*)0);
95static GtkWidget *custom_shortcut_command_entry = NULL((void*)0);
96
97static GtkWidget* _gtk_builder_get_widget(GtkBuilder* builder, const gchar* name)
98{
99 return GTK_WIDGET (gtk_builder_get_object (builder, name))((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, name))), ((gtk_widget_get_type
()))))))
;
100}
101
102static char* binding_name(guint keyval, guint keycode, EggVirtualModifierType mask, gboolean translate)
103{
104 if (keyval != 0 || keycode != 0)
105 {
106 if (translate)
107 {
108 return egg_virtual_accelerator_label (keyval, keycode, mask);
109 }
110 else
111 {
112 return egg_virtual_accelerator_name (keyval, keycode, mask);
113 }
114 }
115 else
116 {
117 return g_strdup (translate ? _("Disabled") : "")g_strdup_inline (translate ? gettext ("Disabled") : "");
118 }
119}
120
121static gboolean
122binding_from_string (const char *str,
123 guint *accelerator_key,
124 guint *keycode,
125 EggVirtualModifierType *accelerator_mods)
126{
127 g_return_val_if_fail (accelerator_key != NULL, FALSE)do { if ((accelerator_key != ((void*)0))) { } else { g_return_if_fail_warning
("keybinding-properties", ((const char*) (__func__)), "accelerator_key != NULL"
); return ((0)); } } while (0)
;
128
129 if (str == NULL((void*)0) || strcmp (str, "disabled") == 0)
130 {
131 *accelerator_key = 0;
132 *keycode = 0;
133 *accelerator_mods = 0;
134 return TRUE(!(0));
135 }
136
137 egg_accelerator_parse_virtual (str, accelerator_key, keycode, accelerator_mods);
138
139 if (*accelerator_key == 0)
140 return FALSE(0);
141 else
142 return TRUE(!(0));
143}
144
145static void
146accel_set_func (GtkTreeViewColumn *tree_column,
147 GtkCellRenderer *cell,
148 GtkTreeModel *model,
149 GtkTreeIter *iter,
150 gpointer data)
151{
152 KeyEntry *key_entry;
153
154 gtk_tree_model_get (model, iter,
155 KEYENTRY_COLUMN, &key_entry,
156 -1);
157
158 if (key_entry == NULL((void*)0))
159 g_object_set (cell,
160 "visible", FALSE(0),
161 NULL((void*)0));
162 else if (! key_entry->editable)
163 g_object_set (cell,
164 "visible", TRUE(!(0)),
165 "editable", FALSE(0),
166 "accel_key", key_entry->keyval,
167 "accel_mask", key_entry->mask,
168 "keycode", key_entry->keycode,
169 "style", PANGO_STYLE_ITALIC,
170 NULL((void*)0));
171 else
172 g_object_set (cell,
173 "visible", TRUE(!(0)),
174 "editable", TRUE(!(0)),
175 "accel_key", key_entry->keyval,
176 "accel_mask", key_entry->mask,
177 "keycode", key_entry->keycode,
178 "style", PANGO_STYLE_NORMAL,
179 NULL((void*)0));
180}
181
182static void
183description_set_func (GtkTreeViewColumn *tree_column,
184 GtkCellRenderer *cell,
185 GtkTreeModel *model,
186 GtkTreeIter *iter,
187 gpointer data)
188{
189 KeyEntry *key_entry;
190
191 gtk_tree_model_get (model, iter,
192 KEYENTRY_COLUMN, &key_entry,
193 -1);
194
195 if (key_entry != NULL((void*)0))
196 g_object_set (cell,
197 "editable", FALSE(0),
198 "text", key_entry->description != NULL((void*)0) ?
199 key_entry->description : _("<Unknown Action>")gettext ("<Unknown Action>"),
200 NULL((void*)0));
201 else
202 g_object_set (cell,
203 "editable", FALSE(0), NULL((void*)0));
204}
205
206static gboolean
207keybinding_key_changed_foreach (GtkTreeModel *model,
208 GtkTreePath *path,
209 GtkTreeIter *iter,
210 gpointer user_data)
211{
212 KeyEntry *key_entry;
213 KeyEntry *tmp_key_entry;
214
215 key_entry = (KeyEntry *)user_data;
216 gtk_tree_model_get (key_entry->model, iter,
217 KEYENTRY_COLUMN, &tmp_key_entry,
218 -1);
219
220 if (key_entry == tmp_key_entry)
221 {
222 gtk_tree_model_row_changed (key_entry->model, path, iter);
223 return TRUE(!(0));
224 }
225 return FALSE(0);
226}
227
228static void
229keybinding_key_changed (GSettings *settings,
230 gchar *key,
231 KeyEntry *key_entry)
232{
233 gchar *key_value;
234
235 key_value = g_settings_get_string (settings, key);
236
237 binding_from_string (key_value, &key_entry->keyval, &key_entry->keycode, &key_entry->mask);
238 key_entry->editable = g_settings_is_writable (settings, key);
239
240 /* update the model */
241 gtk_tree_model_foreach (key_entry->model, keybinding_key_changed_foreach, key_entry);
242}
243
244static void
245keybinding_description_changed (GSettings *settings,
246 gchar *key,
247 KeyEntry *key_entry)
248{
249 gchar *key_value;
250
251 key_value = g_settings_get_string (settings, key);
252
253 g_free (key_entry->description);
254 key_entry->description = key_value ? g_strdup (key_value)g_strdup_inline (key_value) : NULL((void*)0);
255 g_free (key_value);
256
257 key_entry->desc_editable = g_settings_is_writable (settings, key);
258
259 /* update the model */
260 gtk_tree_model_foreach (key_entry->model, keybinding_key_changed_foreach, key_entry);
261}
262
263static void
264keybinding_command_changed (GSettings *settings,
265 gchar *key,
266 KeyEntry *key_entry)
267{
268 gchar *key_value;
269
270 key_value = g_settings_get_string (settings, key);
271
272 g_free (key_entry->command);
273 key_entry->command = key_value ? g_strdup (key_value)g_strdup_inline (key_value) : NULL((void*)0);
274 key_entry->cmd_editable = g_settings_is_writable (settings, key);
275 g_free (key_value);
276
277 /* update the model */
278 gtk_tree_model_foreach (key_entry->model, keybinding_key_changed_foreach, key_entry);
279}
280
281static int
282keyentry_sort_func (GtkTreeModel *model,
283 GtkTreeIter *a,
284 GtkTreeIter *b,
285 gpointer user_data)
286{
287 KeyEntry *key_entry_a;
288 KeyEntry *key_entry_b;
289 int retval;
290
291 key_entry_a = NULL((void*)0);
292 gtk_tree_model_get (model, a,
293 KEYENTRY_COLUMN, &key_entry_a,
294 -1);
295
296 key_entry_b = NULL((void*)0);
297 gtk_tree_model_get (model, b,
298 KEYENTRY_COLUMN, &key_entry_b,
299 -1);
300
301 if (key_entry_a && key_entry_b)
302 {
303 if ((key_entry_a->keyval || key_entry_a->keycode) &&
304 (key_entry_b->keyval || key_entry_b->keycode))
305 {
306 gchar *name_a, *name_b;
307
308 name_a = binding_name (key_entry_a->keyval,
309 key_entry_a->keycode,
310 key_entry_a->mask,
311 TRUE(!(0)));
312
313 name_b = binding_name (key_entry_b->keyval,
314 key_entry_b->keycode,
315 key_entry_b->mask,
316 TRUE(!(0)));
317
318 retval = g_utf8_collate (name_a, name_b);
319
320 g_free (name_a);
321 g_free (name_b);
322 }
323 else if (key_entry_a->keyval || key_entry_a->keycode)
324 retval = -1;
325 else if (key_entry_b->keyval || key_entry_b->keycode)
326 retval = 1;
327 else
328 retval = 0;
329 }
330 else if (key_entry_a)
331 retval = -1;
332 else if (key_entry_b)
333 retval = 1;
334 else
335 retval = 0;
336
337 return retval;
338}
339
340static void
341clear_old_model (GtkBuilder *builder)
342{
343 GtkWidget *tree_view;
344 GtkWidget *actions_swindow;
345 GtkTreeModel *model;
346
347 tree_view = _gtk_builder_get_widget (builder, "shortcut_treeview");
348 model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tree_view)), ((gtk_tree_view_get_type ()))))))
);
349
350 if (model == NULL((void*)0))
351 {
352 /* create a new model */
353 model = (GtkTreeModel *) gtk_tree_store_new (N_COLUMNS, G_TYPE_STRING((GType) ((16) << (2))), G_TYPE_POINTER((GType) ((17) << (2))));
354
355 gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (model)((((GtkTreeSortable*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_sortable_get_type ()))))))
,
356 KEYENTRY_COLUMN,
357 keyentry_sort_func,
358 NULL((void*)0), NULL((void*)0));
359
360 gtk_tree_view_set_model (GTK_TREE_VIEW (tree_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tree_view)), ((gtk_tree_view_get_type ()))))))
, model);
361
362 g_object_unref (model);
363 }
364 else
365 {
366 /* clear the existing model */
367 gboolean valid;
368 GtkTreeIter iter;
369 KeyEntry *key_entry;
370
371 for (valid = gtk_tree_model_get_iter_first (model, &iter);
372 valid;
373 valid = gtk_tree_model_iter_next (model, &iter))
374 {
375 gtk_tree_model_get (model, &iter,
376 KEYENTRY_COLUMN, &key_entry,
377 -1);
378
379 if (key_entry != NULL((void*)0))
380 {
381 g_signal_handler_disconnect (key_entry->settings, key_entry->gsettings_cnxn);
382 if (key_entry->gsettings_cnxn_desc != 0)
383 g_signal_handler_disconnect (key_entry->settings, key_entry->gsettings_cnxn_desc);
384 if (key_entry->gsettings_cnxn_cmd != 0)
385 g_signal_handler_disconnect (key_entry->settings, key_entry->gsettings_cnxn_cmd);
386
387 g_object_unref (key_entry->settings);
388 if (key_entry->gsettings_path)
389 g_free (key_entry->gsettings_path);
390 g_free (key_entry->gsettings_key);
391 g_free (key_entry->description);
392 g_free (key_entry->desc_gsettings_key);
393 g_free (key_entry->command);
394 g_free (key_entry->cmd_gsettings_key);
395 g_free (key_entry);
396 }
397 }
398
399 gtk_tree_store_clear (GTK_TREE_STORE (model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
);
400 }
401
402 actions_swindow = _gtk_builder_get_widget (builder, "actions_swindow");
403 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (actions_swindow)((((GtkScrolledWindow*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((actions_swindow)), ((gtk_scrolled_window_get_type
()))))))
,
404 GTK_POLICY_NEVER, GTK_POLICY_NEVER);
405 gtk_widget_set_size_request (actions_swindow, -1, -1);
406}
407
408typedef struct {
409 const char *key;
410 const char *path;
411 const char *schema;
412 gboolean found;
413} KeyMatchData;
414
415static gboolean
416key_match (GtkTreeModel *model,
417 GtkTreePath *path,
418 GtkTreeIter *iter,
419 gpointer data)
420{
421 KeyMatchData *match_data = data;
422 KeyEntry *element;
423 gchar *element_schema = NULL((void*)0);
424 gchar *element_path = NULL((void*)0);
425 gboolean found = FALSE(0);
426
427 gtk_tree_model_get (model, iter,
428 KEYENTRY_COLUMN, &element,
429 -1);
430
431 if (!element)
432 return FALSE(0);
433
434 if (!element->settings || !G_IS_SETTINGS (element->settings)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(element->settings)); GType __t = ((g_settings_get_type ()
)); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
)
435 return FALSE(0);
436
437 g_object_get (element->settings, "schema-id", &element_schema, NULL((void*)0));
438 g_object_get (element->settings, "path", &element_path, NULL((void*)0));
439
440 if ((g_strcmp0 (element->gsettings_key, match_data->key) == 0) &&
441 (g_strcmp0 (element_schema, match_data->schema) == 0) &&
442 (g_strcmp0 (element_path, match_data->path) == 0))
443 {
444 match_data->found = TRUE(!(0));
445 found = TRUE(!(0));
446 }
447
448 g_free (element_schema);
449 g_free (element_path);
450
451 return found;
452}
453
454static gboolean key_is_already_shown(GtkTreeModel* model, const KeyListEntry* entry)
455{
456 KeyMatchData data;
457
458 data.key = entry->name;
459 data.schema = entry->schema;
460 data.path = entry->gsettings_path;
461 data.found = FALSE(0);
462 gtk_tree_model_foreach(model, key_match, &data);
463
464 return data.found;
465}
466
467static gboolean should_show_key(const KeyListEntry* entry)
468{
469 GSettings *settings;
470 int value;
471
472 if (entry->comparison == COMPARISON_NONE)
473 {
474 return TRUE(!(0));
475 }
476
477 g_return_val_if_fail(entry->value_key != NULL, FALSE)do { if ((entry->value_key != ((void*)0))) { } else { g_return_if_fail_warning
("keybinding-properties", ((const char*) (__func__)), "entry->value_key != NULL"
); return ((0)); } } while (0)
;
478 g_return_val_if_fail(entry->value_schema != NULL, FALSE)do { if ((entry->value_schema != ((void*)0))) { } else { g_return_if_fail_warning
("keybinding-properties", ((const char*) (__func__)), "entry->value_schema != NULL"
); return ((0)); } } while (0)
;
479
480 settings = g_settings_new (entry->value_schema);
481 value = g_settings_get_int (settings, entry->value_key);
482 g_object_unref (settings);
483
484 switch (entry->comparison)
485 {
486 case COMPARISON_NONE:
487 /* For compiler warnings */
488 g_assert_not_reached ()do { g_assertion_message_expr ("keybinding-properties", "mate-keybinding-properties.c"
, 488, ((const char*) (__func__)), ((void*)0)); } while (0)
;
489 return FALSE(0);
490 case COMPARISON_GT:
491 if (value > entry->value)
492 {
493 return TRUE(!(0));
494 }
495 break;
496 case COMPARISON_LT:
497 if (value < entry->value)
498 {
499 return TRUE(!(0));
500 }
501 break;
502 case COMPARISON_EQ:
503 if (value == entry->value)
504 {
505 return TRUE(!(0));
506 }
507 break;
508 }
509
510 return FALSE(0);
511}
512
513static gboolean
514count_rows_foreach (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
515{
516 gint *rows = data;
517
518 (*rows)++;
519
520 return FALSE(0);
521}
522
523static void
524ensure_scrollbar (GtkBuilder *builder, int i)
525{
526 if (i == MAX_ELEMENTS_BEFORE_SCROLLING10)
527 {
528 GtkRequisition rectangle;
529 GObject *actions_swindow = gtk_builder_get_object (builder,
530 "actions_swindow");
531 GtkWidget *treeview = _gtk_builder_get_widget (builder,
532 "shortcut_treeview");
533 gtk_widget_get_preferred_size (treeview, &rectangle, NULL((void*)0));
534 gtk_widget_set_size_request (treeview, -1, rectangle.height);
535 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (actions_swindow)((((GtkScrolledWindow*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((actions_swindow)), ((gtk_scrolled_window_get_type
()))))))
,
536 GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
537 }
538}
539
540static void
541find_section (GtkTreeModel *model,
542 GtkTreeIter *iter,
543 const char *title)
544{
545 GtkTreeStore *store;
546 gboolean success;
547
548 success = gtk_tree_model_get_iter_first (model, iter);
549 while (success)
550 {
551 char *description;
552 gint res;
553
554 gtk_tree_model_get (model, iter,
555 DESCRIPTION_COLUMN, &description,
556 -1);
557 res = g_strcmp0 (description, title);
558 g_free (description);
559 if (res == 0)
560 return;
561 success = gtk_tree_model_iter_next (model, iter);
562 }
563 store = GTK_TREE_STORE (model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
;
564 gtk_tree_store_append (store, iter, NULL((void*)0));
565 gtk_tree_store_set (store, iter,
566 DESCRIPTION_COLUMN, title,
567 -1);
568}
569
570static void
571append_keys_to_tree (GtkBuilder *builder,
572 const gchar *title,
573 const gchar *schema,
574 const gchar *package,
575 const KeyListEntry *keys_list)
576{
577 GtkTreeIter parent_iter, iter;
578 GtkTreeModel *model;
579 gint i, j;
580
581 model = gtk_tree_view_get_model (GTK_TREE_VIEW (gtk_builder_get_object (builder, "shortcut_treeview"))((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, "shortcut_treeview"))),
((gtk_tree_view_get_type ()))))))
);
582
583 /* Try to find a section parent iter, if it already exists */
584 find_section (model, &iter, title);
585 parent_iter = iter;
586
587 i = 0;
588 gtk_tree_model_foreach (model, count_rows_foreach, &i);
589
590 /* If the header we just added is the MAX_ELEMENTS_BEFORE_SCROLLING th,
591 * then we need to scroll now */
592 ensure_scrollbar (builder, i - 1);
593
594 for (j = 0; keys_list[j].name != NULL((void*)0); j++)
595 {
596 GSettings *settings = NULL((void*)0);
597 gchar *settings_path;
598 KeyEntry *key_entry;
599 const gchar *key_string;
600 gchar *key_value;
601 gchar *description;
602 gchar *command;
603
604 if (!should_show_key (&keys_list[j]))
605 continue;
606
607 if (key_is_already_shown (model, &keys_list[j]))
608 continue;
609
610 key_string = keys_list[j].name;
611
612 if (keys_list[j].gsettings_path != NULL((void*)0))
613 {
614 settings = g_settings_new_with_path (schema, keys_list[j].gsettings_path);
615 settings_path = g_strdup(keys_list[j].gsettings_path)g_strdup_inline (keys_list[j].gsettings_path);
616 }
617 else
618 {
619 settings = g_settings_new (schema);
620 settings_path = NULL((void*)0);
621 }
622
623 if (keys_list[j].description_key != NULL((void*)0))
624 {
625 /* it's a custom shortcut, so description is in gsettings */
626 description = g_settings_get_string (settings, keys_list[j].description_key);
627 }
628 else
629 {
630 /* it's from keyfile, so description need to be translated */
631 description = keys_list[j].description;
632 if (package)
633 {
634 bind_textdomain_codeset (package, "UTF-8");
635 description = dgettext (package, description);
636 }
637 else
638 {
639 description = _(description)gettext (description);
640 }
641 }
642
643 if (description == NULL((void*)0))
644 {
645 /* Only print a warning for keys that should have a schema */
646 if (keys_list[j].description_key == NULL((void*)0))
647 g_warning ("No description for key '%s'", key_string);
648 }
649
650 if (keys_list[j].cmd_key != NULL((void*)0))
651 {
652 command = g_settings_get_string (settings, keys_list[j].cmd_key);
653 }
654 else
655 {
656 command = NULL((void*)0);
657 }
658
659 key_entry = g_new0 (KeyEntry, 1)((KeyEntry *) g_malloc0_n ((1), sizeof (KeyEntry)));
660 key_entry->settings = settings;
661 key_entry->gsettings_path = settings_path;
662 key_entry->gsettings_key = g_strdup (key_string)g_strdup_inline (key_string);
663 key_entry->editable = g_settings_is_writable (settings, key_string);
664 key_entry->model = model;
665 key_entry->description = description;
666 key_entry->command = command;
667 if (keys_list[j].description_key != NULL((void*)0))
668 {
669 key_entry->desc_gsettings_key = g_strdup (keys_list[j].description_key)g_strdup_inline (keys_list[j].description_key);
670 key_entry->desc_editable = g_settings_is_writable (settings, key_entry->desc_gsettings_key);
671 gchar *gsettings_signal = g_strconcat ("changed::", key_entry->desc_gsettings_key, NULL((void*)0));
672 key_entry->gsettings_cnxn_desc = g_signal_connect (settings,g_signal_connect_data ((settings), (gsettings_signal), (((GCallback
) (keybinding_description_changed))), (key_entry), ((void*)0)
, (GConnectFlags) 0)
673 gsettings_signal,g_signal_connect_data ((settings), (gsettings_signal), (((GCallback
) (keybinding_description_changed))), (key_entry), ((void*)0)
, (GConnectFlags) 0)
674 G_CALLBACK (keybinding_description_changed),g_signal_connect_data ((settings), (gsettings_signal), (((GCallback
) (keybinding_description_changed))), (key_entry), ((void*)0)
, (GConnectFlags) 0)
675 key_entry)g_signal_connect_data ((settings), (gsettings_signal), (((GCallback
) (keybinding_description_changed))), (key_entry), ((void*)0)
, (GConnectFlags) 0)
;
676 g_free (gsettings_signal);
677 }
678 if (keys_list[j].cmd_key != NULL((void*)0))
679 {
680 key_entry->cmd_gsettings_key = g_strdup (keys_list[j].cmd_key)g_strdup_inline (keys_list[j].cmd_key);
681 key_entry->cmd_editable = g_settings_is_writable (settings, key_entry->cmd_gsettings_key);
682 gchar *gsettings_signal = g_strconcat ("changed::", key_entry->cmd_gsettings_key, NULL((void*)0));
683 key_entry->gsettings_cnxn_cmd = g_signal_connect (settings,g_signal_connect_data ((settings), (gsettings_signal), (((GCallback
) (keybinding_command_changed))), (key_entry), ((void*)0), (GConnectFlags
) 0)
684 gsettings_signal,g_signal_connect_data ((settings), (gsettings_signal), (((GCallback
) (keybinding_command_changed))), (key_entry), ((void*)0), (GConnectFlags
) 0)
685 G_CALLBACK (keybinding_command_changed),g_signal_connect_data ((settings), (gsettings_signal), (((GCallback
) (keybinding_command_changed))), (key_entry), ((void*)0), (GConnectFlags
) 0)
686 key_entry)g_signal_connect_data ((settings), (gsettings_signal), (((GCallback
) (keybinding_command_changed))), (key_entry), ((void*)0), (GConnectFlags
) 0)
;
687 g_free (gsettings_signal);
688 }
689
690 gchar *gsettings_signal = g_strconcat ("changed::", key_string, NULL((void*)0));
691 key_entry->gsettings_cnxn = g_signal_connect (settings,g_signal_connect_data ((settings), (gsettings_signal), (((GCallback
) (keybinding_key_changed))), (key_entry), ((void*)0), (GConnectFlags
) 0)
692 gsettings_signal,g_signal_connect_data ((settings), (gsettings_signal), (((GCallback
) (keybinding_key_changed))), (key_entry), ((void*)0), (GConnectFlags
) 0)
693 G_CALLBACK (keybinding_key_changed),g_signal_connect_data ((settings), (gsettings_signal), (((GCallback
) (keybinding_key_changed))), (key_entry), ((void*)0), (GConnectFlags
) 0)
694 key_entry)g_signal_connect_data ((settings), (gsettings_signal), (((GCallback
) (keybinding_key_changed))), (key_entry), ((void*)0), (GConnectFlags
) 0)
;
695 g_free (gsettings_signal);
696
697 key_value = g_settings_get_string (settings, key_string);
698 binding_from_string (key_value, &key_entry->keyval, &key_entry->keycode, &key_entry->mask);
699 g_free (key_value);
700
701 ensure_scrollbar (builder, i);
702
703 ++i;
704 gtk_tree_store_append (GTK_TREE_STORE (model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, &iter, &parent_iter);
705 /* we use the DESCRIPTION_COLUMN only for the section headers */
706 gtk_tree_store_set (GTK_TREE_STORE (model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, &iter,
707 KEYENTRY_COLUMN, key_entry,
708 -1);
709 gtk_tree_view_expand_all (GTK_TREE_VIEW (gtk_builder_get_object (builder, "shortcut_treeview"))((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, "shortcut_treeview"))),
((gtk_tree_view_get_type ()))))))
);
710 }
711
712 /* Don't show an empty section */
713 if (gtk_tree_model_iter_n_children (model, &parent_iter) == 0)
714 gtk_tree_store_remove (GTK_TREE_STORE (model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, &parent_iter);
715
716 if (i == 0)
717 gtk_widget_hide (_gtk_builder_get_widget (builder, "shortcuts_vbox"));
718 else
719 gtk_widget_show (_gtk_builder_get_widget (builder, "shortcuts_vbox"));
720}
721
722static void
723parse_start_tag (GMarkupParseContext *ctx,
724 const gchar *element_name,
725 const gchar **attr_names,
726 const gchar **attr_values,
727 gpointer user_data,
728 GError **error)
729{
730 KeyList *keylist = (KeyList *) user_data;
731 KeyListEntry key;
732 const char *name, *value_key, *description, *value_schema;
733 int value;
734 Comparison comparison;
735 const char *schema = NULL((void*)0);
736
737 name = NULL((void*)0);
738
739 /* The top-level element, names the section in the tree */
740 if (g_str_equal (element_name, "KeyListEntries")(strcmp ((const char *) (element_name), (const char *) ("KeyListEntries"
)) == 0)
)
741 {
742 const char *wm_name = NULL((void*)0);
743 const char *package = NULL((void*)0);
744
745 while (*attr_names && *attr_values)
746 {
747 if (g_str_equal (*attr_names, "name")(strcmp ((const char *) (*attr_names), (const char *) ("name"
)) == 0)
)
748 {
749 if (**attr_values)
750 name = *attr_values;
751 }
752 else if (g_str_equal (*attr_names, "wm_name")(strcmp ((const char *) (*attr_names), (const char *) ("wm_name"
)) == 0)
)
753 {
754 if (**attr_values)
755 wm_name = *attr_values;
756 }
757 else if (g_str_equal (*attr_names, "package")(strcmp ((const char *) (*attr_names), (const char *) ("package"
)) == 0)
)
758 {
759 if (**attr_values)
760 package = *attr_values;
761 }
762 else if (g_str_equal (*attr_names, "schema")(strcmp ((const char *) (*attr_names), (const char *) ("schema"
)) == 0)
)
763 {
764 if (**attr_values)
765 schema = *attr_values;
766 }
767 ++attr_names;
768 ++attr_values;
769 }
770
771 if (name)
772 {
773 if (keylist->name)
774 g_warning ("Duplicate section name");
775 g_free (keylist->name);
776 keylist->name = g_strdup (name)g_strdup_inline (name);
777 }
778 if (wm_name)
779 {
780 if (keylist->wm_name)
781 g_warning ("Duplicate window manager name");
782 g_free (keylist->wm_name);
783 keylist->wm_name = g_strdup (wm_name)g_strdup_inline (wm_name);
784 }
785 if (package)
786 {
787 if (keylist->package)
788 g_warning ("Duplicate gettext package name");
789 g_free (keylist->package);
790 keylist->package = g_strdup (package)g_strdup_inline (package);
791 }
792 if (schema)
793 {
794 if (keylist->schema)
795 g_warning ("Duplicate schema name");
796 g_free (keylist->schema);
797 keylist->schema = g_strdup (schema)g_strdup_inline (schema);
798 }
799 return;
800 }
801
802 if (!g_str_equal (element_name, "KeyListEntry")(strcmp ((const char *) (element_name), (const char *) ("KeyListEntry"
)) == 0)
803 || attr_names == NULL((void*)0)
804 || attr_values == NULL((void*)0))
805 return;
806
807 value = 0;
808 comparison = COMPARISON_NONE;
809 value_key = NULL((void*)0);
810 value_schema = NULL((void*)0);
811 description = NULL((void*)0);
812
813 while (*attr_names && *attr_values)
814 {
815 if (g_str_equal (*attr_names, "name")(strcmp ((const char *) (*attr_names), (const char *) ("name"
)) == 0)
)
816 {
817 /* skip if empty */
818 if (**attr_values)
819 name = *attr_values;
820 } else if (g_str_equal (*attr_names, "value")(strcmp ((const char *) (*attr_names), (const char *) ("value"
)) == 0)
) {
821 if (**attr_values) {
822 value = (int) g_ascii_strtoull (*attr_values, NULL((void*)0), 0);
823 }
824 } else if (g_str_equal (*attr_names, "key")(strcmp ((const char *) (*attr_names), (const char *) ("key")
) == 0)
) {
825 if (**attr_values) {
826 value_key = *attr_values;
827 }
828 } else if (g_str_equal (*attr_names, "comparison")(strcmp ((const char *) (*attr_names), (const char *) ("comparison"
)) == 0)
) {
829 if (**attr_values) {
830 if (g_str_equal (*attr_values, "gt")(strcmp ((const char *) (*attr_values), (const char *) ("gt")
) == 0)
) {
831 comparison = COMPARISON_GT;
832 } else if (g_str_equal (*attr_values, "lt")(strcmp ((const char *) (*attr_values), (const char *) ("lt")
) == 0)
) {
833 comparison = COMPARISON_LT;
834 } else if (g_str_equal (*attr_values, "eq")(strcmp ((const char *) (*attr_values), (const char *) ("eq")
) == 0)
) {
835 comparison = COMPARISON_EQ;
836 }
837 }
838 } else if (g_str_equal (*attr_names, "description")(strcmp ((const char *) (*attr_names), (const char *) ("description"
)) == 0)
) {
839 if (**attr_values) {
840 description = *attr_values;
841 }
842 } else if (g_str_equal (*attr_names, "schema")(strcmp ((const char *) (*attr_names), (const char *) ("schema"
)) == 0)
) {
843 if (**attr_values) {
844 value_schema = *attr_values;
845 }
846 }
847
848 ++attr_names;
849 ++attr_values;
850 }
851
852 if (name == NULL((void*)0))
853 return;
854
855 key.name = g_strdup (name)g_strdup_inline (name);
856 key.gsettings_path = NULL((void*)0);
857 key.description_key = NULL((void*)0);
858 key.description = g_strdup(description)g_strdup_inline (description);
859 key.schema = g_strdup(schema)g_strdup_inline (schema);
860 key.value = value;
861 if (value_key) {
862 key.value_key = g_strdup (value_key)g_strdup_inline (value_key);
863 key.value_schema = g_strdup (value_schema)g_strdup_inline (value_schema);
864 }
865 else {
866 key.value_key = NULL((void*)0);
867 key.value_schema = NULL((void*)0);
868 }
869 key.comparison = comparison;
870 key.cmd_key = NULL((void*)0);
871 g_array_append_val (keylist->entries, key)g_array_append_vals (keylist->entries, &(key), 1);
872}
873
874static gboolean
875strv_contains (char **strv,
876 char *str)
877{
878 char **p;
879
880 for (p = strv; *p; p++)
881 if (strcmp (*p, str) == 0)
882 return TRUE(!(0));
883
884 return FALSE(0);
885}
886
887static void
888append_keys_to_tree_from_file (GtkBuilder *builder,
889 const char *filename,
890 char **wm_keybindings)
891{
892 GMarkupParseContext *ctx;
893 GMarkupParser parser = { parse_start_tag, NULL((void*)0), NULL((void*)0), NULL((void*)0), NULL((void*)0) };
894 KeyList *keylist;
895 KeyListEntry key, *keys;
896 GError *err = NULL((void*)0);
897 char *buf;
898 const char *title;
899 gsize buf_len;
900 guint i;
901
902 if (!g_file_get_contents (filename, &buf, &buf_len, &err))
903 return;
904
905 keylist = g_new0 (KeyList, 1)((KeyList *) g_malloc0_n ((1), sizeof (KeyList)));
906 keylist->entries = g_array_new (FALSE(0), TRUE(!(0)), sizeof (KeyListEntry));
907 ctx = g_markup_parse_context_new (&parser, 0, keylist, NULL((void*)0));
908
909 if (!g_markup_parse_context_parse (ctx, buf, buf_len, &err))
910 {
911 g_warning ("Failed to parse '%s': '%s'", filename, err->message);
912 g_error_free (err);
913 g_free (keylist->name);
914 g_free (keylist->package);
915 g_free (keylist->wm_name);
916 g_free (keylist->schema);
917 for (i = 0; i < keylist->entries->len; i++)
918 g_free (((KeyListEntry *) &(keylist->entries->data[i]))->name);
919 g_array_free (keylist->entries, TRUE(!(0)));
920 g_free (keylist);
921 keylist = NULL((void*)0);
922 }
923 g_markup_parse_context_free (ctx);
924 g_free (buf);
925
926 if (keylist == NULL((void*)0))
927 return;
928
929 /* If there's no keys to add, or the settings apply to a window manager
930 * that's not the one we're running */
931 if (keylist->entries->len == 0
932 || (keylist->wm_name != NULL((void*)0) && !strv_contains (wm_keybindings, keylist->wm_name))
933 || keylist->name == NULL((void*)0))
934 {
935 g_free (keylist->name);
936 g_free (keylist->package);
937 g_free (keylist->wm_name);
938 g_free (keylist->schema);
939 g_array_free (keylist->entries, TRUE(!(0)));
940 g_free (keylist);
941 return;
942 }
943
944 /* Empty KeyListEntry to end the array */
945 key.name = NULL((void*)0);
946 key.description_key = NULL((void*)0);
947 key.value_key = NULL((void*)0);
948 key.value = 0;
949 key.comparison = COMPARISON_NONE;
950 g_array_append_val (keylist->entries, key)g_array_append_vals (keylist->entries, &(key), 1);
951
952 keys = (KeyListEntry *) g_array_free (keylist->entries, FALSE(0));
953 if (keylist->package)
954 {
955 bind_textdomain_codeset (keylist->package, "UTF-8");
956 title = dgettext (keylist->package, keylist->name);
957 } else {
958 title = _(keylist->name)gettext (keylist->name);
959 }
960
961 append_keys_to_tree (builder, title, keylist->schema, keylist->package, keys);
962
963 g_free (keylist->name);
964 g_free (keylist->package);
965 for (i = 0; keys[i].name != NULL((void*)0); i++)
966 g_free (keys[i].name);
967 g_free (keylist);
968}
969
970static void
971append_keys_to_tree_from_gsettings (GtkBuilder *builder, const gchar *gsettings_path)
972{
973 gchar **custom_list;
974 GArray *entries;
975 KeyListEntry key;
976 gint i;
977
978 /* load custom shortcuts from GSettings */
979 entries = g_array_new (FALSE(0), TRUE(!(0)), sizeof (KeyListEntry));
980
981 key.value_key = NULL((void*)0);
982 key.value = 0;
983 key.comparison = COMPARISON_NONE;
984
985 custom_list = dconf_util_list_subdirs (gsettings_path, FALSE(0));
986
987 if (custom_list != NULL((void*)0))
988 {
989 for (i = 0; custom_list[i] != NULL((void*)0); i++)
990 {
991 key.gsettings_path = g_strdup_printf("%s%s", gsettings_path, custom_list[i]);
992 key.name = g_strdup("binding")g_strdup_inline ("binding");
993 key.cmd_key = g_strdup("action")g_strdup_inline ("action");
994 key.description_key = g_strdup("name")g_strdup_inline ("name");
995 key.schema = NULL((void*)0);
996 g_array_append_val (entries, key)g_array_append_vals (entries, &(key), 1);
997 }
998 }
999
1000 g_strfreev (custom_list);
1001
1002 if (entries->len > 0)
1003 {
1004 KeyListEntry *keys;
1005 int i;
1006
1007 /* Empty KeyListEntry to end the array */
1008 key.gsettings_path = NULL((void*)0);
1009 key.name = NULL((void*)0);
1010 key.description_key = NULL((void*)0);
1011 key.cmd_key = NULL((void*)0);
1012 g_array_append_val (entries, key)g_array_append_vals (entries, &(key), 1);
1013
1014 keys = (KeyListEntry *) entries->data;
1015 append_keys_to_tree (builder, _("Custom Shortcuts")gettext ("Custom Shortcuts"), CUSTOM_KEYBINDING_SCHEMA"org.mate.control-center.keybinding", NULL((void*)0), keys);
1016 for (i = 0; i < entries->len; ++i)
1017 {
1018 g_free (keys[i].name);
1019 g_free (keys[i].description_key);
1020 g_free (keys[i].cmd_key);
1021 g_free (keys[i].gsettings_path);
1022 }
1023 }
1024
1025 g_array_free (entries, TRUE(!(0)));
1026}
1027
1028static void
1029reload_key_entries (GtkBuilder *builder)
1030{
1031 gchar **wm_keybindings;
1032 GList *list, *l;
1033 const gchar * const * data_dirs;
1034 GHashTable *loaded_files;
1035 guint i;
1036
1037 wm_keybindings = wm_common_get_current_keybindings();
1038
1039 clear_old_model (builder);
1040
1041 loaded_files = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
1042 data_dirs = g_get_system_data_dirs ();
1043 for (i = 0; data_dirs[i] != NULL((void*)0); i++)
1044 {
1045 g_autofree__attribute__((cleanup(g_autoptr_cleanup_generic_gfree))) gchar *dir_path = NULL((void*)0);
1046 GDir *dir;
1047 const gchar *name;
1048
1049 dir_path = g_build_filename (data_dirs[i], "mate-control-center", "keybindings", NULL((void*)0));
1050 g_debug ("Keybinding dir: %s", dir_path);
1051
1052 dir = g_dir_open (dir_path, 0, NULL((void*)0));
1053 if (!dir)
1054 continue;
1055
1056 for (name = g_dir_read_name (dir) ; name ; name = g_dir_read_name (dir))
1057 {
1058 if (g_str_has_suffix (name, ".xml")(__builtin_constant_p (".xml")? __extension__ ({ const char *
const __str = (name); const char * const __suffix = (".xml")
; gboolean __result = (0); if (__str == ((void*)0) || __suffix
== ((void*)0)) __result = (g_str_has_suffix) (__str, __suffix
); else { const size_t __str_len = strlen (((__str) + !(__str
))); const size_t __suffix_len = strlen (((__suffix) + !(__suffix
))); if (__str_len >= __suffix_len) __result = memcmp (__str
+ __str_len - __suffix_len, ((__suffix) + !(__suffix)), __suffix_len
) == 0; } __result; }) : (g_str_has_suffix) (name, ".xml") )
== FALSE(0))
1059 continue;
1060
1061 if (g_hash_table_lookup (loaded_files, name) != NULL((void*)0))
1062 {
1063 g_debug ("Not loading %s, it was already loaded from another directory", name);
1064 continue;
1065 }
1066
1067 g_hash_table_insert (loaded_files, g_strdup (name)g_strdup_inline (name), g_strdup (dir_path)g_strdup_inline (dir_path));
1068 }
1069
1070 g_dir_close (dir);
1071 }
1072 list = g_hash_table_get_keys (loaded_files);
1073 list = g_list_sort(list, (GCompareFunc) g_str_equal);
1074 for (l = list; l != NULL((void*)0); l = l->next)
1075 {
1076 g_autofree__attribute__((cleanup(g_autoptr_cleanup_generic_gfree))) gchar *path = NULL((void*)0);
1077 path = g_build_filename (g_hash_table_lookup (loaded_files, l->data), l->data, NULL((void*)0));
1078 g_debug ("Keybinding file: %s", path);
1079 append_keys_to_tree_from_file (builder, path, wm_keybindings);
1080 }
1081 g_list_free (list);
1082 g_hash_table_destroy (loaded_files);
1083
1084 /* Load custom shortcuts _after_ system-provided ones,
1085 * since some of the custom shortcuts may also be listed
1086 * in a file. Loading the custom shortcuts last makes
1087 * such keys not show up in the custom section.
1088 */
1089 append_keys_to_tree_from_gsettings (builder, GSETTINGS_KEYBINDINGS_DIR"/org/mate/desktop/keybindings/");
1090
1091 g_strfreev (wm_keybindings);
1092}
1093
1094static void
1095key_entry_controlling_key_changed (GSettings *settings, gchar *key, gpointer user_data)
1096{
1097 reload_key_entries (user_data);
1098}
1099
1100static gboolean cb_check_for_uniqueness(GtkTreeModel* model, GtkTreePath* path, GtkTreeIter* iter, KeyEntry* new_key)
1101{
1102 KeyEntry* element;
1103
1104 gtk_tree_model_get (new_key->model, iter,
1105 KEYENTRY_COLUMN, &element,
1106 -1);
1107
1108 /* no conflict for : blanks, different modifiers, or ourselves */
1109 if (element == NULL((void*)0) || new_key->mask != element->mask)
1110 {
1111 return FALSE(0);
1112 }
1113
1114 gchar *new_key_schema = NULL((void*)0);
1115 gchar *element_schema = NULL((void*)0);
1116 gchar *new_key_path = NULL((void*)0);
1117 gchar *element_path = NULL((void*)0);
1118
1119 if (new_key && new_key->settings)
1120 {
1121 g_object_get (new_key->settings, "schema-id", &new_key_schema, NULL((void*)0));
1122 g_object_get (new_key->settings, "path", &new_key_path, NULL((void*)0));
1123 }
1124
1125 if (element->settings)
1126 {
1127 g_object_get (element->settings, "schema-id", &element_schema, NULL((void*)0));
1128 g_object_get (element->settings, "path", &element_path, NULL((void*)0));
1129 }
1130
1131 if (!g_strcmp0 (new_key->gsettings_key, element->gsettings_key) &&
1132 !g_strcmp0 (new_key_schema, element_schema) &&
1133 !g_strcmp0 (new_key_path, element_path))
1134 {
1135 return FALSE(0);
1136 }
1137
1138 if (new_key->keyval != 0)
1139 {
1140 if (new_key->keyval != element->keyval)
1141 {
1142 return FALSE(0);
1143 }
1144 }
1145 else if (element->keyval != 0 || new_key->keycode != element->keycode)
1146 {
1147 return FALSE(0);
1148 }
1149
1150 new_key->editable = FALSE(0);
1151 new_key->settings = element->settings;
1152 new_key->gsettings_key = element->gsettings_key;
1153 new_key->description = element->description;
1154 new_key->desc_gsettings_key = element->desc_gsettings_key;
1155 new_key->desc_editable = element->desc_editable;
1156
1157 return TRUE(!(0));
1158}
1159
1160static const guint forbidden_keyvals[] = {
1161 /* Navigation keys */
1162 GDK_KEY_Home0xff50,
1163 GDK_KEY_Left0xff51,
1164 GDK_KEY_Up0xff52,
1165 GDK_KEY_Right0xff53,
1166 GDK_KEY_Down0xff54,
1167 GDK_KEY_Page_Up0xff55,
1168 GDK_KEY_Page_Down0xff56,
1169 GDK_KEY_End0xff57,
1170 GDK_KEY_Tab0xff09,
1171
1172 /* Return */
1173 GDK_KEY_KP_Enter0xff8d,
1174 GDK_KEY_Return0xff0d,
1175
1176 GDK_KEY_space0x020,
1177 GDK_KEY_Mode_switch0xff7e
1178};
1179
1180static gboolean keyval_is_forbidden(guint keyval)
1181{
1182 guint i;
1183
1184 for (i = 0; i < G_N_ELEMENTS(forbidden_keyvals)(sizeof (forbidden_keyvals) / sizeof ((forbidden_keyvals)[0])
)
; i++)
1185 {
1186 if (keyval == forbidden_keyvals[i])
1187 {
1188 return TRUE(!(0));
1189 }
1190 }
1191
1192 return FALSE(0);
1193}
1194
1195static void show_error(GtkWindow* parent, GError* err)
1196{
1197 GtkWidget *dialog;
1198
1199 dialog = gtk_message_dialog_new (parent,
1200 GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL,
1201 GTK_MESSAGE_WARNING,
1202 GTK_BUTTONS_OK,
1203 _("Error saving the new shortcut")gettext ("Error saving the new shortcut"));
1204
1205 gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog)((((GtkMessageDialog*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((dialog)), ((gtk_message_dialog_get_type ())
)))))
,
1206 "%s", err->message);
19
Access to field 'message' results in a dereference of a null pointer (loaded from variable 'err')
1207 gtk_dialog_run (GTK_DIALOG (dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_dialog_get_type ()))))))
);
1208 gtk_widget_destroy (dialog);
1209}
1210
1211static void accel_edited_callback(GtkCellRendererText* cell, const char* path_string, guint keyval, EggVirtualModifierType mask, guint keycode, gpointer data)
1212{
1213 GtkTreeView* view = (GtkTreeView*) data;
1214 GtkTreeModel* model;
1215 GtkTreePath* path = gtk_tree_path_new_from_string (path_string);
1216 GtkTreeIter iter;
1217 KeyEntry* key_entry, tmp_key;
1218 char* str;
1219
1220 block_accels = FALSE(0);
1221
1222 model = gtk_tree_view_get_model (view);
1223 gtk_tree_model_get_iter (model, &iter, path);
1224 gtk_tree_path_free (path);
1225 gtk_tree_model_get (model, &iter,
1226 KEYENTRY_COLUMN, &key_entry,
1227 -1);
1228
1229 /* sanity check */
1230 if (key_entry == NULL((void*)0))
1231 {
1232 return;
1233 }
1234
1235 /* CapsLock isn't supported as a keybinding modifier, so keep it from confusing us */
1236 mask &= ~EGG_VIRTUAL_LOCK_MASK;
1237
1238 tmp_key.model = model;
1239 tmp_key.keyval = keyval;
1240 tmp_key.keycode = keycode;
1241 tmp_key.mask = mask;
1242 tmp_key.settings = key_entry->settings;
1243 tmp_key.gsettings_key = key_entry->gsettings_key;
1244 tmp_key.description = NULL((void*)0);
1245 tmp_key.editable = TRUE(!(0)); /* kludge to stuff in a return flag */
1246
1247 if (keyval != 0 || keycode != 0) /* any number of keys can be disabled */
1248 {
1249 gtk_tree_model_foreach(model, (GtkTreeModelForeachFunc) cb_check_for_uniqueness, &tmp_key);
1250 }
1251
1252 /* Check for unmodified keys */
1253 if (tmp_key.mask == 0 && tmp_key.keycode != 0)
1254 {
1255 if ((tmp_key.keyval >= GDK_KEY_a0x061 && tmp_key.keyval <= GDK_KEY_z0x07a)
1256 || (tmp_key.keyval >= GDK_KEY_A0x041 && tmp_key.keyval <= GDK_KEY_Z0x05a)
1257 || (tmp_key.keyval >= GDK_KEY_00x030 && tmp_key.keyval <= GDK_KEY_90x039)
1258 || (tmp_key.keyval >= GDK_KEY_kana_fullstop0x4a1 && tmp_key.keyval <= GDK_KEY_semivoicedsound0x4df)
1259 || (tmp_key.keyval >= GDK_KEY_Arabic_comma0x5ac && tmp_key.keyval <= GDK_KEY_Arabic_sukun0x5f2)
1260 || (tmp_key.keyval >= GDK_KEY_Serbian_dje0x6a1 && tmp_key.keyval <= GDK_KEY_Cyrillic_HARDSIGN0x6ff)
1261 || (tmp_key.keyval >= GDK_KEY_Greek_ALPHAaccent0x7a1 && tmp_key.keyval <= GDK_KEY_Greek_omega0x7f9)
1262 || (tmp_key.keyval >= GDK_KEY_hebrew_doublelowline0xcdf && tmp_key.keyval <= GDK_KEY_hebrew_taf0xcfa)
1263 || (tmp_key.keyval >= GDK_KEY_Thai_kokai0xda1 && tmp_key.keyval <= GDK_KEY_Thai_lekkao0xdf9)
1264 || (tmp_key.keyval >= GDK_KEY_Hangul0xff31 && tmp_key.keyval <= GDK_KEY_Hangul_Special0xff3f)
1265 || (tmp_key.keyval >= GDK_KEY_Hangul_Kiyeog0xea1 && tmp_key.keyval <= GDK_KEY_Hangul_J_YeorinHieuh0xefa)
1266 || keyval_is_forbidden (tmp_key.keyval))
1267 {
1268
1269 GtkWidget *dialog;
1270 char *name;
1271
1272 name = binding_name (keyval, keycode, mask, TRUE(!(0)));
1273
1274 dialog = gtk_message_dialog_new (
1275 GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (view)))((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_widget_get_toplevel (((((GtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((view)), ((gtk_widget_get_type ()))))))))
), ((gtk_window_get_type ()))))))
,
1276 GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL,
1277 GTK_MESSAGE_WARNING,
1278 GTK_BUTTONS_CANCEL,
1279 _("The shortcut \"%s\" cannot be used because it will become impossible to type using this key.\n"gettext ("The shortcut \"%s\" cannot be used because it will become impossible to type using this key.\n"
"Please try with a key such as Control, Alt or Shift at the same time."
)
1280 "Please try with a key such as Control, Alt or Shift at the same time.")gettext ("The shortcut \"%s\" cannot be used because it will become impossible to type using this key.\n"
"Please try with a key such as Control, Alt or Shift at the same time."
)
,
1281 name);
1282
1283 g_free (name);
1284 gtk_dialog_run (GTK_DIALOG (dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_dialog_get_type ()))))))
);
1285 gtk_widget_destroy (dialog);
1286
1287 /* set it back to its previous value. */
1288 egg_cell_renderer_keys_set_accelerator(
1289 EGG_CELL_RENDERER_KEYS(cell)((((EggCellRendererKeys*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((cell)), ((egg_cell_renderer_keys_get_type
()))))))
,
1290 key_entry->keyval,
1291 key_entry->keycode,
1292 key_entry->mask);
1293 return;
1294 }
1295 }
1296
1297 /* flag to see if the new accelerator was in use by something */
1298 if (!tmp_key.editable)
1299 {
1300 GtkWidget* dialog;
1301 char* name;
1302 int response;
1303
1304 name = binding_name(keyval, keycode, mask, TRUE(!(0)));
1305
1306 dialog = gtk_message_dialog_new(
1307 GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(view)))((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_widget_get_toplevel(((((GtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((view)), ((gtk_widget_get_type ()))))))))
), ((gtk_window_get_type ()))))))
,
1308 GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL,
1309 GTK_MESSAGE_WARNING,
1310 GTK_BUTTONS_CANCEL,
1311 _("The shortcut \"%s\" is already used for\n\"%s\"")gettext ("The shortcut \"%s\" is already used for\n\"%s\""),
1312 name,
1313 tmp_key.description ? tmp_key.description : tmp_key.gsettings_key);
1314 g_free (name);
1315
1316 gtk_message_dialog_format_secondary_text (
1317 GTK_MESSAGE_DIALOG (dialog)((((GtkMessageDialog*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((dialog)), ((gtk_message_dialog_get_type ())
)))))
,
1318 _("If you reassign the shortcut to \"%s\", the \"%s\" shortcut "gettext ("If you reassign the shortcut to \"%s\", the \"%s\" shortcut "
"will be disabled.")
1319 "will be disabled.")gettext ("If you reassign the shortcut to \"%s\", the \"%s\" shortcut "
"will be disabled.")
,
1320 key_entry->description ? key_entry->description : key_entry->gsettings_key,
1321 tmp_key.description ? tmp_key.description : tmp_key.gsettings_key);
1322
1323 gtk_dialog_add_button(GTK_DIALOG (dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_dialog_get_type ()))))))
, _("_Reassign")gettext ("_Reassign"), GTK_RESPONSE_ACCEPT);
1324
1325 gtk_dialog_set_default_response(GTK_DIALOG (dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_dialog_get_type ()))))))
, GTK_RESPONSE_ACCEPT);
1326
1327 response = gtk_dialog_run (GTK_DIALOG (dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_dialog_get_type ()))))))
);
1328 gtk_widget_destroy (dialog);
1329
1330 if (response == GTK_RESPONSE_ACCEPT)
1331 {
1332 g_settings_set_string (tmp_key.settings, tmp_key.gsettings_key, "disabled");
1333
1334 str = binding_name (keyval, keycode, mask, FALSE(0));
1335 g_settings_set_string (key_entry->settings, key_entry->gsettings_key, str);
1336
1337 g_free (str);
1338 }
1339 else
1340 {
1341 /* set it back to its previous value. */
1342 egg_cell_renderer_keys_set_accelerator(
1343 EGG_CELL_RENDERER_KEYS(cell)((((EggCellRendererKeys*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((cell)), ((egg_cell_renderer_keys_get_type
()))))))
,
1344 key_entry->keyval,
1345 key_entry->keycode,
1346 key_entry->mask);
1347 }
1348
1349 return;
1350 }
1351
1352 str = binding_name (keyval, keycode, mask, FALSE(0));
1353
1354 g_settings_set_string(
1355 key_entry->settings,
1356 key_entry->gsettings_key,
1357 str);
1358
1359 g_free (str);
1360
1361}
1362
1363static void
1364accel_cleared_callback (GtkCellRendererText *cell,
1365 const char *path_string,
1366 gpointer data)
1367{
1368 GtkTreeView *view = (GtkTreeView *) data;
1369 GtkTreePath *path = gtk_tree_path_new_from_string (path_string);
1370 KeyEntry *key_entry;
1371 GtkTreeIter iter;
1372 GtkTreeModel *model;
1373
1374 block_accels = FALSE(0);
1375
1376 model = gtk_tree_view_get_model (view);
1377 gtk_tree_model_get_iter (model, &iter, path);
1378 gtk_tree_path_free (path);
1379 gtk_tree_model_get (model, &iter,
1380 KEYENTRY_COLUMN, &key_entry,
1381 -1);
1382
1383 /* sanity check */
1384 if (key_entry == NULL((void*)0))
1385 return;
1386
1387 /* Unset the key */
1388 g_settings_set_string (key_entry->settings,
1389 key_entry->gsettings_key,
1390 "disabled");
1391}
1392
1393static void
1394description_edited_callback (GtkCellRendererText *renderer,
1395 gchar *path_string,
1396 gchar *new_text,
1397 gpointer user_data)
1398{
1399 GtkTreeView *view = GTK_TREE_VIEW (user_data)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((gtk_tree_view_get_type ()))))))
;
1400 GtkTreeModel *model;
1401 GtkTreePath *path = gtk_tree_path_new_from_string (path_string);
1402 GtkTreeIter iter;
1403 KeyEntry *key_entry;
1404
1405 model = gtk_tree_view_get_model (view);
1406 gtk_tree_model_get_iter (model, &iter, path);
1407 gtk_tree_path_free (path);
1408
1409 gtk_tree_model_get (model, &iter,
1410 KEYENTRY_COLUMN, &key_entry,
1411 -1);
1412
1413 /* sanity check */
1414 if (key_entry == NULL((void*)0) || key_entry->desc_gsettings_key == NULL((void*)0))
1415 return;
1416
1417 if (!g_settings_set_string (key_entry->settings, key_entry->desc_gsettings_key, new_text))
1418 key_entry->desc_editable = FALSE(0);
1419}
1420
1421typedef struct
1422{
1423 GtkTreeView *tree_view;
1424 GtkTreePath *path;
1425 GtkTreeViewColumn *column;
1426} IdleData;
1427
1428static gboolean
1429real_start_editing_cb (IdleData *idle_data)
1430{
1431 gtk_widget_grab_focus (GTK_WIDGET (idle_data->tree_view)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((idle_data->tree_view)), ((gtk_widget_get_type ())))))
)
);
1432 gtk_tree_view_set_cursor (idle_data->tree_view,
1433 idle_data->path,
1434 idle_data->column,
1435 TRUE(!(0)));
1436 gtk_tree_path_free (idle_data->path);
1437 g_free (idle_data);
1438 return FALSE(0);
1439}
1440
1441static gboolean
1442edit_custom_shortcut (KeyEntry *key)
1443{
1444 gint result;
1445 const gchar *text;
1446 gboolean ret;
1447
1448 gtk_entry_set_text (GTK_ENTRY (custom_shortcut_name_entry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((custom_shortcut_name_entry)), ((gtk_entry_get_type ())))
)))
, key->description ? key->description : "");
1449 gtk_widget_set_sensitive (custom_shortcut_name_entry, key->desc_editable);
1450 gtk_widget_grab_focus (custom_shortcut_name_entry);
1451 gtk_entry_set_text (GTK_ENTRY (custom_shortcut_command_entry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((custom_shortcut_command_entry)), ((gtk_entry_get_type ()
))))))
, key->command ? key->command : "");
1452 gtk_widget_set_sensitive (custom_shortcut_command_entry, key->cmd_editable);
1453
1454 gtk_window_present (GTK_WINDOW (custom_shortcut_dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((custom_shortcut_dialog)), ((gtk_window_get_type ()))))))
);
1455 result = gtk_dialog_run (GTK_DIALOG (custom_shortcut_dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((custom_shortcut_dialog)), ((gtk_dialog_get_type ()))))))
);
1456 switch (result)
1457 {
1458 case GTK_RESPONSE_OK:
1459 text = gtk_entry_get_text (GTK_ENTRY (custom_shortcut_name_entry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((custom_shortcut_name_entry)), ((gtk_entry_get_type ())))
)))
);
1460 g_free (key->description);
1461 key->description = g_strdup (text)g_strdup_inline (text);
1462 text = gtk_entry_get_text (GTK_ENTRY (custom_shortcut_command_entry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((custom_shortcut_command_entry)), ((gtk_entry_get_type ()
))))))
);
1463 g_free (key->command);
1464 key->command = g_strdup (text)g_strdup_inline (text);
1465 ret = TRUE(!(0));
1466 break;
1467 default:
1468 ret = FALSE(0);
1469 break;
1470 }
1471
1472 gtk_widget_hide (custom_shortcut_dialog);
1473
1474 return ret;
1475}
1476
1477static gboolean
1478remove_custom_shortcut (GtkTreeModel *model, GtkTreeIter *iter)
1479{
1480 GtkTreeIter parent;
1481 KeyEntry *key;
1482
1483 gtk_tree_model_get (model, iter,
1484 KEYENTRY_COLUMN, &key,
1485 -1);
1486
1487 /* not a custom shortcut */
1488 if (key->command == NULL((void*)0))
1489 return FALSE(0);
1490
1491 g_signal_handler_disconnect (key->settings, key->gsettings_cnxn);
1492 if (key->gsettings_cnxn_desc != 0)
1493 g_signal_handler_disconnect (key->settings, key->gsettings_cnxn_desc);
1494 if (key->gsettings_cnxn_cmd != 0)
1495 g_signal_handler_disconnect (key->settings, key->gsettings_cnxn_cmd);
1496
1497 dconf_util_recursive_reset (key->gsettings_path, NULL((void*)0));
1498 g_object_unref (key->settings);
1499
1500 g_free (key->gsettings_path);
1501 g_free (key->gsettings_key);
1502 g_free (key->description);
1503 g_free (key->desc_gsettings_key);
1504 g_free (key->command);
1505 g_free (key->cmd_gsettings_key);
1506 g_free (key);
1507
1508 gtk_tree_model_iter_parent (model, &parent, iter);
1509 gtk_tree_store_remove (GTK_TREE_STORE (model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter);
1510 if (!gtk_tree_model_iter_has_child (model, &parent))
1511 gtk_tree_store_remove (GTK_TREE_STORE (model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, &parent);
1512
1513 return TRUE(!(0));
1514}
1515
1516static void
1517update_custom_shortcut (GtkTreeModel *model, GtkTreeIter *iter)
1518{
1519 KeyEntry *key;
1520
1521 gtk_tree_model_get (model, iter,
1522 KEYENTRY_COLUMN, &key,
1523 -1);
1524
1525 edit_custom_shortcut (key);
1526 if (key->command == NULL((void*)0) || key->command[0] == '\0')
1527 {
1528 remove_custom_shortcut (model, iter);
1529 }
1530 else
1531 {
1532 gtk_tree_store_set (GTK_TREE_STORE (model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter,
1533 KEYENTRY_COLUMN, key, -1);
1534 if (key->description != NULL((void*)0))
1535 g_settings_set_string (key->settings, key->desc_gsettings_key, key->description);
1536 else
1537 g_settings_reset (key->settings, key->desc_gsettings_key);
1538 g_settings_set_string (key->settings, key->cmd_gsettings_key, key->command);
1539 }
1540}
1541
1542static gchar *
1543find_free_gsettings_path (GError **error)
1544{
1545 gchar **existing_dirs;
1546 gchar *dir = NULL((void*)0);
1547 gchar *fulldir = NULL((void*)0);
1548 int i;
1549 int j;
1550 gboolean found;
1551
1552 existing_dirs = dconf_util_list_subdirs (GSETTINGS_KEYBINDINGS_DIR"/org/mate/desktop/keybindings/", FALSE(0));
1553
1554 for (i = 0; i < MAX_CUSTOM_SHORTCUTS1000; i++)
8
Loop condition is true. Entering loop body
1555 {
1556 found = TRUE(!(0));
1557 dir = g_strdup_printf ("custom%d/", i);
1558 for (j = 0; existing_dirs[j] != NULL((void*)0); j++)
9
Assuming the condition is false
10
Loop condition is false. Execution continues on line 1565
1559 if (!g_strcmp0(dir, existing_dirs[j]))
1560 {
1561 found = FALSE(0);
1562 g_free (dir);
1563 break;
1564 }
1565 if (found
10.1
'found' is 1
)
11
Taking true branch
1566 break;
1567 }
1568 g_strfreev (existing_dirs);
1569
1570 if (i
11.1
'i' is not equal to MAX_CUSTOM_SHORTCUTS
== MAX_CUSTOM_SHORTCUTS1000)
12
Taking false branch
1571 {
1572 g_free (dir);
1573 dir = NULL((void*)0);
1574 g_set_error_literal (error,
1575 g_quark_from_string ("Keyboard Shortcuts"),
1576 0,
1577 _("Too many custom shortcuts")gettext ("Too many custom shortcuts"));
1578 }
1579
1580 fulldir = g_strdup_printf ("%s%s", GSETTINGS_KEYBINDINGS_DIR"/org/mate/desktop/keybindings/", dir);
1581 g_free (dir);
1582 return fulldir;
13
Returning without writing to '*error'
1583}
1584
1585static void
1586add_custom_shortcut (GtkTreeView *tree_view,
1587 GtkTreeModel *model)
1588{
1589 KeyEntry *key_entry;
1590 GtkTreeIter iter;
1591 GtkTreeIter parent_iter;
1592 GtkTreePath *path;
1593 gchar *dir;
1594 GError *error;
1595
1596 error = NULL((void*)0);
6
Null pointer value stored to 'error'
1597 dir = find_free_gsettings_path (&error);
7
Calling 'find_free_gsettings_path'
14
Returning from 'find_free_gsettings_path'
1598 if (dir == NULL((void*)0))
15
Assuming 'dir' is equal to NULL
16
Taking true branch
1599 {
1600 show_error (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (tree_view)))((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_widget_get_toplevel (((((GtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((tree_view)), ((gtk_widget_get_type ())))
)))))), ((gtk_window_get_type ()))))))
, error)
;
17
Passing null pointer value via 2nd parameter 'err'
18
Calling 'show_error'
1601
1602 g_error_free (error);
1603 return;
1604 }
1605
1606 key_entry = g_new0 (KeyEntry, 1)((KeyEntry *) g_malloc0_n ((1), sizeof (KeyEntry)));
1607 key_entry->gsettings_path = g_strdup(dir)g_strdup_inline (dir);
1608 key_entry->gsettings_key = g_strdup("binding")g_strdup_inline ("binding");
1609 key_entry->editable = TRUE(!(0));
1610 key_entry->model = model;
1611 key_entry->desc_gsettings_key = g_strdup("name")g_strdup_inline ("name");
1612 key_entry->description = g_strdup ("")g_strdup_inline ("");
1613 key_entry->desc_editable = TRUE(!(0));
1614 key_entry->cmd_gsettings_key = g_strdup("action")g_strdup_inline ("action");
1615 key_entry->command = g_strdup ("")g_strdup_inline ("");
1616 key_entry->cmd_editable = TRUE(!(0));
1617 g_free (dir);
1618
1619 if (edit_custom_shortcut (key_entry) &&
1620 key_entry->command && key_entry->command[0])
1621 {
1622 find_section (model, &iter, _("Custom Shortcuts")gettext ("Custom Shortcuts"));
1623 parent_iter = iter;
1624 gtk_tree_store_append (GTK_TREE_STORE (model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, &iter, &parent_iter);
1625 gtk_tree_store_set (GTK_TREE_STORE (model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, &iter, KEYENTRY_COLUMN, key_entry, -1);
1626
1627 /* store in gsettings */
1628 key_entry->settings = g_settings_new_with_path (CUSTOM_KEYBINDING_SCHEMA"org.mate.control-center.keybinding", key_entry->gsettings_path);
1629 g_settings_set_string (key_entry->settings, key_entry->gsettings_key, "disabled");
1630 g_settings_set_string (key_entry->settings, key_entry->desc_gsettings_key, key_entry->description);
1631 g_settings_set_string (key_entry->settings, key_entry->cmd_gsettings_key, key_entry->command);
1632
1633 /* add gsettings watches */
1634 key_entry->gsettings_cnxn_desc = g_signal_connect (key_entry->settings,g_signal_connect_data ((key_entry->settings), ("changed::name"
), (((GCallback) (keybinding_description_changed))), (key_entry
), ((void*)0), (GConnectFlags) 0)
1635 "changed::name",g_signal_connect_data ((key_entry->settings), ("changed::name"
), (((GCallback) (keybinding_description_changed))), (key_entry
), ((void*)0), (GConnectFlags) 0)
1636 G_CALLBACK (keybinding_description_changed),g_signal_connect_data ((key_entry->settings), ("changed::name"
), (((GCallback) (keybinding_description_changed))), (key_entry
), ((void*)0), (GConnectFlags) 0)
1637 key_entry)g_signal_connect_data ((key_entry->settings), ("changed::name"
), (((GCallback) (keybinding_description_changed))), (key_entry
), ((void*)0), (GConnectFlags) 0)
;
1638 key_entry->gsettings_cnxn_cmd = g_signal_connect (key_entry->settings,g_signal_connect_data ((key_entry->settings), ("changed::action"
), (((GCallback) (keybinding_command_changed))), (key_entry),
((void*)0), (GConnectFlags) 0)
1639 "changed::action",g_signal_connect_data ((key_entry->settings), ("changed::action"
), (((GCallback) (keybinding_command_changed))), (key_entry),
((void*)0), (GConnectFlags) 0)
1640 G_CALLBACK (keybinding_command_changed),g_signal_connect_data ((key_entry->settings), ("changed::action"
), (((GCallback) (keybinding_command_changed))), (key_entry),
((void*)0), (GConnectFlags) 0)
1641 key_entry)g_signal_connect_data ((key_entry->settings), ("changed::action"
), (((GCallback) (keybinding_command_changed))), (key_entry),
((void*)0), (GConnectFlags) 0)
;
1642 key_entry->gsettings_cnxn = g_signal_connect (key_entry->settings,g_signal_connect_data ((key_entry->settings), ("changed::binding"
), (((GCallback) (keybinding_key_changed))), (key_entry), ((void
*)0), (GConnectFlags) 0)
1643 "changed::binding",g_signal_connect_data ((key_entry->settings), ("changed::binding"
), (((GCallback) (keybinding_key_changed))), (key_entry), ((void
*)0), (GConnectFlags) 0)
1644 G_CALLBACK (keybinding_key_changed),g_signal_connect_data ((key_entry->settings), ("changed::binding"
), (((GCallback) (keybinding_key_changed))), (key_entry), ((void
*)0), (GConnectFlags) 0)
1645 key_entry)g_signal_connect_data ((key_entry->settings), ("changed::binding"
), (((GCallback) (keybinding_key_changed))), (key_entry), ((void
*)0), (GConnectFlags) 0)
;
1646
1647 /* make the new shortcut visible */
1648 path = gtk_tree_model_get_path (model, &iter);
1649 gtk_tree_view_expand_to_path (tree_view, path);
1650 gtk_tree_view_scroll_to_cell (tree_view, path, NULL((void*)0), FALSE(0), 0, 0);
1651 gtk_tree_path_free (path);
1652 }
1653 else
1654 {
1655 g_free (key_entry->gsettings_path);
1656 g_free (key_entry->gsettings_key);
1657 g_free (key_entry->description);
1658 g_free (key_entry->desc_gsettings_key);
1659 g_free (key_entry->command);
1660 g_free (key_entry->cmd_gsettings_key);
1661 g_free (key_entry);
1662 }
1663}
1664
1665static void
1666start_editing_kb_cb (GtkTreeView *treeview,
1667 GtkTreePath *path,
1668 GtkTreeViewColumn *column,
1669 gpointer user_data)
1670{
1671 GtkTreeModel *model;
1672 GtkTreeIter iter;
1673 KeyEntry *key;
1674
1675 model = gtk_tree_view_get_model (treeview);
1676 gtk_tree_model_get_iter (model, &iter, path);
1677 gtk_tree_model_get (model, &iter,
1678 KEYENTRY_COLUMN, &key,
1679 -1);
1680
1681 if (key == NULL((void*)0))
1682 {
1683 /* This is a section heading - expand or collapse */
1684 if (gtk_tree_view_row_expanded (treeview, path))
1685 gtk_tree_view_collapse_row (treeview, path);
1686 else
1687 gtk_tree_view_expand_row (treeview, path, FALSE(0));
1688 return;
1689 }
1690
1691 /* if only the accel can be edited on the selected row
1692 * always select the accel column */
1693 if (key->desc_editable &&
1694 column == gtk_tree_view_get_column (treeview, 0))
1695 {
1696 gtk_widget_grab_focus (GTK_WIDGET (treeview)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((treeview)), ((gtk_widget_get_type ()))))))
);
1697 gtk_tree_view_set_cursor (treeview, path,
1698 gtk_tree_view_get_column (treeview, 0),
1699 FALSE(0));
1700 update_custom_shortcut (model, &iter);
1701 }
1702 else
1703 {
1704 gtk_widget_grab_focus (GTK_WIDGET (treeview)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((treeview)), ((gtk_widget_get_type ()))))))
);
1705 gtk_tree_view_set_cursor (treeview,
1706 path,
1707 gtk_tree_view_get_column (treeview, 1),
1708 TRUE(!(0)));
1709 }
1710}
1711
1712static gboolean
1713start_editing_cb (GtkTreeView *tree_view,
1714 GdkEventButton *event,
1715 gpointer user_data)
1716{
1717 GtkTreePath *path;
1718 GtkTreeViewColumn *column;
1719
1720 if ((event->window != gtk_tree_view_get_bin_window (tree_view)) ||
1721 (event->type != GDK_2BUTTON_PRESS))
1722 return FALSE(0);
1723
1724 if (gtk_tree_view_get_path_at_pos (tree_view,
1725 (gint) event->x,
1726 (gint) event->y,
1727 &path, &column,
1728 NULL((void*)0), NULL((void*)0)))
1729 {
1730 IdleData *idle_data;
1731 GtkTreeModel *model;
1732 GtkTreeIter iter;
1733 KeyEntry *key;
1734
1735 if (gtk_tree_path_get_depth (path) == 1)
1736 {
1737 gtk_tree_path_free (path);
1738 return FALSE(0);
1739 }
1740
1741 model = gtk_tree_view_get_model (tree_view);
1742 gtk_tree_model_get_iter (model, &iter, path);
1743 gtk_tree_model_get (model, &iter,
1744 KEYENTRY_COLUMN, &key,
1745 -1);
1746
1747 /* if only the accel can be edited on the selected row
1748 * always select the accel column */
1749 if (key->desc_editable &&
1750 column == gtk_tree_view_get_column (tree_view, 0))
1751 {
1752 gtk_widget_grab_focus (GTK_WIDGET (tree_view)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tree_view)), ((gtk_widget_get_type ()))))))
);
1753 gtk_tree_view_set_cursor (tree_view, path,
1754 gtk_tree_view_get_column (tree_view, 0),
1755 FALSE(0));
1756 update_custom_shortcut (model, &iter);
1757 }
1758 else
1759 {
1760 idle_data = g_new (IdleData, 1)((IdleData *) g_malloc_n ((1), sizeof (IdleData)));
1761 idle_data->tree_view = tree_view;
1762 idle_data->path = path;
1763 idle_data->column = key->desc_editable ? column :
1764 gtk_tree_view_get_column (tree_view, 1);
1765 g_idle_add ((GSourceFunc) real_start_editing_cb, idle_data);
1766 block_accels = TRUE(!(0));
1767 }
1768 g_signal_stop_emission_by_name (tree_view, "button_press_event");
1769 }
1770 return TRUE(!(0));
1771}
1772
1773/* this handler is used to keep accels from activating while the user
1774 * is assigning a new shortcut so that he won't accidentally trigger one
1775 * of the widgets */
1776static gboolean maybe_block_accels(GtkWidget* widget, GdkEventKey* event, gpointer user_data)
1777{
1778 if (block_accels)
1779 {
1780 return gtk_window_propagate_key_event(GTK_WINDOW(widget)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_window_get_type ()))))))
, event);
1781 }
1782
1783 return FALSE(0);
1784}
1785
1786static void
1787cb_dialog_response (GtkWidget *widget, gint response_id, gpointer data)
1788{
1789 GtkBuilder *builder = data;
1790 GtkTreeView *treeview;
1791 GtkTreeModel *model;
1792 GtkTreeSelection *selection;
1793 GtkTreeIter iter;
1794
1795 treeview = GTK_TREE_VIEW (gtk_builder_get_object (builder,((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, "shortcut_treeview"))),
((gtk_tree_view_get_type ()))))))
1796 "shortcut_treeview"))((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, "shortcut_treeview"))),
((gtk_tree_view_get_type ()))))))
;
1797 model = gtk_tree_view_get_model (treeview);
1798
1799 if (response_id == GTK_RESPONSE_HELP)
1
Assuming 'response_id' is not equal to GTK_RESPONSE_HELP
2
Taking false branch
1800 {
1801 capplet_help (GTK_WINDOW (widget)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_window_get_type ()))))))
,
1802 "goscustdesk-39");
1803 }
1804 else if (response_id == RESPONSE_ADD0)
3
Assuming 'response_id' is equal to RESPONSE_ADD
4
Taking true branch
1805 {
1806 add_custom_shortcut (treeview, model);
5
Calling 'add_custom_shortcut'
1807 }
1808 else if (response_id == RESPONSE_REMOVE1)
1809 {
1810 selection = gtk_tree_view_get_selection (treeview);
1811 if (gtk_tree_selection_get_selected (selection, NULL((void*)0), &iter))
1812 {
1813 remove_custom_shortcut (model, &iter);
1814 }
1815 }
1816 else
1817 {
1818 clear_old_model (builder);
1819 gtk_main_quit ();
1820 }
1821}
1822
1823static void
1824selection_changed (GtkTreeSelection *selection, gpointer data)
1825{
1826 GtkWidget *button = data;
1827 GtkTreeModel *model;
1828 GtkTreeIter iter;
1829 KeyEntry *key;
1830 gboolean can_remove;
1831
1832 can_remove = FALSE(0);
1833 if (gtk_tree_selection_get_selected (selection, &model, &iter))
1834 {
1835 gtk_tree_model_get (model, &iter, KEYENTRY_COLUMN, &key, -1);
1836 if (key && key->command != NULL((void*)0) && key->editable)
1837 can_remove = TRUE(!(0));
1838 }
1839
1840 gtk_widget_set_sensitive (button, can_remove);
1841}
1842
1843static void
1844cb_app_dialog_response (GtkWidget *dialog, gint response_id, gpointer data)
1845{
1846 if (response_id == GTK_RESPONSE_OK)
1847 {
1848 GAppInfo *info;
1849 const gchar *custom_name;
1850
1851 info = gtk_app_chooser_get_app_info (GTK_APP_CHOOSER (dialog)((((GtkAppChooser*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_app_chooser_get_type ()))))))
);
1852
1853 gtk_entry_set_text (GTK_ENTRY (custom_shortcut_command_entry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((custom_shortcut_command_entry)), ((gtk_entry_get_type ()
))))))
,
1854 g_app_info_get_executable (info));
1855 /* if name isn't set yet, use the associated one */
1856 custom_name = gtk_entry_get_text (GTK_ENTRY (custom_shortcut_name_entry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((custom_shortcut_name_entry)), ((gtk_entry_get_type ())))
)))
);
1857 if (! custom_name || custom_name[0] == '\0')
1858 gtk_entry_set_text (GTK_ENTRY (custom_shortcut_name_entry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((custom_shortcut_name_entry)), ((gtk_entry_get_type ())))
)))
,
1859 g_app_info_get_display_name (info));
1860
1861 g_object_unref (info);
1862 }
1863
1864 gtk_widget_hide (dialog);
1865}
1866
1867static void
1868setup_dialog (GtkBuilder *builder, GSettings *marco_settings)
1869{
1870 GtkCellRenderer *renderer;
1871 GtkTreeViewColumn *column;
1872 GtkWidget *widget;
1873 GtkTreeView *treeview;
1874 GtkTreeSelection *selection;
1875 GtkWidget *button;
1876
1877 treeview = GTK_TREE_VIEW (gtk_builder_get_object (builder,((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, "shortcut_treeview"))),
((gtk_tree_view_get_type ()))))))
1878 "shortcut_treeview"))((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, "shortcut_treeview"))),
((gtk_tree_view_get_type ()))))))
;
1879
1880 g_signal_connect (treeview, "button_press_event",g_signal_connect_data ((treeview), ("button_press_event"), ((
(GCallback) (start_editing_cb))), (builder), ((void*)0), (GConnectFlags
) 0)
1881 G_CALLBACK (start_editing_cb), builder)g_signal_connect_data ((treeview), ("button_press_event"), ((
(GCallback) (start_editing_cb))), (builder), ((void*)0), (GConnectFlags
) 0)
;
1882 g_signal_connect (treeview, "row-activated",g_signal_connect_data ((treeview), ("row-activated"), (((GCallback
) (start_editing_kb_cb))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
1883 G_CALLBACK (start_editing_kb_cb), NULL)g_signal_connect_data ((treeview), ("row-activated"), (((GCallback
) (start_editing_kb_cb))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
;
1884
1885 renderer = gtk_cell_renderer_text_new ();
1886
1887 g_signal_connect (renderer, "edited",g_signal_connect_data ((renderer), ("edited"), (((GCallback) (
description_edited_callback))), (treeview), ((void*)0), (GConnectFlags
) 0)
1888 G_CALLBACK (description_edited_callback),g_signal_connect_data ((renderer), ("edited"), (((GCallback) (
description_edited_callback))), (treeview), ((void*)0), (GConnectFlags
) 0)
1889 treeview)g_signal_connect_data ((renderer), ("edited"), (((GCallback) (
description_edited_callback))), (treeview), ((void*)0), (GConnectFlags
) 0)
;
1890
1891 column = gtk_tree_view_column_new_with_attributes (_("Action")gettext ("Action"),
1892 renderer,
1893 "text", DESCRIPTION_COLUMN,
1894 NULL((void*)0));
1895 gtk_tree_view_column_set_cell_data_func (column, renderer, description_set_func, NULL((void*)0), NULL((void*)0));
1896 gtk_tree_view_column_set_resizable (column, FALSE(0));
1897
1898 gtk_tree_view_append_column (treeview, column);
1899 gtk_tree_view_column_set_sort_column_id (column, DESCRIPTION_COLUMN);
1900
1901 renderer = (GtkCellRenderer *) g_object_new (EGG_TYPE_CELL_RENDERER_KEYS(egg_cell_renderer_keys_get_type ()),
1902 "accel_mode", EGG_CELL_RENDERER_KEYS_MODE_X,
1903 NULL((void*)0));
1904
1905 g_signal_connect (renderer, "accel_edited",g_signal_connect_data ((renderer), ("accel_edited"), (((GCallback
) (accel_edited_callback))), (treeview), ((void*)0), (GConnectFlags
) 0)
1906 G_CALLBACK (accel_edited_callback),g_signal_connect_data ((renderer), ("accel_edited"), (((GCallback
) (accel_edited_callback))), (treeview), ((void*)0), (GConnectFlags
) 0)
1907 treeview)g_signal_connect_data ((renderer), ("accel_edited"), (((GCallback
) (accel_edited_callback))), (treeview), ((void*)0), (GConnectFlags
) 0)
;
1908
1909 g_signal_connect (renderer, "accel_cleared",g_signal_connect_data ((renderer), ("accel_cleared"), (((GCallback
) (accel_cleared_callback))), (treeview), ((void*)0), (GConnectFlags
) 0)
1910 G_CALLBACK (accel_cleared_callback),g_signal_connect_data ((renderer), ("accel_cleared"), (((GCallback
) (accel_cleared_callback))), (treeview), ((void*)0), (GConnectFlags
) 0)
1911 treeview)g_signal_connect_data ((renderer), ("accel_cleared"), (((GCallback
) (accel_cleared_callback))), (treeview), ((void*)0), (GConnectFlags
) 0)
;
1912
1913 column = gtk_tree_view_column_new_with_attributes (_("Shortcut")gettext ("Shortcut"), renderer, NULL((void*)0));
1914 gtk_tree_view_column_set_cell_data_func (column, renderer, accel_set_func, NULL((void*)0), NULL((void*)0));
1915 gtk_tree_view_column_set_resizable (column, FALSE(0));
1916
1917 gtk_tree_view_append_column (treeview, column);
1918 gtk_tree_view_column_set_sort_column_id (column, KEYENTRY_COLUMN);
1919
1920 g_signal_connect (marco_settings,g_signal_connect_data ((marco_settings), ("changed::num-workspaces"
), (((GCallback) (key_entry_controlling_key_changed))), (builder
), ((void*)0), (GConnectFlags) 0)
1921 "changed::num-workspaces",g_signal_connect_data ((marco_settings), ("changed::num-workspaces"
), (((GCallback) (key_entry_controlling_key_changed))), (builder
), ((void*)0), (GConnectFlags) 0)
1922 G_CALLBACK (key_entry_controlling_key_changed),g_signal_connect_data ((marco_settings), ("changed::num-workspaces"
), (((GCallback) (key_entry_controlling_key_changed))), (builder
), ((void*)0), (GConnectFlags) 0)
1923 builder)g_signal_connect_data ((marco_settings), ("changed::num-workspaces"
), (((GCallback) (key_entry_controlling_key_changed))), (builder
), ((void*)0), (GConnectFlags) 0)
;
1924
1925 /* set up the dialog */
1926 reload_key_entries (builder);
1927
1928 widget = _gtk_builder_get_widget (builder, "mate-keybinding-dialog");
1929 gtk_window_set_default_size (GTK_WINDOW (widget)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_window_get_type ()))))))
, 400, 500);
1930 widget = _gtk_builder_get_widget (builder, "label-suggest");
1931 gtk_label_set_line_wrap (GTK_LABEL (widget)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_label_get_type ()))))))
, TRUE(!(0)));
1932 gtk_label_set_max_width_chars (GTK_LABEL (widget)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_label_get_type ()))))))
, 60);
1933
1934 widget = _gtk_builder_get_widget (builder, "mate-keybinding-dialog");
1935 capplet_set_icon (widget, "preferences-desktop-keyboard-shortcuts");
1936 gtk_widget_show (widget);
1937
1938 g_signal_connect (widget, "key_press_event", G_CALLBACK (maybe_block_accels), NULL)g_signal_connect_data ((widget), ("key_press_event"), (((GCallback
) (maybe_block_accels))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
;
1939 g_signal_connect (widget, "response", G_CALLBACK (cb_dialog_response), builder)g_signal_connect_data ((widget), ("response"), (((GCallback) (
cb_dialog_response))), (builder), ((void*)0), (GConnectFlags)
0)
;
1940
1941 selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((treeview)), ((gtk_tree_view_get_type ()))))))
);
1942 g_signal_connect (selection, "changed",g_signal_connect_data ((selection), ("changed"), (((GCallback
) (selection_changed))), (_gtk_builder_get_widget (builder, "remove-button"
)), ((void*)0), (GConnectFlags) 0)
1943 G_CALLBACK (selection_changed),g_signal_connect_data ((selection), ("changed"), (((GCallback
) (selection_changed))), (_gtk_builder_get_widget (builder, "remove-button"
)), ((void*)0), (GConnectFlags) 0)
1944 _gtk_builder_get_widget (builder, "remove-button"))g_signal_connect_data ((selection), ("changed"), (((GCallback
) (selection_changed))), (_gtk_builder_get_widget (builder, "remove-button"
)), ((void*)0), (GConnectFlags) 0)
;
1945
1946 /* setup the custom shortcut dialog */
1947 custom_shortcut_dialog = _gtk_builder_get_widget (builder,
1948 "custom-shortcut-dialog");
1949 custom_shortcut_name_entry = _gtk_builder_get_widget (builder,
1950 "custom-shortcut-name-entry");
1951 custom_shortcut_command_entry = _gtk_builder_get_widget (builder,
1952 "custom-shortcut-command-entry");
1953 gtk_dialog_set_default_response (GTK_DIALOG (custom_shortcut_dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((custom_shortcut_dialog)), ((gtk_dialog_get_type ()))))))
,
1954 GTK_RESPONSE_OK);
1955 gtk_window_set_transient_for (GTK_WINDOW (custom_shortcut_dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((custom_shortcut_dialog)), ((gtk_window_get_type ()))))))
,
1956 GTK_WINDOW (widget)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_window_get_type ()))))))
);
1957 button = _gtk_builder_get_widget (builder, "custom-shortcut-command-button");
1958 widget = _gtk_builder_get_widget (builder, "custom-shortcut-application-dialog");
1959 g_signal_connect_swapped (button, "clicked", G_CALLBACK (gtk_dialog_run), widget)g_signal_connect_data ((button), ("clicked"), (((GCallback) (
gtk_dialog_run))), (widget), ((void*)0), G_CONNECT_SWAPPED)
;
1960 g_signal_connect (widget, "response", G_CALLBACK (cb_app_dialog_response), NULL)g_signal_connect_data ((widget), ("response"), (((GCallback) (
cb_app_dialog_response))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
;
1961 widget = gtk_app_chooser_dialog_get_widget (GTK_APP_CHOOSER_DIALOG (widget)((((GtkAppChooserDialog*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((widget)), ((gtk_app_chooser_dialog_get_type
()))))))
);
1962 gtk_app_chooser_widget_set_show_all (GTK_APP_CHOOSER_WIDGET (widget)((((GtkAppChooserWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((widget)), ((gtk_app_chooser_widget_get_type
()))))))
, TRUE(!(0)));
1963}
1964
1965static void
1966on_window_manager_change (const char *wm_name, GtkBuilder *builder)
1967{
1968 reload_key_entries (builder);
1969}
1970
1971int
1972main (int argc, char *argv[])
1973{
1974 GtkBuilder *builder;
1975 GSettings *marco_settings;
1976
1977 capplet_init (NULL((void*)0), &argc, &argv);
1978
1979 activate_settings_daemon ();
1980
1981 builder = gtk_builder_new_from_resource ("/org/mate/mcc/keybindings/mate-keybinding-properties.ui");
1982
1983 wm_common_register_window_manager_change ((GFunc) on_window_manager_change, builder);
1984
1985 marco_settings = g_settings_new ("org.mate.Marco.general");
1986
1987 setup_dialog (builder, marco_settings);
1988
1989 gtk_main ();
1990
1991 g_object_unref (marco_settings);
1992 g_object_unref (builder);
1993 return 0;
1994}
1995
1996/*
1997 * vim: sw=2 ts=8 cindent noai bs=2
1998 */
diff --git a/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-db9c1a.html b/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-db9c1a.html new file mode 100644 index 00000000..435065ae --- /dev/null +++ b/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-db9c1a.html @@ -0,0 +1,2678 @@ + + + +mate-keybinding-properties.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:capplets/keybindings/mate-keybinding-properties.c
Warning:line 918, column 18
Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name mate-keybinding-properties.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/capplets/keybindings -fcoverage-compilation-dir=/rootdir/capplets/keybindings -resource-dir /usr/bin/../lib/clang/18 -D HAVE_CONFIG_H -I . -I ../.. -I ../../capplets/common -I /usr/include/udisks2 -I /usr/include/libgtop-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/libxml2 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/gio-unix-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/dconf -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I ../../ -D G_LOG_DOMAIN="keybinding-properties" -I /usr/include/polkit-1 -I /usr/include/gio-unix-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -D MATECC_DATA_DIR="/usr/local/share/mate-control-center" -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-06-07-044335-13427-1 -x c mate-keybinding-properties.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* This program was written with lots of love under the GPL by Jonathan
2 * Blandford <jrb@gnome.org>
3 */
4
5#include <config.h>
6
7#include <stdlib.h>
8#include <string.h>
9#include <gtk/gtk.h>
10#include <gio/gio.h>
11#include <gdk/gdkx.h>
12#include <X11/Xatom.h>
13#include <glib/gi18n.h>
14#include <gdk/gdkkeysyms.h>
15
16#include "wm-common.h"
17#include "capplet-util.h"
18#include "eggcellrendererkeys.h"
19#include "activate-settings-daemon.h"
20#include "dconf-util.h"
21
22#define GSETTINGS_KEYBINDINGS_DIR"/org/mate/desktop/keybindings/" "/org/mate/desktop/keybindings/"
23#define CUSTOM_KEYBINDING_SCHEMA"org.mate.control-center.keybinding" "org.mate.control-center.keybinding"
24
25#define MAX_ELEMENTS_BEFORE_SCROLLING10 10
26#define MAX_CUSTOM_SHORTCUTS1000 1000
27#define RESPONSE_ADD0 0
28#define RESPONSE_REMOVE1 1
29
30typedef struct {
31 /* The untranslated name, combine with ->package to translate */
32 char *name;
33 /* The gettext package to use to translate the section title */
34 char *package;
35 /* Name of the window manager the keys would apply to */
36 char *wm_name;
37 /* The GSettings schema for the whole file */
38 char *schema;
39 /* an array of KeyListEntry */
40 GArray *entries;
41} KeyList;
42
43typedef enum {
44 COMPARISON_NONE = 0,
45 COMPARISON_GT,
46 COMPARISON_LT,
47 COMPARISON_EQ
48} Comparison;
49
50typedef struct
51{
52 char *gsettings_path;
53 char *schema;
54 char *name;
55 int value;
56 char *value_schema; /* gsettings schema for key/value */
57 char *value_key;
58 char *description;
59 char *description_key;
60 char *cmd_key;
61 Comparison comparison;
62} KeyListEntry;
63
64enum
65{
66 DESCRIPTION_COLUMN,
67 KEYENTRY_COLUMN,
68 N_COLUMNS
69};
70
71typedef struct
72{
73 GSettings *settings;
74 char *gsettings_path;
75 char *gsettings_key;
76 guint keyval;
77 guint keycode;
78 EggVirtualModifierType mask;
79 gboolean editable;
80 GtkTreeModel *model;
81 char *description;
82 char *desc_gsettings_key;
83 gboolean desc_editable;
84 char *command;
85 char *cmd_gsettings_key;
86 gboolean cmd_editable;
87 gulong gsettings_cnxn;
88 gulong gsettings_cnxn_desc;
89 gulong gsettings_cnxn_cmd;
90} KeyEntry;
91
92static gboolean block_accels = FALSE(0);
93static GtkWidget *custom_shortcut_dialog = NULL((void*)0);
94static GtkWidget *custom_shortcut_name_entry = NULL((void*)0);
95static GtkWidget *custom_shortcut_command_entry = NULL((void*)0);
96
97static GtkWidget* _gtk_builder_get_widget(GtkBuilder* builder, const gchar* name)
98{
99 return GTK_WIDGET (gtk_builder_get_object (builder, name))((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, name))), ((gtk_widget_get_type
()))))))
;
100}
101
102static char* binding_name(guint keyval, guint keycode, EggVirtualModifierType mask, gboolean translate)
103{
104 if (keyval != 0 || keycode != 0)
105 {
106 if (translate)
107 {
108 return egg_virtual_accelerator_label (keyval, keycode, mask);
109 }
110 else
111 {
112 return egg_virtual_accelerator_name (keyval, keycode, mask);
113 }
114 }
115 else
116 {
117 return g_strdup (translate ? _("Disabled") : "")g_strdup_inline (translate ? gettext ("Disabled") : "");
118 }
119}
120
121static gboolean
122binding_from_string (const char *str,
123 guint *accelerator_key,
124 guint *keycode,
125 EggVirtualModifierType *accelerator_mods)
126{
127 g_return_val_if_fail (accelerator_key != NULL, FALSE)do { if ((accelerator_key != ((void*)0))) { } else { g_return_if_fail_warning
("keybinding-properties", ((const char*) (__func__)), "accelerator_key != NULL"
); return ((0)); } } while (0)
;
128
129 if (str == NULL((void*)0) || strcmp (str, "disabled") == 0)
130 {
131 *accelerator_key = 0;
132 *keycode = 0;
133 *accelerator_mods = 0;
134 return TRUE(!(0));
135 }
136
137 egg_accelerator_parse_virtual (str, accelerator_key, keycode, accelerator_mods);
138
139 if (*accelerator_key == 0)
140 return FALSE(0);
141 else
142 return TRUE(!(0));
143}
144
145static void
146accel_set_func (GtkTreeViewColumn *tree_column,
147 GtkCellRenderer *cell,
148 GtkTreeModel *model,
149 GtkTreeIter *iter,
150 gpointer data)
151{
152 KeyEntry *key_entry;
153
154 gtk_tree_model_get (model, iter,
155 KEYENTRY_COLUMN, &key_entry,
156 -1);
157
158 if (key_entry == NULL((void*)0))
159 g_object_set (cell,
160 "visible", FALSE(0),
161 NULL((void*)0));
162 else if (! key_entry->editable)
163 g_object_set (cell,
164 "visible", TRUE(!(0)),
165 "editable", FALSE(0),
166 "accel_key", key_entry->keyval,
167 "accel_mask", key_entry->mask,
168 "keycode", key_entry->keycode,
169 "style", PANGO_STYLE_ITALIC,
170 NULL((void*)0));
171 else
172 g_object_set (cell,
173 "visible", TRUE(!(0)),
174 "editable", TRUE(!(0)),
175 "accel_key", key_entry->keyval,
176 "accel_mask", key_entry->mask,
177 "keycode", key_entry->keycode,
178 "style", PANGO_STYLE_NORMAL,
179 NULL((void*)0));
180}
181
182static void
183description_set_func (GtkTreeViewColumn *tree_column,
184 GtkCellRenderer *cell,
185 GtkTreeModel *model,
186 GtkTreeIter *iter,
187 gpointer data)
188{
189 KeyEntry *key_entry;
190
191 gtk_tree_model_get (model, iter,
192 KEYENTRY_COLUMN, &key_entry,
193 -1);
194
195 if (key_entry != NULL((void*)0))
196 g_object_set (cell,
197 "editable", FALSE(0),
198 "text", key_entry->description != NULL((void*)0) ?
199 key_entry->description : _("<Unknown Action>")gettext ("<Unknown Action>"),
200 NULL((void*)0));
201 else
202 g_object_set (cell,
203 "editable", FALSE(0), NULL((void*)0));
204}
205
206static gboolean
207keybinding_key_changed_foreach (GtkTreeModel *model,
208 GtkTreePath *path,
209 GtkTreeIter *iter,
210 gpointer user_data)
211{
212 KeyEntry *key_entry;
213 KeyEntry *tmp_key_entry;
214
215 key_entry = (KeyEntry *)user_data;
216 gtk_tree_model_get (key_entry->model, iter,
217 KEYENTRY_COLUMN, &tmp_key_entry,
218 -1);
219
220 if (key_entry == tmp_key_entry)
221 {
222 gtk_tree_model_row_changed (key_entry->model, path, iter);
223 return TRUE(!(0));
224 }
225 return FALSE(0);
226}
227
228static void
229keybinding_key_changed (GSettings *settings,
230 gchar *key,
231 KeyEntry *key_entry)
232{
233 gchar *key_value;
234
235 key_value = g_settings_get_string (settings, key);
236
237 binding_from_string (key_value, &key_entry->keyval, &key_entry->keycode, &key_entry->mask);
238 key_entry->editable = g_settings_is_writable (settings, key);
239
240 /* update the model */
241 gtk_tree_model_foreach (key_entry->model, keybinding_key_changed_foreach, key_entry);
242}
243
244static void
245keybinding_description_changed (GSettings *settings,
246 gchar *key,
247 KeyEntry *key_entry)
248{
249 gchar *key_value;
250
251 key_value = g_settings_get_string (settings, key);
252
253 g_free (key_entry->description);
254 key_entry->description = key_value ? g_strdup (key_value)g_strdup_inline (key_value) : NULL((void*)0);
255 g_free (key_value);
256
257 key_entry->desc_editable = g_settings_is_writable (settings, key);
258
259 /* update the model */
260 gtk_tree_model_foreach (key_entry->model, keybinding_key_changed_foreach, key_entry);
261}
262
263static void
264keybinding_command_changed (GSettings *settings,
265 gchar *key,
266 KeyEntry *key_entry)
267{
268 gchar *key_value;
269
270 key_value = g_settings_get_string (settings, key);
271
272 g_free (key_entry->command);
273 key_entry->command = key_value ? g_strdup (key_value)g_strdup_inline (key_value) : NULL((void*)0);
274 key_entry->cmd_editable = g_settings_is_writable (settings, key);
275 g_free (key_value);
276
277 /* update the model */
278 gtk_tree_model_foreach (key_entry->model, keybinding_key_changed_foreach, key_entry);
279}
280
281static int
282keyentry_sort_func (GtkTreeModel *model,
283 GtkTreeIter *a,
284 GtkTreeIter *b,
285 gpointer user_data)
286{
287 KeyEntry *key_entry_a;
288 KeyEntry *key_entry_b;
289 int retval;
290
291 key_entry_a = NULL((void*)0);
292 gtk_tree_model_get (model, a,
293 KEYENTRY_COLUMN, &key_entry_a,
294 -1);
295
296 key_entry_b = NULL((void*)0);
297 gtk_tree_model_get (model, b,
298 KEYENTRY_COLUMN, &key_entry_b,
299 -1);
300
301 if (key_entry_a && key_entry_b)
302 {
303 if ((key_entry_a->keyval || key_entry_a->keycode) &&
304 (key_entry_b->keyval || key_entry_b->keycode))
305 {
306 gchar *name_a, *name_b;
307
308 name_a = binding_name (key_entry_a->keyval,
309 key_entry_a->keycode,
310 key_entry_a->mask,
311 TRUE(!(0)));
312
313 name_b = binding_name (key_entry_b->keyval,
314 key_entry_b->keycode,
315 key_entry_b->mask,
316 TRUE(!(0)));
317
318 retval = g_utf8_collate (name_a, name_b);
319
320 g_free (name_a);
321 g_free (name_b);
322 }
323 else if (key_entry_a->keyval || key_entry_a->keycode)
324 retval = -1;
325 else if (key_entry_b->keyval || key_entry_b->keycode)
326 retval = 1;
327 else
328 retval = 0;
329 }
330 else if (key_entry_a)
331 retval = -1;
332 else if (key_entry_b)
333 retval = 1;
334 else
335 retval = 0;
336
337 return retval;
338}
339
340static void
341clear_old_model (GtkBuilder *builder)
342{
343 GtkWidget *tree_view;
344 GtkWidget *actions_swindow;
345 GtkTreeModel *model;
346
347 tree_view = _gtk_builder_get_widget (builder, "shortcut_treeview");
348 model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tree_view)), ((gtk_tree_view_get_type ()))))))
);
349
350 if (model == NULL((void*)0))
351 {
352 /* create a new model */
353 model = (GtkTreeModel *) gtk_tree_store_new (N_COLUMNS, G_TYPE_STRING((GType) ((16) << (2))), G_TYPE_POINTER((GType) ((17) << (2))));
354
355 gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (model)((((GtkTreeSortable*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_sortable_get_type ()))))))
,
356 KEYENTRY_COLUMN,
357 keyentry_sort_func,
358 NULL((void*)0), NULL((void*)0));
359
360 gtk_tree_view_set_model (GTK_TREE_VIEW (tree_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tree_view)), ((gtk_tree_view_get_type ()))))))
, model);
361
362 g_object_unref (model);
363 }
364 else
365 {
366 /* clear the existing model */
367 gboolean valid;
368 GtkTreeIter iter;
369 KeyEntry *key_entry;
370
371 for (valid = gtk_tree_model_get_iter_first (model, &iter);
372 valid;
373 valid = gtk_tree_model_iter_next (model, &iter))
374 {
375 gtk_tree_model_get (model, &iter,
376 KEYENTRY_COLUMN, &key_entry,
377 -1);
378
379 if (key_entry != NULL((void*)0))
380 {
381 g_signal_handler_disconnect (key_entry->settings, key_entry->gsettings_cnxn);
382 if (key_entry->gsettings_cnxn_desc != 0)
383 g_signal_handler_disconnect (key_entry->settings, key_entry->gsettings_cnxn_desc);
384 if (key_entry->gsettings_cnxn_cmd != 0)
385 g_signal_handler_disconnect (key_entry->settings, key_entry->gsettings_cnxn_cmd);
386
387 g_object_unref (key_entry->settings);
388 if (key_entry->gsettings_path)
389 g_free (key_entry->gsettings_path);
390 g_free (key_entry->gsettings_key);
391 g_free (key_entry->description);
392 g_free (key_entry->desc_gsettings_key);
393 g_free (key_entry->command);
394 g_free (key_entry->cmd_gsettings_key);
395 g_free (key_entry);
396 }
397 }
398
399 gtk_tree_store_clear (GTK_TREE_STORE (model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
);
400 }
401
402 actions_swindow = _gtk_builder_get_widget (builder, "actions_swindow");
403 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (actions_swindow)((((GtkScrolledWindow*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((actions_swindow)), ((gtk_scrolled_window_get_type
()))))))
,
404 GTK_POLICY_NEVER, GTK_POLICY_NEVER);
405 gtk_widget_set_size_request (actions_swindow, -1, -1);
406}
407
408typedef struct {
409 const char *key;
410 const char *path;
411 const char *schema;
412 gboolean found;
413} KeyMatchData;
414
415static gboolean
416key_match (GtkTreeModel *model,
417 GtkTreePath *path,
418 GtkTreeIter *iter,
419 gpointer data)
420{
421 KeyMatchData *match_data = data;
422 KeyEntry *element;
423 gchar *element_schema = NULL((void*)0);
424 gchar *element_path = NULL((void*)0);
425 gboolean found = FALSE(0);
426
427 gtk_tree_model_get (model, iter,
428 KEYENTRY_COLUMN, &element,
429 -1);
430
431 if (!element)
432 return FALSE(0);
433
434 if (!element->settings || !G_IS_SETTINGS (element->settings)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(element->settings)); GType __t = ((g_settings_get_type ()
)); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
)
435 return FALSE(0);
436
437 g_object_get (element->settings, "schema-id", &element_schema, NULL((void*)0));
438 g_object_get (element->settings, "path", &element_path, NULL((void*)0));
439
440 if ((g_strcmp0 (element->gsettings_key, match_data->key) == 0) &&
441 (g_strcmp0 (element_schema, match_data->schema) == 0) &&
442 (g_strcmp0 (element_path, match_data->path) == 0))
443 {
444 match_data->found = TRUE(!(0));
445 found = TRUE(!(0));
446 }
447
448 g_free (element_schema);
449 g_free (element_path);
450
451 return found;
452}
453
454static gboolean key_is_already_shown(GtkTreeModel* model, const KeyListEntry* entry)
455{
456 KeyMatchData data;
457
458 data.key = entry->name;
459 data.schema = entry->schema;
460 data.path = entry->gsettings_path;
461 data.found = FALSE(0);
462 gtk_tree_model_foreach(model, key_match, &data);
463
464 return data.found;
465}
466
467static gboolean should_show_key(const KeyListEntry* entry)
468{
469 GSettings *settings;
470 int value;
471
472 if (entry->comparison == COMPARISON_NONE)
473 {
474 return TRUE(!(0));
475 }
476
477 g_return_val_if_fail(entry->value_key != NULL, FALSE)do { if ((entry->value_key != ((void*)0))) { } else { g_return_if_fail_warning
("keybinding-properties", ((const char*) (__func__)), "entry->value_key != NULL"
); return ((0)); } } while (0)
;
478 g_return_val_if_fail(entry->value_schema != NULL, FALSE)do { if ((entry->value_schema != ((void*)0))) { } else { g_return_if_fail_warning
("keybinding-properties", ((const char*) (__func__)), "entry->value_schema != NULL"
); return ((0)); } } while (0)
;
479
480 settings = g_settings_new (entry->value_schema);
481 value = g_settings_get_int (settings, entry->value_key);
482 g_object_unref (settings);
483
484 switch (entry->comparison)
485 {
486 case COMPARISON_NONE:
487 /* For compiler warnings */
488 g_assert_not_reached ()do { g_assertion_message_expr ("keybinding-properties", "mate-keybinding-properties.c"
, 488, ((const char*) (__func__)), ((void*)0)); } while (0)
;
489 return FALSE(0);
490 case COMPARISON_GT:
491 if (value > entry->value)
492 {
493 return TRUE(!(0));
494 }
495 break;
496 case COMPARISON_LT:
497 if (value < entry->value)
498 {
499 return TRUE(!(0));
500 }
501 break;
502 case COMPARISON_EQ:
503 if (value == entry->value)
504 {
505 return TRUE(!(0));
506 }
507 break;
508 }
509
510 return FALSE(0);
511}
512
513static gboolean
514count_rows_foreach (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
515{
516 gint *rows = data;
517
518 (*rows)++;
519
520 return FALSE(0);
521}
522
523static void
524ensure_scrollbar (GtkBuilder *builder, int i)
525{
526 if (i == MAX_ELEMENTS_BEFORE_SCROLLING10)
527 {
528 GtkRequisition rectangle;
529 GObject *actions_swindow = gtk_builder_get_object (builder,
530 "actions_swindow");
531 GtkWidget *treeview = _gtk_builder_get_widget (builder,
532 "shortcut_treeview");
533 gtk_widget_get_preferred_size (treeview, &rectangle, NULL((void*)0));
534 gtk_widget_set_size_request (treeview, -1, rectangle.height);
535 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (actions_swindow)((((GtkScrolledWindow*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((actions_swindow)), ((gtk_scrolled_window_get_type
()))))))
,
536 GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
537 }
538}
539
540static void
541find_section (GtkTreeModel *model,
542 GtkTreeIter *iter,
543 const char *title)
544{
545 GtkTreeStore *store;
546 gboolean success;
547
548 success = gtk_tree_model_get_iter_first (model, iter);
549 while (success)
550 {
551 char *description;
552 gint res;
553
554 gtk_tree_model_get (model, iter,
555 DESCRIPTION_COLUMN, &description,
556 -1);
557 res = g_strcmp0 (description, title);
558 g_free (description);
559 if (res == 0)
560 return;
561 success = gtk_tree_model_iter_next (model, iter);
562 }
563 store = GTK_TREE_STORE (model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
;
564 gtk_tree_store_append (store, iter, NULL((void*)0));
565 gtk_tree_store_set (store, iter,
566 DESCRIPTION_COLUMN, title,
567 -1);
568}
569
570static void
571append_keys_to_tree (GtkBuilder *builder,
572 const gchar *title,
573 const gchar *schema,
574 const gchar *package,
575 const KeyListEntry *keys_list)
576{
577 GtkTreeIter parent_iter, iter;
578 GtkTreeModel *model;
579 gint i, j;
580
581 model = gtk_tree_view_get_model (GTK_TREE_VIEW (gtk_builder_get_object (builder, "shortcut_treeview"))((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, "shortcut_treeview"))),
((gtk_tree_view_get_type ()))))))
);
582
583 /* Try to find a section parent iter, if it already exists */
584 find_section (model, &iter, title);
585 parent_iter = iter;
586
587 i = 0;
588 gtk_tree_model_foreach (model, count_rows_foreach, &i);
589
590 /* If the header we just added is the MAX_ELEMENTS_BEFORE_SCROLLING th,
591 * then we need to scroll now */
592 ensure_scrollbar (builder, i - 1);
593
594 for (j = 0; keys_list[j].name != NULL((void*)0); j++)
595 {
596 GSettings *settings = NULL((void*)0);
597 gchar *settings_path;
598 KeyEntry *key_entry;
599 const gchar *key_string;
600 gchar *key_value;
601 gchar *description;
602 gchar *command;
603
604 if (!should_show_key (&keys_list[j]))
605 continue;
606
607 if (key_is_already_shown (model, &keys_list[j]))
608 continue;
609
610 key_string = keys_list[j].name;
611
612 if (keys_list[j].gsettings_path != NULL((void*)0))
613 {
614 settings = g_settings_new_with_path (schema, keys_list[j].gsettings_path);
615 settings_path = g_strdup(keys_list[j].gsettings_path)g_strdup_inline (keys_list[j].gsettings_path);
616 }
617 else
618 {
619 settings = g_settings_new (schema);
620 settings_path = NULL((void*)0);
621 }
622
623 if (keys_list[j].description_key != NULL((void*)0))
624 {
625 /* it's a custom shortcut, so description is in gsettings */
626 description = g_settings_get_string (settings, keys_list[j].description_key);
627 }
628 else
629 {
630 /* it's from keyfile, so description need to be translated */
631 description = keys_list[j].description;
632 if (package)
633 {
634 bind_textdomain_codeset (package, "UTF-8");
635 description = dgettext (package, description);
636 }
637 else
638 {
639 description = _(description)gettext (description);
640 }
641 }
642
643 if (description == NULL((void*)0))
644 {
645 /* Only print a warning for keys that should have a schema */
646 if (keys_list[j].description_key == NULL((void*)0))
647 g_warning ("No description for key '%s'", key_string);
648 }
649
650 if (keys_list[j].cmd_key != NULL((void*)0))
651 {
652 command = g_settings_get_string (settings, keys_list[j].cmd_key);
653 }
654 else
655 {
656 command = NULL((void*)0);
657 }
658
659 key_entry = g_new0 (KeyEntry, 1)((KeyEntry *) g_malloc0_n ((1), sizeof (KeyEntry)));
660 key_entry->settings = settings;
661 key_entry->gsettings_path = settings_path;
662 key_entry->gsettings_key = g_strdup (key_string)g_strdup_inline (key_string);
663 key_entry->editable = g_settings_is_writable (settings, key_string);
664 key_entry->model = model;
665 key_entry->description = description;
666 key_entry->command = command;
667 if (keys_list[j].description_key != NULL((void*)0))
668 {
669 key_entry->desc_gsettings_key = g_strdup (keys_list[j].description_key)g_strdup_inline (keys_list[j].description_key);
670 key_entry->desc_editable = g_settings_is_writable (settings, key_entry->desc_gsettings_key);
671 gchar *gsettings_signal = g_strconcat ("changed::", key_entry->desc_gsettings_key, NULL((void*)0));
672 key_entry->gsettings_cnxn_desc = g_signal_connect (settings,g_signal_connect_data ((settings), (gsettings_signal), (((GCallback
) (keybinding_description_changed))), (key_entry), ((void*)0)
, (GConnectFlags) 0)
673 gsettings_signal,g_signal_connect_data ((settings), (gsettings_signal), (((GCallback
) (keybinding_description_changed))), (key_entry), ((void*)0)
, (GConnectFlags) 0)
674 G_CALLBACK (keybinding_description_changed),g_signal_connect_data ((settings), (gsettings_signal), (((GCallback
) (keybinding_description_changed))), (key_entry), ((void*)0)
, (GConnectFlags) 0)
675 key_entry)g_signal_connect_data ((settings), (gsettings_signal), (((GCallback
) (keybinding_description_changed))), (key_entry), ((void*)0)
, (GConnectFlags) 0)
;
676 g_free (gsettings_signal);
677 }
678 if (keys_list[j].cmd_key != NULL((void*)0))
679 {
680 key_entry->cmd_gsettings_key = g_strdup (keys_list[j].cmd_key)g_strdup_inline (keys_list[j].cmd_key);
681 key_entry->cmd_editable = g_settings_is_writable (settings, key_entry->cmd_gsettings_key);
682 gchar *gsettings_signal = g_strconcat ("changed::", key_entry->cmd_gsettings_key, NULL((void*)0));
683 key_entry->gsettings_cnxn_cmd = g_signal_connect (settings,g_signal_connect_data ((settings), (gsettings_signal), (((GCallback
) (keybinding_command_changed))), (key_entry), ((void*)0), (GConnectFlags
) 0)
684 gsettings_signal,g_signal_connect_data ((settings), (gsettings_signal), (((GCallback
) (keybinding_command_changed))), (key_entry), ((void*)0), (GConnectFlags
) 0)
685 G_CALLBACK (keybinding_command_changed),g_signal_connect_data ((settings), (gsettings_signal), (((GCallback
) (keybinding_command_changed))), (key_entry), ((void*)0), (GConnectFlags
) 0)
686 key_entry)g_signal_connect_data ((settings), (gsettings_signal), (((GCallback
) (keybinding_command_changed))), (key_entry), ((void*)0), (GConnectFlags
) 0)
;
687 g_free (gsettings_signal);
688 }
689
690 gchar *gsettings_signal = g_strconcat ("changed::", key_string, NULL((void*)0));
691 key_entry->gsettings_cnxn = g_signal_connect (settings,g_signal_connect_data ((settings), (gsettings_signal), (((GCallback
) (keybinding_key_changed))), (key_entry), ((void*)0), (GConnectFlags
) 0)
692 gsettings_signal,g_signal_connect_data ((settings), (gsettings_signal), (((GCallback
) (keybinding_key_changed))), (key_entry), ((void*)0), (GConnectFlags
) 0)
693 G_CALLBACK (keybinding_key_changed),g_signal_connect_data ((settings), (gsettings_signal), (((GCallback
) (keybinding_key_changed))), (key_entry), ((void*)0), (GConnectFlags
) 0)
694 key_entry)g_signal_connect_data ((settings), (gsettings_signal), (((GCallback
) (keybinding_key_changed))), (key_entry), ((void*)0), (GConnectFlags
) 0)
;
695 g_free (gsettings_signal);
696
697 key_value = g_settings_get_string (settings, key_string);
698 binding_from_string (key_value, &key_entry->keyval, &key_entry->keycode, &key_entry->mask);
699 g_free (key_value);
700
701 ensure_scrollbar (builder, i);
702
703 ++i;
704 gtk_tree_store_append (GTK_TREE_STORE (model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, &iter, &parent_iter);
705 /* we use the DESCRIPTION_COLUMN only for the section headers */
706 gtk_tree_store_set (GTK_TREE_STORE (model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, &iter,
707 KEYENTRY_COLUMN, key_entry,
708 -1);
709 gtk_tree_view_expand_all (GTK_TREE_VIEW (gtk_builder_get_object (builder, "shortcut_treeview"))((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, "shortcut_treeview"))),
((gtk_tree_view_get_type ()))))))
);
710 }
711
712 /* Don't show an empty section */
713 if (gtk_tree_model_iter_n_children (model, &parent_iter) == 0)
714 gtk_tree_store_remove (GTK_TREE_STORE (model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, &parent_iter);
715
716 if (i == 0)
717 gtk_widget_hide (_gtk_builder_get_widget (builder, "shortcuts_vbox"));
718 else
719 gtk_widget_show (_gtk_builder_get_widget (builder, "shortcuts_vbox"));
720}
721
722static void
723parse_start_tag (GMarkupParseContext *ctx,
724 const gchar *element_name,
725 const gchar **attr_names,
726 const gchar **attr_values,
727 gpointer user_data,
728 GError **error)
729{
730 KeyList *keylist = (KeyList *) user_data;
731 KeyListEntry key;
732 const char *name, *value_key, *description, *value_schema;
733 int value;
734 Comparison comparison;
735 const char *schema = NULL((void*)0);
736
737 name = NULL((void*)0);
738
739 /* The top-level element, names the section in the tree */
740 if (g_str_equal (element_name, "KeyListEntries")(strcmp ((const char *) (element_name), (const char *) ("KeyListEntries"
)) == 0)
)
741 {
742 const char *wm_name = NULL((void*)0);
743 const char *package = NULL((void*)0);
744
745 while (*attr_names && *attr_values)
746 {
747 if (g_str_equal (*attr_names, "name")(strcmp ((const char *) (*attr_names), (const char *) ("name"
)) == 0)
)
748 {
749 if (**attr_values)
750 name = *attr_values;
751 }
752 else if (g_str_equal (*attr_names, "wm_name")(strcmp ((const char *) (*attr_names), (const char *) ("wm_name"
)) == 0)
)
753 {
754 if (**attr_values)
755 wm_name = *attr_values;
756 }
757 else if (g_str_equal (*attr_names, "package")(strcmp ((const char *) (*attr_names), (const char *) ("package"
)) == 0)
)
758 {
759 if (**attr_values)
760 package = *attr_values;
761 }
762 else if (g_str_equal (*attr_names, "schema")(strcmp ((const char *) (*attr_names), (const char *) ("schema"
)) == 0)
)
763 {
764 if (**attr_values)
765 schema = *attr_values;
766 }
767 ++attr_names;
768 ++attr_values;
769 }
770
771 if (name)
772 {
773 if (keylist->name)
774 g_warning ("Duplicate section name");
775 g_free (keylist->name);
776 keylist->name = g_strdup (name)g_strdup_inline (name);
777 }
778 if (wm_name)
779 {
780 if (keylist->wm_name)
781 g_warning ("Duplicate window manager name");
782 g_free (keylist->wm_name);
783 keylist->wm_name = g_strdup (wm_name)g_strdup_inline (wm_name);
784 }
785 if (package)
786 {
787 if (keylist->package)
788 g_warning ("Duplicate gettext package name");
789 g_free (keylist->package);
790 keylist->package = g_strdup (package)g_strdup_inline (package);
791 }
792 if (schema)
793 {
794 if (keylist->schema)
795 g_warning ("Duplicate schema name");
796 g_free (keylist->schema);
797 keylist->schema = g_strdup (schema)g_strdup_inline (schema);
798 }
799 return;
800 }
801
802 if (!g_str_equal (element_name, "KeyListEntry")(strcmp ((const char *) (element_name), (const char *) ("KeyListEntry"
)) == 0)
803 || attr_names == NULL((void*)0)
804 || attr_values == NULL((void*)0))
805 return;
806
807 value = 0;
808 comparison = COMPARISON_NONE;
809 value_key = NULL((void*)0);
810 value_schema = NULL((void*)0);
811 description = NULL((void*)0);
812
813 while (*attr_names && *attr_values)
814 {
815 if (g_str_equal (*attr_names, "name")(strcmp ((const char *) (*attr_names), (const char *) ("name"
)) == 0)
)
816 {
817 /* skip if empty */
818 if (**attr_values)
819 name = *attr_values;
820 } else if (g_str_equal (*attr_names, "value")(strcmp ((const char *) (*attr_names), (const char *) ("value"
)) == 0)
) {
821 if (**attr_values) {
822 value = (int) g_ascii_strtoull (*attr_values, NULL((void*)0), 0);
823 }
824 } else if (g_str_equal (*attr_names, "key")(strcmp ((const char *) (*attr_names), (const char *) ("key")
) == 0)
) {
825 if (**attr_values) {
826 value_key = *attr_values;
827 }
828 } else if (g_str_equal (*attr_names, "comparison")(strcmp ((const char *) (*attr_names), (const char *) ("comparison"
)) == 0)
) {
829 if (**attr_values) {
830 if (g_str_equal (*attr_values, "gt")(strcmp ((const char *) (*attr_values), (const char *) ("gt")
) == 0)
) {
831 comparison = COMPARISON_GT;
832 } else if (g_str_equal (*attr_values, "lt")(strcmp ((const char *) (*attr_values), (const char *) ("lt")
) == 0)
) {
833 comparison = COMPARISON_LT;
834 } else if (g_str_equal (*attr_values, "eq")(strcmp ((const char *) (*attr_values), (const char *) ("eq")
) == 0)
) {
835 comparison = COMPARISON_EQ;
836 }
837 }
838 } else if (g_str_equal (*attr_names, "description")(strcmp ((const char *) (*attr_names), (const char *) ("description"
)) == 0)
) {
839 if (**attr_values) {
840 description = *attr_values;
841 }
842 } else if (g_str_equal (*attr_names, "schema")(strcmp ((const char *) (*attr_names), (const char *) ("schema"
)) == 0)
) {
843 if (**attr_values) {
844 value_schema = *attr_values;
845 }
846 }
847
848 ++attr_names;
849 ++attr_values;
850 }
851
852 if (name == NULL((void*)0))
853 return;
854
855 key.name = g_strdup (name)g_strdup_inline (name);
856 key.gsettings_path = NULL((void*)0);
857 key.description_key = NULL((void*)0);
858 key.description = g_strdup(description)g_strdup_inline (description);
859 key.schema = g_strdup(schema)g_strdup_inline (schema);
860 key.value = value;
861 if (value_key) {
862 key.value_key = g_strdup (value_key)g_strdup_inline (value_key);
863 key.value_schema = g_strdup (value_schema)g_strdup_inline (value_schema);
864 }
865 else {
866 key.value_key = NULL((void*)0);
867 key.value_schema = NULL((void*)0);
868 }
869 key.comparison = comparison;
870 key.cmd_key = NULL((void*)0);
871 g_array_append_val (keylist->entries, key)g_array_append_vals (keylist->entries, &(key), 1);
872}
873
874static gboolean
875strv_contains (char **strv,
876 char *str)
877{
878 char **p;
879
880 for (p = strv; *p; p++)
881 if (strcmp (*p, str) == 0)
882 return TRUE(!(0));
883
884 return FALSE(0);
885}
886
887static void
888append_keys_to_tree_from_file (GtkBuilder *builder,
889 const char *filename,
890 char **wm_keybindings)
891{
892 GMarkupParseContext *ctx;
893 GMarkupParser parser = { parse_start_tag, NULL((void*)0), NULL((void*)0), NULL((void*)0), NULL((void*)0) };
894 KeyList *keylist;
895 KeyListEntry key, *keys;
896 GError *err = NULL((void*)0);
897 char *buf;
898 const char *title;
899 gsize buf_len;
900 guint i;
901
902 if (!g_file_get_contents (filename, &buf, &buf_len, &err))
903 return;
904
905 keylist = g_new0 (KeyList, 1)((KeyList *) g_malloc0_n ((1), sizeof (KeyList)));
906 keylist->entries = g_array_new (FALSE(0), TRUE(!(0)), sizeof (KeyListEntry));
907 ctx = g_markup_parse_context_new (&parser, 0, keylist, NULL((void*)0));
908
909 if (!g_markup_parse_context_parse (ctx, buf, buf_len, &err))
910 {
911 g_warning ("Failed to parse '%s': '%s'", filename, err->message);
912 g_error_free (err);
913 g_free (keylist->name);
914 g_free (keylist->package);
915 g_free (keylist->wm_name);
916 g_free (keylist->schema);
917 for (i = 0; i < keylist->entries->len; i++)
918 g_free (((KeyListEntry *) &(keylist->entries->data[i]))->name);
Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption
919 g_array_free (keylist->entries, TRUE(!(0)));
920 g_free (keylist);
921 keylist = NULL((void*)0);
922 }
923 g_markup_parse_context_free (ctx);
924 g_free (buf);
925
926 if (keylist == NULL((void*)0))
927 return;
928
929 /* If there's no keys to add, or the settings apply to a window manager
930 * that's not the one we're running */
931 if (keylist->entries->len == 0
932 || (keylist->wm_name != NULL((void*)0) && !strv_contains (wm_keybindings, keylist->wm_name))
933 || keylist->name == NULL((void*)0))
934 {
935 g_free (keylist->name);
936 g_free (keylist->package);
937 g_free (keylist->wm_name);
938 g_free (keylist->schema);
939 g_array_free (keylist->entries, TRUE(!(0)));
940 g_free (keylist);
941 return;
942 }
943
944 /* Empty KeyListEntry to end the array */
945 key.name = NULL((void*)0);
946 key.description_key = NULL((void*)0);
947 key.value_key = NULL((void*)0);
948 key.value = 0;
949 key.comparison = COMPARISON_NONE;
950 g_array_append_val (keylist->entries, key)g_array_append_vals (keylist->entries, &(key), 1);
951
952 keys = (KeyListEntry *) g_array_free (keylist->entries, FALSE(0));
953 if (keylist->package)
954 {
955 bind_textdomain_codeset (keylist->package, "UTF-8");
956 title = dgettext (keylist->package, keylist->name);
957 } else {
958 title = _(keylist->name)gettext (keylist->name);
959 }
960
961 append_keys_to_tree (builder, title, keylist->schema, keylist->package, keys);
962
963 g_free (keylist->name);
964 g_free (keylist->package);
965 for (i = 0; keys[i].name != NULL((void*)0); i++)
966 g_free (keys[i].name);
967 g_free (keylist);
968}
969
970static void
971append_keys_to_tree_from_gsettings (GtkBuilder *builder, const gchar *gsettings_path)
972{
973 gchar **custom_list;
974 GArray *entries;
975 KeyListEntry key;
976 gint i;
977
978 /* load custom shortcuts from GSettings */
979 entries = g_array_new (FALSE(0), TRUE(!(0)), sizeof (KeyListEntry));
980
981 key.value_key = NULL((void*)0);
982 key.value = 0;
983 key.comparison = COMPARISON_NONE;
984
985 custom_list = dconf_util_list_subdirs (gsettings_path, FALSE(0));
986
987 if (custom_list != NULL((void*)0))
988 {
989 for (i = 0; custom_list[i] != NULL((void*)0); i++)
990 {
991 key.gsettings_path = g_strdup_printf("%s%s", gsettings_path, custom_list[i]);
992 key.name = g_strdup("binding")g_strdup_inline ("binding");
993 key.cmd_key = g_strdup("action")g_strdup_inline ("action");
994 key.description_key = g_strdup("name")g_strdup_inline ("name");
995 key.schema = NULL((void*)0);
996 g_array_append_val (entries, key)g_array_append_vals (entries, &(key), 1);
997 }
998 }
999
1000 g_strfreev (custom_list);
1001
1002 if (entries->len > 0)
1003 {
1004 KeyListEntry *keys;
1005 int i;
1006
1007 /* Empty KeyListEntry to end the array */
1008 key.gsettings_path = NULL((void*)0);
1009 key.name = NULL((void*)0);
1010 key.description_key = NULL((void*)0);
1011 key.cmd_key = NULL((void*)0);
1012 g_array_append_val (entries, key)g_array_append_vals (entries, &(key), 1);
1013
1014 keys = (KeyListEntry *) entries->data;
1015 append_keys_to_tree (builder, _("Custom Shortcuts")gettext ("Custom Shortcuts"), CUSTOM_KEYBINDING_SCHEMA"org.mate.control-center.keybinding", NULL((void*)0), keys);
1016 for (i = 0; i < entries->len; ++i)
1017 {
1018 g_free (keys[i].name);
1019 g_free (keys[i].description_key);
1020 g_free (keys[i].cmd_key);
1021 g_free (keys[i].gsettings_path);
1022 }
1023 }
1024
1025 g_array_free (entries, TRUE(!(0)));
1026}
1027
1028static void
1029reload_key_entries (GtkBuilder *builder)
1030{
1031 gchar **wm_keybindings;
1032 GList *list, *l;
1033 const gchar * const * data_dirs;
1034 GHashTable *loaded_files;
1035 guint i;
1036
1037 wm_keybindings = wm_common_get_current_keybindings();
1038
1039 clear_old_model (builder);
1040
1041 loaded_files = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
1042 data_dirs = g_get_system_data_dirs ();
1043 for (i = 0; data_dirs[i] != NULL((void*)0); i++)
1044 {
1045 g_autofree__attribute__((cleanup(g_autoptr_cleanup_generic_gfree))) gchar *dir_path = NULL((void*)0);
1046 GDir *dir;
1047 const gchar *name;
1048
1049 dir_path = g_build_filename (data_dirs[i], "mate-control-center", "keybindings", NULL((void*)0));
1050 g_debug ("Keybinding dir: %s", dir_path);
1051
1052 dir = g_dir_open (dir_path, 0, NULL((void*)0));
1053 if (!dir)
1054 continue;
1055
1056 for (name = g_dir_read_name (dir) ; name ; name = g_dir_read_name (dir))
1057 {
1058 if (g_str_has_suffix (name, ".xml")(__builtin_constant_p (".xml")? __extension__ ({ const char *
const __str = (name); const char * const __suffix = (".xml")
; gboolean __result = (0); if (__str == ((void*)0) || __suffix
== ((void*)0)) __result = (g_str_has_suffix) (__str, __suffix
); else { const size_t __str_len = strlen (((__str) + !(__str
))); const size_t __suffix_len = strlen (((__suffix) + !(__suffix
))); if (__str_len >= __suffix_len) __result = memcmp (__str
+ __str_len - __suffix_len, ((__suffix) + !(__suffix)), __suffix_len
) == 0; } __result; }) : (g_str_has_suffix) (name, ".xml") )
== FALSE(0))
1059 continue;
1060
1061 if (g_hash_table_lookup (loaded_files, name) != NULL((void*)0))
1062 {
1063 g_debug ("Not loading %s, it was already loaded from another directory", name);
1064 continue;
1065 }
1066
1067 g_hash_table_insert (loaded_files, g_strdup (name)g_strdup_inline (name), g_strdup (dir_path)g_strdup_inline (dir_path));
1068 }
1069
1070 g_dir_close (dir);
1071 }
1072 list = g_hash_table_get_keys (loaded_files);
1073 list = g_list_sort(list, (GCompareFunc) g_str_equal);
1074 for (l = list; l != NULL((void*)0); l = l->next)
1075 {
1076 g_autofree__attribute__((cleanup(g_autoptr_cleanup_generic_gfree))) gchar *path = NULL((void*)0);
1077 path = g_build_filename (g_hash_table_lookup (loaded_files, l->data), l->data, NULL((void*)0));
1078 g_debug ("Keybinding file: %s", path);
1079 append_keys_to_tree_from_file (builder, path, wm_keybindings);
1080 }
1081 g_list_free (list);
1082 g_hash_table_destroy (loaded_files);
1083
1084 /* Load custom shortcuts _after_ system-provided ones,
1085 * since some of the custom shortcuts may also be listed
1086 * in a file. Loading the custom shortcuts last makes
1087 * such keys not show up in the custom section.
1088 */
1089 append_keys_to_tree_from_gsettings (builder, GSETTINGS_KEYBINDINGS_DIR"/org/mate/desktop/keybindings/");
1090
1091 g_strfreev (wm_keybindings);
1092}
1093
1094static void
1095key_entry_controlling_key_changed (GSettings *settings, gchar *key, gpointer user_data)
1096{
1097 reload_key_entries (user_data);
1098}
1099
1100static gboolean cb_check_for_uniqueness(GtkTreeModel* model, GtkTreePath* path, GtkTreeIter* iter, KeyEntry* new_key)
1101{
1102 KeyEntry* element;
1103
1104 gtk_tree_model_get (new_key->model, iter,
1105 KEYENTRY_COLUMN, &element,
1106 -1);
1107
1108 /* no conflict for : blanks, different modifiers, or ourselves */
1109 if (element == NULL((void*)0) || new_key->mask != element->mask)
1110 {
1111 return FALSE(0);
1112 }
1113
1114 gchar *new_key_schema = NULL((void*)0);
1115 gchar *element_schema = NULL((void*)0);
1116 gchar *new_key_path = NULL((void*)0);
1117 gchar *element_path = NULL((void*)0);
1118
1119 if (new_key && new_key->settings)
1120 {
1121 g_object_get (new_key->settings, "schema-id", &new_key_schema, NULL((void*)0));
1122 g_object_get (new_key->settings, "path", &new_key_path, NULL((void*)0));
1123 }
1124
1125 if (element->settings)
1126 {
1127 g_object_get (element->settings, "schema-id", &element_schema, NULL((void*)0));
1128 g_object_get (element->settings, "path", &element_path, NULL((void*)0));
1129 }
1130
1131 if (!g_strcmp0 (new_key->gsettings_key, element->gsettings_key) &&
1132 !g_strcmp0 (new_key_schema, element_schema) &&
1133 !g_strcmp0 (new_key_path, element_path))
1134 {
1135 return FALSE(0);
1136 }
1137
1138 if (new_key->keyval != 0)
1139 {
1140 if (new_key->keyval != element->keyval)
1141 {
1142 return FALSE(0);
1143 }
1144 }
1145 else if (element->keyval != 0 || new_key->keycode != element->keycode)
1146 {
1147 return FALSE(0);
1148 }
1149
1150 new_key->editable = FALSE(0);
1151 new_key->settings = element->settings;
1152 new_key->gsettings_key = element->gsettings_key;
1153 new_key->description = element->description;
1154 new_key->desc_gsettings_key = element->desc_gsettings_key;
1155 new_key->desc_editable = element->desc_editable;
1156
1157 return TRUE(!(0));
1158}
1159
1160static const guint forbidden_keyvals[] = {
1161 /* Navigation keys */
1162 GDK_KEY_Home0xff50,
1163 GDK_KEY_Left0xff51,
1164 GDK_KEY_Up0xff52,
1165 GDK_KEY_Right0xff53,
1166 GDK_KEY_Down0xff54,
1167 GDK_KEY_Page_Up0xff55,
1168 GDK_KEY_Page_Down0xff56,
1169 GDK_KEY_End0xff57,
1170 GDK_KEY_Tab0xff09,
1171
1172 /* Return */
1173 GDK_KEY_KP_Enter0xff8d,
1174 GDK_KEY_Return0xff0d,
1175
1176 GDK_KEY_space0x020,
1177 GDK_KEY_Mode_switch0xff7e
1178};
1179
1180static gboolean keyval_is_forbidden(guint keyval)
1181{
1182 guint i;
1183
1184 for (i = 0; i < G_N_ELEMENTS(forbidden_keyvals)(sizeof (forbidden_keyvals) / sizeof ((forbidden_keyvals)[0])
)
; i++)
1185 {
1186 if (keyval == forbidden_keyvals[i])
1187 {
1188 return TRUE(!(0));
1189 }
1190 }
1191
1192 return FALSE(0);
1193}
1194
1195static void show_error(GtkWindow* parent, GError* err)
1196{
1197 GtkWidget *dialog;
1198
1199 dialog = gtk_message_dialog_new (parent,
1200 GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL,
1201 GTK_MESSAGE_WARNING,
1202 GTK_BUTTONS_OK,
1203 _("Error saving the new shortcut")gettext ("Error saving the new shortcut"));
1204
1205 gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog)((((GtkMessageDialog*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((dialog)), ((gtk_message_dialog_get_type ())
)))))
,
1206 "%s", err->message);
1207 gtk_dialog_run (GTK_DIALOG (dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_dialog_get_type ()))))))
);
1208 gtk_widget_destroy (dialog);
1209}
1210
1211static void accel_edited_callback(GtkCellRendererText* cell, const char* path_string, guint keyval, EggVirtualModifierType mask, guint keycode, gpointer data)
1212{
1213 GtkTreeView* view = (GtkTreeView*) data;
1214 GtkTreeModel* model;
1215 GtkTreePath* path = gtk_tree_path_new_from_string (path_string);
1216 GtkTreeIter iter;
1217 KeyEntry* key_entry, tmp_key;
1218 char* str;
1219
1220 block_accels = FALSE(0);
1221
1222 model = gtk_tree_view_get_model (view);
1223 gtk_tree_model_get_iter (model, &iter, path);
1224 gtk_tree_path_free (path);
1225 gtk_tree_model_get (model, &iter,
1226 KEYENTRY_COLUMN, &key_entry,
1227 -1);
1228
1229 /* sanity check */
1230 if (key_entry == NULL((void*)0))
1231 {
1232 return;
1233 }
1234
1235 /* CapsLock isn't supported as a keybinding modifier, so keep it from confusing us */
1236 mask &= ~EGG_VIRTUAL_LOCK_MASK;
1237
1238 tmp_key.model = model;
1239 tmp_key.keyval = keyval;
1240 tmp_key.keycode = keycode;
1241 tmp_key.mask = mask;
1242 tmp_key.settings = key_entry->settings;
1243 tmp_key.gsettings_key = key_entry->gsettings_key;
1244 tmp_key.description = NULL((void*)0);
1245 tmp_key.editable = TRUE(!(0)); /* kludge to stuff in a return flag */
1246
1247 if (keyval != 0 || keycode != 0) /* any number of keys can be disabled */
1248 {
1249 gtk_tree_model_foreach(model, (GtkTreeModelForeachFunc) cb_check_for_uniqueness, &tmp_key);
1250 }
1251
1252 /* Check for unmodified keys */
1253 if (tmp_key.mask == 0 && tmp_key.keycode != 0)
1254 {
1255 if ((tmp_key.keyval >= GDK_KEY_a0x061 && tmp_key.keyval <= GDK_KEY_z0x07a)
1256 || (tmp_key.keyval >= GDK_KEY_A0x041 && tmp_key.keyval <= GDK_KEY_Z0x05a)
1257 || (tmp_key.keyval >= GDK_KEY_00x030 && tmp_key.keyval <= GDK_KEY_90x039)
1258 || (tmp_key.keyval >= GDK_KEY_kana_fullstop0x4a1 && tmp_key.keyval <= GDK_KEY_semivoicedsound0x4df)
1259 || (tmp_key.keyval >= GDK_KEY_Arabic_comma0x5ac && tmp_key.keyval <= GDK_KEY_Arabic_sukun0x5f2)
1260 || (tmp_key.keyval >= GDK_KEY_Serbian_dje0x6a1 && tmp_key.keyval <= GDK_KEY_Cyrillic_HARDSIGN0x6ff)
1261 || (tmp_key.keyval >= GDK_KEY_Greek_ALPHAaccent0x7a1 && tmp_key.keyval <= GDK_KEY_Greek_omega0x7f9)
1262 || (tmp_key.keyval >= GDK_KEY_hebrew_doublelowline0xcdf && tmp_key.keyval <= GDK_KEY_hebrew_taf0xcfa)
1263 || (tmp_key.keyval >= GDK_KEY_Thai_kokai0xda1 && tmp_key.keyval <= GDK_KEY_Thai_lekkao0xdf9)
1264 || (tmp_key.keyval >= GDK_KEY_Hangul0xff31 && tmp_key.keyval <= GDK_KEY_Hangul_Special0xff3f)
1265 || (tmp_key.keyval >= GDK_KEY_Hangul_Kiyeog0xea1 && tmp_key.keyval <= GDK_KEY_Hangul_J_YeorinHieuh0xefa)
1266 || keyval_is_forbidden (tmp_key.keyval))
1267 {
1268
1269 GtkWidget *dialog;
1270 char *name;
1271
1272 name = binding_name (keyval, keycode, mask, TRUE(!(0)));
1273
1274 dialog = gtk_message_dialog_new (
1275 GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (view)))((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_widget_get_toplevel (((((GtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((view)), ((gtk_widget_get_type ()))))))))
), ((gtk_window_get_type ()))))))
,
1276 GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL,
1277 GTK_MESSAGE_WARNING,
1278 GTK_BUTTONS_CANCEL,
1279 _("The shortcut \"%s\" cannot be used because it will become impossible to type using this key.\n"gettext ("The shortcut \"%s\" cannot be used because it will become impossible to type using this key.\n"
"Please try with a key such as Control, Alt or Shift at the same time."
)
1280 "Please try with a key such as Control, Alt or Shift at the same time.")gettext ("The shortcut \"%s\" cannot be used because it will become impossible to type using this key.\n"
"Please try with a key such as Control, Alt or Shift at the same time."
)
,
1281 name);
1282
1283 g_free (name);
1284 gtk_dialog_run (GTK_DIALOG (dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_dialog_get_type ()))))))
);
1285 gtk_widget_destroy (dialog);
1286
1287 /* set it back to its previous value. */
1288 egg_cell_renderer_keys_set_accelerator(
1289 EGG_CELL_RENDERER_KEYS(cell)((((EggCellRendererKeys*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((cell)), ((egg_cell_renderer_keys_get_type
()))))))
,
1290 key_entry->keyval,
1291 key_entry->keycode,
1292 key_entry->mask);
1293 return;
1294 }
1295 }
1296
1297 /* flag to see if the new accelerator was in use by something */
1298 if (!tmp_key.editable)
1299 {
1300 GtkWidget* dialog;
1301 char* name;
1302 int response;
1303
1304 name = binding_name(keyval, keycode, mask, TRUE(!(0)));
1305
1306 dialog = gtk_message_dialog_new(
1307 GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(view)))((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_widget_get_toplevel(((((GtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((view)), ((gtk_widget_get_type ()))))))))
), ((gtk_window_get_type ()))))))
,
1308 GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL,
1309 GTK_MESSAGE_WARNING,
1310 GTK_BUTTONS_CANCEL,
1311 _("The shortcut \"%s\" is already used for\n\"%s\"")gettext ("The shortcut \"%s\" is already used for\n\"%s\""),
1312 name,
1313 tmp_key.description ? tmp_key.description : tmp_key.gsettings_key);
1314 g_free (name);
1315
1316 gtk_message_dialog_format_secondary_text (
1317 GTK_MESSAGE_DIALOG (dialog)((((GtkMessageDialog*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((dialog)), ((gtk_message_dialog_get_type ())
)))))
,
1318 _("If you reassign the shortcut to \"%s\", the \"%s\" shortcut "gettext ("If you reassign the shortcut to \"%s\", the \"%s\" shortcut "
"will be disabled.")
1319 "will be disabled.")gettext ("If you reassign the shortcut to \"%s\", the \"%s\" shortcut "
"will be disabled.")
,
1320 key_entry->description ? key_entry->description : key_entry->gsettings_key,
1321 tmp_key.description ? tmp_key.description : tmp_key.gsettings_key);
1322
1323 gtk_dialog_add_button(GTK_DIALOG (dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_dialog_get_type ()))))))
, _("_Reassign")gettext ("_Reassign"), GTK_RESPONSE_ACCEPT);
1324
1325 gtk_dialog_set_default_response(GTK_DIALOG (dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_dialog_get_type ()))))))
, GTK_RESPONSE_ACCEPT);
1326
1327 response = gtk_dialog_run (GTK_DIALOG (dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_dialog_get_type ()))))))
);
1328 gtk_widget_destroy (dialog);
1329
1330 if (response == GTK_RESPONSE_ACCEPT)
1331 {
1332 g_settings_set_string (tmp_key.settings, tmp_key.gsettings_key, "disabled");
1333
1334 str = binding_name (keyval, keycode, mask, FALSE(0));
1335 g_settings_set_string (key_entry->settings, key_entry->gsettings_key, str);
1336
1337 g_free (str);
1338 }
1339 else
1340 {
1341 /* set it back to its previous value. */
1342 egg_cell_renderer_keys_set_accelerator(
1343 EGG_CELL_RENDERER_KEYS(cell)((((EggCellRendererKeys*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((cell)), ((egg_cell_renderer_keys_get_type
()))))))
,
1344 key_entry->keyval,
1345 key_entry->keycode,
1346 key_entry->mask);
1347 }
1348
1349 return;
1350 }
1351
1352 str = binding_name (keyval, keycode, mask, FALSE(0));
1353
1354 g_settings_set_string(
1355 key_entry->settings,
1356 key_entry->gsettings_key,
1357 str);
1358
1359 g_free (str);
1360
1361}
1362
1363static void
1364accel_cleared_callback (GtkCellRendererText *cell,
1365 const char *path_string,
1366 gpointer data)
1367{
1368 GtkTreeView *view = (GtkTreeView *) data;
1369 GtkTreePath *path = gtk_tree_path_new_from_string (path_string);
1370 KeyEntry *key_entry;
1371 GtkTreeIter iter;
1372 GtkTreeModel *model;
1373
1374 block_accels = FALSE(0);
1375
1376 model = gtk_tree_view_get_model (view);
1377 gtk_tree_model_get_iter (model, &iter, path);
1378 gtk_tree_path_free (path);
1379 gtk_tree_model_get (model, &iter,
1380 KEYENTRY_COLUMN, &key_entry,
1381 -1);
1382
1383 /* sanity check */
1384 if (key_entry == NULL((void*)0))
1385 return;
1386
1387 /* Unset the key */
1388 g_settings_set_string (key_entry->settings,
1389 key_entry->gsettings_key,
1390 "disabled");
1391}
1392
1393static void
1394description_edited_callback (GtkCellRendererText *renderer,
1395 gchar *path_string,
1396 gchar *new_text,
1397 gpointer user_data)
1398{
1399 GtkTreeView *view = GTK_TREE_VIEW (user_data)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((gtk_tree_view_get_type ()))))))
;
1400 GtkTreeModel *model;
1401 GtkTreePath *path = gtk_tree_path_new_from_string (path_string);
1402 GtkTreeIter iter;
1403 KeyEntry *key_entry;
1404
1405 model = gtk_tree_view_get_model (view);
1406 gtk_tree_model_get_iter (model, &iter, path);
1407 gtk_tree_path_free (path);
1408
1409 gtk_tree_model_get (model, &iter,
1410 KEYENTRY_COLUMN, &key_entry,
1411 -1);
1412
1413 /* sanity check */
1414 if (key_entry == NULL((void*)0) || key_entry->desc_gsettings_key == NULL((void*)0))
1415 return;
1416
1417 if (!g_settings_set_string (key_entry->settings, key_entry->desc_gsettings_key, new_text))
1418 key_entry->desc_editable = FALSE(0);
1419}
1420
1421typedef struct
1422{
1423 GtkTreeView *tree_view;
1424 GtkTreePath *path;
1425 GtkTreeViewColumn *column;
1426} IdleData;
1427
1428static gboolean
1429real_start_editing_cb (IdleData *idle_data)
1430{
1431 gtk_widget_grab_focus (GTK_WIDGET (idle_data->tree_view)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((idle_data->tree_view)), ((gtk_widget_get_type ())))))
)
);
1432 gtk_tree_view_set_cursor (idle_data->tree_view,
1433 idle_data->path,
1434 idle_data->column,
1435 TRUE(!(0)));
1436 gtk_tree_path_free (idle_data->path);
1437 g_free (idle_data);
1438 return FALSE(0);
1439}
1440
1441static gboolean
1442edit_custom_shortcut (KeyEntry *key)
1443{
1444 gint result;
1445 const gchar *text;
1446 gboolean ret;
1447
1448 gtk_entry_set_text (GTK_ENTRY (custom_shortcut_name_entry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((custom_shortcut_name_entry)), ((gtk_entry_get_type ())))
)))
, key->description ? key->description : "");
1449 gtk_widget_set_sensitive (custom_shortcut_name_entry, key->desc_editable);
1450 gtk_widget_grab_focus (custom_shortcut_name_entry);
1451 gtk_entry_set_text (GTK_ENTRY (custom_shortcut_command_entry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((custom_shortcut_command_entry)), ((gtk_entry_get_type ()
))))))
, key->command ? key->command : "");
1452 gtk_widget_set_sensitive (custom_shortcut_command_entry, key->cmd_editable);
1453
1454 gtk_window_present (GTK_WINDOW (custom_shortcut_dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((custom_shortcut_dialog)), ((gtk_window_get_type ()))))))
);
1455 result = gtk_dialog_run (GTK_DIALOG (custom_shortcut_dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((custom_shortcut_dialog)), ((gtk_dialog_get_type ()))))))
);
1456 switch (result)
1457 {
1458 case GTK_RESPONSE_OK:
1459 text = gtk_entry_get_text (GTK_ENTRY (custom_shortcut_name_entry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((custom_shortcut_name_entry)), ((gtk_entry_get_type ())))
)))
);
1460 g_free (key->description);
1461 key->description = g_strdup (text)g_strdup_inline (text);
1462 text = gtk_entry_get_text (GTK_ENTRY (custom_shortcut_command_entry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((custom_shortcut_command_entry)), ((gtk_entry_get_type ()
))))))
);
1463 g_free (key->command);
1464 key->command = g_strdup (text)g_strdup_inline (text);
1465 ret = TRUE(!(0));
1466 break;
1467 default:
1468 ret = FALSE(0);
1469 break;
1470 }
1471
1472 gtk_widget_hide (custom_shortcut_dialog);
1473
1474 return ret;
1475}
1476
1477static gboolean
1478remove_custom_shortcut (GtkTreeModel *model, GtkTreeIter *iter)
1479{
1480 GtkTreeIter parent;
1481 KeyEntry *key;
1482
1483 gtk_tree_model_get (model, iter,
1484 KEYENTRY_COLUMN, &key,
1485 -1);
1486
1487 /* not a custom shortcut */
1488 if (key->command == NULL((void*)0))
1489 return FALSE(0);
1490
1491 g_signal_handler_disconnect (key->settings, key->gsettings_cnxn);
1492 if (key->gsettings_cnxn_desc != 0)
1493 g_signal_handler_disconnect (key->settings, key->gsettings_cnxn_desc);
1494 if (key->gsettings_cnxn_cmd != 0)
1495 g_signal_handler_disconnect (key->settings, key->gsettings_cnxn_cmd);
1496
1497 dconf_util_recursive_reset (key->gsettings_path, NULL((void*)0));
1498 g_object_unref (key->settings);
1499
1500 g_free (key->gsettings_path);
1501 g_free (key->gsettings_key);
1502 g_free (key->description);
1503 g_free (key->desc_gsettings_key);
1504 g_free (key->command);
1505 g_free (key->cmd_gsettings_key);
1506 g_free (key);
1507
1508 gtk_tree_model_iter_parent (model, &parent, iter);
1509 gtk_tree_store_remove (GTK_TREE_STORE (model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter);
1510 if (!gtk_tree_model_iter_has_child (model, &parent))
1511 gtk_tree_store_remove (GTK_TREE_STORE (model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, &parent);
1512
1513 return TRUE(!(0));
1514}
1515
1516static void
1517update_custom_shortcut (GtkTreeModel *model, GtkTreeIter *iter)
1518{
1519 KeyEntry *key;
1520
1521 gtk_tree_model_get (model, iter,
1522 KEYENTRY_COLUMN, &key,
1523 -1);
1524
1525 edit_custom_shortcut (key);
1526 if (key->command == NULL((void*)0) || key->command[0] == '\0')
1527 {
1528 remove_custom_shortcut (model, iter);
1529 }
1530 else
1531 {
1532 gtk_tree_store_set (GTK_TREE_STORE (model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter,
1533 KEYENTRY_COLUMN, key, -1);
1534 if (key->description != NULL((void*)0))
1535 g_settings_set_string (key->settings, key->desc_gsettings_key, key->description);
1536 else
1537 g_settings_reset (key->settings, key->desc_gsettings_key);
1538 g_settings_set_string (key->settings, key->cmd_gsettings_key, key->command);
1539 }
1540}
1541
1542static gchar *
1543find_free_gsettings_path (GError **error)
1544{
1545 gchar **existing_dirs;
1546 gchar *dir = NULL((void*)0);
1547 gchar *fulldir = NULL((void*)0);
1548 int i;
1549 int j;
1550 gboolean found;
1551
1552 existing_dirs = dconf_util_list_subdirs (GSETTINGS_KEYBINDINGS_DIR"/org/mate/desktop/keybindings/", FALSE(0));
1553
1554 for (i = 0; i < MAX_CUSTOM_SHORTCUTS1000; i++)
1555 {
1556 found = TRUE(!(0));
1557 dir = g_strdup_printf ("custom%d/", i);
1558 for (j = 0; existing_dirs[j] != NULL((void*)0); j++)
1559 if (!g_strcmp0(dir, existing_dirs[j]))
1560 {
1561 found = FALSE(0);
1562 g_free (dir);
1563 break;
1564 }
1565 if (found)
1566 break;
1567 }
1568 g_strfreev (existing_dirs);
1569
1570 if (i == MAX_CUSTOM_SHORTCUTS1000)
1571 {
1572 g_free (dir);
1573 dir = NULL((void*)0);
1574 g_set_error_literal (error,
1575 g_quark_from_string ("Keyboard Shortcuts"),
1576 0,
1577 _("Too many custom shortcuts")gettext ("Too many custom shortcuts"));
1578 }
1579
1580 fulldir = g_strdup_printf ("%s%s", GSETTINGS_KEYBINDINGS_DIR"/org/mate/desktop/keybindings/", dir);
1581 g_free (dir);
1582 return fulldir;
1583}
1584
1585static void
1586add_custom_shortcut (GtkTreeView *tree_view,
1587 GtkTreeModel *model)
1588{
1589 KeyEntry *key_entry;
1590 GtkTreeIter iter;
1591 GtkTreeIter parent_iter;
1592 GtkTreePath *path;
1593 gchar *dir;
1594 GError *error;
1595
1596 error = NULL((void*)0);
1597 dir = find_free_gsettings_path (&error);
1598 if (dir == NULL((void*)0))
1599 {
1600 show_error (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (tree_view)))((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_widget_get_toplevel (((((GtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((tree_view)), ((gtk_widget_get_type ())))
)))))), ((gtk_window_get_type ()))))))
, error);
1601
1602 g_error_free (error);
1603 return;
1604 }
1605
1606 key_entry = g_new0 (KeyEntry, 1)((KeyEntry *) g_malloc0_n ((1), sizeof (KeyEntry)));
1607 key_entry->gsettings_path = g_strdup(dir)g_strdup_inline (dir);
1608 key_entry->gsettings_key = g_strdup("binding")g_strdup_inline ("binding");
1609 key_entry->editable = TRUE(!(0));
1610 key_entry->model = model;
1611 key_entry->desc_gsettings_key = g_strdup("name")g_strdup_inline ("name");
1612 key_entry->description = g_strdup ("")g_strdup_inline ("");
1613 key_entry->desc_editable = TRUE(!(0));
1614 key_entry->cmd_gsettings_key = g_strdup("action")g_strdup_inline ("action");
1615 key_entry->command = g_strdup ("")g_strdup_inline ("");
1616 key_entry->cmd_editable = TRUE(!(0));
1617 g_free (dir);
1618
1619 if (edit_custom_shortcut (key_entry) &&
1620 key_entry->command && key_entry->command[0])
1621 {
1622 find_section (model, &iter, _("Custom Shortcuts")gettext ("Custom Shortcuts"));
1623 parent_iter = iter;
1624 gtk_tree_store_append (GTK_TREE_STORE (model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, &iter, &parent_iter);
1625 gtk_tree_store_set (GTK_TREE_STORE (model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, &iter, KEYENTRY_COLUMN, key_entry, -1);
1626
1627 /* store in gsettings */
1628 key_entry->settings = g_settings_new_with_path (CUSTOM_KEYBINDING_SCHEMA"org.mate.control-center.keybinding", key_entry->gsettings_path);
1629 g_settings_set_string (key_entry->settings, key_entry->gsettings_key, "disabled");
1630 g_settings_set_string (key_entry->settings, key_entry->desc_gsettings_key, key_entry->description);
1631 g_settings_set_string (key_entry->settings, key_entry->cmd_gsettings_key, key_entry->command);
1632
1633 /* add gsettings watches */
1634 key_entry->gsettings_cnxn_desc = g_signal_connect (key_entry->settings,g_signal_connect_data ((key_entry->settings), ("changed::name"
), (((GCallback) (keybinding_description_changed))), (key_entry
), ((void*)0), (GConnectFlags) 0)
1635 "changed::name",g_signal_connect_data ((key_entry->settings), ("changed::name"
), (((GCallback) (keybinding_description_changed))), (key_entry
), ((void*)0), (GConnectFlags) 0)
1636 G_CALLBACK (keybinding_description_changed),g_signal_connect_data ((key_entry->settings), ("changed::name"
), (((GCallback) (keybinding_description_changed))), (key_entry
), ((void*)0), (GConnectFlags) 0)
1637 key_entry)g_signal_connect_data ((key_entry->settings), ("changed::name"
), (((GCallback) (keybinding_description_changed))), (key_entry
), ((void*)0), (GConnectFlags) 0)
;
1638 key_entry->gsettings_cnxn_cmd = g_signal_connect (key_entry->settings,g_signal_connect_data ((key_entry->settings), ("changed::action"
), (((GCallback) (keybinding_command_changed))), (key_entry),
((void*)0), (GConnectFlags) 0)
1639 "changed::action",g_signal_connect_data ((key_entry->settings), ("changed::action"
), (((GCallback) (keybinding_command_changed))), (key_entry),
((void*)0), (GConnectFlags) 0)
1640 G_CALLBACK (keybinding_command_changed),g_signal_connect_data ((key_entry->settings), ("changed::action"
), (((GCallback) (keybinding_command_changed))), (key_entry),
((void*)0), (GConnectFlags) 0)
1641 key_entry)g_signal_connect_data ((key_entry->settings), ("changed::action"
), (((GCallback) (keybinding_command_changed))), (key_entry),
((void*)0), (GConnectFlags) 0)
;
1642 key_entry->gsettings_cnxn = g_signal_connect (key_entry->settings,g_signal_connect_data ((key_entry->settings), ("changed::binding"
), (((GCallback) (keybinding_key_changed))), (key_entry), ((void
*)0), (GConnectFlags) 0)
1643 "changed::binding",g_signal_connect_data ((key_entry->settings), ("changed::binding"
), (((GCallback) (keybinding_key_changed))), (key_entry), ((void
*)0), (GConnectFlags) 0)
1644 G_CALLBACK (keybinding_key_changed),g_signal_connect_data ((key_entry->settings), ("changed::binding"
), (((GCallback) (keybinding_key_changed))), (key_entry), ((void
*)0), (GConnectFlags) 0)
1645 key_entry)g_signal_connect_data ((key_entry->settings), ("changed::binding"
), (((GCallback) (keybinding_key_changed))), (key_entry), ((void
*)0), (GConnectFlags) 0)
;
1646
1647 /* make the new shortcut visible */
1648 path = gtk_tree_model_get_path (model, &iter);
1649 gtk_tree_view_expand_to_path (tree_view, path);
1650 gtk_tree_view_scroll_to_cell (tree_view, path, NULL((void*)0), FALSE(0), 0, 0);
1651 gtk_tree_path_free (path);
1652 }
1653 else
1654 {
1655 g_free (key_entry->gsettings_path);
1656 g_free (key_entry->gsettings_key);
1657 g_free (key_entry->description);
1658 g_free (key_entry->desc_gsettings_key);
1659 g_free (key_entry->command);
1660 g_free (key_entry->cmd_gsettings_key);
1661 g_free (key_entry);
1662 }
1663}
1664
1665static void
1666start_editing_kb_cb (GtkTreeView *treeview,
1667 GtkTreePath *path,
1668 GtkTreeViewColumn *column,
1669 gpointer user_data)
1670{
1671 GtkTreeModel *model;
1672 GtkTreeIter iter;
1673 KeyEntry *key;
1674
1675 model = gtk_tree_view_get_model (treeview);
1676 gtk_tree_model_get_iter (model, &iter, path);
1677 gtk_tree_model_get (model, &iter,
1678 KEYENTRY_COLUMN, &key,
1679 -1);
1680
1681 if (key == NULL((void*)0))
1682 {
1683 /* This is a section heading - expand or collapse */
1684 if (gtk_tree_view_row_expanded (treeview, path))
1685 gtk_tree_view_collapse_row (treeview, path);
1686 else
1687 gtk_tree_view_expand_row (treeview, path, FALSE(0));
1688 return;
1689 }
1690
1691 /* if only the accel can be edited on the selected row
1692 * always select the accel column */
1693 if (key->desc_editable &&
1694 column == gtk_tree_view_get_column (treeview, 0))
1695 {
1696 gtk_widget_grab_focus (GTK_WIDGET (treeview)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((treeview)), ((gtk_widget_get_type ()))))))
);
1697 gtk_tree_view_set_cursor (treeview, path,
1698 gtk_tree_view_get_column (treeview, 0),
1699 FALSE(0));
1700 update_custom_shortcut (model, &iter);
1701 }
1702 else
1703 {
1704 gtk_widget_grab_focus (GTK_WIDGET (treeview)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((treeview)), ((gtk_widget_get_type ()))))))
);
1705 gtk_tree_view_set_cursor (treeview,
1706 path,
1707 gtk_tree_view_get_column (treeview, 1),
1708 TRUE(!(0)));
1709 }
1710}
1711
1712static gboolean
1713start_editing_cb (GtkTreeView *tree_view,
1714 GdkEventButton *event,
1715 gpointer user_data)
1716{
1717 GtkTreePath *path;
1718 GtkTreeViewColumn *column;
1719
1720 if ((event->window != gtk_tree_view_get_bin_window (tree_view)) ||
1721 (event->type != GDK_2BUTTON_PRESS))
1722 return FALSE(0);
1723
1724 if (gtk_tree_view_get_path_at_pos (tree_view,
1725 (gint) event->x,
1726 (gint) event->y,
1727 &path, &column,
1728 NULL((void*)0), NULL((void*)0)))
1729 {
1730 IdleData *idle_data;
1731 GtkTreeModel *model;
1732 GtkTreeIter iter;
1733 KeyEntry *key;
1734
1735 if (gtk_tree_path_get_depth (path) == 1)
1736 {
1737 gtk_tree_path_free (path);
1738 return FALSE(0);
1739 }
1740
1741 model = gtk_tree_view_get_model (tree_view);
1742 gtk_tree_model_get_iter (model, &iter, path);
1743 gtk_tree_model_get (model, &iter,
1744 KEYENTRY_COLUMN, &key,
1745 -1);
1746
1747 /* if only the accel can be edited on the selected row
1748 * always select the accel column */
1749 if (key->desc_editable &&
1750 column == gtk_tree_view_get_column (tree_view, 0))
1751 {
1752 gtk_widget_grab_focus (GTK_WIDGET (tree_view)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tree_view)), ((gtk_widget_get_type ()))))))
);
1753 gtk_tree_view_set_cursor (tree_view, path,
1754 gtk_tree_view_get_column (tree_view, 0),
1755 FALSE(0));
1756 update_custom_shortcut (model, &iter);
1757 }
1758 else
1759 {
1760 idle_data = g_new (IdleData, 1)((IdleData *) g_malloc_n ((1), sizeof (IdleData)));
1761 idle_data->tree_view = tree_view;
1762 idle_data->path = path;
1763 idle_data->column = key->desc_editable ? column :
1764 gtk_tree_view_get_column (tree_view, 1);
1765 g_idle_add ((GSourceFunc) real_start_editing_cb, idle_data);
1766 block_accels = TRUE(!(0));
1767 }
1768 g_signal_stop_emission_by_name (tree_view, "button_press_event");
1769 }
1770 return TRUE(!(0));
1771}
1772
1773/* this handler is used to keep accels from activating while the user
1774 * is assigning a new shortcut so that he won't accidentally trigger one
1775 * of the widgets */
1776static gboolean maybe_block_accels(GtkWidget* widget, GdkEventKey* event, gpointer user_data)
1777{
1778 if (block_accels)
1779 {
1780 return gtk_window_propagate_key_event(GTK_WINDOW(widget)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_window_get_type ()))))))
, event);
1781 }
1782
1783 return FALSE(0);
1784}
1785
1786static void
1787cb_dialog_response (GtkWidget *widget, gint response_id, gpointer data)
1788{
1789 GtkBuilder *builder = data;
1790 GtkTreeView *treeview;
1791 GtkTreeModel *model;
1792 GtkTreeSelection *selection;
1793 GtkTreeIter iter;
1794
1795 treeview = GTK_TREE_VIEW (gtk_builder_get_object (builder,((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, "shortcut_treeview"))),
((gtk_tree_view_get_type ()))))))
1796 "shortcut_treeview"))((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, "shortcut_treeview"))),
((gtk_tree_view_get_type ()))))))
;
1797 model = gtk_tree_view_get_model (treeview);
1798
1799 if (response_id == GTK_RESPONSE_HELP)
1800 {
1801 capplet_help (GTK_WINDOW (widget)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_window_get_type ()))))))
,
1802 "goscustdesk-39");
1803 }
1804 else if (response_id == RESPONSE_ADD0)
1805 {
1806 add_custom_shortcut (treeview, model);
1807 }
1808 else if (response_id == RESPONSE_REMOVE1)
1809 {
1810 selection = gtk_tree_view_get_selection (treeview);
1811 if (gtk_tree_selection_get_selected (selection, NULL((void*)0), &iter))
1812 {
1813 remove_custom_shortcut (model, &iter);
1814 }
1815 }
1816 else
1817 {
1818 clear_old_model (builder);
1819 gtk_main_quit ();
1820 }
1821}
1822
1823static void
1824selection_changed (GtkTreeSelection *selection, gpointer data)
1825{
1826 GtkWidget *button = data;
1827 GtkTreeModel *model;
1828 GtkTreeIter iter;
1829 KeyEntry *key;
1830 gboolean can_remove;
1831
1832 can_remove = FALSE(0);
1833 if (gtk_tree_selection_get_selected (selection, &model, &iter))
1834 {
1835 gtk_tree_model_get (model, &iter, KEYENTRY_COLUMN, &key, -1);
1836 if (key && key->command != NULL((void*)0) && key->editable)
1837 can_remove = TRUE(!(0));
1838 }
1839
1840 gtk_widget_set_sensitive (button, can_remove);
1841}
1842
1843static void
1844cb_app_dialog_response (GtkWidget *dialog, gint response_id, gpointer data)
1845{
1846 if (response_id == GTK_RESPONSE_OK)
1847 {
1848 GAppInfo *info;
1849 const gchar *custom_name;
1850
1851 info = gtk_app_chooser_get_app_info (GTK_APP_CHOOSER (dialog)((((GtkAppChooser*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_app_chooser_get_type ()))))))
);
1852
1853 gtk_entry_set_text (GTK_ENTRY (custom_shortcut_command_entry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((custom_shortcut_command_entry)), ((gtk_entry_get_type ()
))))))
,
1854 g_app_info_get_executable (info));
1855 /* if name isn't set yet, use the associated one */
1856 custom_name = gtk_entry_get_text (GTK_ENTRY (custom_shortcut_name_entry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((custom_shortcut_name_entry)), ((gtk_entry_get_type ())))
)))
);
1857 if (! custom_name || custom_name[0] == '\0')
1858 gtk_entry_set_text (GTK_ENTRY (custom_shortcut_name_entry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((custom_shortcut_name_entry)), ((gtk_entry_get_type ())))
)))
,
1859 g_app_info_get_display_name (info));
1860
1861 g_object_unref (info);
1862 }
1863
1864 gtk_widget_hide (dialog);
1865}
1866
1867static void
1868setup_dialog (GtkBuilder *builder, GSettings *marco_settings)
1869{
1870 GtkCellRenderer *renderer;
1871 GtkTreeViewColumn *column;
1872 GtkWidget *widget;
1873 GtkTreeView *treeview;
1874 GtkTreeSelection *selection;
1875 GtkWidget *button;
1876
1877 treeview = GTK_TREE_VIEW (gtk_builder_get_object (builder,((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, "shortcut_treeview"))),
((gtk_tree_view_get_type ()))))))
1878 "shortcut_treeview"))((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, "shortcut_treeview"))),
((gtk_tree_view_get_type ()))))))
;
1879
1880 g_signal_connect (treeview, "button_press_event",g_signal_connect_data ((treeview), ("button_press_event"), ((
(GCallback) (start_editing_cb))), (builder), ((void*)0), (GConnectFlags
) 0)
1881 G_CALLBACK (start_editing_cb), builder)g_signal_connect_data ((treeview), ("button_press_event"), ((
(GCallback) (start_editing_cb))), (builder), ((void*)0), (GConnectFlags
) 0)
;
1882 g_signal_connect (treeview, "row-activated",g_signal_connect_data ((treeview), ("row-activated"), (((GCallback
) (start_editing_kb_cb))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
1883 G_CALLBACK (start_editing_kb_cb), NULL)g_signal_connect_data ((treeview), ("row-activated"), (((GCallback
) (start_editing_kb_cb))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
;
1884
1885 renderer = gtk_cell_renderer_text_new ();
1886
1887 g_signal_connect (renderer, "edited",g_signal_connect_data ((renderer), ("edited"), (((GCallback) (
description_edited_callback))), (treeview), ((void*)0), (GConnectFlags
) 0)
1888 G_CALLBACK (description_edited_callback),g_signal_connect_data ((renderer), ("edited"), (((GCallback) (
description_edited_callback))), (treeview), ((void*)0), (GConnectFlags
) 0)
1889 treeview)g_signal_connect_data ((renderer), ("edited"), (((GCallback) (
description_edited_callback))), (treeview), ((void*)0), (GConnectFlags
) 0)
;
1890
1891 column = gtk_tree_view_column_new_with_attributes (_("Action")gettext ("Action"),
1892 renderer,
1893 "text", DESCRIPTION_COLUMN,
1894 NULL((void*)0));
1895 gtk_tree_view_column_set_cell_data_func (column, renderer, description_set_func, NULL((void*)0), NULL((void*)0));
1896 gtk_tree_view_column_set_resizable (column, FALSE(0));
1897
1898 gtk_tree_view_append_column (treeview, column);
1899 gtk_tree_view_column_set_sort_column_id (column, DESCRIPTION_COLUMN);
1900
1901 renderer = (GtkCellRenderer *) g_object_new (EGG_TYPE_CELL_RENDERER_KEYS(egg_cell_renderer_keys_get_type ()),
1902 "accel_mode", EGG_CELL_RENDERER_KEYS_MODE_X,
1903 NULL((void*)0));
1904
1905 g_signal_connect (renderer, "accel_edited",g_signal_connect_data ((renderer), ("accel_edited"), (((GCallback
) (accel_edited_callback))), (treeview), ((void*)0), (GConnectFlags
) 0)
1906 G_CALLBACK (accel_edited_callback),g_signal_connect_data ((renderer), ("accel_edited"), (((GCallback
) (accel_edited_callback))), (treeview), ((void*)0), (GConnectFlags
) 0)
1907 treeview)g_signal_connect_data ((renderer), ("accel_edited"), (((GCallback
) (accel_edited_callback))), (treeview), ((void*)0), (GConnectFlags
) 0)
;
1908
1909 g_signal_connect (renderer, "accel_cleared",g_signal_connect_data ((renderer), ("accel_cleared"), (((GCallback
) (accel_cleared_callback))), (treeview), ((void*)0), (GConnectFlags
) 0)
1910 G_CALLBACK (accel_cleared_callback),g_signal_connect_data ((renderer), ("accel_cleared"), (((GCallback
) (accel_cleared_callback))), (treeview), ((void*)0), (GConnectFlags
) 0)
1911 treeview)g_signal_connect_data ((renderer), ("accel_cleared"), (((GCallback
) (accel_cleared_callback))), (treeview), ((void*)0), (GConnectFlags
) 0)
;
1912
1913 column = gtk_tree_view_column_new_with_attributes (_("Shortcut")gettext ("Shortcut"), renderer, NULL((void*)0));
1914 gtk_tree_view_column_set_cell_data_func (column, renderer, accel_set_func, NULL((void*)0), NULL((void*)0));
1915 gtk_tree_view_column_set_resizable (column, FALSE(0));
1916
1917 gtk_tree_view_append_column (treeview, column);
1918 gtk_tree_view_column_set_sort_column_id (column, KEYENTRY_COLUMN);
1919
1920 g_signal_connect (marco_settings,g_signal_connect_data ((marco_settings), ("changed::num-workspaces"
), (((GCallback) (key_entry_controlling_key_changed))), (builder
), ((void*)0), (GConnectFlags) 0)
1921 "changed::num-workspaces",g_signal_connect_data ((marco_settings), ("changed::num-workspaces"
), (((GCallback) (key_entry_controlling_key_changed))), (builder
), ((void*)0), (GConnectFlags) 0)
1922 G_CALLBACK (key_entry_controlling_key_changed),g_signal_connect_data ((marco_settings), ("changed::num-workspaces"
), (((GCallback) (key_entry_controlling_key_changed))), (builder
), ((void*)0), (GConnectFlags) 0)
1923 builder)g_signal_connect_data ((marco_settings), ("changed::num-workspaces"
), (((GCallback) (key_entry_controlling_key_changed))), (builder
), ((void*)0), (GConnectFlags) 0)
;
1924
1925 /* set up the dialog */
1926 reload_key_entries (builder);
1927
1928 widget = _gtk_builder_get_widget (builder, "mate-keybinding-dialog");
1929 gtk_window_set_default_size (GTK_WINDOW (widget)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_window_get_type ()))))))
, 400, 500);
1930 widget = _gtk_builder_get_widget (builder, "label-suggest");
1931 gtk_label_set_line_wrap (GTK_LABEL (widget)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_label_get_type ()))))))
, TRUE(!(0)));
1932 gtk_label_set_max_width_chars (GTK_LABEL (widget)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_label_get_type ()))))))
, 60);
1933
1934 widget = _gtk_builder_get_widget (builder, "mate-keybinding-dialog");
1935 capplet_set_icon (widget, "preferences-desktop-keyboard-shortcuts");
1936 gtk_widget_show (widget);
1937
1938 g_signal_connect (widget, "key_press_event", G_CALLBACK (maybe_block_accels), NULL)g_signal_connect_data ((widget), ("key_press_event"), (((GCallback
) (maybe_block_accels))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
;
1939 g_signal_connect (widget, "response", G_CALLBACK (cb_dialog_response), builder)g_signal_connect_data ((widget), ("response"), (((GCallback) (
cb_dialog_response))), (builder), ((void*)0), (GConnectFlags)
0)
;
1940
1941 selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((treeview)), ((gtk_tree_view_get_type ()))))))
);
1942 g_signal_connect (selection, "changed",g_signal_connect_data ((selection), ("changed"), (((GCallback
) (selection_changed))), (_gtk_builder_get_widget (builder, "remove-button"
)), ((void*)0), (GConnectFlags) 0)
1943 G_CALLBACK (selection_changed),g_signal_connect_data ((selection), ("changed"), (((GCallback
) (selection_changed))), (_gtk_builder_get_widget (builder, "remove-button"
)), ((void*)0), (GConnectFlags) 0)
1944 _gtk_builder_get_widget (builder, "remove-button"))g_signal_connect_data ((selection), ("changed"), (((GCallback
) (selection_changed))), (_gtk_builder_get_widget (builder, "remove-button"
)), ((void*)0), (GConnectFlags) 0)
;
1945
1946 /* setup the custom shortcut dialog */
1947 custom_shortcut_dialog = _gtk_builder_get_widget (builder,
1948 "custom-shortcut-dialog");
1949 custom_shortcut_name_entry = _gtk_builder_get_widget (builder,
1950 "custom-shortcut-name-entry");
1951 custom_shortcut_command_entry = _gtk_builder_get_widget (builder,
1952 "custom-shortcut-command-entry");
1953 gtk_dialog_set_default_response (GTK_DIALOG (custom_shortcut_dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((custom_shortcut_dialog)), ((gtk_dialog_get_type ()))))))
,
1954 GTK_RESPONSE_OK);
1955 gtk_window_set_transient_for (GTK_WINDOW (custom_shortcut_dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((custom_shortcut_dialog)), ((gtk_window_get_type ()))))))
,
1956 GTK_WINDOW (widget)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_window_get_type ()))))))
);
1957 button = _gtk_builder_get_widget (builder, "custom-shortcut-command-button");
1958 widget = _gtk_builder_get_widget (builder, "custom-shortcut-application-dialog");
1959 g_signal_connect_swapped (button, "clicked", G_CALLBACK (gtk_dialog_run), widget)g_signal_connect_data ((button), ("clicked"), (((GCallback) (
gtk_dialog_run))), (widget), ((void*)0), G_CONNECT_SWAPPED)
;
1960 g_signal_connect (widget, "response", G_CALLBACK (cb_app_dialog_response), NULL)g_signal_connect_data ((widget), ("response"), (((GCallback) (
cb_app_dialog_response))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
;
1961 widget = gtk_app_chooser_dialog_get_widget (GTK_APP_CHOOSER_DIALOG (widget)((((GtkAppChooserDialog*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((widget)), ((gtk_app_chooser_dialog_get_type
()))))))
);
1962 gtk_app_chooser_widget_set_show_all (GTK_APP_CHOOSER_WIDGET (widget)((((GtkAppChooserWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((widget)), ((gtk_app_chooser_widget_get_type
()))))))
, TRUE(!(0)));
1963}
1964
1965static void
1966on_window_manager_change (const char *wm_name, GtkBuilder *builder)
1967{
1968 reload_key_entries (builder);
1969}
1970
1971int
1972main (int argc, char *argv[])
1973{
1974 GtkBuilder *builder;
1975 GSettings *marco_settings;
1976
1977 capplet_init (NULL((void*)0), &argc, &argv);
1978
1979 activate_settings_daemon ();
1980
1981 builder = gtk_builder_new_from_resource ("/org/mate/mcc/keybindings/mate-keybinding-properties.ui");
1982
1983 wm_common_register_window_manager_change ((GFunc) on_window_manager_change, builder);
1984
1985 marco_settings = g_settings_new ("org.mate.Marco.general");
1986
1987 setup_dialog (builder, marco_settings);
1988
1989 gtk_main ();
1990
1991 g_object_unref (marco_settings);
1992 g_object_unref (builder);
1993 return 0;
1994}
1995
1996/*
1997 * vim: sw=2 ts=8 cindent noai bs=2
1998 */
diff --git a/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-dbd148.html b/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-dbd148.html new file mode 100644 index 00000000..cd95e1d8 --- /dev/null +++ b/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-dbd148.html @@ -0,0 +1,1115 @@ + + + +theme-save.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:capplets/appearance/theme-save.c
Warning:line 64, column 4
Access of the heap area at index 3, while it holds only 3 'char' elements
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name theme-save.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/capplets/appearance -fcoverage-compilation-dir=/rootdir/capplets/appearance -resource-dir /usr/bin/../lib/clang/18 -D HAVE_CONFIG_H -I . -I ../.. -I /usr/include/marco-1 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/gio-unix-2.0 -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I ../../capplets/common -I /usr/include/udisks2 -I /usr/include/libgtop-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/libxml2 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/gio-unix-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/dconf -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I ../../ -D G_LOG_DOMAIN="appearance-properties" -I /usr/include/polkit-1 -I /usr/include/gio-unix-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I /usr/include/udisks2 -I /usr/include/libgtop-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/gio-unix-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/libxml2 -I /usr/include/harfbuzz -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/freetype2 -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/dconf -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libpng16 -D WITH_GZFILEOP -I /usr/include/sysprof-6 -I /usr/include/pixman-1 -D MATECC_DATA_DIR="/usr/local/share/mate-control-center" -D MATECC_PIXMAP_DIR="/usr/local/share/mate-control-center/pixmaps" -D WALLPAPER_DATADIR="/usr/local/share/mate-background-properties" -D BACKGROUND_DATADIR="/usr/local/share/backgrounds" -D MATE_DESKTOP_USE_UNSTABLE_API -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-06-07-044335-13427-1 -x c theme-save.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 * Copyright (C) 2007 The GNOME Foundation
3 * Written by Thomas Wood <thos@gnome.org>
4 * Jens Granseuer <jensgr@gmx.net>
5 * All Rights Reserved
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 */
21
22#include "appearance.h"
23
24#include <glib/gstdio.h>
25#include <glib/gi18n.h>
26#include <gio/gio.h>
27#include <string.h>
28
29#include "theme-save.h"
30#include "theme-util.h"
31#include "capplet-util.h"
32
33static GQuark error_quark;
34enum {
35 INVALID_THEME_NAME
36};
37
38/* taken from mate-desktop-item.c */
39static gchar *
40escape_string_and_dup (const gchar *s)
41{
42 gchar *return_value, *p;
43 const gchar *q;
44 int len = 0;
45
46 if (s == NULL((void*)0))
4
Assuming 's' is not equal to NULL
5
Taking false branch
47 return g_strdup("")g_strdup_inline ("");
48
49 q = s;
50 while (*q)
6
Loop condition is true. Entering loop body
9
Loop condition is true. Entering loop body
12
Loop condition is false. Execution continues on line 57
51 {
52 len++;
53 if (strchr ("\n\r\t\\", *q) != NULL((void*)0))
7
Assuming the condition is false
8
Taking false branch
10
Assuming the condition is false
11
Taking false branch
54 len++;
55 q++;
56 }
57 return_value = p = (gchar *) g_malloc (len + 1);
58 do
15
Loop condition is true. Execution continues on line 60
59 {
60 switch (*s)
13
Control jumps to 'case 92:' at line 74
16
Control jumps to 'case 9:' at line 62
61 {
62 case '\t':
63 *p++ = '\\';
64 *p++ = 't';
17
Access of the heap area at index 3, while it holds only 3 'char' elements
65 break;
66 case '\n':
67 *p++ = '\\';
68 *p++ = 'n';
69 break;
70 case '\r':
71 *p++ = '\\';
72 *p++ = 'r';
73 break;
74 case '\\':
75 *p++ = '\\';
76 *p++ = '\\';
77 break;
14
Execution continues on line 82
78 default:
79 *p++ = *s;
80 }
81 }
82 while (*s++);
83 return return_value;
84}
85
86static gboolean
87check_theme_name (const gchar *theme_name,
88 GError **error)
89{
90 if (theme_name == NULL((void*)0)) {
91 g_set_error (error,
92 error_quark,
93 INVALID_THEME_NAME,
94 _("Theme name must be present")gettext ("Theme name must be present"));
95 return FALSE(0);
96 }
97 return TRUE(!(0));
98}
99
100static gchar *
101str_remove_slash (const gchar *src)
102{
103 const gchar *i;
104 gchar *rtn;
105 gint len = 0;
106 i = src;
107
108 while (*i) {
109 if (*i != '/')
110 len++;
111 i++;
112 }
113
114 rtn = (gchar *) g_malloc (len + 1);
115 while (*src) {
116 if (*src != '/') {
117 *rtn = *src;
118 rtn++;
119 }
120 src++;
121 }
122 *rtn = '\0';
123 return rtn - len;
124}
125
126static gboolean
127setup_directory_structure (const gchar *theme_name,
128 GError **error)
129{
130 gchar *dir, *theme_name_dir;
131 gboolean retval = TRUE(!(0));
132
133 theme_name_dir = str_remove_slash (theme_name);
134
135 dir = g_build_filename (g_get_home_dir (), ".themes", NULL((void*)0));
136 if (!g_file_test (dir, G_FILE_TEST_EXISTS))
137 g_mkdirmkdir (dir, 0775);
138 g_free (dir);
139
140 dir = g_build_filename (g_get_home_dir (), ".themes", theme_name_dir, NULL((void*)0));
141 if (!g_file_test (dir, G_FILE_TEST_EXISTS))
142 g_mkdirmkdir (dir, 0775);
143 g_free (dir);
144
145 dir = g_build_filename (g_get_home_dir (), ".themes", theme_name_dir, "index.theme", NULL((void*)0));
146 g_free (theme_name_dir);
147
148 if (g_file_test (dir, G_FILE_TEST_EXISTS)) {
149 GtkDialog *dialog;
150 GtkWidget *button;
151 gint response;
152
153 dialog = (GtkDialog *) gtk_message_dialog_new (NULL((void*)0),
154 GTK_DIALOG_MODAL,
155 GTK_MESSAGE_QUESTION,
156 GTK_BUTTONS_CANCEL,
157 _("The theme already exists. Would you like to replace it?")gettext ("The theme already exists. Would you like to replace it?"
)
);
158 button = gtk_dialog_add_button (dialog, _("_Overwrite")gettext ("_Overwrite"), GTK_RESPONSE_ACCEPT);
159 gtk_button_set_image (GTK_BUTTON (button)((((GtkButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((button)), ((gtk_button_get_type ()))))))
,
160 gtk_image_new_from_icon_name ("document-save", GTK_ICON_SIZE_BUTTON));
161 response = gtk_dialog_run (dialog);
162 gtk_widget_destroy (GTK_WIDGET (dialog)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_widget_get_type ()))))))
);
163 retval = (response != GTK_RESPONSE_CANCEL);
164 }
165 g_free (dir);
166
167 return retval;
168}
169
170static gboolean
171write_theme_to_disk (MateThemeMetaInfo *theme_info,
172 const gchar *theme_name,
173 const gchar *theme_description,
174 gboolean save_background,
175 gboolean save_notification,
176 GError **error)
177{
178 gchar* dir;
179 gchar* theme_name_dir;
180 GFile* tmp_file;
181 GFile* target_file;
182 GOutputStream* output;
183
184 gchar* str;
185 gchar* current_background;
186
187 GSettings* settings;
188 const gchar* theme_header = ""
189 "[Desktop Entry]\n"
190 "Name=%s\n"
191 "Type=X-GNOME-Metatheme\n"
192 "Comment=%s\n"
193 "\n"
194 "[X-GNOME-Metatheme]\n"
195 "GtkTheme=%s\n"
196 "MetacityTheme=%s\n"
197 "IconTheme=%s\n";
198
199 theme_name_dir = str_remove_slash (theme_name);
200 dir = g_build_filename (g_get_home_dir (), ".themes", theme_name_dir, "index.theme~", NULL((void*)0));
201 g_free (theme_name_dir);
202
203 tmp_file = g_file_new_for_path (dir);
204 dir [strlen (dir) - 1] = '\000';
205 target_file = g_file_new_for_path (dir);
206 g_free (dir);
207
208 /* start making the theme file */
209 str = g_strdup_printf(theme_header, theme_name, theme_description, theme_info->gtk_theme_name, theme_info->marco_theme_name, theme_info->icon_theme_name);
210
211 output = G_OUTPUT_STREAM (g_file_replace (tmp_file, NULL, FALSE, G_FILE_CREATE_NONE, NULL, NULL))((((GOutputStream*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((g_file_replace (tmp_file, ((void*)0), (0), G_FILE_CREATE_NONE
, ((void*)0), ((void*)0)))), ((g_output_stream_get_type ())))
)))
;
212 g_output_stream_write (output, str, strlen (str), NULL((void*)0), NULL((void*)0));
213 g_free (str);
214
215 if (theme_info->gtk_color_scheme) {
216 gchar *a, *tmp;
217 tmp = g_strdup (theme_info->gtk_color_scheme)g_strdup_inline (theme_info->gtk_color_scheme);
218 for (a = tmp; *a != '\0'; a++)
219 if (*a == '\n')
220 *a = ',';
221 str = g_strdup_printf ("GtkColorScheme=%s\n", tmp);
222 g_output_stream_write (output, str, strlen (str), NULL((void*)0), NULL((void*)0));
223
224 g_free (str);
225 g_free (tmp);
226 }
227
228 if (theme_info->cursor_theme_name) {
229 str = g_strdup_printf ("CursorTheme=%s\n"
230 "CursorSize=%i\n",
231 theme_info->cursor_theme_name,
232 theme_info->cursor_size);
233 g_output_stream_write (output, str, strlen (str), NULL((void*)0), NULL((void*)0));
234 g_free (str);
235 }
236
237 if (theme_info->notification_theme_name && save_notification) {
238 str = g_strdup_printf ("NotificationTheme=%s\n", theme_info->notification_theme_name);
239 g_output_stream_write (output, str, strlen (str), NULL((void*)0), NULL((void*)0));
240 g_free (str);
241 }
242
243 if (save_background) {
244 settings = g_settings_new (WP_SCHEMA"org.mate.background");
245 current_background = g_settings_get_string (settings, WP_FILE_KEY"picture-filename");
246
247 if (current_background != NULL((void*)0)) {
248 str = g_strdup_printf ("BackgroundImage=%s\n", current_background);
249
250 g_output_stream_write (output, str, strlen (str), NULL((void*)0), NULL((void*)0));
251
252 g_free (current_background);
253 g_free (str);
254 }
255 g_object_unref (settings);
256 }
257
258 g_file_move (tmp_file, target_file, G_FILE_COPY_OVERWRITE, NULL((void*)0), NULL((void*)0), NULL((void*)0), NULL((void*)0));
259 g_output_stream_close (output, NULL((void*)0), NULL((void*)0));
260
261 g_object_unref (tmp_file);
262 g_object_unref (target_file);
263
264 return TRUE(!(0));
265}
266
267static gboolean
268save_theme_to_disk (MateThemeMetaInfo *theme_info,
269 const gchar *theme_name,
270 const gchar *theme_description,
271 gboolean save_background,
272 gboolean save_notification,
273 GError **error)
274{
275 if (!check_theme_name (theme_name, error))
276 return FALSE(0);
277
278 if (!setup_directory_structure (theme_name, error))
279 return FALSE(0);
280
281 if (!write_theme_to_disk (theme_info, theme_name, theme_description, save_background, save_notification, error))
282 return FALSE(0);
283
284 return TRUE(!(0));
285}
286
287static void
288save_dialog_response (GtkWidget *save_dialog,
289 gint response_id,
290 AppearanceData *data)
291{
292 if (response_id == GTK_RESPONSE_OK) {
1
Assuming 'response_id' is equal to GTK_RESPONSE_OK
2
Taking true branch
293 GtkWidget *entry;
294 GtkWidget *text_view;
295 GtkTextBuffer *buffer;
296 GtkTextIter start_iter;
297 GtkTextIter end_iter;
298 gchar *buffer_text;
299 MateThemeMetaInfo *theme_info;
300 gchar *theme_description = NULL((void*)0);
301 gchar *theme_name = NULL((void*)0);
302 gboolean save_background;
303 gboolean save_notification;
304 GError *error = NULL((void*)0);
305
306 entry = appearance_capplet_get_widget (data, "save_dialog_entry")(GtkWidget*) gtk_builder_get_object(data->ui, "save_dialog_entry"
)
;
307 theme_name = escape_string_and_dup (gtk_entry_get_text (GTK_ENTRY (entry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((entry)), ((gtk_entry_get_type ()))))))
))
;
3
Calling 'escape_string_and_dup'
308
309 text_view = appearance_capplet_get_widget (data, "save_dialog_textview")(GtkWidget*) gtk_builder_get_object(data->ui, "save_dialog_textview"
)
;
310 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view)((((GtkTextView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((text_view)), ((gtk_text_view_get_type ()))))))
);
311 gtk_text_buffer_get_start_iter (buffer, &start_iter);
312 gtk_text_buffer_get_end_iter (buffer, &end_iter);
313 buffer_text = gtk_text_buffer_get_text (buffer, &start_iter, &end_iter, FALSE(0));
314 theme_description = escape_string_and_dup (buffer_text);
315 g_free (buffer_text);
316 theme_info = (MateThemeMetaInfo *) g_object_get_data (G_OBJECT (save_dialog)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((save_dialog)), (((GType) ((20) << (2))))))))
, "meta-theme-info");
317 save_background = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (((((GtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (((GtkWidget*) gtk_builder_get_object(data->ui, "save_background_checkbutton"
))), ((gtk_toggle_button_get_type ()))))))
318 appearance_capplet_get_widget (data, "save_background_checkbutton"))((((GtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (((GtkWidget*) gtk_builder_get_object(data->ui, "save_background_checkbutton"
))), ((gtk_toggle_button_get_type ()))))))
);
319 save_notification = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (((((GtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (((GtkWidget*) gtk_builder_get_object(data->ui, "save_notification_checkbutton"
))), ((gtk_toggle_button_get_type ()))))))
320 appearance_capplet_get_widget (data, "save_notification_checkbutton"))((((GtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (((GtkWidget*) gtk_builder_get_object(data->ui, "save_notification_checkbutton"
))), ((gtk_toggle_button_get_type ()))))))
);
321
322 if (save_theme_to_disk (theme_info, theme_name, theme_description, save_background, save_notification, &error)) {
323 /* remove the custom theme */
324 GtkTreeIter iter;
325
326 if (theme_find_in_model (GTK_TREE_MODEL (data->theme_store)((((GtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data->theme_store)), ((gtk_tree_model_get_type ()))))
))
, "__custom__", &iter))
327 gtk_list_store_remove (data->theme_store, &iter);
328 }
329
330 g_free (theme_name);
331 g_free (theme_description);
332 g_clear_error (&error);
333 }
334
335 gtk_widget_hide (save_dialog);
336}
337
338static void
339entry_text_changed (GtkEditable *editable,
340 AppearanceData *data)
341{
342 const gchar *text;
343 GtkWidget *button;
344
345 text = gtk_entry_get_text (GTK_ENTRY (editable)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((editable)), ((gtk_entry_get_type ()))))))
);
346 button = appearance_capplet_get_widget (data, "save_dialog_save_button")(GtkWidget*) gtk_builder_get_object(data->ui, "save_dialog_save_button"
)
;
347
348 gtk_widget_set_sensitive (button, text != NULL((void*)0) && text[0] != '\000');
349}
350
351void
352theme_save_dialog_run (MateThemeMetaInfo *theme_info,
353 AppearanceData *data)
354{
355 GtkWidget *entry;
356 GtkWidget *text_view;
357 GtkTextBuffer *text_buffer;
358
359 entry = appearance_capplet_get_widget (data, "save_dialog_entry")(GtkWidget*) gtk_builder_get_object(data->ui, "save_dialog_entry"
)
;
360 text_view = appearance_capplet_get_widget (data, "save_dialog_textview")(GtkWidget*) gtk_builder_get_object(data->ui, "save_dialog_textview"
)
;
361
362 if (data->theme_save_dialog == NULL((void*)0)) {
363 data->theme_save_dialog = appearance_capplet_get_widget (data, "theme_save_dialog")(GtkWidget*) gtk_builder_get_object(data->ui, "theme_save_dialog"
)
;
364
365 g_signal_connect (data->theme_save_dialog, "response", (GCallback) save_dialog_response, data)g_signal_connect_data ((data->theme_save_dialog), ("response"
), ((GCallback) save_dialog_response), (data), ((void*)0), (GConnectFlags
) 0)
;
366 g_signal_connect (data->theme_save_dialog, "delete-event", (GCallback) gtk_true, NULL)g_signal_connect_data ((data->theme_save_dialog), ("delete-event"
), ((GCallback) gtk_true), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
;
367 g_signal_connect (entry, "changed", (GCallback) entry_text_changed, data)g_signal_connect_data ((entry), ("changed"), ((GCallback) entry_text_changed
), (data), ((void*)0), (GConnectFlags) 0)
;
368
369 error_quark = g_quark_from_string ("mate-theme-save");
370 gtk_widget_set_size_request (text_view, 300, 100);
371 }
372
373 gtk_entry_set_text (GTK_ENTRY (entry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((entry)), ((gtk_entry_get_type ()))))))
, "");
374 entry_text_changed (GTK_EDITABLE (entry)((((GtkEditable*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((entry)), ((gtk_editable_get_type ()))))))
, data);
375 gtk_widget_grab_focus (entry);
376
377 text_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view)((((GtkTextView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((text_view)), ((gtk_text_view_get_type ()))))))
);
378 gtk_text_buffer_set_text (text_buffer, "", 0);
379 g_object_set_data (G_OBJECT (data->theme_save_dialog)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data->theme_save_dialog)), (((GType) ((20) << (
2))))))))
, "meta-theme-info", theme_info);
380 gtk_window_set_transient_for (GTK_WINDOW (data->theme_save_dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data->theme_save_dialog)), ((gtk_window_get_type ()))
))))
,
381 GET_WINDOW ("appearance_window")(((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (data->ui, ("appearance_window"
)))), ((gtk_window_get_type ())))))))
);
382 gtk_widget_show (data->theme_save_dialog);
383}
diff --git a/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-df0d78.html b/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-df0d78.html new file mode 100644 index 00000000..8acc2df9 --- /dev/null +++ b/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-df0d78.html @@ -0,0 +1,1555 @@ + + + +mate-about-me-fingerprint.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:capplets/about-me/mate-about-me-fingerprint.c
Warning:line 122, column 6
Null pointer passed to 1st parameter expecting 'nonnull'
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name mate-about-me-fingerprint.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/capplets/about-me -fcoverage-compilation-dir=/rootdir/capplets/about-me -resource-dir /usr/bin/../lib/clang/18 -D HAVE_CONFIG_H -I . -I ../.. -I ../../capplets/common -I /usr/include/udisks2 -I /usr/include/libgtop-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/libxml2 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/gio-unix-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/dconf -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I ../../ -D G_LOG_DOMAIN="about-me-properties" -I /usr/include/polkit-1 -I /usr/include/gio-unix-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -D DATADIR="/usr/local/share" -D MATECC_DATA_DIR="/usr/local/share/mate-control-center" -D MATECC_PIXMAP_DIR="/usr/local/share/mate-control-center/pixmaps" -D MATELOCALEDIR="/usr/local/share/locale" -I /usr/include/accountsservice-1.0 -I /usr/include/gio-unix-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/polkit-1 -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-06-07-044335-13427-1 -x c mate-about-me-fingerprint.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* mate-about-me-fingerprint.h
2 * Copyright (C) 2008 Bastien Nocera <hadess@hadess.net>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2, or (at your option)
7 * any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
17 * 02110-1301, USA.
18 */
19
20#include <glib/gi18n.h>
21#include <gtk/gtk.h>
22
23#include "fingerprint-strings.h"
24#include "capplet-util.h"
25
26/* This must match the number of images on the 2nd page in the UI file */
27#define MAX_ENROLL_STAGES5 5
28
29/* Translate fprintd strings */
30#define TR(s)dgettext("fprintd", s) dgettext("fprintd", s)
31
32static GDBusProxy *manager = NULL((void*)0);
33static gboolean is_disable = FALSE(0);
34
35enum {
36 STATE_NONE,
37 STATE_CLAIMED,
38 STATE_ENROLLING
39};
40
41typedef struct {
42 GtkWidget *enable;
43 GtkWidget *disable;
44
45 GtkWidget *ass;
46 GtkBuilder *dialog;
47
48 GDBusProxy *device;
49 gboolean is_swipe;
50 int num_enroll_stages;
51 int num_stages_done;
52 char *name;
53 const char *finger;
54 gint state;
55} EnrollData;
56
57void set_fingerprint_label (GtkWidget *enable, GtkWidget *disable);
58void fingerprint_button_clicked (GtkBuilder *dialog, GtkWidget *enable, GtkWidget *disable);
59
60static void create_manager (void)
61{
62 GError *error = NULL((void*)0);
63
64 manager = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
65 G_DBUS_PROXY_FLAGS_NONE,
66 NULL((void*)0),
67 "net.reactivated.Fprint",
68 "/net/reactivated/Fprint/Manager",
69 "net.reactivated.Fprint.Manager",
70 NULL((void*)0),
71 &error);
72 if (manager == NULL((void*)0)) {
73 g_warning ("Unable to contact Fprint Manager daemon: %s\n", error->message);
74 g_error_free (error);
75 }
76}
77
78static GDBusProxy*
79get_first_device (void)
80{
81 GDBusProxy *device = NULL((void*)0);
82 GVariant *ret;
83 char *device_str;
84 GError *error = NULL((void*)0);
85
86 ret = g_dbus_proxy_call_sync (manager,
87 "GetDefaultDevice",
88 g_variant_new ("()"),
89 G_DBUS_CALL_FLAGS_NONE,
90 -1,
91 NULL((void*)0),
92 &error);
93 if (ret == NULL((void*)0)) {
94 g_warning ("Could not get default fprint device: %s", error->message);
95 g_error_free (error);
96 return NULL((void*)0);
97 }
98
99 g_variant_get (ret, "(o)", &device_str);
100 g_variant_unref (ret);
101
102 device = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
103 G_DBUS_PROXY_FLAGS_NONE,
104 NULL((void*)0),
105 "net.reactivated.Fprint",
106 device_str,
107 "net.reactivated.Fprint.Device",
108 NULL((void*)0),
109 &error);
110 if (device == NULL((void*)0)) {
111 g_warning ("Unable to contact Fprint Manager daemon: %s\n", error->message);
112 g_error_free (error);
113 }
114
115 g_free (device_str);
116 return device;
117}
118
119static const char *
120get_reason_for_error (const char *dbus_error)
121{
122 if (g_str_equal (dbus_error, "net.reactivated.Fprint.Error.PermissionDenied")(strcmp ((const char *) (dbus_error), (const char *) ("net.reactivated.Fprint.Error.PermissionDenied"
)) == 0)
)
13
Null pointer passed to 1st parameter expecting 'nonnull'
123 return N_("You are not allowed to access the device. Contact your system administrator.")("You are not allowed to access the device. Contact your system administrator."
)
;
124 if (g_str_equal (dbus_error, "net.reactivated.Fprint.Error.AlreadyInUse")(strcmp ((const char *) (dbus_error), (const char *) ("net.reactivated.Fprint.Error.AlreadyInUse"
)) == 0)
)
125 return N_("The device is already in use.")("The device is already in use.");
126 if (g_str_equal (dbus_error, "net.reactivated.Fprint.Error.Internal")(strcmp ((const char *) (dbus_error), (const char *) ("net.reactivated.Fprint.Error.Internal"
)) == 0)
)
127 return N_("An internal error occurred")("An internal error occurred");
128
129 return NULL((void*)0);
130}
131
132static GtkWidget *
133get_error_dialog (const char *title,
134 const char *dbus_error,
135 GtkWindow *parent)
136{
137 GtkWidget *error_dialog;
138 const char *reason;
139
140 if (dbus_error == NULL((void*)0))
9
Assuming 'dbus_error' is equal to NULL
10
Taking true branch
141 g_warning ("get_error_dialog called with reason == NULL");
142
143 error_dialog =
144 gtk_message_dialog_new (parent,
145 GTK_DIALOG_MODAL,
146 GTK_MESSAGE_ERROR,
147 GTK_BUTTONS_OK,
148 "%s", title);
149 reason = get_reason_for_error (dbus_error);
11
Passing null pointer value via 1st parameter 'dbus_error'
12
Calling 'get_reason_for_error'
150 gtk_message_dialog_format_secondary_text
151 (GTK_MESSAGE_DIALOG (error_dialog)((((GtkMessageDialog*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((error_dialog)), ((gtk_message_dialog_get_type
()))))))
, "%s", reason ? _(reason)gettext (reason) : _(dbus_error)gettext (dbus_error));
152
153 gtk_window_set_title (GTK_WINDOW (error_dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((error_dialog)), ((gtk_window_get_type ()))))))
, ""); /* as per HIG */
154 gtk_container_set_border_width (GTK_CONTAINER (error_dialog)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((error_dialog)), ((gtk_container_get_type ()))))))
, 5);
155 gtk_dialog_set_default_response (GTK_DIALOG (error_dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((error_dialog)), ((gtk_dialog_get_type ()))))))
,
156 GTK_RESPONSE_OK);
157 gtk_window_set_modal (GTK_WINDOW (error_dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((error_dialog)), ((gtk_window_get_type ()))))))
, TRUE(!(0)));
158 gtk_window_set_position (GTK_WINDOW (error_dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((error_dialog)), ((gtk_window_get_type ()))))))
, GTK_WIN_POS_CENTER_ON_PARENT);
159
160 return error_dialog;
161}
162
163void
164set_fingerprint_label (GtkWidget *enable, GtkWidget *disable)
165{
166 gchar **enrolled_fingers;
167 GDBusProxy *device;
168 GError *error = NULL((void*)0);
169 GVariant *ret;
170
171 gtk_widget_set_no_show_all (enable, TRUE(!(0)));
172 gtk_widget_set_no_show_all (disable, TRUE(!(0)));
173
174 if (manager == NULL((void*)0)) {
175 create_manager ();
176 if (manager == NULL((void*)0)) {
177 gtk_widget_hide (enable);
178 gtk_widget_hide (disable);
179 return;
180 }
181 }
182
183 device = get_first_device ();
184 if (device == NULL((void*)0)) {
185 gtk_widget_hide (enable);
186 gtk_widget_hide (disable);
187 return;
188 }
189
190 ret = g_dbus_proxy_call_sync (device,
191 "ListEnrolledFingers",
192 g_variant_new ("(s)", ""),
193 G_DBUS_CALL_FLAGS_NONE,
194 -1,
195 NULL((void*)0),
196 &error);
197 if (ret == NULL((void*)0)) {
198 gchar *error_name = g_dbus_error_get_remote_error (error);
199 if (!g_str_equal (error_name, "net.reactivated.Fprint.Error.NoEnrolledPrints")(strcmp ((const char *) (error_name), (const char *) ("net.reactivated.Fprint.Error.NoEnrolledPrints"
)) == 0)
) {
200 gtk_widget_hide (enable);
201 gtk_widget_hide (disable);
202 g_object_unref (device);
203 g_free(error_name);
204 return;
205 }
206 g_free(error_name);
207 enrolled_fingers = NULL((void*)0);
208 } else {
209 g_variant_get (ret, "(^as)", &enrolled_fingers);
210 g_variant_unref (ret);
211 }
212
213 if (enrolled_fingers == NULL((void*)0) || g_strv_length (enrolled_fingers) == 0) {
214 gtk_widget_hide (disable);
215 gtk_widget_show (enable);
216 is_disable = FALSE(0);
217 } else {
218 gtk_widget_hide (enable);
219 gtk_widget_show (disable);
220 is_disable = TRUE(!(0));
221 }
222 g_strfreev (enrolled_fingers);
223 g_object_unref (device);
224}
225
226static void
227delete_fingerprints (void)
228{
229 GVariant *ret;
230 GDBusProxy *device;
231 GError *error = NULL((void*)0);
232
233 if (manager == NULL((void*)0)) {
234 create_manager ();
235 if (manager == NULL((void*)0))
236 return;
237 }
238
239 device = get_first_device ();
240 if (device == NULL((void*)0))
241 return;
242
243 ret = g_dbus_proxy_call_sync (device,
244 "DeleteEnrolledFingers",
245 g_variant_new ("(s)", ""),
246 G_DBUS_CALL_FLAGS_NONE,
247 -1,
248 NULL((void*)0),
249 &error);
250 if (ret == NULL((void*)0)) {
251 g_warning ("Could not delete enrolled fingers: %s", error->message);
252 g_error_free (error);
253 } else {
254 g_variant_unref (ret);
255 }
256
257 g_object_unref (device);
258}
259
260static void
261delete_fingerprints_question (GtkBuilder *dialog, GtkWidget *enable, GtkWidget *disable)
262{
263 GtkWidget *question;
264 GtkWidget *button;
265
266 question = gtk_message_dialog_new (GTK_WINDOW (gtk_builder_get_object (dialog, "about-me-dialog"))((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (dialog, "about-me-dialog"))), ((
gtk_window_get_type ()))))))
,
267 GTK_DIALOG_MODAL,
268 GTK_MESSAGE_QUESTION,
269 GTK_BUTTONS_NONE,
270 _("Delete registered fingerprints?")gettext ("Delete registered fingerprints?"));
271 gtk_dialog_add_button (GTK_DIALOG (question)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((question)), ((gtk_dialog_get_type ()))))))
, "gtk-cancel", GTK_RESPONSE_CANCEL);
272
273 button = gtk_button_new_with_mnemonic (_("_Delete Fingerprints")gettext ("_Delete Fingerprints"));
274 gtk_button_set_image (GTK_BUTTON (button)((((GtkButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((button)), ((gtk_button_get_type ()))))))
, gtk_image_new_from_icon_name ("edit-delete", GTK_ICON_SIZE_BUTTON));
275 gtk_widget_set_can_default (button, TRUE(!(0)));
276 gtk_widget_show (button);
277 gtk_dialog_add_action_widget (GTK_DIALOG (question)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((question)), ((gtk_dialog_get_type ()))))))
, button, GTK_RESPONSE_OK);
278
279 gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (question)((((GtkMessageDialog*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((question)), ((gtk_message_dialog_get_type (
)))))))
,
280 _("Do you want to delete your registered fingerprints so fingerprint login is disabled?")gettext ("Do you want to delete your registered fingerprints so fingerprint login is disabled?"
)
);
281 gtk_container_set_border_width (GTK_CONTAINER (question)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((question)), ((gtk_container_get_type ()))))))
, 5);
282 gtk_dialog_set_default_response (GTK_DIALOG (question)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((question)), ((gtk_dialog_get_type ()))))))
, GTK_RESPONSE_OK);
283 gtk_window_set_position (GTK_WINDOW (question)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((question)), ((gtk_window_get_type ()))))))
, GTK_WIN_POS_CENTER_ON_PARENT);
284 gtk_window_set_modal (GTK_WINDOW (question)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((question)), ((gtk_window_get_type ()))))))
, TRUE(!(0)));
285
286 if (gtk_dialog_run (GTK_DIALOG (question)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((question)), ((gtk_dialog_get_type ()))))))
) == GTK_RESPONSE_OK) {
287 delete_fingerprints ();
288 set_fingerprint_label (enable, disable);
289 }
290
291 gtk_widget_destroy (question);
292}
293
294static void
295enroll_data_destroy (EnrollData *data)
296{
297 GVariant *ret;
298 switch (data->state) {
299 case STATE_ENROLLING:
300 ret = g_dbus_proxy_call_sync (data->device,
301 "EnrollStop",
302 g_variant_new ("()"),
303 G_DBUS_CALL_FLAGS_NONE,
304 -1,
305 NULL((void*)0),
306 NULL((void*)0));
307 if (ret != NULL((void*)0)) {
308 g_variant_unref (ret);
309 }
310 /* fall-through */
311 case STATE_CLAIMED:
312 ret = g_dbus_proxy_call_sync (data->device,
313 "Release",
314 g_variant_new ("()"),
315 G_DBUS_CALL_FLAGS_NONE,
316 -1,
317 NULL((void*)0),
318 NULL((void*)0));
319 if (ret != NULL((void*)0)) {
320 g_variant_unref (ret);
321 }
322 /* fall-through */
323 case STATE_NONE:
324 g_free (data->name);
325 g_object_unref (data->device);
326 g_object_unref (data->dialog);
327 gtk_widget_destroy (data->ass);
328
329 g_free (data);
330 }
331}
332
333static const char *
334selected_finger (GtkBuilder *dialog)
335{
336 GtkWidget *finger_combobox;
337 int index;
338
339 finger_combobox = WID ("finger_combobox")((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (dialog, "finger_combobox"))), ((
gtk_widget_get_type ()))))))
;
340
341 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (dialog, "radiobutton1"))((((GtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (dialog, "radiobutton1"))), ((gtk_toggle_button_get_type
()))))))
)) {
342 gtk_widget_set_sensitive (finger_combobox, FALSE(0));
343 return "right-index-finger";
344 }
345
346 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (dialog, "radiobutton2"))((((GtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (dialog, "radiobutton2"))), ((gtk_toggle_button_get_type
()))))))
)) {
347 gtk_widget_set_sensitive (finger_combobox, FALSE(0));
348 return "left-index-finger";
349 }
350
351 gtk_widget_set_sensitive (finger_combobox, TRUE(!(0)));
352
353 index = gtk_combo_box_get_active (GTK_COMBO_BOX (finger_combobox)((((GtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((finger_combobox)), ((gtk_combo_box_get_type ()))))))
);
354 switch (index) {
355 case 0:
356 return "left-thumb";
357 case 1:
358 return "left-middle-finger";
359 case 2:
360 return "left-ring-finger";
361 case 3:
362 return "left-little-finger";
363 case 4:
364 return "right-thumb";
365 case 5:
366 return "right-middle-finger";
367 case 6:
368 return "right-ring-finger";
369 case 7:
370 return "right-little-finger";
371 default:
372 g_assert_not_reached ()do { g_assertion_message_expr ("about-me-properties", "mate-about-me-fingerprint.c"
, 372, ((const char*) (__func__)), ((void*)0)); } while (0)
;
373 }
374
375 return NULL((void*)0);
376}
377
378static void
379finger_radio_button_toggled (GtkToggleButton *button, EnrollData *data)
380{
381 char *msg;
382
383 data->finger = selected_finger (data->dialog);
384
385 msg = g_strdup_printf (TR(finger_str_to_msg (data->finger, data->is_swipe))dgettext("fprintd", finger_str_to_msg (data->finger, data->
is_swipe))
, data->name);
386 gtk_label_set_text (GTK_LABEL (gtk_builder_get_object (data->dialog, "enroll-label"))((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (data->dialog, "enroll-label")
)), ((gtk_label_get_type ()))))))
, msg);
387 g_free (msg);
388}
389
390static void
391finger_combobox_changed (GtkComboBox *combobox, EnrollData *data)
392{
393 GtkBuilder *dialog = data->dialog;
394 char *msg;
395
396 data->finger = selected_finger (data->dialog);
397
398 msg = g_strdup_printf (TR(finger_str_to_msg (data->finger, data->is_swipe))dgettext("fprintd", finger_str_to_msg (data->finger, data->
is_swipe))
, data->name);
399 gtk_label_set_text (GTK_LABEL (WID("enroll-label"))((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (dialog, "enroll-label"))), ((gtk_widget_get_type
())))))))), ((gtk_label_get_type ()))))))
, msg);
400 g_free (msg);
401}
402
403static void
404assistant_cancelled (GtkAssistant *ass, EnrollData *data)
405{
406 GtkWidget *enable, *disable;
407
408 enable = data->enable;
409 disable = data->disable;
410
411 enroll_data_destroy (data);
412 set_fingerprint_label (enable, disable);
413}
414
415static void
416on_signal (GDBusProxy *proxy G_GNUC_UNUSED__attribute__ ((__unused__)),
417 gchar *sender_name G_GNUC_UNUSED__attribute__ ((__unused__)),
418 gchar *signal_name,
419 GVariant *parameters,
420 EnrollData *data)
421{
422 char *msg;
423 gchar *result;
424 gboolean done;
425
426 if (!g_str_equal (signal_name, "EnrollStatus")(strcmp ((const char *) (signal_name), (const char *) ("EnrollStatus"
)) == 0)
) {
427 return;
428 }
429
430 GtkBuilder *dialog = data->dialog;
431
432 g_variant_get (parameters, "(sb)", &result, &done);
433
434 if (g_str_equal (result, "enroll-completed")(strcmp ((const char *) (result), (const char *) ("enroll-completed"
)) == 0)
|| g_str_equal (result, "enroll-stage-passed")(strcmp ((const char *) (result), (const char *) ("enroll-stage-passed"
)) == 0)
) {
435 char *name, *path;
436
437 data->num_stages_done++;
438 name = g_strdup_printf ("image%d", data->num_stages_done);
439 path = g_build_filename (MATECC_PIXMAP_DIR"/usr/local/share/mate-control-center/pixmaps", "print_ok.png", NULL((void*)0));
440 gtk_image_set_from_file (GTK_IMAGE (gtk_builder_get_object (dialog, name))((((GtkImage*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (dialog, name))), ((gtk_image_get_type
()))))))
, path);
441 g_free (name);
442 g_free (path);
443 }
444 if (g_str_equal (result, "enroll-completed")(strcmp ((const char *) (result), (const char *) ("enroll-completed"
)) == 0)
) {
445 gtk_label_set_text (GTK_LABEL (gtk_builder_get_object (dialog, "status-label"))((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (dialog, "status-label"))), ((gtk_label_get_type
()))))))
, _("Done!")gettext ("Done!"));
446 gtk_assistant_set_page_complete (GTK_ASSISTANT (data->ass)((((GtkAssistant*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data->ass)), ((gtk_assistant_get_type ()))))))
, WID ("page2")((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (dialog, "page2"))), ((gtk_widget_get_type
()))))))
, TRUE(!(0)));
447 }
448
449 if (done) {
450 GVariant *ret;
451 ret = g_dbus_proxy_call_sync (data->device,
452 "EnrollStop",
453 g_variant_new ("()"),
454 G_DBUS_CALL_FLAGS_NONE,
455 -1,
456 NULL((void*)0),
457 NULL((void*)0));
458 if (ret != NULL((void*)0)) {
459 g_variant_unref (ret);
460 }
461 data->state = STATE_CLAIMED;
462 if (g_str_equal (result, "enroll-completed")(strcmp ((const char *) (result), (const char *) ("enroll-completed"
)) == 0)
== FALSE(0)) {
463 /* The enrollment failed, restart it */
464 ret = g_dbus_proxy_call_sync (data->device,
465 "EnrollStart",
466 g_variant_new ("(s)", data->finger),
467 G_DBUS_CALL_FLAGS_NONE,
468 -1,
469 NULL((void*)0),
470 NULL((void*)0));
471 if (ret != NULL((void*)0)) {
472 g_variant_unref (ret);
473 }
474 data->state = STATE_ENROLLING;
475 g_free (result);
476 result = g_strdup ("enroll-retry-scan")g_strdup_inline ("enroll-retry-scan");
477 } else {
478 g_free (result);
479 return;
480 }
481 }
482
483 msg = g_strdup_printf (TR(enroll_result_str_to_msg (result, data->is_swipe))dgettext("fprintd", enroll_result_str_to_msg (result, data->
is_swipe))
, data->name);
484 gtk_label_set_text (GTK_LABEL (gtk_builder_get_object (dialog, "status-label"))((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (dialog, "status-label"))), ((gtk_label_get_type
()))))))
, msg);
485 g_free (msg);
486 g_free (result);
487}
488
489static void
490assistant_prepare (GtkAssistant *ass, GtkWidget *page, EnrollData *data)
491{
492 const char *name;
493
494 name = g_object_get_data (G_OBJECT (page)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((page)), (((GType) ((20) << (2))))))))
, "name");
495 if (name == NULL((void*)0))
1
Assuming 'name' is not equal to NULL
2
Taking false branch
496 return;
497
498 if (g_str_equal (name, "enroll")(strcmp ((const char *) (name), (const char *) ("enroll")) ==
0)
) {
3
Taking true branch
499 GError *error = NULL((void*)0);
500 GtkBuilder *dialog = data->dialog;
501 char *path;
502 guint i;
503 GVariant *ret;
504 GtkWidget *d;
505 char *msg;
506 gchar *error_name;
507 GDBusProxy *p;
508
509 ret = g_dbus_proxy_call_sync (data->device,
510 "Claim",
511 g_variant_new ("(s)", ""),
512 G_DBUS_CALL_FLAGS_NONE,
513 -1,
514 NULL((void*)0),
515 &error);
516 if (error != NULL((void*)0)) {
4
Assuming 'error' is not equal to NULL
5
Taking true branch
517 /* translators:
518 * The variable is the name of the device, for example:
519 * "Could you not access "Digital Persona U.are.U 4000/4000B" device */
520 msg = g_strdup_printf (_("Could not access '%s' device")gettext ("Could not access '%s' device"), data->name);
521 error_name = g_dbus_error_get_remote_error (error);
6
Value assigned to 'error_name'
522 d = get_error_dialog (msg, error_name, GTK_WINDOW (data->ass)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data->ass)), ((gtk_window_get_type ()))))))
)
;
7
Passing 'error_name' via 2nd parameter 'dbus_error'
8
Calling 'get_error_dialog'
523 g_error_free (error);
524 gtk_dialog_run (GTK_DIALOG (d)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((d)), ((gtk_dialog_get_type ()))))))
);
525 gtk_widget_destroy (d);
526 g_free (msg);
527 g_free (error_name);
528
529 enroll_data_destroy (data);
530
531 return;
532 } else {
533 g_variant_unref (ret);
534 }
535 data->state = STATE_CLAIMED;
536
537 p = g_dbus_proxy_new_sync (g_dbus_proxy_get_connection (data->device),
538 G_DBUS_PROXY_FLAGS_NONE,
539 NULL((void*)0),
540 g_dbus_proxy_get_name (data->device),
541 g_dbus_proxy_get_object_path (data->device),
542 "org.freedesktop.DBus.Properties",
543 NULL((void*)0),
544 &error);
545 if (p == NULL((void*)0)) {
546 g_warning ("Unable to contact Fprint Device daemon: %s\n", error->message);
547 g_error_free (error);
548 return;
549 }
550 ret = g_dbus_proxy_call_sync (p,
551 "Get",
552 g_variant_new ("(ss)",
553 "net.reactivated.Fprint.Device",
554 "num-enroll-stages"),
555 G_DBUS_CALL_FLAGS_NONE,
556 -1,
557 NULL((void*)0),
558 &error);
559 g_object_unref (p);
560 if (ret == NULL((void*)0)) {
561out:
562 /* translators:
563 * The variable is the name of the device, for example:
564 * "Could you not access "Digital Persona U.are.U 4000/4000B" device */
565 msg = g_strdup_printf (_("Could not access '%s' device")gettext ("Could not access '%s' device"), data->name);
566 d = get_error_dialog (msg, "net.reactivated.Fprint.Error.Internal", GTK_WINDOW (data->ass)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data->ass)), ((gtk_window_get_type ()))))))
);
567 gtk_dialog_run (GTK_DIALOG (d)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((d)), ((gtk_dialog_get_type ()))))))
);
568 gtk_widget_destroy (d);
569 g_free (msg);
570
571 enroll_data_destroy (data);
572
573 g_error_free (error);
574 return;
575 } else {
576 GVariant *value;
577 g_variant_get (ret, "(v)", &value);
578 g_variant_get (value, "i", &data->num_enroll_stages);
579 g_variant_unref (value);
580 g_variant_unref (ret);
581 }
582
583 if (data->num_enroll_stages < 1) {
584 goto out;
585 }
586
587 /* Hide the extra "bulbs" if not needed */
588 for (i = MAX_ENROLL_STAGES5; i > data->num_enroll_stages; i--) {
589 char *image_name;
590
591 image_name = g_strdup_printf ("image%d", i);
592 gtk_widget_hide (WID (image_name)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (dialog, image_name))), ((gtk_widget_get_type
()))))))
);
593 g_free (image_name);
594 }
595 /* And set the right image */
596 {
597 char *filename;
598
599 filename = g_strdup_printf ("%s.png", data->finger);
600 path = g_build_filename (MATECC_PIXMAP_DIR"/usr/local/share/mate-control-center/pixmaps", filename, NULL((void*)0));
601 g_free (filename);
602 }
603 for (i = 1; i <= data->num_enroll_stages; i++) {
604 char *image_name;
605 image_name = g_strdup_printf ("image%d", i);
606 gtk_image_set_from_file (GTK_IMAGE (gtk_builder_get_object (dialog, image_name))((((GtkImage*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (dialog, image_name))), ((gtk_image_get_type
()))))))
, path);
607 g_free (image_name);
608 }
609 g_free (path);
610
611 g_signal_connect (data->device,g_signal_connect_data ((data->device), ("g-signal"), (((GCallback
) (on_signal))), (data), ((void*)0), (GConnectFlags) 0)
612 "g-signal",g_signal_connect_data ((data->device), ("g-signal"), (((GCallback
) (on_signal))), (data), ((void*)0), (GConnectFlags) 0)
613 G_CALLBACK (on_signal),g_signal_connect_data ((data->device), ("g-signal"), (((GCallback
) (on_signal))), (data), ((void*)0), (GConnectFlags) 0)
614 data)g_signal_connect_data ((data->device), ("g-signal"), (((GCallback
) (on_signal))), (data), ((void*)0), (GConnectFlags) 0)
;
615 ret = g_dbus_proxy_call_sync (data->device,
616 "EnrollStart",
617 g_variant_new ("(s)", data->finger),
618 G_DBUS_CALL_FLAGS_NONE,
619 -1,
620 NULL((void*)0),
621 &error);
622 if (ret == NULL((void*)0)) {
623 /* translators:
624 * The variable is the name of the device, for example:
625 * "Could you not access "Digital Persona U.are.U 4000/4000B" device */
626 msg = g_strdup_printf (_("Could not start finger capture on '%s' device")gettext ("Could not start finger capture on '%s' device"), data->name);
627 error_name = g_dbus_error_get_remote_error (error);
628 d = get_error_dialog (msg, error_name, GTK_WINDOW (data->ass)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data->ass)), ((gtk_window_get_type ()))))))
);
629 g_error_free (error);
630 gtk_dialog_run (GTK_DIALOG (d)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((d)), ((gtk_dialog_get_type ()))))))
);
631 gtk_widget_destroy (d);
632 g_free (msg);
633 g_free (error_name);
634
635 enroll_data_destroy (data);
636
637 return;
638 }
639 data->state = STATE_ENROLLING;;
640 g_variant_unref (ret);
641 } else {
642 GVariant *value;
643 if (data->state == STATE_ENROLLING) {
644 value = g_dbus_proxy_call_sync (data->device,
645 "EnrollStop",
646 g_variant_new ("()"),
647 G_DBUS_CALL_FLAGS_NONE,
648 -1,
649 NULL((void*)0),
650 NULL((void*)0));
651 if (value != NULL((void*)0)) {
652 g_variant_unref (value);
653 }
654 data->state = STATE_CLAIMED;
655 }
656 if (data->state == STATE_CLAIMED) {
657 value = g_dbus_proxy_call_sync (data->device,
658 "Release",
659 g_variant_new ("()"),
660 G_DBUS_CALL_FLAGS_NONE,
661 -1,
662 NULL((void*)0),
663 NULL((void*)0));
664 if (value != NULL((void*)0)) {
665 g_variant_unref (value);
666 }
667 data->state = STATE_NONE;
668 }
669 }
670}
671
672static void
673enroll_fingerprints (GtkWindow *parent, GtkWidget *enable, GtkWidget *disable)
674{
675 GDBusProxy *device;
676 GtkBuilder *dialog;
677 EnrollData *data;
678 GtkWidget *ass;
679 char *msg;
680 GError *error = NULL((void*)0);
681 GVariant *ret;
682
683 device = NULL((void*)0);
684
685 if (manager == NULL((void*)0)) {
686 create_manager ();
687 if (manager != NULL((void*)0))
688 device = get_first_device ();
689 } else {
690 device = get_first_device ();
691 }
692
693 if (manager == NULL((void*)0) || device == NULL((void*)0)) {
694 GtkWidget *d;
695
696 d = get_error_dialog (_("Could not access any fingerprint readers")gettext ("Could not access any fingerprint readers"),
697 _("Please contact your system administrator for help.")gettext ("Please contact your system administrator for help."
)
,
698 parent);
699 gtk_dialog_run (GTK_DIALOG (d)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((d)), ((gtk_dialog_get_type ()))))))
);
700 gtk_widget_destroy (d);
701 return;
702 }
703
704 GDBusProxy *p;
705 p = g_dbus_proxy_new_sync (g_dbus_proxy_get_connection (device),
706 G_DBUS_PROXY_FLAGS_NONE,
707 NULL((void*)0),
708 g_dbus_proxy_get_name (device),
709 g_dbus_proxy_get_object_path (device),
710 "org.freedesktop.DBus.Properties",
711 NULL((void*)0),
712 &error);
713 if (p == NULL((void*)0)) {
714 g_warning ("Unable to contact Fprint Device daemon: %s\n", error->message);
715 g_error_free (error);
716 return;
717 }
718
719 data = g_new0 (EnrollData, 1)((EnrollData *) g_malloc0_n ((1), sizeof (EnrollData)));
720 data->device = device;
721 data->enable = enable;
722 data->disable = disable;
723
724 /* Get some details about the device */
725 ret = g_dbus_proxy_call_sync (p,
726 "GetAll",
727 g_variant_new ("(s)", "net.reactivated.Fprint.Device"),
728 G_DBUS_CALL_FLAGS_NONE,
729 -1,
730 NULL((void*)0),
731 NULL((void*)0));
732 if (ret != NULL((void*)0)) {
733 GVariantIter *iter;
734 const gchar *key;
735 GVariant *value;
736
737 g_variant_get (ret, "(a{sv})", &iter);
738 while (g_variant_iter_loop (iter, "{sv}", &key, &value))
739 {
740 if (g_str_equal (key, "name")(strcmp ((const char *) (key), (const char *) ("name")) == 0) && g_variant_is_of_type (value, G_VARIANT_TYPE ("(s)")(g_variant_type_checked_ (("(s)"))))) {
741 data->name = g_strdup (g_variant_get_string (value, NULL))g_strdup_inline (g_variant_get_string (value, ((void*)0)));
742 } else if (g_str_equal (key, "scan-type")(strcmp ((const char *) (key), (const char *) ("scan-type")) ==
0)
&& g_variant_is_of_type (value, G_VARIANT_TYPE ("(s)")(g_variant_type_checked_ (("(s)"))))) {
743 if (g_str_equal (g_variant_get_string (value, NULL), "swipe")(strcmp ((const char *) (g_variant_get_string (value, ((void*
)0))), (const char *) ("swipe")) == 0)
)
744 data->is_swipe = TRUE(!(0));
745 }
746 }
747 g_variant_iter_free (iter);
748 g_variant_unref (ret);
749 }
750 g_object_unref (p);
751
752 dialog = gtk_builder_new ();
753 if (gtk_builder_add_from_resource (dialog, "/org/mate/mcc/am/mate-about-me-fingerprint.ui", &error) == 0)
754 {
755 g_warning ("Could not parse UI definition: %s", error->message);
756 g_error_free (error);
757 }
758 data->dialog = dialog;
759
760 ass = WID ("assistant")((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (dialog, "assistant"))), ((gtk_widget_get_type
()))))))
;
761 gtk_window_set_title (GTK_WINDOW (ass)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((ass)), ((gtk_window_get_type ()))))))
, _("Enable Fingerprint Login")gettext ("Enable Fingerprint Login"));
762 gtk_window_set_transient_for (GTK_WINDOW (ass)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((ass)), ((gtk_window_get_type ()))))))
, parent);
763 gtk_window_set_position (GTK_WINDOW (ass)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((ass)), ((gtk_window_get_type ()))))))
, GTK_WIN_POS_CENTER_ON_PARENT);
764 g_signal_connect (ass, "cancel",g_signal_connect_data ((ass), ("cancel"), (((GCallback) (assistant_cancelled
))), (data), ((void*)0), (GConnectFlags) 0)
765 G_CALLBACK (assistant_cancelled),g_signal_connect_data ((ass), ("cancel"), (((GCallback) (assistant_cancelled
))), (data), ((void*)0), (GConnectFlags) 0)
766 data)g_signal_connect_data ((ass), ("cancel"), (((GCallback) (assistant_cancelled
))), (data), ((void*)0), (GConnectFlags) 0)
;
767 g_signal_connect (ass, "close",g_signal_connect_data ((ass), ("close"), (((GCallback) (assistant_cancelled
))), (data), ((void*)0), (GConnectFlags) 0)
768 G_CALLBACK (assistant_cancelled),g_signal_connect_data ((ass), ("close"), (((GCallback) (assistant_cancelled
))), (data), ((void*)0), (GConnectFlags) 0)
769 data)g_signal_connect_data ((ass), ("close"), (((GCallback) (assistant_cancelled
))), (data), ((void*)0), (GConnectFlags) 0)
;
770 g_signal_connect (ass, "prepare",g_signal_connect_data ((ass), ("prepare"), (((GCallback) (assistant_prepare
))), (data), ((void*)0), (GConnectFlags) 0)
771 G_CALLBACK (assistant_prepare),g_signal_connect_data ((ass), ("prepare"), (((GCallback) (assistant_prepare
))), (data), ((void*)0), (GConnectFlags) 0)
772 data)g_signal_connect_data ((ass), ("prepare"), (((GCallback) (assistant_prepare
))), (data), ((void*)0), (GConnectFlags) 0)
;
773
774 /* Page 1 */
775 gtk_combo_box_set_active (GTK_COMBO_BOX (gtk_builder_get_object (dialog, "finger_combobox"))((((GtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (dialog, "finger_combobox"))), ((
gtk_combo_box_get_type ()))))))
, 0);
776
777 g_signal_connect (gtk_builder_get_object (dialog, "radiobutton1"), "toggled",g_signal_connect_data ((gtk_builder_get_object (dialog, "radiobutton1"
)), ("toggled"), (((GCallback) (finger_radio_button_toggled))
), (data), ((void*)0), (GConnectFlags) 0)
778 G_CALLBACK (finger_radio_button_toggled),g_signal_connect_data ((gtk_builder_get_object (dialog, "radiobutton1"
)), ("toggled"), (((GCallback) (finger_radio_button_toggled))
), (data), ((void*)0), (GConnectFlags) 0)
779 data)g_signal_connect_data ((gtk_builder_get_object (dialog, "radiobutton1"
)), ("toggled"), (((GCallback) (finger_radio_button_toggled))
), (data), ((void*)0), (GConnectFlags) 0)
;
780 g_signal_connect (gtk_builder_get_object (dialog, "radiobutton2"), "toggled",g_signal_connect_data ((gtk_builder_get_object (dialog, "radiobutton2"
)), ("toggled"), (((GCallback) (finger_radio_button_toggled))
), (data), ((void*)0), (GConnectFlags) 0)
781 G_CALLBACK (finger_radio_button_toggled),g_signal_connect_data ((gtk_builder_get_object (dialog, "radiobutton2"
)), ("toggled"), (((GCallback) (finger_radio_button_toggled))
), (data), ((void*)0), (GConnectFlags) 0)
782 data)g_signal_connect_data ((gtk_builder_get_object (dialog, "radiobutton2"
)), ("toggled"), (((GCallback) (finger_radio_button_toggled))
), (data), ((void*)0), (GConnectFlags) 0)
;
783 g_signal_connect (gtk_builder_get_object (dialog, "radiobutton3"), "toggled",g_signal_connect_data ((gtk_builder_get_object (dialog, "radiobutton3"
)), ("toggled"), (((GCallback) (finger_radio_button_toggled))
), (data), ((void*)0), (GConnectFlags) 0)
784 G_CALLBACK (finger_radio_button_toggled),g_signal_connect_data ((gtk_builder_get_object (dialog, "radiobutton3"
)), ("toggled"), (((GCallback) (finger_radio_button_toggled))
), (data), ((void*)0), (GConnectFlags) 0)
785 data)g_signal_connect_data ((gtk_builder_get_object (dialog, "radiobutton3"
)), ("toggled"), (((GCallback) (finger_radio_button_toggled))
), (data), ((void*)0), (GConnectFlags) 0)
;
786 g_signal_connect (gtk_builder_get_object (dialog, "finger_combobox"), "changed",g_signal_connect_data ((gtk_builder_get_object (dialog, "finger_combobox"
)), ("changed"), (((GCallback) (finger_combobox_changed))), (
data), ((void*)0), (GConnectFlags) 0)
787 G_CALLBACK (finger_combobox_changed),g_signal_connect_data ((gtk_builder_get_object (dialog, "finger_combobox"
)), ("changed"), (((GCallback) (finger_combobox_changed))), (
data), ((void*)0), (GConnectFlags) 0)
788 data)g_signal_connect_data ((gtk_builder_get_object (dialog, "finger_combobox"
)), ("changed"), (((GCallback) (finger_combobox_changed))), (
data), ((void*)0), (GConnectFlags) 0)
;
789
790 data->finger = selected_finger (dialog);
791
792 g_object_set_data (gtk_builder_get_object (dialog, "page1"), "name", "intro");
793
794 /* translators:
795 * The variable is the name of the device, for example:
796 * "To enable fingerprint login, you need to save one of your fingerprints, using the
797 * 'Digital Persona U.are.U 4000/4000B' device." */
798 msg = g_strdup_printf (_("To enable fingerprint login, you need to save one of your fingerprints, using the '%s' device.")gettext ("To enable fingerprint login, you need to save one of your fingerprints, using the '%s' device."
)
,
799 data->name);
800 gtk_label_set_text (GTK_LABEL (gtk_builder_get_object (dialog, "intro-label"))((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (dialog, "intro-label"))), ((gtk_label_get_type
()))))))
, msg);
801 g_free (msg);
802
803 gtk_assistant_set_page_complete (GTK_ASSISTANT (ass)((((GtkAssistant*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((ass)), ((gtk_assistant_get_type ()))))))
, WID("page1")((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (dialog, "page1"))), ((gtk_widget_get_type
()))))))
, TRUE(!(0)));
804
805 /* Page 2 */
806 if (data->is_swipe != FALSE(0))
807 gtk_assistant_set_page_title (GTK_ASSISTANT (ass)((((GtkAssistant*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((ass)), ((gtk_assistant_get_type ()))))))
, WID("page2")((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (dialog, "page2"))), ((gtk_widget_get_type
()))))))
, _("Swipe finger on reader")gettext ("Swipe finger on reader"));
808 else
809 gtk_assistant_set_page_title (GTK_ASSISTANT (ass)((((GtkAssistant*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((ass)), ((gtk_assistant_get_type ()))))))
, WID("page2")((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (dialog, "page2"))), ((gtk_widget_get_type
()))))))
, _("Place finger on reader")gettext ("Place finger on reader"));
810
811 g_object_set_data (G_OBJECT (WID("page2"))((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (dialog, "page2"))), ((gtk_widget_get_type
())))))))), (((GType) ((20) << (2))))))))
, "name", "enroll");
812
813 msg = g_strdup_printf (TR(finger_str_to_msg (data->finger, data->is_swipe))dgettext("fprintd", finger_str_to_msg (data->finger, data->
is_swipe))
, data->name);
814 gtk_label_set_text (GTK_LABEL (WID("enroll-label"))((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (dialog, "enroll-label"))), ((gtk_widget_get_type
())))))))), ((gtk_label_get_type ()))))))
, msg);
815 g_free (msg);
816
817 /* Page 3 */
818 g_object_set_data (G_OBJECT (WID("page3"))((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (dialog, "page3"))), ((gtk_widget_get_type
())))))))), (((GType) ((20) << (2))))))))
, "name", "summary");
819
820 data->ass = ass;
821 gtk_widget_show_all (ass);
822}
823
824void
825fingerprint_button_clicked (GtkBuilder *dialog,
826 GtkWidget *enable,
827 GtkWidget *disable)
828{
829 bindtextdomain ("fprintd", MATELOCALEDIR"/usr/local/share/locale");
830 bind_textdomain_codeset ("fprintd", "UTF-8");
831
832 if (is_disable != FALSE(0)) {
833 delete_fingerprints_question (dialog, enable, disable);
834 } else {
835 enroll_fingerprints (GTK_WINDOW (gtk_builder_get_object (dialog, "about-me-dialog"))((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (dialog, "about-me-dialog"))), ((
gtk_window_get_type ()))))))
, enable, disable);
836 }
837}
diff --git a/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-dfa6cb.html b/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-dfa6cb.html new file mode 100644 index 00000000..89016934 --- /dev/null +++ b/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-dfa6cb.html @@ -0,0 +1,2678 @@ + + + +mate-keybinding-properties.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:capplets/keybindings/mate-keybinding-properties.c
Warning:line 952, column 10
Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name mate-keybinding-properties.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/capplets/keybindings -fcoverage-compilation-dir=/rootdir/capplets/keybindings -resource-dir /usr/bin/../lib/clang/18 -D HAVE_CONFIG_H -I . -I ../.. -I ../../capplets/common -I /usr/include/udisks2 -I /usr/include/libgtop-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/libxml2 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/gio-unix-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/dconf -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I ../../ -D G_LOG_DOMAIN="keybinding-properties" -I /usr/include/polkit-1 -I /usr/include/gio-unix-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -D MATECC_DATA_DIR="/usr/local/share/mate-control-center" -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-06-07-044335-13427-1 -x c mate-keybinding-properties.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* This program was written with lots of love under the GPL by Jonathan
2 * Blandford <jrb@gnome.org>
3 */
4
5#include <config.h>
6
7#include <stdlib.h>
8#include <string.h>
9#include <gtk/gtk.h>
10#include <gio/gio.h>
11#include <gdk/gdkx.h>
12#include <X11/Xatom.h>
13#include <glib/gi18n.h>
14#include <gdk/gdkkeysyms.h>
15
16#include "wm-common.h"
17#include "capplet-util.h"
18#include "eggcellrendererkeys.h"
19#include "activate-settings-daemon.h"
20#include "dconf-util.h"
21
22#define GSETTINGS_KEYBINDINGS_DIR"/org/mate/desktop/keybindings/" "/org/mate/desktop/keybindings/"
23#define CUSTOM_KEYBINDING_SCHEMA"org.mate.control-center.keybinding" "org.mate.control-center.keybinding"
24
25#define MAX_ELEMENTS_BEFORE_SCROLLING10 10
26#define MAX_CUSTOM_SHORTCUTS1000 1000
27#define RESPONSE_ADD0 0
28#define RESPONSE_REMOVE1 1
29
30typedef struct {
31 /* The untranslated name, combine with ->package to translate */
32 char *name;
33 /* The gettext package to use to translate the section title */
34 char *package;
35 /* Name of the window manager the keys would apply to */
36 char *wm_name;
37 /* The GSettings schema for the whole file */
38 char *schema;
39 /* an array of KeyListEntry */
40 GArray *entries;
41} KeyList;
42
43typedef enum {
44 COMPARISON_NONE = 0,
45 COMPARISON_GT,
46 COMPARISON_LT,
47 COMPARISON_EQ
48} Comparison;
49
50typedef struct
51{
52 char *gsettings_path;
53 char *schema;
54 char *name;
55 int value;
56 char *value_schema; /* gsettings schema for key/value */
57 char *value_key;
58 char *description;
59 char *description_key;
60 char *cmd_key;
61 Comparison comparison;
62} KeyListEntry;
63
64enum
65{
66 DESCRIPTION_COLUMN,
67 KEYENTRY_COLUMN,
68 N_COLUMNS
69};
70
71typedef struct
72{
73 GSettings *settings;
74 char *gsettings_path;
75 char *gsettings_key;
76 guint keyval;
77 guint keycode;
78 EggVirtualModifierType mask;
79 gboolean editable;
80 GtkTreeModel *model;
81 char *description;
82 char *desc_gsettings_key;
83 gboolean desc_editable;
84 char *command;
85 char *cmd_gsettings_key;
86 gboolean cmd_editable;
87 gulong gsettings_cnxn;
88 gulong gsettings_cnxn_desc;
89 gulong gsettings_cnxn_cmd;
90} KeyEntry;
91
92static gboolean block_accels = FALSE(0);
93static GtkWidget *custom_shortcut_dialog = NULL((void*)0);
94static GtkWidget *custom_shortcut_name_entry = NULL((void*)0);
95static GtkWidget *custom_shortcut_command_entry = NULL((void*)0);
96
97static GtkWidget* _gtk_builder_get_widget(GtkBuilder* builder, const gchar* name)
98{
99 return GTK_WIDGET (gtk_builder_get_object (builder, name))((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, name))), ((gtk_widget_get_type
()))))))
;
100}
101
102static char* binding_name(guint keyval, guint keycode, EggVirtualModifierType mask, gboolean translate)
103{
104 if (keyval != 0 || keycode != 0)
105 {
106 if (translate)
107 {
108 return egg_virtual_accelerator_label (keyval, keycode, mask);
109 }
110 else
111 {
112 return egg_virtual_accelerator_name (keyval, keycode, mask);
113 }
114 }
115 else
116 {
117 return g_strdup (translate ? _("Disabled") : "")g_strdup_inline (translate ? gettext ("Disabled") : "");
118 }
119}
120
121static gboolean
122binding_from_string (const char *str,
123 guint *accelerator_key,
124 guint *keycode,
125 EggVirtualModifierType *accelerator_mods)
126{
127 g_return_val_if_fail (accelerator_key != NULL, FALSE)do { if ((accelerator_key != ((void*)0))) { } else { g_return_if_fail_warning
("keybinding-properties", ((const char*) (__func__)), "accelerator_key != NULL"
); return ((0)); } } while (0)
;
128
129 if (str == NULL((void*)0) || strcmp (str, "disabled") == 0)
130 {
131 *accelerator_key = 0;
132 *keycode = 0;
133 *accelerator_mods = 0;
134 return TRUE(!(0));
135 }
136
137 egg_accelerator_parse_virtual (str, accelerator_key, keycode, accelerator_mods);
138
139 if (*accelerator_key == 0)
140 return FALSE(0);
141 else
142 return TRUE(!(0));
143}
144
145static void
146accel_set_func (GtkTreeViewColumn *tree_column,
147 GtkCellRenderer *cell,
148 GtkTreeModel *model,
149 GtkTreeIter *iter,
150 gpointer data)
151{
152 KeyEntry *key_entry;
153
154 gtk_tree_model_get (model, iter,
155 KEYENTRY_COLUMN, &key_entry,
156 -1);
157
158 if (key_entry == NULL((void*)0))
159 g_object_set (cell,
160 "visible", FALSE(0),
161 NULL((void*)0));
162 else if (! key_entry->editable)
163 g_object_set (cell,
164 "visible", TRUE(!(0)),
165 "editable", FALSE(0),
166 "accel_key", key_entry->keyval,
167 "accel_mask", key_entry->mask,
168 "keycode", key_entry->keycode,
169 "style", PANGO_STYLE_ITALIC,
170 NULL((void*)0));
171 else
172 g_object_set (cell,
173 "visible", TRUE(!(0)),
174 "editable", TRUE(!(0)),
175 "accel_key", key_entry->keyval,
176 "accel_mask", key_entry->mask,
177 "keycode", key_entry->keycode,
178 "style", PANGO_STYLE_NORMAL,
179 NULL((void*)0));
180}
181
182static void
183description_set_func (GtkTreeViewColumn *tree_column,
184 GtkCellRenderer *cell,
185 GtkTreeModel *model,
186 GtkTreeIter *iter,
187 gpointer data)
188{
189 KeyEntry *key_entry;
190
191 gtk_tree_model_get (model, iter,
192 KEYENTRY_COLUMN, &key_entry,
193 -1);
194
195 if (key_entry != NULL((void*)0))
196 g_object_set (cell,
197 "editable", FALSE(0),
198 "text", key_entry->description != NULL((void*)0) ?
199 key_entry->description : _("<Unknown Action>")gettext ("<Unknown Action>"),
200 NULL((void*)0));
201 else
202 g_object_set (cell,
203 "editable", FALSE(0), NULL((void*)0));
204}
205
206static gboolean
207keybinding_key_changed_foreach (GtkTreeModel *model,
208 GtkTreePath *path,
209 GtkTreeIter *iter,
210 gpointer user_data)
211{
212 KeyEntry *key_entry;
213 KeyEntry *tmp_key_entry;
214
215 key_entry = (KeyEntry *)user_data;
216 gtk_tree_model_get (key_entry->model, iter,
217 KEYENTRY_COLUMN, &tmp_key_entry,
218 -1);
219
220 if (key_entry == tmp_key_entry)
221 {
222 gtk_tree_model_row_changed (key_entry->model, path, iter);
223 return TRUE(!(0));
224 }
225 return FALSE(0);
226}
227
228static void
229keybinding_key_changed (GSettings *settings,
230 gchar *key,
231 KeyEntry *key_entry)
232{
233 gchar *key_value;
234
235 key_value = g_settings_get_string (settings, key);
236
237 binding_from_string (key_value, &key_entry->keyval, &key_entry->keycode, &key_entry->mask);
238 key_entry->editable = g_settings_is_writable (settings, key);
239
240 /* update the model */
241 gtk_tree_model_foreach (key_entry->model, keybinding_key_changed_foreach, key_entry);
242}
243
244static void
245keybinding_description_changed (GSettings *settings,
246 gchar *key,
247 KeyEntry *key_entry)
248{
249 gchar *key_value;
250
251 key_value = g_settings_get_string (settings, key);
252
253 g_free (key_entry->description);
254 key_entry->description = key_value ? g_strdup (key_value)g_strdup_inline (key_value) : NULL((void*)0);
255 g_free (key_value);
256
257 key_entry->desc_editable = g_settings_is_writable (settings, key);
258
259 /* update the model */
260 gtk_tree_model_foreach (key_entry->model, keybinding_key_changed_foreach, key_entry);
261}
262
263static void
264keybinding_command_changed (GSettings *settings,
265 gchar *key,
266 KeyEntry *key_entry)
267{
268 gchar *key_value;
269
270 key_value = g_settings_get_string (settings, key);
271
272 g_free (key_entry->command);
273 key_entry->command = key_value ? g_strdup (key_value)g_strdup_inline (key_value) : NULL((void*)0);
274 key_entry->cmd_editable = g_settings_is_writable (settings, key);
275 g_free (key_value);
276
277 /* update the model */
278 gtk_tree_model_foreach (key_entry->model, keybinding_key_changed_foreach, key_entry);
279}
280
281static int
282keyentry_sort_func (GtkTreeModel *model,
283 GtkTreeIter *a,
284 GtkTreeIter *b,
285 gpointer user_data)
286{
287 KeyEntry *key_entry_a;
288 KeyEntry *key_entry_b;
289 int retval;
290
291 key_entry_a = NULL((void*)0);
292 gtk_tree_model_get (model, a,
293 KEYENTRY_COLUMN, &key_entry_a,
294 -1);
295
296 key_entry_b = NULL((void*)0);
297 gtk_tree_model_get (model, b,
298 KEYENTRY_COLUMN, &key_entry_b,
299 -1);
300
301 if (key_entry_a && key_entry_b)
302 {
303 if ((key_entry_a->keyval || key_entry_a->keycode) &&
304 (key_entry_b->keyval || key_entry_b->keycode))
305 {
306 gchar *name_a, *name_b;
307
308 name_a = binding_name (key_entry_a->keyval,
309 key_entry_a->keycode,
310 key_entry_a->mask,
311 TRUE(!(0)));
312
313 name_b = binding_name (key_entry_b->keyval,
314 key_entry_b->keycode,
315 key_entry_b->mask,
316 TRUE(!(0)));
317
318 retval = g_utf8_collate (name_a, name_b);
319
320 g_free (name_a);
321 g_free (name_b);
322 }
323 else if (key_entry_a->keyval || key_entry_a->keycode)
324 retval = -1;
325 else if (key_entry_b->keyval || key_entry_b->keycode)
326 retval = 1;
327 else
328 retval = 0;
329 }
330 else if (key_entry_a)
331 retval = -1;
332 else if (key_entry_b)
333 retval = 1;
334 else
335 retval = 0;
336
337 return retval;
338}
339
340static void
341clear_old_model (GtkBuilder *builder)
342{
343 GtkWidget *tree_view;
344 GtkWidget *actions_swindow;
345 GtkTreeModel *model;
346
347 tree_view = _gtk_builder_get_widget (builder, "shortcut_treeview");
348 model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tree_view)), ((gtk_tree_view_get_type ()))))))
);
349
350 if (model == NULL((void*)0))
351 {
352 /* create a new model */
353 model = (GtkTreeModel *) gtk_tree_store_new (N_COLUMNS, G_TYPE_STRING((GType) ((16) << (2))), G_TYPE_POINTER((GType) ((17) << (2))));
354
355 gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (model)((((GtkTreeSortable*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_sortable_get_type ()))))))
,
356 KEYENTRY_COLUMN,
357 keyentry_sort_func,
358 NULL((void*)0), NULL((void*)0));
359
360 gtk_tree_view_set_model (GTK_TREE_VIEW (tree_view)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tree_view)), ((gtk_tree_view_get_type ()))))))
, model);
361
362 g_object_unref (model);
363 }
364 else
365 {
366 /* clear the existing model */
367 gboolean valid;
368 GtkTreeIter iter;
369 KeyEntry *key_entry;
370
371 for (valid = gtk_tree_model_get_iter_first (model, &iter);
372 valid;
373 valid = gtk_tree_model_iter_next (model, &iter))
374 {
375 gtk_tree_model_get (model, &iter,
376 KEYENTRY_COLUMN, &key_entry,
377 -1);
378
379 if (key_entry != NULL((void*)0))
380 {
381 g_signal_handler_disconnect (key_entry->settings, key_entry->gsettings_cnxn);
382 if (key_entry->gsettings_cnxn_desc != 0)
383 g_signal_handler_disconnect (key_entry->settings, key_entry->gsettings_cnxn_desc);
384 if (key_entry->gsettings_cnxn_cmd != 0)
385 g_signal_handler_disconnect (key_entry->settings, key_entry->gsettings_cnxn_cmd);
386
387 g_object_unref (key_entry->settings);
388 if (key_entry->gsettings_path)
389 g_free (key_entry->gsettings_path);
390 g_free (key_entry->gsettings_key);
391 g_free (key_entry->description);
392 g_free (key_entry->desc_gsettings_key);
393 g_free (key_entry->command);
394 g_free (key_entry->cmd_gsettings_key);
395 g_free (key_entry);
396 }
397 }
398
399 gtk_tree_store_clear (GTK_TREE_STORE (model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
);
400 }
401
402 actions_swindow = _gtk_builder_get_widget (builder, "actions_swindow");
403 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (actions_swindow)((((GtkScrolledWindow*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((actions_swindow)), ((gtk_scrolled_window_get_type
()))))))
,
404 GTK_POLICY_NEVER, GTK_POLICY_NEVER);
405 gtk_widget_set_size_request (actions_swindow, -1, -1);
406}
407
408typedef struct {
409 const char *key;
410 const char *path;
411 const char *schema;
412 gboolean found;
413} KeyMatchData;
414
415static gboolean
416key_match (GtkTreeModel *model,
417 GtkTreePath *path,
418 GtkTreeIter *iter,
419 gpointer data)
420{
421 KeyMatchData *match_data = data;
422 KeyEntry *element;
423 gchar *element_schema = NULL((void*)0);
424 gchar *element_path = NULL((void*)0);
425 gboolean found = FALSE(0);
426
427 gtk_tree_model_get (model, iter,
428 KEYENTRY_COLUMN, &element,
429 -1);
430
431 if (!element)
432 return FALSE(0);
433
434 if (!element->settings || !G_IS_SETTINGS (element->settings)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(element->settings)); GType __t = ((g_settings_get_type ()
)); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))
)
435 return FALSE(0);
436
437 g_object_get (element->settings, "schema-id", &element_schema, NULL((void*)0));
438 g_object_get (element->settings, "path", &element_path, NULL((void*)0));
439
440 if ((g_strcmp0 (element->gsettings_key, match_data->key) == 0) &&
441 (g_strcmp0 (element_schema, match_data->schema) == 0) &&
442 (g_strcmp0 (element_path, match_data->path) == 0))
443 {
444 match_data->found = TRUE(!(0));
445 found = TRUE(!(0));
446 }
447
448 g_free (element_schema);
449 g_free (element_path);
450
451 return found;
452}
453
454static gboolean key_is_already_shown(GtkTreeModel* model, const KeyListEntry* entry)
455{
456 KeyMatchData data;
457
458 data.key = entry->name;
459 data.schema = entry->schema;
460 data.path = entry->gsettings_path;
461 data.found = FALSE(0);
462 gtk_tree_model_foreach(model, key_match, &data);
463
464 return data.found;
465}
466
467static gboolean should_show_key(const KeyListEntry* entry)
468{
469 GSettings *settings;
470 int value;
471
472 if (entry->comparison == COMPARISON_NONE)
473 {
474 return TRUE(!(0));
475 }
476
477 g_return_val_if_fail(entry->value_key != NULL, FALSE)do { if ((entry->value_key != ((void*)0))) { } else { g_return_if_fail_warning
("keybinding-properties", ((const char*) (__func__)), "entry->value_key != NULL"
); return ((0)); } } while (0)
;
478 g_return_val_if_fail(entry->value_schema != NULL, FALSE)do { if ((entry->value_schema != ((void*)0))) { } else { g_return_if_fail_warning
("keybinding-properties", ((const char*) (__func__)), "entry->value_schema != NULL"
); return ((0)); } } while (0)
;
479
480 settings = g_settings_new (entry->value_schema);
481 value = g_settings_get_int (settings, entry->value_key);
482 g_object_unref (settings);
483
484 switch (entry->comparison)
485 {
486 case COMPARISON_NONE:
487 /* For compiler warnings */
488 g_assert_not_reached ()do { g_assertion_message_expr ("keybinding-properties", "mate-keybinding-properties.c"
, 488, ((const char*) (__func__)), ((void*)0)); } while (0)
;
489 return FALSE(0);
490 case COMPARISON_GT:
491 if (value > entry->value)
492 {
493 return TRUE(!(0));
494 }
495 break;
496 case COMPARISON_LT:
497 if (value < entry->value)
498 {
499 return TRUE(!(0));
500 }
501 break;
502 case COMPARISON_EQ:
503 if (value == entry->value)
504 {
505 return TRUE(!(0));
506 }
507 break;
508 }
509
510 return FALSE(0);
511}
512
513static gboolean
514count_rows_foreach (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
515{
516 gint *rows = data;
517
518 (*rows)++;
519
520 return FALSE(0);
521}
522
523static void
524ensure_scrollbar (GtkBuilder *builder, int i)
525{
526 if (i == MAX_ELEMENTS_BEFORE_SCROLLING10)
527 {
528 GtkRequisition rectangle;
529 GObject *actions_swindow = gtk_builder_get_object (builder,
530 "actions_swindow");
531 GtkWidget *treeview = _gtk_builder_get_widget (builder,
532 "shortcut_treeview");
533 gtk_widget_get_preferred_size (treeview, &rectangle, NULL((void*)0));
534 gtk_widget_set_size_request (treeview, -1, rectangle.height);
535 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (actions_swindow)((((GtkScrolledWindow*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((actions_swindow)), ((gtk_scrolled_window_get_type
()))))))
,
536 GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
537 }
538}
539
540static void
541find_section (GtkTreeModel *model,
542 GtkTreeIter *iter,
543 const char *title)
544{
545 GtkTreeStore *store;
546 gboolean success;
547
548 success = gtk_tree_model_get_iter_first (model, iter);
549 while (success)
550 {
551 char *description;
552 gint res;
553
554 gtk_tree_model_get (model, iter,
555 DESCRIPTION_COLUMN, &description,
556 -1);
557 res = g_strcmp0 (description, title);
558 g_free (description);
559 if (res == 0)
560 return;
561 success = gtk_tree_model_iter_next (model, iter);
562 }
563 store = GTK_TREE_STORE (model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
;
564 gtk_tree_store_append (store, iter, NULL((void*)0));
565 gtk_tree_store_set (store, iter,
566 DESCRIPTION_COLUMN, title,
567 -1);
568}
569
570static void
571append_keys_to_tree (GtkBuilder *builder,
572 const gchar *title,
573 const gchar *schema,
574 const gchar *package,
575 const KeyListEntry *keys_list)
576{
577 GtkTreeIter parent_iter, iter;
578 GtkTreeModel *model;
579 gint i, j;
580
581 model = gtk_tree_view_get_model (GTK_TREE_VIEW (gtk_builder_get_object (builder, "shortcut_treeview"))((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, "shortcut_treeview"))),
((gtk_tree_view_get_type ()))))))
);
582
583 /* Try to find a section parent iter, if it already exists */
584 find_section (model, &iter, title);
585 parent_iter = iter;
586
587 i = 0;
588 gtk_tree_model_foreach (model, count_rows_foreach, &i);
589
590 /* If the header we just added is the MAX_ELEMENTS_BEFORE_SCROLLING th,
591 * then we need to scroll now */
592 ensure_scrollbar (builder, i - 1);
593
594 for (j = 0; keys_list[j].name != NULL((void*)0); j++)
595 {
596 GSettings *settings = NULL((void*)0);
597 gchar *settings_path;
598 KeyEntry *key_entry;
599 const gchar *key_string;
600 gchar *key_value;
601 gchar *description;
602 gchar *command;
603
604 if (!should_show_key (&keys_list[j]))
605 continue;
606
607 if (key_is_already_shown (model, &keys_list[j]))
608 continue;
609
610 key_string = keys_list[j].name;
611
612 if (keys_list[j].gsettings_path != NULL((void*)0))
613 {
614 settings = g_settings_new_with_path (schema, keys_list[j].gsettings_path);
615 settings_path = g_strdup(keys_list[j].gsettings_path)g_strdup_inline (keys_list[j].gsettings_path);
616 }
617 else
618 {
619 settings = g_settings_new (schema);
620 settings_path = NULL((void*)0);
621 }
622
623 if (keys_list[j].description_key != NULL((void*)0))
624 {
625 /* it's a custom shortcut, so description is in gsettings */
626 description = g_settings_get_string (settings, keys_list[j].description_key);
627 }
628 else
629 {
630 /* it's from keyfile, so description need to be translated */
631 description = keys_list[j].description;
632 if (package)
633 {
634 bind_textdomain_codeset (package, "UTF-8");
635 description = dgettext (package, description);
636 }
637 else
638 {
639 description = _(description)gettext (description);
640 }
641 }
642
643 if (description == NULL((void*)0))
644 {
645 /* Only print a warning for keys that should have a schema */
646 if (keys_list[j].description_key == NULL((void*)0))
647 g_warning ("No description for key '%s'", key_string);
648 }
649
650 if (keys_list[j].cmd_key != NULL((void*)0))
651 {
652 command = g_settings_get_string (settings, keys_list[j].cmd_key);
653 }
654 else
655 {
656 command = NULL((void*)0);
657 }
658
659 key_entry = g_new0 (KeyEntry, 1)((KeyEntry *) g_malloc0_n ((1), sizeof (KeyEntry)));
660 key_entry->settings = settings;
661 key_entry->gsettings_path = settings_path;
662 key_entry->gsettings_key = g_strdup (key_string)g_strdup_inline (key_string);
663 key_entry->editable = g_settings_is_writable (settings, key_string);
664 key_entry->model = model;
665 key_entry->description = description;
666 key_entry->command = command;
667 if (keys_list[j].description_key != NULL((void*)0))
668 {
669 key_entry->desc_gsettings_key = g_strdup (keys_list[j].description_key)g_strdup_inline (keys_list[j].description_key);
670 key_entry->desc_editable = g_settings_is_writable (settings, key_entry->desc_gsettings_key);
671 gchar *gsettings_signal = g_strconcat ("changed::", key_entry->desc_gsettings_key, NULL((void*)0));
672 key_entry->gsettings_cnxn_desc = g_signal_connect (settings,g_signal_connect_data ((settings), (gsettings_signal), (((GCallback
) (keybinding_description_changed))), (key_entry), ((void*)0)
, (GConnectFlags) 0)
673 gsettings_signal,g_signal_connect_data ((settings), (gsettings_signal), (((GCallback
) (keybinding_description_changed))), (key_entry), ((void*)0)
, (GConnectFlags) 0)
674 G_CALLBACK (keybinding_description_changed),g_signal_connect_data ((settings), (gsettings_signal), (((GCallback
) (keybinding_description_changed))), (key_entry), ((void*)0)
, (GConnectFlags) 0)
675 key_entry)g_signal_connect_data ((settings), (gsettings_signal), (((GCallback
) (keybinding_description_changed))), (key_entry), ((void*)0)
, (GConnectFlags) 0)
;
676 g_free (gsettings_signal);
677 }
678 if (keys_list[j].cmd_key != NULL((void*)0))
679 {
680 key_entry->cmd_gsettings_key = g_strdup (keys_list[j].cmd_key)g_strdup_inline (keys_list[j].cmd_key);
681 key_entry->cmd_editable = g_settings_is_writable (settings, key_entry->cmd_gsettings_key);
682 gchar *gsettings_signal = g_strconcat ("changed::", key_entry->cmd_gsettings_key, NULL((void*)0));
683 key_entry->gsettings_cnxn_cmd = g_signal_connect (settings,g_signal_connect_data ((settings), (gsettings_signal), (((GCallback
) (keybinding_command_changed))), (key_entry), ((void*)0), (GConnectFlags
) 0)
684 gsettings_signal,g_signal_connect_data ((settings), (gsettings_signal), (((GCallback
) (keybinding_command_changed))), (key_entry), ((void*)0), (GConnectFlags
) 0)
685 G_CALLBACK (keybinding_command_changed),g_signal_connect_data ((settings), (gsettings_signal), (((GCallback
) (keybinding_command_changed))), (key_entry), ((void*)0), (GConnectFlags
) 0)
686 key_entry)g_signal_connect_data ((settings), (gsettings_signal), (((GCallback
) (keybinding_command_changed))), (key_entry), ((void*)0), (GConnectFlags
) 0)
;
687 g_free (gsettings_signal);
688 }
689
690 gchar *gsettings_signal = g_strconcat ("changed::", key_string, NULL((void*)0));
691 key_entry->gsettings_cnxn = g_signal_connect (settings,g_signal_connect_data ((settings), (gsettings_signal), (((GCallback
) (keybinding_key_changed))), (key_entry), ((void*)0), (GConnectFlags
) 0)
692 gsettings_signal,g_signal_connect_data ((settings), (gsettings_signal), (((GCallback
) (keybinding_key_changed))), (key_entry), ((void*)0), (GConnectFlags
) 0)
693 G_CALLBACK (keybinding_key_changed),g_signal_connect_data ((settings), (gsettings_signal), (((GCallback
) (keybinding_key_changed))), (key_entry), ((void*)0), (GConnectFlags
) 0)
694 key_entry)g_signal_connect_data ((settings), (gsettings_signal), (((GCallback
) (keybinding_key_changed))), (key_entry), ((void*)0), (GConnectFlags
) 0)
;
695 g_free (gsettings_signal);
696
697 key_value = g_settings_get_string (settings, key_string);
698 binding_from_string (key_value, &key_entry->keyval, &key_entry->keycode, &key_entry->mask);
699 g_free (key_value);
700
701 ensure_scrollbar (builder, i);
702
703 ++i;
704 gtk_tree_store_append (GTK_TREE_STORE (model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, &iter, &parent_iter);
705 /* we use the DESCRIPTION_COLUMN only for the section headers */
706 gtk_tree_store_set (GTK_TREE_STORE (model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, &iter,
707 KEYENTRY_COLUMN, key_entry,
708 -1);
709 gtk_tree_view_expand_all (GTK_TREE_VIEW (gtk_builder_get_object (builder, "shortcut_treeview"))((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, "shortcut_treeview"))),
((gtk_tree_view_get_type ()))))))
);
710 }
711
712 /* Don't show an empty section */
713 if (gtk_tree_model_iter_n_children (model, &parent_iter) == 0)
714 gtk_tree_store_remove (GTK_TREE_STORE (model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, &parent_iter);
715
716 if (i == 0)
717 gtk_widget_hide (_gtk_builder_get_widget (builder, "shortcuts_vbox"));
718 else
719 gtk_widget_show (_gtk_builder_get_widget (builder, "shortcuts_vbox"));
720}
721
722static void
723parse_start_tag (GMarkupParseContext *ctx,
724 const gchar *element_name,
725 const gchar **attr_names,
726 const gchar **attr_values,
727 gpointer user_data,
728 GError **error)
729{
730 KeyList *keylist = (KeyList *) user_data;
731 KeyListEntry key;
732 const char *name, *value_key, *description, *value_schema;
733 int value;
734 Comparison comparison;
735 const char *schema = NULL((void*)0);
736
737 name = NULL((void*)0);
738
739 /* The top-level element, names the section in the tree */
740 if (g_str_equal (element_name, "KeyListEntries")(strcmp ((const char *) (element_name), (const char *) ("KeyListEntries"
)) == 0)
)
741 {
742 const char *wm_name = NULL((void*)0);
743 const char *package = NULL((void*)0);
744
745 while (*attr_names && *attr_values)
746 {
747 if (g_str_equal (*attr_names, "name")(strcmp ((const char *) (*attr_names), (const char *) ("name"
)) == 0)
)
748 {
749 if (**attr_values)
750 name = *attr_values;
751 }
752 else if (g_str_equal (*attr_names, "wm_name")(strcmp ((const char *) (*attr_names), (const char *) ("wm_name"
)) == 0)
)
753 {
754 if (**attr_values)
755 wm_name = *attr_values;
756 }
757 else if (g_str_equal (*attr_names, "package")(strcmp ((const char *) (*attr_names), (const char *) ("package"
)) == 0)
)
758 {
759 if (**attr_values)
760 package = *attr_values;
761 }
762 else if (g_str_equal (*attr_names, "schema")(strcmp ((const char *) (*attr_names), (const char *) ("schema"
)) == 0)
)
763 {
764 if (**attr_values)
765 schema = *attr_values;
766 }
767 ++attr_names;
768 ++attr_values;
769 }
770
771 if (name)
772 {
773 if (keylist->name)
774 g_warning ("Duplicate section name");
775 g_free (keylist->name);
776 keylist->name = g_strdup (name)g_strdup_inline (name);
777 }
778 if (wm_name)
779 {
780 if (keylist->wm_name)
781 g_warning ("Duplicate window manager name");
782 g_free (keylist->wm_name);
783 keylist->wm_name = g_strdup (wm_name)g_strdup_inline (wm_name);
784 }
785 if (package)
786 {
787 if (keylist->package)
788 g_warning ("Duplicate gettext package name");
789 g_free (keylist->package);
790 keylist->package = g_strdup (package)g_strdup_inline (package);
791 }
792 if (schema)
793 {
794 if (keylist->schema)
795 g_warning ("Duplicate schema name");
796 g_free (keylist->schema);
797 keylist->schema = g_strdup (schema)g_strdup_inline (schema);
798 }
799 return;
800 }
801
802 if (!g_str_equal (element_name, "KeyListEntry")(strcmp ((const char *) (element_name), (const char *) ("KeyListEntry"
)) == 0)
803 || attr_names == NULL((void*)0)
804 || attr_values == NULL((void*)0))
805 return;
806
807 value = 0;
808 comparison = COMPARISON_NONE;
809 value_key = NULL((void*)0);
810 value_schema = NULL((void*)0);
811 description = NULL((void*)0);
812
813 while (*attr_names && *attr_values)
814 {
815 if (g_str_equal (*attr_names, "name")(strcmp ((const char *) (*attr_names), (const char *) ("name"
)) == 0)
)
816 {
817 /* skip if empty */
818 if (**attr_values)
819 name = *attr_values;
820 } else if (g_str_equal (*attr_names, "value")(strcmp ((const char *) (*attr_names), (const char *) ("value"
)) == 0)
) {
821 if (**attr_values) {
822 value = (int) g_ascii_strtoull (*attr_values, NULL((void*)0), 0);
823 }
824 } else if (g_str_equal (*attr_names, "key")(strcmp ((const char *) (*attr_names), (const char *) ("key")
) == 0)
) {
825 if (**attr_values) {
826 value_key = *attr_values;
827 }
828 } else if (g_str_equal (*attr_names, "comparison")(strcmp ((const char *) (*attr_names), (const char *) ("comparison"
)) == 0)
) {
829 if (**attr_values) {
830 if (g_str_equal (*attr_values, "gt")(strcmp ((const char *) (*attr_values), (const char *) ("gt")
) == 0)
) {
831 comparison = COMPARISON_GT;
832 } else if (g_str_equal (*attr_values, "lt")(strcmp ((const char *) (*attr_values), (const char *) ("lt")
) == 0)
) {
833 comparison = COMPARISON_LT;
834 } else if (g_str_equal (*attr_values, "eq")(strcmp ((const char *) (*attr_values), (const char *) ("eq")
) == 0)
) {
835 comparison = COMPARISON_EQ;
836 }
837 }
838 } else if (g_str_equal (*attr_names, "description")(strcmp ((const char *) (*attr_names), (const char *) ("description"
)) == 0)
) {
839 if (**attr_values) {
840 description = *attr_values;
841 }
842 } else if (g_str_equal (*attr_names, "schema")(strcmp ((const char *) (*attr_names), (const char *) ("schema"
)) == 0)
) {
843 if (**attr_values) {
844 value_schema = *attr_values;
845 }
846 }
847
848 ++attr_names;
849 ++attr_values;
850 }
851
852 if (name == NULL((void*)0))
853 return;
854
855 key.name = g_strdup (name)g_strdup_inline (name);
856 key.gsettings_path = NULL((void*)0);
857 key.description_key = NULL((void*)0);
858 key.description = g_strdup(description)g_strdup_inline (description);
859 key.schema = g_strdup(schema)g_strdup_inline (schema);
860 key.value = value;
861 if (value_key) {
862 key.value_key = g_strdup (value_key)g_strdup_inline (value_key);
863 key.value_schema = g_strdup (value_schema)g_strdup_inline (value_schema);
864 }
865 else {
866 key.value_key = NULL((void*)0);
867 key.value_schema = NULL((void*)0);
868 }
869 key.comparison = comparison;
870 key.cmd_key = NULL((void*)0);
871 g_array_append_val (keylist->entries, key)g_array_append_vals (keylist->entries, &(key), 1);
872}
873
874static gboolean
875strv_contains (char **strv,
876 char *str)
877{
878 char **p;
879
880 for (p = strv; *p; p++)
881 if (strcmp (*p, str) == 0)
882 return TRUE(!(0));
883
884 return FALSE(0);
885}
886
887static void
888append_keys_to_tree_from_file (GtkBuilder *builder,
889 const char *filename,
890 char **wm_keybindings)
891{
892 GMarkupParseContext *ctx;
893 GMarkupParser parser = { parse_start_tag, NULL((void*)0), NULL((void*)0), NULL((void*)0), NULL((void*)0) };
894 KeyList *keylist;
895 KeyListEntry key, *keys;
896 GError *err = NULL((void*)0);
897 char *buf;
898 const char *title;
899 gsize buf_len;
900 guint i;
901
902 if (!g_file_get_contents (filename, &buf, &buf_len, &err))
903 return;
904
905 keylist = g_new0 (KeyList, 1)((KeyList *) g_malloc0_n ((1), sizeof (KeyList)));
906 keylist->entries = g_array_new (FALSE(0), TRUE(!(0)), sizeof (KeyListEntry));
907 ctx = g_markup_parse_context_new (&parser, 0, keylist, NULL((void*)0));
908
909 if (!g_markup_parse_context_parse (ctx, buf, buf_len, &err))
910 {
911 g_warning ("Failed to parse '%s': '%s'", filename, err->message);
912 g_error_free (err);
913 g_free (keylist->name);
914 g_free (keylist->package);
915 g_free (keylist->wm_name);
916 g_free (keylist->schema);
917 for (i = 0; i < keylist->entries->len; i++)
918 g_free (((KeyListEntry *) &(keylist->entries->data[i]))->name);
919 g_array_free (keylist->entries, TRUE(!(0)));
920 g_free (keylist);
921 keylist = NULL((void*)0);
922 }
923 g_markup_parse_context_free (ctx);
924 g_free (buf);
925
926 if (keylist == NULL((void*)0))
927 return;
928
929 /* If there's no keys to add, or the settings apply to a window manager
930 * that's not the one we're running */
931 if (keylist->entries->len == 0
932 || (keylist->wm_name != NULL((void*)0) && !strv_contains (wm_keybindings, keylist->wm_name))
933 || keylist->name == NULL((void*)0))
934 {
935 g_free (keylist->name);
936 g_free (keylist->package);
937 g_free (keylist->wm_name);
938 g_free (keylist->schema);
939 g_array_free (keylist->entries, TRUE(!(0)));
940 g_free (keylist);
941 return;
942 }
943
944 /* Empty KeyListEntry to end the array */
945 key.name = NULL((void*)0);
946 key.description_key = NULL((void*)0);
947 key.value_key = NULL((void*)0);
948 key.value = 0;
949 key.comparison = COMPARISON_NONE;
950 g_array_append_val (keylist->entries, key)g_array_append_vals (keylist->entries, &(key), 1);
951
952 keys = (KeyListEntry *) g_array_free (keylist->entries, FALSE(0));
Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption
953 if (keylist->package)
954 {
955 bind_textdomain_codeset (keylist->package, "UTF-8");
956 title = dgettext (keylist->package, keylist->name);
957 } else {
958 title = _(keylist->name)gettext (keylist->name);
959 }
960
961 append_keys_to_tree (builder, title, keylist->schema, keylist->package, keys);
962
963 g_free (keylist->name);
964 g_free (keylist->package);
965 for (i = 0; keys[i].name != NULL((void*)0); i++)
966 g_free (keys[i].name);
967 g_free (keylist);
968}
969
970static void
971append_keys_to_tree_from_gsettings (GtkBuilder *builder, const gchar *gsettings_path)
972{
973 gchar **custom_list;
974 GArray *entries;
975 KeyListEntry key;
976 gint i;
977
978 /* load custom shortcuts from GSettings */
979 entries = g_array_new (FALSE(0), TRUE(!(0)), sizeof (KeyListEntry));
980
981 key.value_key = NULL((void*)0);
982 key.value = 0;
983 key.comparison = COMPARISON_NONE;
984
985 custom_list = dconf_util_list_subdirs (gsettings_path, FALSE(0));
986
987 if (custom_list != NULL((void*)0))
988 {
989 for (i = 0; custom_list[i] != NULL((void*)0); i++)
990 {
991 key.gsettings_path = g_strdup_printf("%s%s", gsettings_path, custom_list[i]);
992 key.name = g_strdup("binding")g_strdup_inline ("binding");
993 key.cmd_key = g_strdup("action")g_strdup_inline ("action");
994 key.description_key = g_strdup("name")g_strdup_inline ("name");
995 key.schema = NULL((void*)0);
996 g_array_append_val (entries, key)g_array_append_vals (entries, &(key), 1);
997 }
998 }
999
1000 g_strfreev (custom_list);
1001
1002 if (entries->len > 0)
1003 {
1004 KeyListEntry *keys;
1005 int i;
1006
1007 /* Empty KeyListEntry to end the array */
1008 key.gsettings_path = NULL((void*)0);
1009 key.name = NULL((void*)0);
1010 key.description_key = NULL((void*)0);
1011 key.cmd_key = NULL((void*)0);
1012 g_array_append_val (entries, key)g_array_append_vals (entries, &(key), 1);
1013
1014 keys = (KeyListEntry *) entries->data;
1015 append_keys_to_tree (builder, _("Custom Shortcuts")gettext ("Custom Shortcuts"), CUSTOM_KEYBINDING_SCHEMA"org.mate.control-center.keybinding", NULL((void*)0), keys);
1016 for (i = 0; i < entries->len; ++i)
1017 {
1018 g_free (keys[i].name);
1019 g_free (keys[i].description_key);
1020 g_free (keys[i].cmd_key);
1021 g_free (keys[i].gsettings_path);
1022 }
1023 }
1024
1025 g_array_free (entries, TRUE(!(0)));
1026}
1027
1028static void
1029reload_key_entries (GtkBuilder *builder)
1030{
1031 gchar **wm_keybindings;
1032 GList *list, *l;
1033 const gchar * const * data_dirs;
1034 GHashTable *loaded_files;
1035 guint i;
1036
1037 wm_keybindings = wm_common_get_current_keybindings();
1038
1039 clear_old_model (builder);
1040
1041 loaded_files = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
1042 data_dirs = g_get_system_data_dirs ();
1043 for (i = 0; data_dirs[i] != NULL((void*)0); i++)
1044 {
1045 g_autofree__attribute__((cleanup(g_autoptr_cleanup_generic_gfree))) gchar *dir_path = NULL((void*)0);
1046 GDir *dir;
1047 const gchar *name;
1048
1049 dir_path = g_build_filename (data_dirs[i], "mate-control-center", "keybindings", NULL((void*)0));
1050 g_debug ("Keybinding dir: %s", dir_path);
1051
1052 dir = g_dir_open (dir_path, 0, NULL((void*)0));
1053 if (!dir)
1054 continue;
1055
1056 for (name = g_dir_read_name (dir) ; name ; name = g_dir_read_name (dir))
1057 {
1058 if (g_str_has_suffix (name, ".xml")(__builtin_constant_p (".xml")? __extension__ ({ const char *
const __str = (name); const char * const __suffix = (".xml")
; gboolean __result = (0); if (__str == ((void*)0) || __suffix
== ((void*)0)) __result = (g_str_has_suffix) (__str, __suffix
); else { const size_t __str_len = strlen (((__str) + !(__str
))); const size_t __suffix_len = strlen (((__suffix) + !(__suffix
))); if (__str_len >= __suffix_len) __result = memcmp (__str
+ __str_len - __suffix_len, ((__suffix) + !(__suffix)), __suffix_len
) == 0; } __result; }) : (g_str_has_suffix) (name, ".xml") )
== FALSE(0))
1059 continue;
1060
1061 if (g_hash_table_lookup (loaded_files, name) != NULL((void*)0))
1062 {
1063 g_debug ("Not loading %s, it was already loaded from another directory", name);
1064 continue;
1065 }
1066
1067 g_hash_table_insert (loaded_files, g_strdup (name)g_strdup_inline (name), g_strdup (dir_path)g_strdup_inline (dir_path));
1068 }
1069
1070 g_dir_close (dir);
1071 }
1072 list = g_hash_table_get_keys (loaded_files);
1073 list = g_list_sort(list, (GCompareFunc) g_str_equal);
1074 for (l = list; l != NULL((void*)0); l = l->next)
1075 {
1076 g_autofree__attribute__((cleanup(g_autoptr_cleanup_generic_gfree))) gchar *path = NULL((void*)0);
1077 path = g_build_filename (g_hash_table_lookup (loaded_files, l->data), l->data, NULL((void*)0));
1078 g_debug ("Keybinding file: %s", path);
1079 append_keys_to_tree_from_file (builder, path, wm_keybindings);
1080 }
1081 g_list_free (list);
1082 g_hash_table_destroy (loaded_files);
1083
1084 /* Load custom shortcuts _after_ system-provided ones,
1085 * since some of the custom shortcuts may also be listed
1086 * in a file. Loading the custom shortcuts last makes
1087 * such keys not show up in the custom section.
1088 */
1089 append_keys_to_tree_from_gsettings (builder, GSETTINGS_KEYBINDINGS_DIR"/org/mate/desktop/keybindings/");
1090
1091 g_strfreev (wm_keybindings);
1092}
1093
1094static void
1095key_entry_controlling_key_changed (GSettings *settings, gchar *key, gpointer user_data)
1096{
1097 reload_key_entries (user_data);
1098}
1099
1100static gboolean cb_check_for_uniqueness(GtkTreeModel* model, GtkTreePath* path, GtkTreeIter* iter, KeyEntry* new_key)
1101{
1102 KeyEntry* element;
1103
1104 gtk_tree_model_get (new_key->model, iter,
1105 KEYENTRY_COLUMN, &element,
1106 -1);
1107
1108 /* no conflict for : blanks, different modifiers, or ourselves */
1109 if (element == NULL((void*)0) || new_key->mask != element->mask)
1110 {
1111 return FALSE(0);
1112 }
1113
1114 gchar *new_key_schema = NULL((void*)0);
1115 gchar *element_schema = NULL((void*)0);
1116 gchar *new_key_path = NULL((void*)0);
1117 gchar *element_path = NULL((void*)0);
1118
1119 if (new_key && new_key->settings)
1120 {
1121 g_object_get (new_key->settings, "schema-id", &new_key_schema, NULL((void*)0));
1122 g_object_get (new_key->settings, "path", &new_key_path, NULL((void*)0));
1123 }
1124
1125 if (element->settings)
1126 {
1127 g_object_get (element->settings, "schema-id", &element_schema, NULL((void*)0));
1128 g_object_get (element->settings, "path", &element_path, NULL((void*)0));
1129 }
1130
1131 if (!g_strcmp0 (new_key->gsettings_key, element->gsettings_key) &&
1132 !g_strcmp0 (new_key_schema, element_schema) &&
1133 !g_strcmp0 (new_key_path, element_path))
1134 {
1135 return FALSE(0);
1136 }
1137
1138 if (new_key->keyval != 0)
1139 {
1140 if (new_key->keyval != element->keyval)
1141 {
1142 return FALSE(0);
1143 }
1144 }
1145 else if (element->keyval != 0 || new_key->keycode != element->keycode)
1146 {
1147 return FALSE(0);
1148 }
1149
1150 new_key->editable = FALSE(0);
1151 new_key->settings = element->settings;
1152 new_key->gsettings_key = element->gsettings_key;
1153 new_key->description = element->description;
1154 new_key->desc_gsettings_key = element->desc_gsettings_key;
1155 new_key->desc_editable = element->desc_editable;
1156
1157 return TRUE(!(0));
1158}
1159
1160static const guint forbidden_keyvals[] = {
1161 /* Navigation keys */
1162 GDK_KEY_Home0xff50,
1163 GDK_KEY_Left0xff51,
1164 GDK_KEY_Up0xff52,
1165 GDK_KEY_Right0xff53,
1166 GDK_KEY_Down0xff54,
1167 GDK_KEY_Page_Up0xff55,
1168 GDK_KEY_Page_Down0xff56,
1169 GDK_KEY_End0xff57,
1170 GDK_KEY_Tab0xff09,
1171
1172 /* Return */
1173 GDK_KEY_KP_Enter0xff8d,
1174 GDK_KEY_Return0xff0d,
1175
1176 GDK_KEY_space0x020,
1177 GDK_KEY_Mode_switch0xff7e
1178};
1179
1180static gboolean keyval_is_forbidden(guint keyval)
1181{
1182 guint i;
1183
1184 for (i = 0; i < G_N_ELEMENTS(forbidden_keyvals)(sizeof (forbidden_keyvals) / sizeof ((forbidden_keyvals)[0])
)
; i++)
1185 {
1186 if (keyval == forbidden_keyvals[i])
1187 {
1188 return TRUE(!(0));
1189 }
1190 }
1191
1192 return FALSE(0);
1193}
1194
1195static void show_error(GtkWindow* parent, GError* err)
1196{
1197 GtkWidget *dialog;
1198
1199 dialog = gtk_message_dialog_new (parent,
1200 GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL,
1201 GTK_MESSAGE_WARNING,
1202 GTK_BUTTONS_OK,
1203 _("Error saving the new shortcut")gettext ("Error saving the new shortcut"));
1204
1205 gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog)((((GtkMessageDialog*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((dialog)), ((gtk_message_dialog_get_type ())
)))))
,
1206 "%s", err->message);
1207 gtk_dialog_run (GTK_DIALOG (dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_dialog_get_type ()))))))
);
1208 gtk_widget_destroy (dialog);
1209}
1210
1211static void accel_edited_callback(GtkCellRendererText* cell, const char* path_string, guint keyval, EggVirtualModifierType mask, guint keycode, gpointer data)
1212{
1213 GtkTreeView* view = (GtkTreeView*) data;
1214 GtkTreeModel* model;
1215 GtkTreePath* path = gtk_tree_path_new_from_string (path_string);
1216 GtkTreeIter iter;
1217 KeyEntry* key_entry, tmp_key;
1218 char* str;
1219
1220 block_accels = FALSE(0);
1221
1222 model = gtk_tree_view_get_model (view);
1223 gtk_tree_model_get_iter (model, &iter, path);
1224 gtk_tree_path_free (path);
1225 gtk_tree_model_get (model, &iter,
1226 KEYENTRY_COLUMN, &key_entry,
1227 -1);
1228
1229 /* sanity check */
1230 if (key_entry == NULL((void*)0))
1231 {
1232 return;
1233 }
1234
1235 /* CapsLock isn't supported as a keybinding modifier, so keep it from confusing us */
1236 mask &= ~EGG_VIRTUAL_LOCK_MASK;
1237
1238 tmp_key.model = model;
1239 tmp_key.keyval = keyval;
1240 tmp_key.keycode = keycode;
1241 tmp_key.mask = mask;
1242 tmp_key.settings = key_entry->settings;
1243 tmp_key.gsettings_key = key_entry->gsettings_key;
1244 tmp_key.description = NULL((void*)0);
1245 tmp_key.editable = TRUE(!(0)); /* kludge to stuff in a return flag */
1246
1247 if (keyval != 0 || keycode != 0) /* any number of keys can be disabled */
1248 {
1249 gtk_tree_model_foreach(model, (GtkTreeModelForeachFunc) cb_check_for_uniqueness, &tmp_key);
1250 }
1251
1252 /* Check for unmodified keys */
1253 if (tmp_key.mask == 0 && tmp_key.keycode != 0)
1254 {
1255 if ((tmp_key.keyval >= GDK_KEY_a0x061 && tmp_key.keyval <= GDK_KEY_z0x07a)
1256 || (tmp_key.keyval >= GDK_KEY_A0x041 && tmp_key.keyval <= GDK_KEY_Z0x05a)
1257 || (tmp_key.keyval >= GDK_KEY_00x030 && tmp_key.keyval <= GDK_KEY_90x039)
1258 || (tmp_key.keyval >= GDK_KEY_kana_fullstop0x4a1 && tmp_key.keyval <= GDK_KEY_semivoicedsound0x4df)
1259 || (tmp_key.keyval >= GDK_KEY_Arabic_comma0x5ac && tmp_key.keyval <= GDK_KEY_Arabic_sukun0x5f2)
1260 || (tmp_key.keyval >= GDK_KEY_Serbian_dje0x6a1 && tmp_key.keyval <= GDK_KEY_Cyrillic_HARDSIGN0x6ff)
1261 || (tmp_key.keyval >= GDK_KEY_Greek_ALPHAaccent0x7a1 && tmp_key.keyval <= GDK_KEY_Greek_omega0x7f9)
1262 || (tmp_key.keyval >= GDK_KEY_hebrew_doublelowline0xcdf && tmp_key.keyval <= GDK_KEY_hebrew_taf0xcfa)
1263 || (tmp_key.keyval >= GDK_KEY_Thai_kokai0xda1 && tmp_key.keyval <= GDK_KEY_Thai_lekkao0xdf9)
1264 || (tmp_key.keyval >= GDK_KEY_Hangul0xff31 && tmp_key.keyval <= GDK_KEY_Hangul_Special0xff3f)
1265 || (tmp_key.keyval >= GDK_KEY_Hangul_Kiyeog0xea1 && tmp_key.keyval <= GDK_KEY_Hangul_J_YeorinHieuh0xefa)
1266 || keyval_is_forbidden (tmp_key.keyval))
1267 {
1268
1269 GtkWidget *dialog;
1270 char *name;
1271
1272 name = binding_name (keyval, keycode, mask, TRUE(!(0)));
1273
1274 dialog = gtk_message_dialog_new (
1275 GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (view)))((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_widget_get_toplevel (((((GtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((view)), ((gtk_widget_get_type ()))))))))
), ((gtk_window_get_type ()))))))
,
1276 GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL,
1277 GTK_MESSAGE_WARNING,
1278 GTK_BUTTONS_CANCEL,
1279 _("The shortcut \"%s\" cannot be used because it will become impossible to type using this key.\n"gettext ("The shortcut \"%s\" cannot be used because it will become impossible to type using this key.\n"
"Please try with a key such as Control, Alt or Shift at the same time."
)
1280 "Please try with a key such as Control, Alt or Shift at the same time.")gettext ("The shortcut \"%s\" cannot be used because it will become impossible to type using this key.\n"
"Please try with a key such as Control, Alt or Shift at the same time."
)
,
1281 name);
1282
1283 g_free (name);
1284 gtk_dialog_run (GTK_DIALOG (dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_dialog_get_type ()))))))
);
1285 gtk_widget_destroy (dialog);
1286
1287 /* set it back to its previous value. */
1288 egg_cell_renderer_keys_set_accelerator(
1289 EGG_CELL_RENDERER_KEYS(cell)((((EggCellRendererKeys*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((cell)), ((egg_cell_renderer_keys_get_type
()))))))
,
1290 key_entry->keyval,
1291 key_entry->keycode,
1292 key_entry->mask);
1293 return;
1294 }
1295 }
1296
1297 /* flag to see if the new accelerator was in use by something */
1298 if (!tmp_key.editable)
1299 {
1300 GtkWidget* dialog;
1301 char* name;
1302 int response;
1303
1304 name = binding_name(keyval, keycode, mask, TRUE(!(0)));
1305
1306 dialog = gtk_message_dialog_new(
1307 GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(view)))((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_widget_get_toplevel(((((GtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((view)), ((gtk_widget_get_type ()))))))))
), ((gtk_window_get_type ()))))))
,
1308 GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL,
1309 GTK_MESSAGE_WARNING,
1310 GTK_BUTTONS_CANCEL,
1311 _("The shortcut \"%s\" is already used for\n\"%s\"")gettext ("The shortcut \"%s\" is already used for\n\"%s\""),
1312 name,
1313 tmp_key.description ? tmp_key.description : tmp_key.gsettings_key);
1314 g_free (name);
1315
1316 gtk_message_dialog_format_secondary_text (
1317 GTK_MESSAGE_DIALOG (dialog)((((GtkMessageDialog*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((dialog)), ((gtk_message_dialog_get_type ())
)))))
,
1318 _("If you reassign the shortcut to \"%s\", the \"%s\" shortcut "gettext ("If you reassign the shortcut to \"%s\", the \"%s\" shortcut "
"will be disabled.")
1319 "will be disabled.")gettext ("If you reassign the shortcut to \"%s\", the \"%s\" shortcut "
"will be disabled.")
,
1320 key_entry->description ? key_entry->description : key_entry->gsettings_key,
1321 tmp_key.description ? tmp_key.description : tmp_key.gsettings_key);
1322
1323 gtk_dialog_add_button(GTK_DIALOG (dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_dialog_get_type ()))))))
, _("_Reassign")gettext ("_Reassign"), GTK_RESPONSE_ACCEPT);
1324
1325 gtk_dialog_set_default_response(GTK_DIALOG (dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_dialog_get_type ()))))))
, GTK_RESPONSE_ACCEPT);
1326
1327 response = gtk_dialog_run (GTK_DIALOG (dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_dialog_get_type ()))))))
);
1328 gtk_widget_destroy (dialog);
1329
1330 if (response == GTK_RESPONSE_ACCEPT)
1331 {
1332 g_settings_set_string (tmp_key.settings, tmp_key.gsettings_key, "disabled");
1333
1334 str = binding_name (keyval, keycode, mask, FALSE(0));
1335 g_settings_set_string (key_entry->settings, key_entry->gsettings_key, str);
1336
1337 g_free (str);
1338 }
1339 else
1340 {
1341 /* set it back to its previous value. */
1342 egg_cell_renderer_keys_set_accelerator(
1343 EGG_CELL_RENDERER_KEYS(cell)((((EggCellRendererKeys*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((cell)), ((egg_cell_renderer_keys_get_type
()))))))
,
1344 key_entry->keyval,
1345 key_entry->keycode,
1346 key_entry->mask);
1347 }
1348
1349 return;
1350 }
1351
1352 str = binding_name (keyval, keycode, mask, FALSE(0));
1353
1354 g_settings_set_string(
1355 key_entry->settings,
1356 key_entry->gsettings_key,
1357 str);
1358
1359 g_free (str);
1360
1361}
1362
1363static void
1364accel_cleared_callback (GtkCellRendererText *cell,
1365 const char *path_string,
1366 gpointer data)
1367{
1368 GtkTreeView *view = (GtkTreeView *) data;
1369 GtkTreePath *path = gtk_tree_path_new_from_string (path_string);
1370 KeyEntry *key_entry;
1371 GtkTreeIter iter;
1372 GtkTreeModel *model;
1373
1374 block_accels = FALSE(0);
1375
1376 model = gtk_tree_view_get_model (view);
1377 gtk_tree_model_get_iter (model, &iter, path);
1378 gtk_tree_path_free (path);
1379 gtk_tree_model_get (model, &iter,
1380 KEYENTRY_COLUMN, &key_entry,
1381 -1);
1382
1383 /* sanity check */
1384 if (key_entry == NULL((void*)0))
1385 return;
1386
1387 /* Unset the key */
1388 g_settings_set_string (key_entry->settings,
1389 key_entry->gsettings_key,
1390 "disabled");
1391}
1392
1393static void
1394description_edited_callback (GtkCellRendererText *renderer,
1395 gchar *path_string,
1396 gchar *new_text,
1397 gpointer user_data)
1398{
1399 GtkTreeView *view = GTK_TREE_VIEW (user_data)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((gtk_tree_view_get_type ()))))))
;
1400 GtkTreeModel *model;
1401 GtkTreePath *path = gtk_tree_path_new_from_string (path_string);
1402 GtkTreeIter iter;
1403 KeyEntry *key_entry;
1404
1405 model = gtk_tree_view_get_model (view);
1406 gtk_tree_model_get_iter (model, &iter, path);
1407 gtk_tree_path_free (path);
1408
1409 gtk_tree_model_get (model, &iter,
1410 KEYENTRY_COLUMN, &key_entry,
1411 -1);
1412
1413 /* sanity check */
1414 if (key_entry == NULL((void*)0) || key_entry->desc_gsettings_key == NULL((void*)0))
1415 return;
1416
1417 if (!g_settings_set_string (key_entry->settings, key_entry->desc_gsettings_key, new_text))
1418 key_entry->desc_editable = FALSE(0);
1419}
1420
1421typedef struct
1422{
1423 GtkTreeView *tree_view;
1424 GtkTreePath *path;
1425 GtkTreeViewColumn *column;
1426} IdleData;
1427
1428static gboolean
1429real_start_editing_cb (IdleData *idle_data)
1430{
1431 gtk_widget_grab_focus (GTK_WIDGET (idle_data->tree_view)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((idle_data->tree_view)), ((gtk_widget_get_type ())))))
)
);
1432 gtk_tree_view_set_cursor (idle_data->tree_view,
1433 idle_data->path,
1434 idle_data->column,
1435 TRUE(!(0)));
1436 gtk_tree_path_free (idle_data->path);
1437 g_free (idle_data);
1438 return FALSE(0);
1439}
1440
1441static gboolean
1442edit_custom_shortcut (KeyEntry *key)
1443{
1444 gint result;
1445 const gchar *text;
1446 gboolean ret;
1447
1448 gtk_entry_set_text (GTK_ENTRY (custom_shortcut_name_entry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((custom_shortcut_name_entry)), ((gtk_entry_get_type ())))
)))
, key->description ? key->description : "");
1449 gtk_widget_set_sensitive (custom_shortcut_name_entry, key->desc_editable);
1450 gtk_widget_grab_focus (custom_shortcut_name_entry);
1451 gtk_entry_set_text (GTK_ENTRY (custom_shortcut_command_entry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((custom_shortcut_command_entry)), ((gtk_entry_get_type ()
))))))
, key->command ? key->command : "");
1452 gtk_widget_set_sensitive (custom_shortcut_command_entry, key->cmd_editable);
1453
1454 gtk_window_present (GTK_WINDOW (custom_shortcut_dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((custom_shortcut_dialog)), ((gtk_window_get_type ()))))))
);
1455 result = gtk_dialog_run (GTK_DIALOG (custom_shortcut_dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((custom_shortcut_dialog)), ((gtk_dialog_get_type ()))))))
);
1456 switch (result)
1457 {
1458 case GTK_RESPONSE_OK:
1459 text = gtk_entry_get_text (GTK_ENTRY (custom_shortcut_name_entry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((custom_shortcut_name_entry)), ((gtk_entry_get_type ())))
)))
);
1460 g_free (key->description);
1461 key->description = g_strdup (text)g_strdup_inline (text);
1462 text = gtk_entry_get_text (GTK_ENTRY (custom_shortcut_command_entry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((custom_shortcut_command_entry)), ((gtk_entry_get_type ()
))))))
);
1463 g_free (key->command);
1464 key->command = g_strdup (text)g_strdup_inline (text);
1465 ret = TRUE(!(0));
1466 break;
1467 default:
1468 ret = FALSE(0);
1469 break;
1470 }
1471
1472 gtk_widget_hide (custom_shortcut_dialog);
1473
1474 return ret;
1475}
1476
1477static gboolean
1478remove_custom_shortcut (GtkTreeModel *model, GtkTreeIter *iter)
1479{
1480 GtkTreeIter parent;
1481 KeyEntry *key;
1482
1483 gtk_tree_model_get (model, iter,
1484 KEYENTRY_COLUMN, &key,
1485 -1);
1486
1487 /* not a custom shortcut */
1488 if (key->command == NULL((void*)0))
1489 return FALSE(0);
1490
1491 g_signal_handler_disconnect (key->settings, key->gsettings_cnxn);
1492 if (key->gsettings_cnxn_desc != 0)
1493 g_signal_handler_disconnect (key->settings, key->gsettings_cnxn_desc);
1494 if (key->gsettings_cnxn_cmd != 0)
1495 g_signal_handler_disconnect (key->settings, key->gsettings_cnxn_cmd);
1496
1497 dconf_util_recursive_reset (key->gsettings_path, NULL((void*)0));
1498 g_object_unref (key->settings);
1499
1500 g_free (key->gsettings_path);
1501 g_free (key->gsettings_key);
1502 g_free (key->description);
1503 g_free (key->desc_gsettings_key);
1504 g_free (key->command);
1505 g_free (key->cmd_gsettings_key);
1506 g_free (key);
1507
1508 gtk_tree_model_iter_parent (model, &parent, iter);
1509 gtk_tree_store_remove (GTK_TREE_STORE (model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter);
1510 if (!gtk_tree_model_iter_has_child (model, &parent))
1511 gtk_tree_store_remove (GTK_TREE_STORE (model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, &parent);
1512
1513 return TRUE(!(0));
1514}
1515
1516static void
1517update_custom_shortcut (GtkTreeModel *model, GtkTreeIter *iter)
1518{
1519 KeyEntry *key;
1520
1521 gtk_tree_model_get (model, iter,
1522 KEYENTRY_COLUMN, &key,
1523 -1);
1524
1525 edit_custom_shortcut (key);
1526 if (key->command == NULL((void*)0) || key->command[0] == '\0')
1527 {
1528 remove_custom_shortcut (model, iter);
1529 }
1530 else
1531 {
1532 gtk_tree_store_set (GTK_TREE_STORE (model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, iter,
1533 KEYENTRY_COLUMN, key, -1);
1534 if (key->description != NULL((void*)0))
1535 g_settings_set_string (key->settings, key->desc_gsettings_key, key->description);
1536 else
1537 g_settings_reset (key->settings, key->desc_gsettings_key);
1538 g_settings_set_string (key->settings, key->cmd_gsettings_key, key->command);
1539 }
1540}
1541
1542static gchar *
1543find_free_gsettings_path (GError **error)
1544{
1545 gchar **existing_dirs;
1546 gchar *dir = NULL((void*)0);
1547 gchar *fulldir = NULL((void*)0);
1548 int i;
1549 int j;
1550 gboolean found;
1551
1552 existing_dirs = dconf_util_list_subdirs (GSETTINGS_KEYBINDINGS_DIR"/org/mate/desktop/keybindings/", FALSE(0));
1553
1554 for (i = 0; i < MAX_CUSTOM_SHORTCUTS1000; i++)
1555 {
1556 found = TRUE(!(0));
1557 dir = g_strdup_printf ("custom%d/", i);
1558 for (j = 0; existing_dirs[j] != NULL((void*)0); j++)
1559 if (!g_strcmp0(dir, existing_dirs[j]))
1560 {
1561 found = FALSE(0);
1562 g_free (dir);
1563 break;
1564 }
1565 if (found)
1566 break;
1567 }
1568 g_strfreev (existing_dirs);
1569
1570 if (i == MAX_CUSTOM_SHORTCUTS1000)
1571 {
1572 g_free (dir);
1573 dir = NULL((void*)0);
1574 g_set_error_literal (error,
1575 g_quark_from_string ("Keyboard Shortcuts"),
1576 0,
1577 _("Too many custom shortcuts")gettext ("Too many custom shortcuts"));
1578 }
1579
1580 fulldir = g_strdup_printf ("%s%s", GSETTINGS_KEYBINDINGS_DIR"/org/mate/desktop/keybindings/", dir);
1581 g_free (dir);
1582 return fulldir;
1583}
1584
1585static void
1586add_custom_shortcut (GtkTreeView *tree_view,
1587 GtkTreeModel *model)
1588{
1589 KeyEntry *key_entry;
1590 GtkTreeIter iter;
1591 GtkTreeIter parent_iter;
1592 GtkTreePath *path;
1593 gchar *dir;
1594 GError *error;
1595
1596 error = NULL((void*)0);
1597 dir = find_free_gsettings_path (&error);
1598 if (dir == NULL((void*)0))
1599 {
1600 show_error (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (tree_view)))((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_widget_get_toplevel (((((GtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((tree_view)), ((gtk_widget_get_type ())))
)))))), ((gtk_window_get_type ()))))))
, error);
1601
1602 g_error_free (error);
1603 return;
1604 }
1605
1606 key_entry = g_new0 (KeyEntry, 1)((KeyEntry *) g_malloc0_n ((1), sizeof (KeyEntry)));
1607 key_entry->gsettings_path = g_strdup(dir)g_strdup_inline (dir);
1608 key_entry->gsettings_key = g_strdup("binding")g_strdup_inline ("binding");
1609 key_entry->editable = TRUE(!(0));
1610 key_entry->model = model;
1611 key_entry->desc_gsettings_key = g_strdup("name")g_strdup_inline ("name");
1612 key_entry->description = g_strdup ("")g_strdup_inline ("");
1613 key_entry->desc_editable = TRUE(!(0));
1614 key_entry->cmd_gsettings_key = g_strdup("action")g_strdup_inline ("action");
1615 key_entry->command = g_strdup ("")g_strdup_inline ("");
1616 key_entry->cmd_editable = TRUE(!(0));
1617 g_free (dir);
1618
1619 if (edit_custom_shortcut (key_entry) &&
1620 key_entry->command && key_entry->command[0])
1621 {
1622 find_section (model, &iter, _("Custom Shortcuts")gettext ("Custom Shortcuts"));
1623 parent_iter = iter;
1624 gtk_tree_store_append (GTK_TREE_STORE (model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, &iter, &parent_iter);
1625 gtk_tree_store_set (GTK_TREE_STORE (model)((((GtkTreeStore*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), ((gtk_tree_store_get_type ()))))))
, &iter, KEYENTRY_COLUMN, key_entry, -1);
1626
1627 /* store in gsettings */
1628 key_entry->settings = g_settings_new_with_path (CUSTOM_KEYBINDING_SCHEMA"org.mate.control-center.keybinding", key_entry->gsettings_path);
1629 g_settings_set_string (key_entry->settings, key_entry->gsettings_key, "disabled");
1630 g_settings_set_string (key_entry->settings, key_entry->desc_gsettings_key, key_entry->description);
1631 g_settings_set_string (key_entry->settings, key_entry->cmd_gsettings_key, key_entry->command);
1632
1633 /* add gsettings watches */
1634 key_entry->gsettings_cnxn_desc = g_signal_connect (key_entry->settings,g_signal_connect_data ((key_entry->settings), ("changed::name"
), (((GCallback) (keybinding_description_changed))), (key_entry
), ((void*)0), (GConnectFlags) 0)
1635 "changed::name",g_signal_connect_data ((key_entry->settings), ("changed::name"
), (((GCallback) (keybinding_description_changed))), (key_entry
), ((void*)0), (GConnectFlags) 0)
1636 G_CALLBACK (keybinding_description_changed),g_signal_connect_data ((key_entry->settings), ("changed::name"
), (((GCallback) (keybinding_description_changed))), (key_entry
), ((void*)0), (GConnectFlags) 0)
1637 key_entry)g_signal_connect_data ((key_entry->settings), ("changed::name"
), (((GCallback) (keybinding_description_changed))), (key_entry
), ((void*)0), (GConnectFlags) 0)
;
1638 key_entry->gsettings_cnxn_cmd = g_signal_connect (key_entry->settings,g_signal_connect_data ((key_entry->settings), ("changed::action"
), (((GCallback) (keybinding_command_changed))), (key_entry),
((void*)0), (GConnectFlags) 0)
1639 "changed::action",g_signal_connect_data ((key_entry->settings), ("changed::action"
), (((GCallback) (keybinding_command_changed))), (key_entry),
((void*)0), (GConnectFlags) 0)
1640 G_CALLBACK (keybinding_command_changed),g_signal_connect_data ((key_entry->settings), ("changed::action"
), (((GCallback) (keybinding_command_changed))), (key_entry),
((void*)0), (GConnectFlags) 0)
1641 key_entry)g_signal_connect_data ((key_entry->settings), ("changed::action"
), (((GCallback) (keybinding_command_changed))), (key_entry),
((void*)0), (GConnectFlags) 0)
;
1642 key_entry->gsettings_cnxn = g_signal_connect (key_entry->settings,g_signal_connect_data ((key_entry->settings), ("changed::binding"
), (((GCallback) (keybinding_key_changed))), (key_entry), ((void
*)0), (GConnectFlags) 0)
1643 "changed::binding",g_signal_connect_data ((key_entry->settings), ("changed::binding"
), (((GCallback) (keybinding_key_changed))), (key_entry), ((void
*)0), (GConnectFlags) 0)
1644 G_CALLBACK (keybinding_key_changed),g_signal_connect_data ((key_entry->settings), ("changed::binding"
), (((GCallback) (keybinding_key_changed))), (key_entry), ((void
*)0), (GConnectFlags) 0)
1645 key_entry)g_signal_connect_data ((key_entry->settings), ("changed::binding"
), (((GCallback) (keybinding_key_changed))), (key_entry), ((void
*)0), (GConnectFlags) 0)
;
1646
1647 /* make the new shortcut visible */
1648 path = gtk_tree_model_get_path (model, &iter);
1649 gtk_tree_view_expand_to_path (tree_view, path);
1650 gtk_tree_view_scroll_to_cell (tree_view, path, NULL((void*)0), FALSE(0), 0, 0);
1651 gtk_tree_path_free (path);
1652 }
1653 else
1654 {
1655 g_free (key_entry->gsettings_path);
1656 g_free (key_entry->gsettings_key);
1657 g_free (key_entry->description);
1658 g_free (key_entry->desc_gsettings_key);
1659 g_free (key_entry->command);
1660 g_free (key_entry->cmd_gsettings_key);
1661 g_free (key_entry);
1662 }
1663}
1664
1665static void
1666start_editing_kb_cb (GtkTreeView *treeview,
1667 GtkTreePath *path,
1668 GtkTreeViewColumn *column,
1669 gpointer user_data)
1670{
1671 GtkTreeModel *model;
1672 GtkTreeIter iter;
1673 KeyEntry *key;
1674
1675 model = gtk_tree_view_get_model (treeview);
1676 gtk_tree_model_get_iter (model, &iter, path);
1677 gtk_tree_model_get (model, &iter,
1678 KEYENTRY_COLUMN, &key,
1679 -1);
1680
1681 if (key == NULL((void*)0))
1682 {
1683 /* This is a section heading - expand or collapse */
1684 if (gtk_tree_view_row_expanded (treeview, path))
1685 gtk_tree_view_collapse_row (treeview, path);
1686 else
1687 gtk_tree_view_expand_row (treeview, path, FALSE(0));
1688 return;
1689 }
1690
1691 /* if only the accel can be edited on the selected row
1692 * always select the accel column */
1693 if (key->desc_editable &&
1694 column == gtk_tree_view_get_column (treeview, 0))
1695 {
1696 gtk_widget_grab_focus (GTK_WIDGET (treeview)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((treeview)), ((gtk_widget_get_type ()))))))
);
1697 gtk_tree_view_set_cursor (treeview, path,
1698 gtk_tree_view_get_column (treeview, 0),
1699 FALSE(0));
1700 update_custom_shortcut (model, &iter);
1701 }
1702 else
1703 {
1704 gtk_widget_grab_focus (GTK_WIDGET (treeview)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((treeview)), ((gtk_widget_get_type ()))))))
);
1705 gtk_tree_view_set_cursor (treeview,
1706 path,
1707 gtk_tree_view_get_column (treeview, 1),
1708 TRUE(!(0)));
1709 }
1710}
1711
1712static gboolean
1713start_editing_cb (GtkTreeView *tree_view,
1714 GdkEventButton *event,
1715 gpointer user_data)
1716{
1717 GtkTreePath *path;
1718 GtkTreeViewColumn *column;
1719
1720 if ((event->window != gtk_tree_view_get_bin_window (tree_view)) ||
1721 (event->type != GDK_2BUTTON_PRESS))
1722 return FALSE(0);
1723
1724 if (gtk_tree_view_get_path_at_pos (tree_view,
1725 (gint) event->x,
1726 (gint) event->y,
1727 &path, &column,
1728 NULL((void*)0), NULL((void*)0)))
1729 {
1730 IdleData *idle_data;
1731 GtkTreeModel *model;
1732 GtkTreeIter iter;
1733 KeyEntry *key;
1734
1735 if (gtk_tree_path_get_depth (path) == 1)
1736 {
1737 gtk_tree_path_free (path);
1738 return FALSE(0);
1739 }
1740
1741 model = gtk_tree_view_get_model (tree_view);
1742 gtk_tree_model_get_iter (model, &iter, path);
1743 gtk_tree_model_get (model, &iter,
1744 KEYENTRY_COLUMN, &key,
1745 -1);
1746
1747 /* if only the accel can be edited on the selected row
1748 * always select the accel column */
1749 if (key->desc_editable &&
1750 column == gtk_tree_view_get_column (tree_view, 0))
1751 {
1752 gtk_widget_grab_focus (GTK_WIDGET (tree_view)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((tree_view)), ((gtk_widget_get_type ()))))))
);
1753 gtk_tree_view_set_cursor (tree_view, path,
1754 gtk_tree_view_get_column (tree_view, 0),
1755 FALSE(0));
1756 update_custom_shortcut (model, &iter);
1757 }
1758 else
1759 {
1760 idle_data = g_new (IdleData, 1)((IdleData *) g_malloc_n ((1), sizeof (IdleData)));
1761 idle_data->tree_view = tree_view;
1762 idle_data->path = path;
1763 idle_data->column = key->desc_editable ? column :
1764 gtk_tree_view_get_column (tree_view, 1);
1765 g_idle_add ((GSourceFunc) real_start_editing_cb, idle_data);
1766 block_accels = TRUE(!(0));
1767 }
1768 g_signal_stop_emission_by_name (tree_view, "button_press_event");
1769 }
1770 return TRUE(!(0));
1771}
1772
1773/* this handler is used to keep accels from activating while the user
1774 * is assigning a new shortcut so that he won't accidentally trigger one
1775 * of the widgets */
1776static gboolean maybe_block_accels(GtkWidget* widget, GdkEventKey* event, gpointer user_data)
1777{
1778 if (block_accels)
1779 {
1780 return gtk_window_propagate_key_event(GTK_WINDOW(widget)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_window_get_type ()))))))
, event);
1781 }
1782
1783 return FALSE(0);
1784}
1785
1786static void
1787cb_dialog_response (GtkWidget *widget, gint response_id, gpointer data)
1788{
1789 GtkBuilder *builder = data;
1790 GtkTreeView *treeview;
1791 GtkTreeModel *model;
1792 GtkTreeSelection *selection;
1793 GtkTreeIter iter;
1794
1795 treeview = GTK_TREE_VIEW (gtk_builder_get_object (builder,((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, "shortcut_treeview"))),
((gtk_tree_view_get_type ()))))))
1796 "shortcut_treeview"))((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, "shortcut_treeview"))),
((gtk_tree_view_get_type ()))))))
;
1797 model = gtk_tree_view_get_model (treeview);
1798
1799 if (response_id == GTK_RESPONSE_HELP)
1800 {
1801 capplet_help (GTK_WINDOW (widget)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_window_get_type ()))))))
,
1802 "goscustdesk-39");
1803 }
1804 else if (response_id == RESPONSE_ADD0)
1805 {
1806 add_custom_shortcut (treeview, model);
1807 }
1808 else if (response_id == RESPONSE_REMOVE1)
1809 {
1810 selection = gtk_tree_view_get_selection (treeview);
1811 if (gtk_tree_selection_get_selected (selection, NULL((void*)0), &iter))
1812 {
1813 remove_custom_shortcut (model, &iter);
1814 }
1815 }
1816 else
1817 {
1818 clear_old_model (builder);
1819 gtk_main_quit ();
1820 }
1821}
1822
1823static void
1824selection_changed (GtkTreeSelection *selection, gpointer data)
1825{
1826 GtkWidget *button = data;
1827 GtkTreeModel *model;
1828 GtkTreeIter iter;
1829 KeyEntry *key;
1830 gboolean can_remove;
1831
1832 can_remove = FALSE(0);
1833 if (gtk_tree_selection_get_selected (selection, &model, &iter))
1834 {
1835 gtk_tree_model_get (model, &iter, KEYENTRY_COLUMN, &key, -1);
1836 if (key && key->command != NULL((void*)0) && key->editable)
1837 can_remove = TRUE(!(0));
1838 }
1839
1840 gtk_widget_set_sensitive (button, can_remove);
1841}
1842
1843static void
1844cb_app_dialog_response (GtkWidget *dialog, gint response_id, gpointer data)
1845{
1846 if (response_id == GTK_RESPONSE_OK)
1847 {
1848 GAppInfo *info;
1849 const gchar *custom_name;
1850
1851 info = gtk_app_chooser_get_app_info (GTK_APP_CHOOSER (dialog)((((GtkAppChooser*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((gtk_app_chooser_get_type ()))))))
);
1852
1853 gtk_entry_set_text (GTK_ENTRY (custom_shortcut_command_entry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((custom_shortcut_command_entry)), ((gtk_entry_get_type ()
))))))
,
1854 g_app_info_get_executable (info));
1855 /* if name isn't set yet, use the associated one */
1856 custom_name = gtk_entry_get_text (GTK_ENTRY (custom_shortcut_name_entry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((custom_shortcut_name_entry)), ((gtk_entry_get_type ())))
)))
);
1857 if (! custom_name || custom_name[0] == '\0')
1858 gtk_entry_set_text (GTK_ENTRY (custom_shortcut_name_entry)((((GtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((custom_shortcut_name_entry)), ((gtk_entry_get_type ())))
)))
,
1859 g_app_info_get_display_name (info));
1860
1861 g_object_unref (info);
1862 }
1863
1864 gtk_widget_hide (dialog);
1865}
1866
1867static void
1868setup_dialog (GtkBuilder *builder, GSettings *marco_settings)
1869{
1870 GtkCellRenderer *renderer;
1871 GtkTreeViewColumn *column;
1872 GtkWidget *widget;
1873 GtkTreeView *treeview;
1874 GtkTreeSelection *selection;
1875 GtkWidget *button;
1876
1877 treeview = GTK_TREE_VIEW (gtk_builder_get_object (builder,((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, "shortcut_treeview"))),
((gtk_tree_view_get_type ()))))))
1878 "shortcut_treeview"))((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gtk_builder_get_object (builder, "shortcut_treeview"))),
((gtk_tree_view_get_type ()))))))
;
1879
1880 g_signal_connect (treeview, "button_press_event",g_signal_connect_data ((treeview), ("button_press_event"), ((
(GCallback) (start_editing_cb))), (builder), ((void*)0), (GConnectFlags
) 0)
1881 G_CALLBACK (start_editing_cb), builder)g_signal_connect_data ((treeview), ("button_press_event"), ((
(GCallback) (start_editing_cb))), (builder), ((void*)0), (GConnectFlags
) 0)
;
1882 g_signal_connect (treeview, "row-activated",g_signal_connect_data ((treeview), ("row-activated"), (((GCallback
) (start_editing_kb_cb))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
1883 G_CALLBACK (start_editing_kb_cb), NULL)g_signal_connect_data ((treeview), ("row-activated"), (((GCallback
) (start_editing_kb_cb))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
;
1884
1885 renderer = gtk_cell_renderer_text_new ();
1886
1887 g_signal_connect (renderer, "edited",g_signal_connect_data ((renderer), ("edited"), (((GCallback) (
description_edited_callback))), (treeview), ((void*)0), (GConnectFlags
) 0)
1888 G_CALLBACK (description_edited_callback),g_signal_connect_data ((renderer), ("edited"), (((GCallback) (
description_edited_callback))), (treeview), ((void*)0), (GConnectFlags
) 0)
1889 treeview)g_signal_connect_data ((renderer), ("edited"), (((GCallback) (
description_edited_callback))), (treeview), ((void*)0), (GConnectFlags
) 0)
;
1890
1891 column = gtk_tree_view_column_new_with_attributes (_("Action")gettext ("Action"),
1892 renderer,
1893 "text", DESCRIPTION_COLUMN,
1894 NULL((void*)0));
1895 gtk_tree_view_column_set_cell_data_func (column, renderer, description_set_func, NULL((void*)0), NULL((void*)0));
1896 gtk_tree_view_column_set_resizable (column, FALSE(0));
1897
1898 gtk_tree_view_append_column (treeview, column);
1899 gtk_tree_view_column_set_sort_column_id (column, DESCRIPTION_COLUMN);
1900
1901 renderer = (GtkCellRenderer *) g_object_new (EGG_TYPE_CELL_RENDERER_KEYS(egg_cell_renderer_keys_get_type ()),
1902 "accel_mode", EGG_CELL_RENDERER_KEYS_MODE_X,
1903 NULL((void*)0));
1904
1905 g_signal_connect (renderer, "accel_edited",g_signal_connect_data ((renderer), ("accel_edited"), (((GCallback
) (accel_edited_callback))), (treeview), ((void*)0), (GConnectFlags
) 0)
1906 G_CALLBACK (accel_edited_callback),g_signal_connect_data ((renderer), ("accel_edited"), (((GCallback
) (accel_edited_callback))), (treeview), ((void*)0), (GConnectFlags
) 0)
1907 treeview)g_signal_connect_data ((renderer), ("accel_edited"), (((GCallback
) (accel_edited_callback))), (treeview), ((void*)0), (GConnectFlags
) 0)
;
1908
1909 g_signal_connect (renderer, "accel_cleared",g_signal_connect_data ((renderer), ("accel_cleared"), (((GCallback
) (accel_cleared_callback))), (treeview), ((void*)0), (GConnectFlags
) 0)
1910 G_CALLBACK (accel_cleared_callback),g_signal_connect_data ((renderer), ("accel_cleared"), (((GCallback
) (accel_cleared_callback))), (treeview), ((void*)0), (GConnectFlags
) 0)
1911 treeview)g_signal_connect_data ((renderer), ("accel_cleared"), (((GCallback
) (accel_cleared_callback))), (treeview), ((void*)0), (GConnectFlags
) 0)
;
1912
1913 column = gtk_tree_view_column_new_with_attributes (_("Shortcut")gettext ("Shortcut"), renderer, NULL((void*)0));
1914 gtk_tree_view_column_set_cell_data_func (column, renderer, accel_set_func, NULL((void*)0), NULL((void*)0));
1915 gtk_tree_view_column_set_resizable (column, FALSE(0));
1916
1917 gtk_tree_view_append_column (treeview, column);
1918 gtk_tree_view_column_set_sort_column_id (column, KEYENTRY_COLUMN);
1919
1920 g_signal_connect (marco_settings,g_signal_connect_data ((marco_settings), ("changed::num-workspaces"
), (((GCallback) (key_entry_controlling_key_changed))), (builder
), ((void*)0), (GConnectFlags) 0)
1921 "changed::num-workspaces",g_signal_connect_data ((marco_settings), ("changed::num-workspaces"
), (((GCallback) (key_entry_controlling_key_changed))), (builder
), ((void*)0), (GConnectFlags) 0)
1922 G_CALLBACK (key_entry_controlling_key_changed),g_signal_connect_data ((marco_settings), ("changed::num-workspaces"
), (((GCallback) (key_entry_controlling_key_changed))), (builder
), ((void*)0), (GConnectFlags) 0)
1923 builder)g_signal_connect_data ((marco_settings), ("changed::num-workspaces"
), (((GCallback) (key_entry_controlling_key_changed))), (builder
), ((void*)0), (GConnectFlags) 0)
;
1924
1925 /* set up the dialog */
1926 reload_key_entries (builder);
1927
1928 widget = _gtk_builder_get_widget (builder, "mate-keybinding-dialog");
1929 gtk_window_set_default_size (GTK_WINDOW (widget)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_window_get_type ()))))))
, 400, 500);
1930 widget = _gtk_builder_get_widget (builder, "label-suggest");
1931 gtk_label_set_line_wrap (GTK_LABEL (widget)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_label_get_type ()))))))
, TRUE(!(0)));
1932 gtk_label_set_max_width_chars (GTK_LABEL (widget)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_label_get_type ()))))))
, 60);
1933
1934 widget = _gtk_builder_get_widget (builder, "mate-keybinding-dialog");
1935 capplet_set_icon (widget, "preferences-desktop-keyboard-shortcuts");
1936 gtk_widget_show (widget);
1937
1938 g_signal_connect (widget, "key_press_event", G_CALLBACK (maybe_block_accels), NULL)g_signal_connect_data ((widget), ("key_press_event"), (((GCallback
) (maybe_block_accels))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
;
1939 g_signal_connect (widget, "response", G_CALLBACK (cb_dialog_response), builder)g_signal_connect_data ((widget), ("response"), (((GCallback) (
cb_dialog_response))), (builder), ((void*)0), (GConnectFlags)
0)
;
1940
1941 selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview)((((GtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((treeview)), ((gtk_tree_view_get_type ()))))))
);
1942 g_signal_connect (selection, "changed",g_signal_connect_data ((selection), ("changed"), (((GCallback
) (selection_changed))), (_gtk_builder_get_widget (builder, "remove-button"
)), ((void*)0), (GConnectFlags) 0)
1943 G_CALLBACK (selection_changed),g_signal_connect_data ((selection), ("changed"), (((GCallback
) (selection_changed))), (_gtk_builder_get_widget (builder, "remove-button"
)), ((void*)0), (GConnectFlags) 0)
1944 _gtk_builder_get_widget (builder, "remove-button"))g_signal_connect_data ((selection), ("changed"), (((GCallback
) (selection_changed))), (_gtk_builder_get_widget (builder, "remove-button"
)), ((void*)0), (GConnectFlags) 0)
;
1945
1946 /* setup the custom shortcut dialog */
1947 custom_shortcut_dialog = _gtk_builder_get_widget (builder,
1948 "custom-shortcut-dialog");
1949 custom_shortcut_name_entry = _gtk_builder_get_widget (builder,
1950 "custom-shortcut-name-entry");
1951 custom_shortcut_command_entry = _gtk_builder_get_widget (builder,
1952 "custom-shortcut-command-entry");
1953 gtk_dialog_set_default_response (GTK_DIALOG (custom_shortcut_dialog)((((GtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((custom_shortcut_dialog)), ((gtk_dialog_get_type ()))))))
,
1954 GTK_RESPONSE_OK);
1955 gtk_window_set_transient_for (GTK_WINDOW (custom_shortcut_dialog)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((custom_shortcut_dialog)), ((gtk_window_get_type ()))))))
,
1956 GTK_WINDOW (widget)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_window_get_type ()))))))
);
1957 button = _gtk_builder_get_widget (builder, "custom-shortcut-command-button");
1958 widget = _gtk_builder_get_widget (builder, "custom-shortcut-application-dialog");
1959 g_signal_connect_swapped (button, "clicked", G_CALLBACK (gtk_dialog_run), widget)g_signal_connect_data ((button), ("clicked"), (((GCallback) (
gtk_dialog_run))), (widget), ((void*)0), G_CONNECT_SWAPPED)
;
1960 g_signal_connect (widget, "response", G_CALLBACK (cb_app_dialog_response), NULL)g_signal_connect_data ((widget), ("response"), (((GCallback) (
cb_app_dialog_response))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
;
1961 widget = gtk_app_chooser_dialog_get_widget (GTK_APP_CHOOSER_DIALOG (widget)((((GtkAppChooserDialog*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((widget)), ((gtk_app_chooser_dialog_get_type
()))))))
);
1962 gtk_app_chooser_widget_set_show_all (GTK_APP_CHOOSER_WIDGET (widget)((((GtkAppChooserWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((widget)), ((gtk_app_chooser_widget_get_type
()))))))
, TRUE(!(0)));
1963}
1964
1965static void
1966on_window_manager_change (const char *wm_name, GtkBuilder *builder)
1967{
1968 reload_key_entries (builder);
1969}
1970
1971int
1972main (int argc, char *argv[])
1973{
1974 GtkBuilder *builder;
1975 GSettings *marco_settings;
1976
1977 capplet_init (NULL((void*)0), &argc, &argv);
1978
1979 activate_settings_daemon ();
1980
1981 builder = gtk_builder_new_from_resource ("/org/mate/mcc/keybindings/mate-keybinding-properties.ui");
1982
1983 wm_common_register_window_manager_change ((GFunc) on_window_manager_change, builder);
1984
1985 marco_settings = g_settings_new ("org.mate.Marco.general");
1986
1987 setup_dialog (builder, marco_settings);
1988
1989 gtk_main ();
1990
1991 g_object_unref (marco_settings);
1992 g_object_unref (builder);
1993 return 0;
1994}
1995
1996/*
1997 * vim: sw=2 ts=8 cindent noai bs=2
1998 */
diff --git a/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-e4a995.html b/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-e4a995.html new file mode 100644 index 00000000..895912c3 --- /dev/null +++ b/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-e4a995.html @@ -0,0 +1,2000 @@ + + + +bookmark-agent.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:shell/bookmark-agent.c
Warning:line 735, column 4
Access of the heap area at index 1, while it holds only a single 'BookmarkItem *' element
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name bookmark-agent.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/shell -fcoverage-compilation-dir=/rootdir/shell -resource-dir /usr/bin/../lib/clang/18 -D HAVE_CONFIG_H -I . -I .. -I .. -I /usr/include/udisks2 -I /usr/include/libgtop-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/atk-1.0 -I /usr/include/startup-notification-1.0 -I /usr/include/mate-menus -I /usr/include/gio-unix-2.0 -I /usr/include/librsvg-2.0 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/libxml2 -I /usr/include/harfbuzz -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/freetype2 -I /usr/include/cloudproviders -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/dconf -I /usr/include/webp -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libpng16 -D WITH_GZFILEOP -I /usr/include/sysprof-6 -I /usr/include/pixman-1 -D MATELOCALEDIR="/usr/local/share/locale" -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-06-07-044335-13427-1 -x c bookmark-agent.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 * This file is part of the Main Menu.
3 *
4 * Copyright (c) 2007 Novell, Inc.
5 *
6 * The Main Menu is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free
8 * Software Foundation; either version 2 of the License, or (at your option)
9 * any later version.
10 *
11 * The Main Menu is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * more details.
15 *
16 * You should have received a copy of the GNU General Public License along with
17 * the Main Menu; if not, write to the Free Software Foundation, Inc., 51
18 * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#include "bookmark-agent.h"
22
23#ifdef HAVE_CONFIG_H1
24# include <config.h>
25#else
26# define PACKAGE"mate-control-center" "mate-main-menu"
27#endif
28
29#include <gtk/gtk.h>
30
31#include <string.h>
32#include <stdlib.h>
33#include <glib/gi18n-lib.h>
34#include <glib/gstdio.h>
35#include <gio/gio.h>
36
37#include "libslab-utils.h"
38
39#define USER_APPS_STORE_FILE_NAME"applications.xbel" "applications.xbel"
40#define USER_DOCS_STORE_FILE_NAME"documents.xbel" "documents.xbel"
41#define USER_DIRS_STORE_FILE_NAME"places.xbel" "places.xbel"
42#define SYSTEM_STORE_FILE_NAME"system-items.xbel" "system-items.xbel"
43#define CALC_TEMPLATE_FILE_NAME"empty.ots" "empty.ots"
44#define WRITER_TEMPLATE_FILE_NAME"empty.ott" "empty.ott"
45
46#define GTK_BOOKMARKS_FILE"bookmarks" "bookmarks"
47
48#define TYPE_IS_RECENT(type)((type) == BOOKMARK_STORE_RECENT_APPS || (type) == BOOKMARK_STORE_RECENT_DOCS
)
((type) == BOOKMARK_STORE_RECENT_APPS || (type) == BOOKMARK_STORE_RECENT_DOCS)
49
50typedef struct {
51 BookmarkStoreType type;
52
53 BookmarkItem **items;
54 gint n_items;
55 BookmarkStoreStatus status;
56
57 GBookmarkFile *store;
58 gboolean needs_sync;
59
60 gchar *store_path;
61 gchar *user_store_path;
62 gboolean user_modifiable;
63 gboolean reorderable;
64 const gchar *store_filename;
65
66 GFileMonitor *store_monitor;
67 GFileMonitor *user_store_monitor;
68
69 void (* update_path) (BookmarkAgent *);
70 void (* load_store) (BookmarkAgent *);
71 void (* save_store) (BookmarkAgent *);
72 void (* create_item) (BookmarkAgent *, const gchar *);
73
74 gchar *gtk_store_path;
75 GFileMonitor *gtk_store_monitor;
76} BookmarkAgentPrivate;
77
78enum {
79 PROP_0,
80 PROP_ITEMS,
81 PROP_STATUS
82};
83
84static BookmarkAgent *instances [BOOKMARK_STORE_N_TYPES];
85
86static BookmarkAgentClass *bookmark_agent_parent_class = NULL((void*)0);
87
88static void bookmark_agent_base_init (BookmarkAgentClass *);
89static void bookmark_agent_class_init (BookmarkAgentClass *);
90static void bookmark_agent_init (BookmarkAgent *);
91static BookmarkAgent *bookmark_agent_new (BookmarkStoreType );
92
93static void get_property (GObject *, guint, GValue *, GParamSpec *);
94static void set_property (GObject *, guint, const GValue *, GParamSpec *);
95static void finalize (GObject *);
96
97static void update_agent (BookmarkAgent *);
98static void update_items (BookmarkAgent *);
99static void save_store (BookmarkAgent *);
100static gint get_rank (BookmarkAgent *, const gchar *);
101static void set_rank (BookmarkAgent *, const gchar *, gint);
102
103static void load_xbel_store (BookmarkAgent *);
104static void load_places_store (BookmarkAgent *);
105static void update_user_spec_path (BookmarkAgent *);
106static void save_xbel_store (BookmarkAgent *);
107static void create_app_item (BookmarkAgent *, const gchar *);
108static void create_doc_item (BookmarkAgent *, const gchar *);
109static void create_dir_item (BookmarkAgent *, const gchar *);
110
111static void store_monitor_cb (GFileMonitor *, GFile *, GFile *,
112 GFileMonitorEvent, gpointer);
113static void weak_destroy_cb (gpointer, GObject *);
114
115static gchar *find_package_data_file (const gchar *filename);
116
117static gint BookmarkAgent_private_offset;
118
119static inline gpointer bookmark_agent_get_instance_private (BookmarkAgent *this)
120{
121 return (G_STRUCT_MEMBER_P (this, BookmarkAgent_private_offset)((gpointer) ((guint8*) (this) + (glong) (BookmarkAgent_private_offset
)))
);
122}
123
124GType
125bookmark_agent_get_type ()
126{
127 static GType g_define_type_id = 0;
128
129 if (G_UNLIKELY (g_define_type_id == 0)(g_define_type_id == 0)) {
130 static const GTypeInfo info = {
131 sizeof (BookmarkAgentClass),
132 (GBaseInitFunc) bookmark_agent_base_init,
133 NULL((void*)0),
134 (GClassInitFunc) bookmark_agent_class_init,
135 NULL((void*)0), NULL((void*)0),
136 sizeof (BookmarkAgent), 0,
137 (GInstanceInitFunc) bookmark_agent_init,
138 NULL((void*)0)
139 };
140
141 g_define_type_id = g_type_register_static (
142 G_TYPE_OBJECT((GType) ((20) << (2))), "BookmarkAgent", & info, 0);
143 G_ADD_PRIVATE (BookmarkAgent){ BookmarkAgent_private_offset = g_type_add_instance_private (
g_define_type_id, sizeof (BookmarkAgentPrivate)); }
;
144 }
145
146 return g_define_type_id;
147}
148
149gboolean
150bookmark_agent_has_item (BookmarkAgent *this, const gchar *uri)
151{
152 BookmarkAgentPrivate *priv = bookmark_agent_get_instance_private (this);
153 return g_bookmark_file_has_item (priv->store, uri);
154}
155
156void
157bookmark_agent_add_item (BookmarkAgent *this, const BookmarkItem *item)
158{
159 BookmarkAgentPrivate *priv = bookmark_agent_get_instance_private (this);
160
161 if (! item)
162 return;
163
164 g_return_if_fail (priv->user_modifiable)do { if ((priv->user_modifiable)) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "priv->user_modifiable"
); return; } } while (0)
;
165 g_return_if_fail (item->uri)do { if ((item->uri)) { } else { g_return_if_fail_warning (
((gchar*) 0), ((const char*) (__func__)), "item->uri"); return
; } } while (0)
;
166 g_return_if_fail (item->mime_type)do { if ((item->mime_type)) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "item->mime_type"
); return; } } while (0)
;
167
168 g_bookmark_file_set_mime_type (priv->store, item->uri, item->mime_type);
169
170 if (item->mtime)
171#if GLIB_CHECK_VERSION(2,66,0)(2 > (2) || (2 == (2) && 80 > (66)) || (2 == (2
) && 80 == (66) && 2 >= (0)))
172 g_bookmark_file_set_modified_date_time (priv->store, item->uri, item->mtime);
173#else
174 g_bookmark_file_set_modified (priv->store, item->uri, item->mtime);
175#endif
176
177 if (item->title)
178 g_bookmark_file_set_title (priv->store, item->uri, item->title);
179
180 g_bookmark_file_add_application (priv->store, item->uri, item->app_name, item->app_exec);
181
182 set_rank (this, item->uri, g_bookmark_file_get_size (priv->store) - 1);
183
184 save_store (this);
185}
186
187void
188bookmark_agent_move_item (BookmarkAgent *this, const gchar *uri, const gchar *uri_new)
189{
190 BookmarkAgentPrivate *priv = bookmark_agent_get_instance_private (this);
191
192 GError *error = NULL((void*)0);
193
194 if (! TYPE_IS_RECENT (priv->type)((priv->type) == BOOKMARK_STORE_RECENT_APPS || (priv->type
) == BOOKMARK_STORE_RECENT_DOCS)
)
195 return;
196
197 gtk_recent_manager_move_item (gtk_recent_manager_get_default (), uri, uri_new, &error);
198 if (error) {
199 g_warning ("Unable to update %s with renamed file, [%s] -> [%s]: %s",
200 priv->store_path, uri, uri_new, error->message);
201 g_error_free (error);
202 }
203}
204
205void
206bookmark_agent_purge_items (BookmarkAgent *this)
207{
208 BookmarkAgentPrivate *priv = bookmark_agent_get_instance_private (this);
209
210 GError *error = NULL((void*)0);
211
212 gchar **uris = NULL((void*)0);
213 gsize uris_len;
214 gint i;
215 g_return_if_fail (priv->user_modifiable)do { if ((priv->user_modifiable)) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "priv->user_modifiable"
); return; } } while (0)
;
216
217 uris = g_bookmark_file_get_uris (priv->store, &uris_len);
218 if (TYPE_IS_RECENT (priv->type)((priv->type) == BOOKMARK_STORE_RECENT_APPS || (priv->type
) == BOOKMARK_STORE_RECENT_DOCS)
) {
219 for (i = 0; i < uris_len; i++) {
220 gtk_recent_manager_remove_item (gtk_recent_manager_get_default (), uris [i], &error);
221 if (error) {
222 g_warning ("Unable to remove [%s] from %s: %s",
223 priv->store_path, uris [i], error->message);
224 g_error_free (error);
225 }
226 }
227 } else {
228 for (i = 0; i < uris_len; i++) {
229 g_bookmark_file_remove_item (priv->store, uris [i], NULL((void*)0));
230 }
231 save_store (this);
232 }
233 g_strfreev (uris);
234}
235
236void
237bookmark_agent_remove_item (BookmarkAgent *this, const gchar *uri)
238{
239 BookmarkAgentPrivate *priv = bookmark_agent_get_instance_private (this);
240 gint rank;
241
242 GError *error = NULL((void*)0);
243
244 gchar **uris = NULL((void*)0);
245 gint rank_i;
246 gint i;
247
248 g_return_if_fail (priv->user_modifiable)do { if ((priv->user_modifiable)) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "priv->user_modifiable"
); return; } } while (0)
;
249
250 if (! bookmark_agent_has_item (this, uri))
251 return;
252
253 if (TYPE_IS_RECENT (priv->type)((priv->type) == BOOKMARK_STORE_RECENT_APPS || (priv->type
) == BOOKMARK_STORE_RECENT_DOCS)
) {
254 gtk_recent_manager_remove_item (gtk_recent_manager_get_default (), uri, &error);
255 if (error) {
256 g_warning ("Unable to remove [%s] from %s: %s", priv->store_path, uri, error->message);
257 g_error_free (error);
258 }
259 }
260 else {
261 rank = get_rank (this, uri);
262
263 g_bookmark_file_remove_item (priv->store, uri, NULL((void*)0));
264
265 if (rank >= 0) {
266 uris = g_bookmark_file_get_uris (priv->store, NULL((void*)0));
267
268 for (i = 0; uris && uris [i]; ++i) {
269 rank_i = get_rank (this, uris [i]);
270
271 if (rank_i > rank)
272 set_rank (this, uris [i], rank_i - 1);
273 }
274
275 g_strfreev (uris);
276 }
277
278 save_store (this);
279 }
280}
281
282void
283bookmark_agent_reorder_items (BookmarkAgent *this, const gchar **uris)
284{
285 BookmarkAgentPrivate *priv = bookmark_agent_get_instance_private (this);
286
287 gint i;
288
289 g_return_if_fail (priv->reorderable)do { if ((priv->reorderable)) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "priv->reorderable"
); return; } } while (0)
;
290
291 for (i = 0; uris && uris [i]; ++i)
292 set_rank (this, uris [i], i);
293
294 save_store (this);
295}
296
297#if !GLIB_CHECK_VERSION(2,66,0)(2 > (2) || (2 == (2) && 80 > (66)) || (2 == (2
) && 80 == (66) && 2 >= (0)))
298static gint
299recent_item_mru_comp_func (gconstpointer a, gconstpointer b)
300{
301 return ((BookmarkItem *) b)->mtime - ((BookmarkItem *) a)->mtime;
302}
303#endif
304
305static GList *
306make_items_from_bookmark_file (BookmarkAgent *this, GBookmarkFile *store)
307{
308 BookmarkAgentPrivate *priv = bookmark_agent_get_instance_private (this);
309 gchar **uris;
310 gint i;
311 GList *items_ordered;
312
313 if (!store)
314 return NULL((void*)0);
315
316 uris = g_bookmark_file_get_uris (store, NULL((void*)0));
317 items_ordered = NULL((void*)0);
318
319 for (i = 0; uris && uris [i]; ++i) {
320 gboolean include;
321
322 if (priv->type == BOOKMARK_STORE_RECENT_APPS)
323 include = g_bookmark_file_has_group (store, uris [i], "recently-used-apps", NULL((void*)0));
324 else
325 include = ! g_bookmark_file_get_is_private (store, uris [i], NULL((void*)0));
326
327 if (include) {
328 BookmarkItem *item;
329
330 item = g_new0 (BookmarkItem, 1)((BookmarkItem *) g_malloc0_n ((1), sizeof (BookmarkItem)));
331
332 item->uri = g_strdup (uris [i])g_strdup_inline (uris [i]);
333 item->mime_type = g_bookmark_file_get_mime_type (store, uris [i], NULL((void*)0));
334#if GLIB_CHECK_VERSION(2,66,0)(2 > (2) || (2 == (2) && 80 > (66)) || (2 == (2
) && 80 == (66) && 2 >= (0)))
335 item->mtime = g_bookmark_file_get_modified_date_time (store, uris [i], NULL((void*)0));
336#else
337 item->mtime = g_bookmark_file_get_modified (store, uris [i], NULL((void*)0));
338#endif
339
340 items_ordered = g_list_prepend (items_ordered, item);
341 }
342 }
343
344#if GLIB_CHECK_VERSION(2,66,0)(2 > (2) || (2 == (2) && 80 > (66)) || (2 == (2
) && 80 == (66) && 2 >= (0)))
345 items_ordered = g_list_sort (items_ordered, g_date_time_compare);
346#else
347 items_ordered = g_list_sort (items_ordered, recent_item_mru_comp_func);
348#endif
349 g_strfreev (uris);
350
351 return items_ordered;
352}
353
354void
355bookmark_agent_update_from_bookmark_file (BookmarkAgent *this, GBookmarkFile *store)
356{
357 BookmarkAgentPrivate *priv;
358 GList *items_ordered;
359 GList *node;
360
361 g_return_if_fail (IS_BOOKMARK_AGENT (this))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((this)); GType __t = ((bookmark_agent_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "IS_BOOKMARK_AGENT (this)"); return; } } while
(0)
;
362
363 priv = bookmark_agent_get_instance_private (this);
364
365 items_ordered = make_items_from_bookmark_file (this, store);
366
367 g_bookmark_file_free (priv->store);
368 priv->store = g_bookmark_file_new ();
369
370 for (node = items_ordered; node; node = node->next) {
371 BookmarkItem *item;
372
373 item = (BookmarkItem *) node->data;
374
375 g_bookmark_file_set_mime_type (priv->store, item->uri, item->mime_type);
376 #if GLIB_CHECK_VERSION(2,66,0)(2 > (2) || (2 == (2) && 80 > (66)) || (2 == (2
) && 80 == (66) && 2 >= (0)))
377 g_bookmark_file_set_modified_date_time (priv->store, item->uri, item->mtime);
378 #else
379 g_bookmark_file_set_modified (priv->store, item->uri, item->mtime);
380 #endif
381
382 bookmark_item_free (item);
383 }
384
385 g_list_free (items_ordered);
386
387 update_items (this);
388}
389
390void
391bookmark_item_free (BookmarkItem *item)
392{
393 if (! item)
394 return;
395
396 g_free (item->uri);
397 g_free (item->title);
398 g_free (item->mime_type);
399 g_free (item->icon);
400 g_free (item->app_name);
401 g_free (item->app_exec);
402 g_free (item);
403}
404
405static void
406bookmark_agent_base_init (BookmarkAgentClass *this_class)
407{
408 gint i;
409
410 for (i = 0; i < BOOKMARK_STORE_N_TYPES; ++i)
411 instances [i] = NULL((void*)0);
412}
413
414static void
415bookmark_agent_class_init (BookmarkAgentClass *this_class)
416{
417 GObjectClass *g_obj_class = G_OBJECT_CLASS (this_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((this_class)), (((GType) ((20) << (2))))))))
;
418
419 GParamSpec *items_pspec;
420 GParamSpec *status_pspec;
421
422 if (BookmarkAgent_private_offset != 0)
423 g_type_class_adjust_private_offset (this_class, &BookmarkAgent_private_offset);
424
425 g_obj_class->get_property = get_property;
426 g_obj_class->set_property = set_property;
427 g_obj_class->finalize = finalize;
428
429 items_pspec = g_param_spec_pointer (
430 BOOKMARK_AGENT_ITEMS_PROP"items", BOOKMARK_AGENT_ITEMS_PROP"items",
431 "the null-terminated list which contains the bookmark items in this store",
432 G_PARAM_READABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB);
433
434 status_pspec = g_param_spec_int (
435 BOOKMARK_AGENT_STORE_STATUS_PROP"store-status", BOOKMARK_AGENT_STORE_STATUS_PROP"store-status", "the status of the store",
436 BOOKMARK_STORE_DEFAULT_ONLY, BOOKMARK_STORE_USER, BOOKMARK_STORE_DEFAULT,
437 G_PARAM_READABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB);
438
439 g_object_class_install_property (g_obj_class, PROP_ITEMS, items_pspec);
440 g_object_class_install_property (g_obj_class, PROP_STATUS, status_pspec);
441
442 bookmark_agent_parent_class = g_type_class_peek_parent (this_class);
443}
444
445static void
446bookmark_agent_init (BookmarkAgent *this)
447{
448 BookmarkAgentPrivate *priv = bookmark_agent_get_instance_private (this);
449
450 priv->type = -1;
451
452 priv->items = NULL((void*)0);
453 priv->n_items = 0;
454 priv->status = BOOKMARK_STORE_ABSENT;
455
456 priv->store = NULL((void*)0);
457 priv->needs_sync = FALSE(0);
458
459 priv->store_path = NULL((void*)0);
460 priv->user_store_path = NULL((void*)0);
461 priv->user_modifiable = FALSE(0);
462 priv->reorderable = FALSE(0);
463 priv->store_filename = NULL((void*)0);
464
465 priv->store_monitor = NULL((void*)0);
466 priv->user_store_monitor = NULL((void*)0);
467
468 priv->update_path = NULL((void*)0);
469 priv->load_store = NULL((void*)0);
470 priv->save_store = NULL((void*)0);
471 priv->create_item = NULL((void*)0);
472
473 priv->gtk_store_path = NULL((void*)0);
474 priv->gtk_store_monitor = NULL((void*)0);
475}
476
477static BookmarkAgent *
478bookmark_agent_new (BookmarkStoreType type)
479{
480 BookmarkAgent *this;
481 BookmarkAgentPrivate *priv;
482 GFile *gtk_store_file;
483
484 this = g_object_new (BOOKMARK_AGENT_TYPE(bookmark_agent_get_type ()), NULL((void*)0));
485 priv = bookmark_agent_get_instance_private (this);
486
487 priv->type = type;
488 priv->store = g_bookmark_file_new ();
489
490 switch (type) {
491 case BOOKMARK_STORE_USER_APPS:
492 priv->store_filename = USER_APPS_STORE_FILE_NAME"applications.xbel";
493 priv->create_item = create_app_item;
494
495 break;
496
497 case BOOKMARK_STORE_USER_DOCS:
498 priv->store_filename = USER_DOCS_STORE_FILE_NAME"documents.xbel";
499 priv->create_item = create_doc_item;
500
501 break;
502
503 case BOOKMARK_STORE_USER_DIRS:
504 priv->store_filename = USER_DIRS_STORE_FILE_NAME"places.xbel";
505 priv->create_item = create_dir_item;
506
507 priv->user_modifiable = TRUE(!(0));
508 priv->reorderable = FALSE(0);
509
510 priv->load_store = load_places_store;
511
512 priv->gtk_store_path = g_build_filename (g_get_user_config_dir (),
513 "gtk-3.0", GTK_BOOKMARKS_FILE"bookmarks", NULL((void*)0));
514 gtk_store_file = g_file_new_for_path (priv->gtk_store_path);
515 priv->gtk_store_monitor = g_file_monitor_file (gtk_store_file,
516 0, NULL((void*)0), NULL((void*)0));
517 if (priv->gtk_store_monitor) {
518 g_signal_connect (priv->gtk_store_monitor, "changed",g_signal_connect_data ((priv->gtk_store_monitor), ("changed"
), (((GCallback) (store_monitor_cb))), (this), ((void*)0), (GConnectFlags
) 0)
519 G_CALLBACK (store_monitor_cb), this)g_signal_connect_data ((priv->gtk_store_monitor), ("changed"
), (((GCallback) (store_monitor_cb))), (this), ((void*)0), (GConnectFlags
) 0)
;
520 }
521
522 g_object_unref (gtk_store_file);
523
524 break;
525
526 case BOOKMARK_STORE_RECENT_APPS:
527 case BOOKMARK_STORE_RECENT_DOCS:
528 priv->user_modifiable = TRUE(!(0));
529 priv->reorderable = FALSE(0);
530
531 priv->store_path = g_build_filename (g_get_user_data_dir (), "recently-used.xbel", NULL((void*)0));
532
533 break;
534
535 case BOOKMARK_STORE_SYSTEM:
536 priv->store_filename = SYSTEM_STORE_FILE_NAME"system-items.xbel";
537 priv->create_item = create_app_item;
538
539 break;
540
541 default:
542 break;
543 }
544
545 if (
546 type == BOOKMARK_STORE_USER_APPS || type == BOOKMARK_STORE_USER_DOCS ||
547 type == BOOKMARK_STORE_USER_DIRS || type == BOOKMARK_STORE_SYSTEM)
548 {
549 priv->user_modifiable = TRUE(!(0));
550
551 priv->user_store_path = g_build_filename (
552 g_get_user_data_dir (), PACKAGE"mate-control-center", priv->store_filename, NULL((void*)0));
553
554 priv->update_path = update_user_spec_path;
555 }
556
557 if (type == BOOKMARK_STORE_USER_APPS || type == BOOKMARK_STORE_USER_DOCS || type == BOOKMARK_STORE_SYSTEM) {
558 priv->reorderable = TRUE(!(0));
559 priv->load_store = load_xbel_store;
560 priv->save_store = save_xbel_store;
561 }
562
563 update_agent (this);
564
565 return this;
566}
567
568BookmarkAgent *
569bookmark_agent_get_instance (BookmarkStoreType type)
570{
571 g_return_val_if_fail (0 <= type, NULL)do { if ((0 <= type)) { } else { g_return_if_fail_warning (
((gchar*) 0), ((const char*) (__func__)), "0 <= type"); return
(((void*)0)); } } while (0)
;
572 g_return_val_if_fail (type < BOOKMARK_STORE_N_TYPES, NULL)do { if ((type < BOOKMARK_STORE_N_TYPES)) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "type < BOOKMARK_STORE_N_TYPES"
); return (((void*)0)); } } while (0)
;
573
574 if (! instances [type]) {
575 instances [type] = bookmark_agent_new (type);
576 g_object_weak_ref (G_OBJECT (instances [type])((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((instances [type])), (((GType) ((20) << (2))))))))
, weak_destroy_cb, GINT_TO_POINTER (type)((gpointer) (glong) (type)));
577 }
578 else
579 g_object_ref (G_OBJECT (instances [type]))((__typeof__ (((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((instances [type])), (((GType) ((20) <<
(2)))))))))) (g_object_ref) (((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((instances [type])), (((GType) ((20) <<
(2))))))))))
;
580
581 return instances [type];
582}
583
584static void
585get_property (GObject *g_obj, guint prop_id, GValue *value, GParamSpec *pspec)
586{
587 BookmarkAgent *this = BOOKMARK_AGENT (g_obj)((((BookmarkAgent*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((g_obj)), ((bookmark_agent_get_type ()))))))
;
588 BookmarkAgentPrivate *priv = bookmark_agent_get_instance_private (this);
589
590 switch (prop_id) {
591 case PROP_ITEMS:
592 g_value_set_pointer (value, priv->items);
593 break;
594
595 case PROP_STATUS:
596 g_value_set_int (value, priv->status);
597 break;
598 }
599}
600
601static void
602set_property (GObject *g_obj, guint prop_id, const GValue *value, GParamSpec *pspec)
603{
604 /* no writeable properties */
605}
606
607static void
608finalize (GObject *g_obj)
609{
610 BookmarkAgent *this = BOOKMARK_AGENT (g_obj)((((BookmarkAgent*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((g_obj)), ((bookmark_agent_get_type ()))))))
;
611 BookmarkAgentPrivate *priv = bookmark_agent_get_instance_private (this);
612
613 gint i;
614
615 for (i = 0; priv->items && priv->items [i]; ++i)
616 bookmark_item_free (priv->items [i]);
617
618 g_free (priv->items);
619 g_free (priv->store_path);
620 g_free (priv->user_store_path);
621 g_free (priv->gtk_store_path);
622
623 if (priv->store_monitor) {
624 g_signal_handlers_disconnect_by_func (priv->store_monitor, store_monitor_cb, this)g_signal_handlers_disconnect_matched ((priv->store_monitor
), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (store_monitor_cb), (this))
;
625 g_file_monitor_cancel (priv->store_monitor);
626 g_object_unref (priv->store_monitor);
627 }
628
629 if (priv->user_store_monitor) {
630 g_signal_handlers_disconnect_by_func (priv->user_store_monitor, store_monitor_cb, this)g_signal_handlers_disconnect_matched ((priv->user_store_monitor
), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (store_monitor_cb), (this))
;
631 g_file_monitor_cancel (priv->user_store_monitor);
632 g_object_unref (priv->user_store_monitor);
633 }
634
635 if (priv->gtk_store_monitor) {
636 g_signal_handlers_disconnect_by_func (priv->gtk_store_monitor, store_monitor_cb, this)g_signal_handlers_disconnect_matched ((priv->gtk_store_monitor
), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (store_monitor_cb), (this))
;
637 g_file_monitor_cancel (priv->gtk_store_monitor);
638 g_object_unref (priv->gtk_store_monitor);
639 }
640
641 g_bookmark_file_free (priv->store);
642
643 G_OBJECT_CLASS (bookmark_agent_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((bookmark_agent_parent_class)), (((GType) ((20) << (
2))))))))
->finalize (g_obj);
644}
645
646static void
647update_agent (BookmarkAgent *this)
648{
649 BookmarkAgentPrivate *priv = bookmark_agent_get_instance_private (this);
650
651 if (priv->update_path)
2
Assuming field 'update_path' is null
3
Taking false branch
652 priv->update_path (this);
653
654 if (priv->load_store)
4
Assuming field 'load_store' is null
5
Taking false branch
655 priv->load_store (this);
656
657 update_items (this);
6
Calling 'update_items'
658}
659
660static void
661update_items (BookmarkAgent *this)
662{
663 BookmarkAgentPrivate *priv = bookmark_agent_get_instance_private (this);
664
665 gchar **uris = NULL((void*)0);
666 gchar **uris_ordered = NULL((void*)0);
667 gsize n_uris = 0;
668 gint rank = -1;
669 gint rank_corr = -1;
670 gboolean needs_update = FALSE(0);
671 gboolean store_corrupted = FALSE(0);
672 gchar *new_title, *old_title;
673
674 gint i;
675
676 uris = g_bookmark_file_get_uris (priv->store, & n_uris);
677 uris_ordered = g_new0 (gchar *, n_uris + 1)((gchar * *) g_malloc0_n ((n_uris + 1), sizeof (gchar *)));
678 uris_ordered [n_uris] = NULL((void*)0);
679
680 for (i = 0; uris
12.1
'uris' is non-null
&& uris [i]; ++i) {
7
Assuming 'uris' is non-null
8
Loop condition is true. Entering loop body
13
Loop condition is false. Execution continues on line 704
681 rank = get_rank (this, uris [i]);
682
683 if (rank
8.1
'rank' is < 0
< 0 || rank >= n_uris)
684 rank = i;
685
686 if (uris_ordered [rank]) {
9
Assuming the condition is true
10
Taking true branch
687 store_corrupted = TRUE(!(0));
688 rank_corr = rank;
689
690 for (rank = 0; rank < n_uris; ++rank)
11
Assuming 'rank' is >= 'n_uris'
12
Loop condition is false. Execution continues on line 694
691 if (! uris_ordered [rank])
692 break;
693
694 g_warning (
695 "store corruption [%s] - multiple uris with same rank (%d): [%s] [%s], moving latter to %d",
696 priv->store_path, rank_corr, uris_ordered [rank_corr], uris [i], rank);
697 }
698
699 set_rank (this, uris [i], rank);
700
701 uris_ordered [rank] = uris [i];
702 }
703
704 if (priv->n_items != n_uris)
14
Assuming 'n_uris' is not equal to field 'n_items'
15
Taking true branch
705 needs_update = TRUE(!(0));
706
707 for (i = 0; ! needs_update
15.1
'needs_update' is 1
&& uris_ordered && uris_ordered [i]; ++i) {
708 if (priv->type == BOOKMARK_STORE_USER_DIRS) {
709 new_title = g_bookmark_file_get_title (priv->store, uris_ordered [i], NULL((void*)0));
710 old_title = priv->items [i]->title;
711 if (!new_title && !old_title) {
712 if (strcmp (priv->items [i]->uri, uris_ordered [i]))
713 needs_update = TRUE(!(0));
714 }
715 else if ((new_title && !old_title) || (!new_title && old_title))
716 needs_update = TRUE(!(0));
717 else if (strcmp (old_title, new_title))
718 needs_update = TRUE(!(0));
719 g_free (new_title);
720 }
721 else if (strcmp (priv->items [i]->uri, uris_ordered [i]))
722 needs_update = TRUE(!(0));
723 }
724
725 if (needs_update
15.2
'needs_update' is 1
) {
16
Taking true branch
726 for (i = 0; priv->items && priv->items [i]; ++i)
17
Assuming field 'items' is null
727 bookmark_item_free (priv->items [i]);
728
729 g_free (priv->items);
730
731 priv->n_items = n_uris;
732 priv->items = g_new0 (BookmarkItem *, priv->n_items + 1)((BookmarkItem * *) g_malloc0_n ((priv->n_items + 1), sizeof
(BookmarkItem *)))
;
733
734 for (i = 0; uris_ordered
17.1
'uris_ordered' is non-null
18.1
'uris_ordered' is non-null
&& uris_ordered [i]; ++i) {
18
Loop condition is true. Entering loop body
19
Loop condition is true. Entering loop body
735 priv->items [i] = g_new0 (BookmarkItem, 1)((BookmarkItem *) g_malloc0_n ((1), sizeof (BookmarkItem)));
20
Access of the heap area at index 1, while it holds only a single 'BookmarkItem *' element
736 priv->items [i]->uri = g_strdup (uris_ordered [i])g_strdup_inline (uris_ordered [i]);
737 priv->items [i]->title = g_bookmark_file_get_title (priv->store, uris_ordered [i], NULL((void*)0));
738 priv->items [i]->mime_type = g_bookmark_file_get_mime_type (priv->store, uris_ordered [i], NULL((void*)0));
739 #if GLIB_CHECK_VERSION(2,66,0)(2 > (2) || (2 == (2) && 80 > (66)) || (2 == (2
) && 80 == (66) && 2 >= (0)))
740 priv->items [i]->mtime = g_bookmark_file_get_modified_date_time (priv->store, uris_ordered [i], NULL((void*)0));
741 #else
742 priv->items [i]->mtime = g_bookmark_file_get_modified (priv->store, uris_ordered [i], NULL((void*)0));
743 #endif
744 priv->items [i]->app_name = NULL((void*)0);
745 priv->items [i]->app_exec = NULL((void*)0);
746
747 g_bookmark_file_get_icon (priv->store, uris_ordered [i], & priv->items [i]->icon, NULL((void*)0), NULL((void*)0));
748 }
749
750 /* Since the bookmark store for recently-used items is updated by the caller of BookmarkAgent,
751 * we don't emit notifications in that case. The caller will know when to update itself.
752 */
753 if (!TYPE_IS_RECENT (priv->type)((priv->type) == BOOKMARK_STORE_RECENT_APPS || (priv->type
) == BOOKMARK_STORE_RECENT_DOCS)
)
754 g_object_notify (G_OBJECT (this)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((this)), (((GType) ((20) << (2))))))))
, BOOKMARK_AGENT_ITEMS_PROP"items");
755 }
756
757 if (store_corrupted)
758 save_store (this);
759
760 g_strfreev (uris);
761 g_free (uris_ordered);
762}
763
764static void
765save_store (BookmarkAgent *this)
766{
767 BookmarkAgentPrivate *priv = bookmark_agent_get_instance_private (this);
768
769 gchar *dir;
770
771 g_return_if_fail (priv->user_modifiable)do { if ((priv->user_modifiable)) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "priv->user_modifiable"
); return; } } while (0)
;
772
773 priv->needs_sync = TRUE(!(0));
774 priv->update_path (this);
775
776 dir = g_path_get_dirname (priv->store_path);
777 g_mkdir_with_parents (dir, 0700);
778 g_free (dir);
779
780 priv->save_store (this);
781 update_items (this);
782}
783
784static gint
785get_rank (BookmarkAgent *this, const gchar *uri)
786{
787 BookmarkAgentPrivate *priv = bookmark_agent_get_instance_private (this);
788
789 gchar **groups;
790 gint rank;
791
792 gint i;
793
794 if (! priv->reorderable)
795 return -1;
796
797 groups = g_bookmark_file_get_groups (priv->store, uri, NULL((void*)0), NULL((void*)0));
798 rank = -1;
799
800 for (i = 0; groups && groups [i]; ++i) {
801 if (g_str_has_prefix (groups [i], "rank-")(__builtin_constant_p ("rank-")? __extension__ ({ const char *
const __str = (groups [i]); const char * const __prefix = ("rank-"
); gboolean __result = (0); if (__str == ((void*)0) || __prefix
== ((void*)0)) __result = (g_str_has_prefix) (__str, __prefix
); else { const size_t __str_len = strlen (((__str) + !(__str
))); const size_t __prefix_len = strlen (((__prefix) + !(__prefix
))); if (__str_len >= __prefix_len) __result = memcmp (((__str
) + !(__str)), ((__prefix) + !(__prefix)), __prefix_len) == 0
; } __result; }) : (g_str_has_prefix) (groups [i], "rank-") )
) {
802 if (rank >= 0)
803 g_warning (
804 "store corruption - multiple ranks for same uri: [%s] [%s]",
805 priv->store_path, uri);
806
807 rank = atoi (& groups [i] [5]);
808 }
809 }
810
811 g_strfreev (groups);
812
813 return rank;
814}
815
816static void
817set_rank (BookmarkAgent *this, const gchar *uri, gint rank)
818{
819 BookmarkAgentPrivate *priv = bookmark_agent_get_instance_private (this);
820
821 gchar **groups;
822 gchar *group;
823
824 gint i;
825
826 if (! (priv->reorderable && bookmark_agent_has_item (this, uri)))
827 return;
828
829 groups = g_bookmark_file_get_groups (priv->store, uri, NULL((void*)0), NULL((void*)0));
830
831 for (i = 0; groups && groups [i]; ++i)
832 if (g_str_has_prefix (groups [i], "rank-")(__builtin_constant_p ("rank-")? __extension__ ({ const char *
const __str = (groups [i]); const char * const __prefix = ("rank-"
); gboolean __result = (0); if (__str == ((void*)0) || __prefix
== ((void*)0)) __result = (g_str_has_prefix) (__str, __prefix
); else { const size_t __str_len = strlen (((__str) + !(__str
))); const size_t __prefix_len = strlen (((__prefix) + !(__prefix
))); if (__str_len >= __prefix_len) __result = memcmp (((__str
) + !(__str)), ((__prefix) + !(__prefix)), __prefix_len) == 0
; } __result; }) : (g_str_has_prefix) (groups [i], "rank-") )
)
833 g_bookmark_file_remove_group (priv->store, uri, groups [i], NULL((void*)0));
834
835 g_strfreev (groups);
836
837 group = g_strdup_printf ("rank-%d", rank);
838 g_bookmark_file_add_group (priv->store, uri, group);
839 g_free (group);
840}
841
842static void
843load_xbel_store (BookmarkAgent *this)
844{
845 BookmarkAgentPrivate *priv = bookmark_agent_get_instance_private (this);
846
847 gchar **uris = NULL((void*)0);
848
849 GError *error = NULL((void*)0);
850
851 gint i;
852 gboolean success;
853
854 if (!priv->store_path)
855 success = FALSE(0);
856 else {
857 success = g_bookmark_file_load_from_file (priv->store, priv->store_path, & error);
858 }
859
860 if (!success) {
861 g_bookmark_file_free (priv->store);
862 priv->store = g_bookmark_file_new ();
863
864 if (error) {
865 g_debug ("Couldn't load bookmark file [%s]: %s", priv->store_path, error->message);
866 g_error_free (error);
867 } else {
868 g_debug ("Couldn't load bookmark file [NULL]");
869 }
870 return;
871 }
872
873 uris = g_bookmark_file_get_uris (priv->store, NULL((void*)0));
874
875 for (i = 0; uris && uris [i]; ++i)
876 priv->create_item (this, uris [i]);
877
878 g_strfreev (uris);
879}
880
881static void
882load_places_store (BookmarkAgent *this)
883{
884 BookmarkAgentPrivate *priv = bookmark_agent_get_instance_private (this);
885
886 gchar **uris;
887 gchar **groups;
888 gchar **bookmarks = NULL((void*)0);
889
890 gchar *buf, *label, *uri;
891
892 gint i, j, bookmark_len;
893
894 load_xbel_store (this);
895
896 uris = g_bookmark_file_get_uris (priv->store, NULL((void*)0));
897
898 for (i = 0; uris && uris [i]; ++i) {
899 groups = g_bookmark_file_get_groups (priv->store, uris [i], NULL((void*)0), NULL((void*)0));
900
901 for (j = 0; groups && groups [j]; ++j) {
902 if (! strcmp (groups [j], "gtk-bookmarks")) {
903 g_bookmark_file_remove_item (priv->store, uris [i], NULL((void*)0));
904
905 break;
906 }
907 }
908
909 g_strfreev (groups);
910 }
911
912 g_strfreev (uris);
913
914 g_file_get_contents (priv->gtk_store_path, & buf, NULL((void*)0), NULL((void*)0));
915
916 if (buf) {
917 bookmarks = g_strsplit (buf, "\n", -1);
918 g_free (buf);
919 }
920
921 for (i = 0; bookmarks && bookmarks [i]; ++i) {
922 bookmark_len = strlen (bookmarks [i]);
923 if (bookmark_len > 0) {
924 label = strstr (bookmarks[i], " ");
925 if (label != NULL((void*)0))
926 uri = g_strndup (bookmarks [i], bookmark_len - strlen (label));
927 else
928 uri = bookmarks [i];
929 g_bookmark_file_add_group (priv->store, uri, "gtk-bookmarks");
930 priv->create_item (this, uri);
931 if (label != NULL((void*)0)) {
932 label++;
933 if (strlen (label) > 0)
934 g_bookmark_file_set_title (priv->store, uri, label);
935 g_free (uri);
936 }
937 }
938 }
939
940 g_strfreev (bookmarks);
941}
942
943static gchar *
944find_package_data_file (const gchar *filename)
945{
946 const gchar * const *dirs = NULL((void*)0);
947 gchar *path = NULL((void*)0);
948 gint i;
949
950 dirs = g_get_system_data_dirs ();
951
952 for (i = 0; ! path && dirs && dirs [i]; ++i) {
953 path = g_build_filename (dirs [i], PACKAGE"mate-control-center", filename, NULL((void*)0));
954
955 if (! g_file_test (path, G_FILE_TEST_EXISTS)) {
956 g_free (path);
957 path = NULL((void*)0);
958 }
959 }
960
961 return path;
962}
963
964static void
965update_user_spec_path (BookmarkAgent *this)
966{
967 BookmarkAgentPrivate *priv = bookmark_agent_get_instance_private (this);
968
969 gboolean use_user_path;
970 gchar *path = NULL((void*)0);
971
972 BookmarkStoreStatus status;
973
974 use_user_path = priv->user_modifiable &&
975 (priv->needs_sync || g_file_test (priv->user_store_path, G_FILE_TEST_EXISTS));
976
977 if (use_user_path)
978 path = g_strdup (priv->user_store_path)g_strdup_inline (priv->user_store_path);
979 else
980 path = find_package_data_file (priv->store_filename);
981
982 if (use_user_path)
983 status = BOOKMARK_STORE_USER;
984 else if (path && priv->user_modifiable)
985 status = BOOKMARK_STORE_DEFAULT;
986 else if (path)
987 status = BOOKMARK_STORE_DEFAULT_ONLY;
988 else
989 status = BOOKMARK_STORE_ABSENT;
990
991 if (priv->status != status) {
992 priv->status = status;
993 g_object_notify (G_OBJECT (this)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((this)), (((GType) ((20) << (2))))))))
, BOOKMARK_AGENT_STORE_STATUS_PROP"store-status");
994
995 if (priv->user_store_monitor) {
996 g_file_monitor_cancel (priv->user_store_monitor);
997 g_object_unref (priv->user_store_monitor);
998 priv->user_store_monitor = NULL((void*)0);
999 }
1000
1001 if (priv->status == BOOKMARK_STORE_DEFAULT) {
1002 GFile *user_store_file;
1003
1004 user_store_file = g_file_new_for_path (priv->user_store_path);
1005 priv->user_store_monitor = g_file_monitor_file (user_store_file,
1006 0, NULL((void*)0), NULL((void*)0));
1007 if (priv->user_store_monitor) {
1008 g_signal_connect (priv->user_store_monitor, "changed",g_signal_connect_data ((priv->user_store_monitor), ("changed"
), (((GCallback) (store_monitor_cb))), (this), ((void*)0), (GConnectFlags
) 0)
1009 G_CALLBACK (store_monitor_cb), this)g_signal_connect_data ((priv->user_store_monitor), ("changed"
), (((GCallback) (store_monitor_cb))), (this), ((void*)0), (GConnectFlags
) 0)
;
1010 }
1011
1012 g_object_unref (user_store_file);
1013 }
1014 }
1015
1016 if (g_strcmp0 (priv->store_path, path)) {
1017 g_free (priv->store_path);
1018 priv->store_path = path;
1019
1020 if (priv->store_monitor) {
1021 g_file_monitor_cancel (priv->store_monitor);
1022 g_object_unref (priv->store_monitor);
1023 }
1024
1025 if (priv->store_path) {
1026 GFile *store_file;
1027
1028 store_file = g_file_new_for_path (priv->store_path);
1029 priv->store_monitor = g_file_monitor_file (store_file,
1030 0, NULL((void*)0), NULL((void*)0));
1031 if (priv->store_monitor) {
1032 g_signal_connect (priv->store_monitor, "changed",g_signal_connect_data ((priv->store_monitor), ("changed"),
(((GCallback) (store_monitor_cb))), (this), ((void*)0), (GConnectFlags
) 0)
1033 G_CALLBACK (store_monitor_cb), this)g_signal_connect_data ((priv->store_monitor), ("changed"),
(((GCallback) (store_monitor_cb))), (this), ((void*)0), (GConnectFlags
) 0)
;
1034 }
1035
1036 g_object_unref (store_file);
1037 }
1038 }
1039 else
1040 g_free (path);
1041}
1042
1043static void
1044save_xbel_store (BookmarkAgent *this)
1045{
1046 BookmarkAgentPrivate *priv = bookmark_agent_get_instance_private (this);
1047
1048 GError *error = NULL((void*)0);
1049
1050 if (g_bookmark_file_to_file (priv->store, priv->store_path, &error))
1051 return;
1052
1053 if (error) {
1054 g_warning ("Couldn't save bookmark file [%s]: %s", priv->store_path, error->message);
1055 g_error_free (error);
1056 } else {
1057 g_warning ("Couldn't save bookmark file [%s]", priv->store_path);
1058 }
1059}
1060
1061static void
1062create_app_item (BookmarkAgent *this, const gchar *uri)
1063{
1064 BookmarkAgentPrivate *priv = bookmark_agent_get_instance_private (this);
1065
1066 MateDesktopItem *ditem;
1067 gchar *uri_new = NULL((void*)0);
1068
1069 ditem = libslab_mate_desktop_item_new_from_unknown_id (uri);
1070
1071 if (ditem) {
1072 uri_new = g_strdup (mate_desktop_item_get_location (ditem))g_strdup_inline (mate_desktop_item_get_location (ditem));
1073 mate_desktop_item_unref (ditem);
1074 }
1075
1076 if (! uri_new)
1077 return;
1078
1079 if (g_strcmp0 (uri, uri_new))
1080 g_bookmark_file_move_item (priv->store, uri, uri_new, NULL((void*)0));
1081
1082 g_free (uri_new);
1083}
1084
1085static void
1086create_doc_item (BookmarkAgent *this, const gchar *uri)
1087{
1088 BookmarkAgentPrivate *priv = bookmark_agent_get_instance_private (this);
1089
1090 gchar *uri_new = NULL((void*)0);
1091
1092 if ((strcmp (uri, "BLANK_SPREADSHEET") == 0) || (strcmp (uri, "BLANK_DOCUMENT") == 0)) {
1093 gchar *template = NULL((void*)0);
1094 gchar *file;
1095
1096 gchar *dir = g_strdup (g_get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS))g_strdup_inline (g_get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS
))
;
1097 if (!dir)
1098 dir = g_build_filename (g_get_home_dir (), "Documents", NULL((void*)0));
1099
1100 if (strcmp (uri, "BLANK_SPREADSHEET") == 0) {
1101 g_bookmark_file_set_title (priv->store, uri, "BLANK_SPREADSHEET");
1102 file = g_strconcat (_("New Spreadsheet")((char *) g_dgettext ("mate-control-center", "New Spreadsheet"
))
, ".ots", NULL((void*)0));
1103 template = find_package_data_file (CALC_TEMPLATE_FILE_NAME"empty.ots");
1104 } else {
1105 g_bookmark_file_set_title (priv->store, uri, "BLANK_DOCUMENT");
1106 file = g_strconcat (_("New Document")((char *) g_dgettext ("mate-control-center", "New Document")), ".ott", NULL((void*)0));
1107 template = find_package_data_file (WRITER_TEMPLATE_FILE_NAME"empty.ott");
1108 }
1109
1110 gchar *path = g_build_filename (dir, file, NULL((void*)0));
1111 if (!g_file_test (path, G_FILE_TEST_EXISTS)) {
1112 g_mkdir_with_parents (dir, 0700);
1113
1114 if (template != NULL((void*)0)) {
1115 gchar *contents;
1116 gsize length;
1117
1118 if (g_file_get_contents (template, &contents, &length, NULL((void*)0)))
1119 g_file_set_contents (path, contents, length, NULL((void*)0));
1120
1121 g_free (contents);
1122 } else {
1123 fclose (g_fopenfopen (path, "w"));
1124 }
1125 }
1126
1127 uri_new = g_filename_to_uri (path, NULL((void*)0), NULL((void*)0));
1128
1129 g_free (dir);
1130 g_free (file);
1131 g_free (path);
1132 g_free (template);
1133 }
1134
1135 if (!uri_new)
1136 return;
1137
1138 if (g_strcmp0 (uri, uri_new))
1139 g_bookmark_file_move_item (priv->store, uri, uri_new, NULL((void*)0));
1140
1141 g_free (uri_new);
1142}
1143
1144static void
1145create_dir_item (BookmarkAgent *this, const gchar *uri)
1146{
1147 BookmarkAgentPrivate *priv = bookmark_agent_get_instance_private (this);
1148
1149 gchar *uri_new = NULL((void*)0);
1150 gchar *path = NULL((void*)0);
1151 gchar *name = NULL((void*)0);
1152 gchar *icon = NULL((void*)0);
1153
1154 gchar *search_string = NULL((void*)0);
1155
1156 gboolean gotta_free_name = FALSE(0);
1157
1158 if (strcmp (uri, "HOME") == 0) {
1159 uri_new = g_filename_to_uri (g_get_home_dir (), NULL((void*)0), NULL((void*)0));
1160 name = g_strdup (C_("Home folder", "Home"))g_strdup_inline (g_dpgettext ("mate-control-center", "Home folder"
"\004" "Home", strlen ("Home folder") + 1))
;
1161 gotta_free_name = TRUE(!(0));
1162 icon = "user-home";
1163 } else if (strcmp (uri, "DOCUMENTS") == 0) {
1164 path = g_strdup (g_get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS))g_strdup_inline (g_get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS
))
;
1165 if (!path)
1166 path = g_build_filename (g_get_home_dir (), "Documents", NULL((void*)0));
1167 name = _("Documents")((char *) g_dgettext ("mate-control-center", "Documents"));
1168 uri_new = g_filename_to_uri (path, NULL((void*)0), NULL((void*)0));
1169 } else if (strcmp (uri, "DESKTOP") == 0) {
1170 path = g_strdup (g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP))g_strdup_inline (g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP
))
;
1171 if (!path)
1172 path = g_build_filename (g_get_home_dir (), "Desktop", NULL((void*)0));
1173 name = _("Desktop")((char *) g_dgettext ("mate-control-center", "Desktop"));
1174 uri_new = g_filename_to_uri (path, NULL((void*)0), NULL((void*)0));
1175 icon = "user-desktop";
1176 } else if (strcmp (uri, "file:///") == 0) {
1177 icon = "drive-harddisk";
1178 name = _("File System")((char *) g_dgettext ("mate-control-center", "File System"));
1179 } else if (strcmp (uri, "network:") == 0) {
1180 icon = "network-workgroup";
1181 name = _("Network Servers")((char *) g_dgettext ("mate-control-center", "Network Servers"
))
;
1182 } else if (g_str_has_prefix (uri, "x-caja-search")(__builtin_constant_p ("x-caja-search")? __extension__ ({ const
char * const __str = (uri); const char * const __prefix = ("x-caja-search"
); gboolean __result = (0); if (__str == ((void*)0) || __prefix
== ((void*)0)) __result = (g_str_has_prefix) (__str, __prefix
); else { const size_t __str_len = strlen (((__str) + !(__str
))); const size_t __prefix_len = strlen (((__prefix) + !(__prefix
))); if (__str_len >= __prefix_len) __result = memcmp (((__str
) + !(__str)), ((__prefix) + !(__prefix)), __prefix_len) == 0
; } __result; }) : (g_str_has_prefix) (uri, "x-caja-search") )
) {
1183 icon = "system-search";
1184
1185 path = g_build_filename (g_get_user_data_dir (), "caja", "searches", & uri [21], NULL((void*)0));
1186
1187 if (g_file_test (path, G_FILE_TEST_EXISTS)) {
1188 gchar *buf = NULL((void*)0);
1189 g_file_get_contents (path, &buf, NULL((void*)0), NULL((void*)0));
1190
1191 gchar *tag_open_ptr = NULL((void*)0);
1192 gchar *tag_close_ptr = NULL((void*)0);
1193
1194 if (buf) {
1195 tag_open_ptr = strstr (buf, "<text>");
1196 tag_close_ptr = strstr (buf, "</text>");
1197 }
1198
1199 if (tag_open_ptr && tag_close_ptr) {
1200 tag_close_ptr [0] = '\0';
1201 tag_close_ptr [0] = 'a';
1202 search_string = g_strdup_printf ("\"%s\"", &tag_open_ptr[6]);
1203 }
1204
1205 g_free (buf);
1206 }
1207
1208 if (search_string) {
1209 name = search_string;
1210 gotta_free_name = TRUE(!(0));
1211 } else {
1212 name = _("Search")((char *) g_dgettext ("mate-control-center", "Search"));
1213 }
1214 }
1215
1216 if (icon)
1217 g_bookmark_file_set_icon (priv->store, uri, icon, "image/png");
1218
1219 if (name)
1220 g_bookmark_file_set_title (priv->store, uri, name);
1221
1222 if (uri_new && g_strcmp0 (uri, uri_new))
1223 g_bookmark_file_move_item (priv->store, uri, uri_new, NULL((void*)0));
1224
1225 if (gotta_free_name) {
1226 g_free (name);
1227 }
1228
1229 g_free (path);
1230 g_free (uri_new);
1231}
1232
1233static void
1234store_monitor_cb (GFileMonitor *mon, GFile *f1, GFile *f2,
1235 GFileMonitorEvent event_type, gpointer user_data)
1236{
1237 update_agent (BOOKMARK_AGENT (user_data)((((BookmarkAgent*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((bookmark_agent_get_type ()))))))
)
;
1
Calling 'update_agent'
1238}
1239
1240static void
1241weak_destroy_cb (gpointer data, GObject *g_obj)
1242{
1243 instances [GPOINTER_TO_INT (data)((gint) (glong) (data))] = NULL((void*)0);
1244}
diff --git a/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-e8a3a6.html b/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-e8a3a6.html new file mode 100644 index 00000000..70d5a72d --- /dev/null +++ b/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/report-e8a3a6.html @@ -0,0 +1,1049 @@ + + + +gtkrc-utils.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:capplets/common/gtkrc-utils.c
Warning:line 165, column 32
Dereference of null pointer (loaded from variable 'engines')
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name gtkrc-utils.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/capplets/common -fcoverage-compilation-dir=/rootdir/capplets/common -resource-dir /usr/bin/../lib/clang/18 -D HAVE_CONFIG_H -I . -I ../.. -D MATECC_DATA_DIR="/usr/local/share/mate-control-center" -D MATELOCALEDIR="/usr/local/share/locale" -D MATEDATADIR="/usr/local/share" -D GTK_ENGINE_DIR="/usr/lib64/gtk-3.0/3.0.0/theming-engines" -D G_LOG_DOMAIN="capplet-common" -D INSTALL_PREFIX="/usr/local" -I ../.. -D PIXMAP_DIR="/usr/local/share/mate-control-center/pixmaps" -I /usr/include/udisks2 -I /usr/include/libgtop-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/libxml2 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/gio-unix-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/dconf -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/startup-notification-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/gio-unix-2.0 -I /usr/include/dconf -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I /usr/include/marco-1 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/atk-1.0 -I /usr/include/freetype2 -I /usr/include/harfbuzz -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/cloudproviders -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/pixman-1 -I /usr/include/libpng16 -I /usr/include/gio-unix-2.0 -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I /usr/include/dconf -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -D WITH_GZFILEOP -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -D PIC -internal-isystem /usr/bin/../lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-06-07-044335-13427-1 -x c gtkrc-utils.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 * Copyright (C) 2007 The GNOME Foundation
3 * Written by Thomas Wood <thos@gnome.org>
4 * Jens Granseuer <jensgr@gmx.net>
5 * All Rights Reserved
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 */
21
22#ifdef HAVE_CONFIG_H1
23#include <config.h>
24#endif
25
26#include <string.h>
27#include <unistd.h>
28#include <glib.h>
29#include <glib/gstdio.h>
30#include <fcntl.h>
31#include <gtk/gtk.h>
32
33#include "gtkrc-utils.h"
34
35#define INCLUDE_SYMBOL((gpointer) 1) ((gpointer) 1)
36#define ENGINE_SYMBOL((gpointer) 2) ((gpointer) 2)
37#define COLOR_SCHEME_SYMBOL((gpointer) 3) ((gpointer) 3)
38
39gchar* gtkrc_find_named(const gchar* name)
40{
41 /* find the gtkrc of the named theme
42 * taken from gtkrc.c (gtk_rc_parse_named)
43 */
44 gchar* path = NULL((void*)0);
45 const gchar* home_dir;
46 const gchar* subpath = "gtk-2.0" G_DIR_SEPARATOR_S"/" "gtkrc";
47
48 /* First look in the users home directory
49 */
50 home_dir = g_get_home_dir();
51
52 if (home_dir)
53 {
54 path = g_build_filename(home_dir, ".themes", name, subpath, NULL((void*)0));
55
56 if (!g_file_test (path, G_FILE_TEST_EXISTS))
57 {
58 g_free (path);
59 path = NULL((void*)0);
60 }
61 }
62
63 if (!path)
64 {
65 const gchar * const * dirs = g_get_system_data_dirs();
66
67 if (dirs != NULL((void*)0))
68 for (; !path && *dirs != NULL((void*)0); ++dirs)
69 {
70 path = g_build_filename(*dirs, "themes", name, subpath, NULL((void*)0));
71
72 if (!g_file_test(path, G_FILE_TEST_EXISTS))
73 {
74 g_free (path);
75 path = NULL((void*)0);
76 }
77 }
78 }
79
80 return path;
81
82}
83
84void gtkrc_get_details(gchar* filename, GSList** engines, GSList** symbolic_colors)
85{
86 gint file = -1;
87 GSList* files = NULL((void*)0);
88 GSList* read_files = NULL((void*)0);
89 GTokenType token;
90 GScanner *scanner = g_scanner_new (NULL((void*)0));
91
92 g_scanner_scope_add_symbol (scanner, 0, "include", INCLUDE_SYMBOL((gpointer) 1));
93
94 if (engines != NULL((void*)0))
1
Assuming 'engines' is equal to NULL
2
Taking false branch
95 {
96 g_scanner_scope_add_symbol (scanner, 0, "engine", ENGINE_SYMBOL((gpointer) 2));
97 }
98
99 files = g_slist_prepend (files, g_strdup (filename)g_strdup_inline (filename));
100
101 while (files != NULL((void*)0))
3
Assuming 'files' is not equal to NULL
4
Loop condition is true. Entering loop body
102 {
103 filename = files->data;
104 files = g_slist_delete_link (files, files);
105
106 if (filename == NULL((void*)0))
5
Assuming 'filename' is not equal to NULL
6
Taking false branch
107 continue;
108
109 if (g_slist_find_custom (read_files, filename, (GCompareFunc) strcmp))
7
Assuming the condition is false
8
Taking false branch
110 {
111 g_warning ("Recursion in the gtkrc detected!");
112 g_free (filename);
113 continue; /* skip this file since we've done it before... */
114 }
115
116 read_files = g_slist_prepend (read_files, filename);
117
118 file = g_openopen (filename, O_RDONLY00);
119 if (file == -1)
9
Assuming the condition is false
10
Taking false branch
120 {
121 g_warning ("Could not open file \"%s\"", filename);
122 }
123 else
124 {
125 g_scanner_input_file (scanner, file);
126 while ((token = g_scanner_get_next_token (scanner)) != G_TOKEN_EOF)
11
Assuming the condition is true
12
Loop condition is true. Entering loop body
127 {
128 GTokenType string_token;
129 if (token == '@')
13
Assuming the condition is false
14
Taking false branch
130 {
131 if (symbolic_colors == NULL((void*)0))
132 continue;
133 token = g_scanner_get_next_token (scanner);
134 if (token != G_TOKEN_IDENTIFIER)
135 continue;
136 if (!g_slist_find_custom (*symbolic_colors, scanner->value.v_identifier, (GCompareFunc) strcmp))
137 *symbolic_colors = g_slist_append (*symbolic_colors, g_strdup (scanner->value.v_identifier)g_strdup_inline (scanner->value.v_identifier));
138 continue;
139 }
140
141 if (token != G_TOKEN_SYMBOL)
15
Assuming 'token' is equal to G_TOKEN_SYMBOL
16
Taking false branch
142 continue;
143
144 if (scanner->value.v_symbol == INCLUDE_SYMBOL((gpointer) 1))
17
Assuming field 'v_symbol' is not equal to INCLUDE_SYMBOL
18
Taking false branch
145 {
146 string_token = g_scanner_get_next_token (scanner);
147 if (string_token != G_TOKEN_STRING)
148 continue;
149 if (g_path_is_absolute (scanner->value.v_string))
150 {
151 files = g_slist_prepend (files, g_strdup (scanner->value.v_string)g_strdup_inline (scanner->value.v_string));
152 }
153 else
154 {
155 gchar *basedir = g_path_get_dirname (filename);
156 files = g_slist_prepend (files, g_build_path (G_DIR_SEPARATOR_S"/", basedir, scanner->value.v_string, NULL((void*)0)));
157 g_free (basedir);
158 }
159 }
160 else if (scanner->value.v_symbol == ENGINE_SYMBOL((gpointer) 2))
19
Assuming field 'v_symbol' is equal to ENGINE_SYMBOL
20
Taking true branch
161 {
162 string_token = g_scanner_get_next_token (scanner);
163 if (string_token != G_TOKEN_STRING || scanner->value.v_string[0] == '\0')
21
Assuming 'string_token' is equal to G_TOKEN_STRING
22
Assuming the condition is false
23
Taking false branch
164 continue;
165 if (!g_slist_find_custom (*engines, scanner->value.v_string, (GCompareFunc) strcmp))
24
Dereference of null pointer (loaded from variable 'engines')
166 *engines = g_slist_append (*engines, g_strdup (scanner->value.v_string)g_strdup_inline (scanner->value.v_string));
167 }
168
169 }
170 close (file);
171 }
172 }
173
174 g_slist_free_full (read_files, g_free);
175
176 g_scanner_destroy (scanner);
177}
178
179static const GScannerConfig gtk_rc_scanner_config =
180{
181 (
182 " \t\r\n"
183 ) /* cset_skip_characters */,
184 (
185 "_"
186 G_CSET_a_2_z"abcdefghijklmnopqrstuvwxyz"
187 G_CSET_A_2_Z"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
188 ) /* cset_identifier_first */,
189 (
190 G_CSET_DIGITS"0123456789"
191 "-_"
192 G_CSET_a_2_z"abcdefghijklmnopqrstuvwxyz"
193 G_CSET_A_2_Z"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
194 ) /* cset_identifier_nth */,
195 ( "#\n" ) /* cpair_comment_single */,
196
197 TRUE(!(0)) /* case_sensitive */,
198
199 TRUE(!(0)) /* skip_comment_multi */,
200 TRUE(!(0)) /* skip_comment_single */,
201 TRUE(!(0)) /* scan_comment_multi */,
202 TRUE(!(0)) /* scan_identifier */,
203 FALSE(0) /* scan_identifier_1char */,
204 FALSE(0) /* scan_identifier_NULL */,
205 TRUE(!(0)) /* scan_symbols */,
206 TRUE(!(0)) /* scan_binary */,
207 TRUE(!(0)) /* scan_octal */,
208 TRUE(!(0)) /* scan_float */,
209 TRUE(!(0)) /* scan_hex */,
210 TRUE(!(0)) /* scan_hex_dollar */,
211 TRUE(!(0)) /* scan_string_sq */,
212 TRUE(!(0)) /* scan_string_dq */,
213 TRUE(!(0)) /* numbers_2_int */,
214 FALSE(0) /* int_2_float */,
215 FALSE(0) /* identifier_2_string */,
216 TRUE(!(0)) /* char_2_token */,
217 TRUE(!(0)) /* symbol_2_token */,
218 FALSE(0) /* scope_0_fallback */,
219 FALSE(0) /* store_int64 */,
220
221 0 /* < private > padding_dummy*/,
222};
223
224gchar *
225gtkrc_get_color_scheme (const gchar *gtkrc_file)
226{
227 gint file = -1;
228 gchar *result = NULL((void*)0);
229 GSList *files = NULL((void*)0);
230 GSList *read_files = NULL((void*)0);
231 GTokenType token;
232 GScanner *scanner = g_scanner_new (&gtk_rc_scanner_config);
233
234 g_scanner_scope_add_symbol (scanner, 0, "include", INCLUDE_SYMBOL((gpointer) 1));
235 g_scanner_scope_add_symbol (scanner, 0, "gtk_color_scheme", COLOR_SCHEME_SYMBOL((gpointer) 3));
236 g_scanner_scope_add_symbol (scanner, 0, "gtk-color-scheme", COLOR_SCHEME_SYMBOL((gpointer) 3));
237
238 files = g_slist_prepend (files, g_strdup (gtkrc_file)g_strdup_inline (gtkrc_file));
239 while (files != NULL((void*)0))
240 {
241 gchar *filename = files->data;
242 files = g_slist_delete_link (files, files);
243
244 if (filename == NULL((void*)0))
245 continue;
246
247 if (g_slist_find_custom (read_files, filename, (GCompareFunc) strcmp))
248 {
249 g_warning ("Recursion in the gtkrc detected!");
250 g_free (filename);
251 continue; /* skip this file since we've done it before... */
252 }
253
254 read_files = g_slist_prepend (read_files, filename);
255
256 file = g_openopen (filename, O_RDONLY00);
257 if (file == -1)
258 {
259 g_warning ("Could not open file \"%s\"", filename);
260 }
261 else
262 {
263 g_scanner_input_file (scanner, file);
264 while ((token = g_scanner_get_next_token (scanner)) != G_TOKEN_EOF)
265 {
266 if (GINT_TO_POINTER (token)((gpointer) (glong) (token)) == COLOR_SCHEME_SYMBOL((gpointer) 3))
267 {
268 if (g_scanner_get_next_token (scanner) == '=')
269 {
270 token = g_scanner_get_next_token (scanner);
271 if (token == G_TOKEN_STRING)
272 {
273 g_free (result);
274 result = g_strdup (scanner->value.v_string)g_strdup_inline (scanner->value.v_string);
275 }
276 }
277 }
278 }
279 close (file);
280 }
281 }
282
283 g_slist_free_full (read_files, g_free);
284
285 g_scanner_destroy (scanner);
286 return result;
287}
288
289gchar* gtkrc_get_color_scheme_for_theme(const gchar* theme_name)
290{
291 /* try to find the color scheme from the gtkrc */
292 gchar* gtkrc_file;
293 gchar* scheme = NULL((void*)0);
294
295 gtkrc_file = gtkrc_find_named(theme_name);
296
297 if (gtkrc_file)
298 {
299 scheme = gtkrc_get_color_scheme(gtkrc_file);
300 g_free(gtkrc_file);
301 }
302
303 return scheme;
304}
diff --git a/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/scanview.css b/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/scanview.css new file mode 100644 index 00000000..cf8a5a6a --- /dev/null +++ b/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/scanview.css @@ -0,0 +1,62 @@ +body { color:#000000; background-color:#ffffff } +body { font-family: Helvetica, sans-serif; font-size:9pt } +h1 { font-size: 14pt; } +h2 { font-size: 12pt; } +table { font-size:9pt } +table { border-spacing: 0px; border: 1px solid black } +th, table thead { + background-color:#eee; color:#666666; + font-weight: bold; cursor: default; + text-align:center; + font-weight: bold; font-family: Verdana; + white-space:nowrap; +} +.W { font-size:0px } +th, td { padding:5px; padding-left:8px; text-align:left } +td.SUMM_DESC { padding-left:12px } +td.DESC { white-space:pre } +td.Q { text-align:right } +td { text-align:left } +tbody.scrollContent { overflow:auto } + +table.form_group { + background-color: #ccc; + border: 1px solid #333; + padding: 2px; +} + +table.form_inner_group { + background-color: #ccc; + border: 1px solid #333; + padding: 0px; +} + +table.form { + background-color: #999; + border: 1px solid #333; + padding: 2px; +} + +td.form_label { + text-align: right; + vertical-align: top; +} +/* For one line entires */ +td.form_clabel { + text-align: right; + vertical-align: center; +} +td.form_value { + text-align: left; + vertical-align: top; +} +td.form_submit { + text-align: right; + vertical-align: top; +} + +h1.SubmitFail { + color: #f00; +} +h1.SubmitOk { +} diff --git a/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/sorttable.js b/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/sorttable.js new file mode 100644 index 00000000..32faa078 --- /dev/null +++ b/2024-06-07-044335-13427-1@649fad9a0117_wayland-theme-customize/sorttable.js @@ -0,0 +1,492 @@ +/* + SortTable + version 2 + 7th April 2007 + Stuart Langridge, http://www.kryogenix.org/code/browser/sorttable/ + + Instructions: + Download this file + Add to your HTML + Add class="sortable" to any table you'd like to make sortable + Click on the headers to sort + + Thanks to many, many people for contributions and suggestions. + Licenced as X11: http://www.kryogenix.org/code/browser/licence.html + This basically means: do what you want with it. +*/ + + +var stIsIE = /*@cc_on!@*/false; + +sorttable = { + init: function() { + // quit if this function has already been called + if (arguments.callee.done) return; + // flag this function so we don't do the same thing twice + arguments.callee.done = true; + // kill the timer + if (_timer) clearInterval(_timer); + + if (!document.createElement || !document.getElementsByTagName) return; + + sorttable.DATE_RE = /^(\d\d?)[\/\.-](\d\d?)[\/\.-]((\d\d)?\d\d)$/; + + forEach(document.getElementsByTagName('table'), function(table) { + if (table.className.search(/\bsortable\b/) != -1) { + sorttable.makeSortable(table); + } + }); + + }, + + makeSortable: function(table) { + if (table.getElementsByTagName('thead').length == 0) { + // table doesn't have a tHead. Since it should have, create one and + // put the first table row in it. + the = document.createElement('thead'); + the.appendChild(table.rows[0]); + table.insertBefore(the,table.firstChild); + } + // Safari doesn't support table.tHead, sigh + if (table.tHead == null) table.tHead = table.getElementsByTagName('thead')[0]; + + if (table.tHead.rows.length != 1) return; // can't cope with two header rows + + // Sorttable v1 put rows with a class of "sortbottom" at the bottom (as + // "total" rows, for example). This is B&R, since what you're supposed + // to do is put them in a tfoot. So, if there are sortbottom rows, + // for backward compatibility, move them to tfoot (creating it if needed). + sortbottomrows = []; + for (var i=0; i5' : ' ▴'; + this.appendChild(sortrevind); + return; + } + if (this.className.search(/\bsorttable_sorted_reverse\b/) != -1) { + // if we're already sorted by this column in reverse, just + // re-reverse the table, which is quicker + sorttable.reverse(this.sorttable_tbody); + this.className = this.className.replace('sorttable_sorted_reverse', + 'sorttable_sorted'); + this.removeChild(document.getElementById('sorttable_sortrevind')); + sortfwdind = document.createElement('span'); + sortfwdind.id = "sorttable_sortfwdind"; + sortfwdind.innerHTML = stIsIE ? ' 6' : ' ▾'; + this.appendChild(sortfwdind); + return; + } + + // remove sorttable_sorted classes + theadrow = this.parentNode; + forEach(theadrow.childNodes, function(cell) { + if (cell.nodeType == 1) { // an element + cell.className = cell.className.replace('sorttable_sorted_reverse',''); + cell.className = cell.className.replace('sorttable_sorted',''); + } + }); + sortfwdind = document.getElementById('sorttable_sortfwdind'); + if (sortfwdind) { sortfwdind.parentNode.removeChild(sortfwdind); } + sortrevind = document.getElementById('sorttable_sortrevind'); + if (sortrevind) { sortrevind.parentNode.removeChild(sortrevind); } + + this.className += ' sorttable_sorted'; + sortfwdind = document.createElement('span'); + sortfwdind.id = "sorttable_sortfwdind"; + sortfwdind.innerHTML = stIsIE ? ' 6' : ' ▾'; + this.appendChild(sortfwdind); + + // build an array to sort. This is a Schwartzian transform thing, + // i.e., we "decorate" each row with the actual sort key, + // sort based on the sort keys, and then put the rows back in order + // which is a lot faster because you only do getInnerText once per row + row_array = []; + col = this.sorttable_columnindex; + rows = this.sorttable_tbody.rows; + for (var j=0; j 12) { + // definitely dd/mm + return sorttable.sort_ddmm; + } else if (second > 12) { + return sorttable.sort_mmdd; + } else { + // looks like a date, but we can't tell which, so assume + // that it's dd/mm (English imperialism!) and keep looking + sortfn = sorttable.sort_ddmm; + } + } + } + } + return sortfn; + }, + + getInnerText: function(node) { + // gets the text we want to use for sorting for a cell. + // strips leading and trailing whitespace. + // this is *not* a generic getInnerText function; it's special to sorttable. + // for example, you can override the cell text with a customkey attribute. + // it also gets .value for fields. + + hasInputs = (typeof node.getElementsByTagName == 'function') && + node.getElementsByTagName('input').length; + + if (node.getAttribute("sorttable_customkey") != null) { + return node.getAttribute("sorttable_customkey"); + } + else if (typeof node.textContent != 'undefined' && !hasInputs) { + return node.textContent.replace(/^\s+|\s+$/g, ''); + } + else if (typeof node.innerText != 'undefined' && !hasInputs) { + return node.innerText.replace(/^\s+|\s+$/g, ''); + } + else if (typeof node.text != 'undefined' && !hasInputs) { + return node.text.replace(/^\s+|\s+$/g, ''); + } + else { + switch (node.nodeType) { + case 3: + if (node.nodeName.toLowerCase() == 'input') { + return node.value.replace(/^\s+|\s+$/g, ''); + } + case 4: + return node.nodeValue.replace(/^\s+|\s+$/g, ''); + break; + case 1: + case 11: + var innerText = ''; + for (var i = 0; i < node.childNodes.length; i++) { + innerText += sorttable.getInnerText(node.childNodes[i]); + } + return innerText.replace(/^\s+|\s+$/g, ''); + break; + default: + return ''; + } + } + }, + + reverse: function(tbody) { + // reverse the rows in a tbody + newrows = []; + for (var i=0; i=0; i--) { + tbody.appendChild(newrows[i]); + } + delete newrows; + }, + + /* sort functions + each sort function takes two parameters, a and b + you are comparing a[0] and b[0] */ + sort_numeric: function(a,b) { + aa = parseFloat(a[0].replace(/[^0-9.-]/g,'')); + if (isNaN(aa)) aa = 0; + bb = parseFloat(b[0].replace(/[^0-9.-]/g,'')); + if (isNaN(bb)) bb = 0; + return aa-bb; + }, + sort_alpha: function(a,b) { + if (a[0]==b[0]) return 0; + if (a[0] 0 ) { + var q = list[i]; list[i] = list[i+1]; list[i+1] = q; + swap = true; + } + } // for + t--; + + if (!swap) break; + + for(var i = t; i > b; --i) { + if ( comp_func(list[i], list[i-1]) < 0 ) { + var q = list[i]; list[i] = list[i-1]; list[i-1] = q; + swap = true; + } + } // for + b++; + + } // while(swap) + } +} + +/* ****************************************************************** + Supporting functions: bundled here to avoid depending on a library + ****************************************************************** */ + +// Dean Edwards/Matthias Miller/John Resig + +/* for Mozilla/Opera9 */ +if (document.addEventListener) { + document.addEventListener("DOMContentLoaded", sorttable.init, false); +} + +/* for Internet Explorer */ +/*@cc_on @*/ +/*@if (@_win32) + document.write("