From c241b0f45983ad53a2a48e6b3ec3a42406a513e4 Mon Sep 17 00:00:00 2001 From: "raveit65 (via Travis CI)" Date: Thu, 20 Aug 2020 16:11:07 +0000 Subject: Deploy mate-desktop/mate-indicator-applet to github.com/mate-desktop/mate-indicator-applet.git:gh-pages --- .../index.html | 109 + .../report-164de5.html | 1412 ++++++++++++ .../report-2e42e2.html | 1412 ++++++++++++ .../report-489a68.html | 1412 ++++++++++++ .../report-53540c.html | 1412 ++++++++++++ .../report-8becd0.html | 1412 ++++++++++++ .../report-90b424.html | 1412 ++++++++++++ .../scanview.css | 62 + .../sorttable.js | 492 +++++ .../0.html | 1208 +++++++++++ .../index.html | 101 + .../stats.html | 89 + .../style.css | 149 ++ .../index.html | 109 + .../report-207019.html | 1412 ++++++++++++ .../report-5948e2.html | 1412 ++++++++++++ .../report-5ba708.html | 1412 ++++++++++++ .../report-9fcfe1.html | 1412 ++++++++++++ .../report-a3a98b.html | 1412 ++++++++++++ .../report-b4f74e.html | 1412 ++++++++++++ .../scanview.css | 62 + .../sorttable.js | 492 +++++ .../0.html | 2284 ++++++++++++++++++++ .../1.html | 1208 +++++++++++ .../index.html | 104 + .../stats.html | 90 + .../style.css | 149 ++ .../index.html | 109 + .../report-21a122.html | 1412 ++++++++++++ .../report-29810e.html | 1412 ++++++++++++ .../report-2cd880.html | 1412 ++++++++++++ .../report-73d269.html | 1412 ++++++++++++ .../report-918ee7.html | 1412 ++++++++++++ .../report-ed246f.html | 1412 ++++++++++++ .../scanview.css | 62 + .../sorttable.js | 492 +++++ .../0.html | 1208 +++++++++++ .../index.html | 101 + .../stats.html | 89 + .../style.css | 149 ++ .../0.html | 2280 +++++++++++++++++++ .../1.html | 1208 +++++++++++ .../index.html | 104 + .../stats.html | 90 + .../style.css | 149 ++ .../0.html | 2280 +++++++++++++++++++ .../1.html | 1208 +++++++++++ .../index.html | 104 + .../stats.html | 90 + .../style.css | 149 ++ .../0.html | 1208 +++++++++++ .../index.html | 101 + .../stats.html | 89 + .../style.css | 149 ++ .../0.html | 1208 +++++++++++ .../index.html | 101 + .../stats.html | 89 + .../style.css | 149 ++ .../0.html | 1208 +++++++++++ .../index.html | 101 + .../stats.html | 89 + .../style.css | 149 ++ .../0.html | 1208 +++++++++++ .../index.html | 101 + .../stats.html | 89 + .../style.css | 149 ++ .../0.html | 1208 +++++++++++ .../index.html | 101 + .../stats.html | 89 + .../style.css | 149 ++ .../0.html | 1208 +++++++++++ .../index.html | 101 + .../stats.html | 89 + .../style.css | 149 ++ .../0.html | 1208 +++++++++++ .../index.html | 101 + .../stats.html | 89 + .../style.css | 149 ++ .../0.html | 1208 +++++++++++ .../index.html | 101 + .../stats.html | 89 + .../style.css | 149 ++ .../0.html | 1208 +++++++++++ .../index.html | 101 + .../stats.html | 89 + .../style.css | 149 ++ .../0.html | 1208 +++++++++++ .../index.html | 101 + .../stats.html | 89 + .../style.css | 149 ++ .../0.html | 1224 +++++++++++ .../index.html | 117 + .../stats.html | 105 + .../style.css | 137 ++ .../0.html | 1224 +++++++++++ .../index.html | 117 + .../stats.html | 105 + .../style.css | 137 ++ CNAME | 1 + index.html | 46 + 100 files changed, 60679 insertions(+) create mode 100644 2020-04-09-113756-6097-1@37cc19e547b1_shadow/index.html create mode 100644 2020-04-09-113756-6097-1@37cc19e547b1_shadow/report-164de5.html create mode 100644 2020-04-09-113756-6097-1@37cc19e547b1_shadow/report-2e42e2.html create mode 100644 2020-04-09-113756-6097-1@37cc19e547b1_shadow/report-489a68.html create mode 100644 2020-04-09-113756-6097-1@37cc19e547b1_shadow/report-53540c.html create mode 100644 2020-04-09-113756-6097-1@37cc19e547b1_shadow/report-8becd0.html create mode 100644 2020-04-09-113756-6097-1@37cc19e547b1_shadow/report-90b424.html create mode 100644 2020-04-09-113756-6097-1@37cc19e547b1_shadow/scanview.css create mode 100644 2020-04-09-113756-6097-1@37cc19e547b1_shadow/sorttable.js create mode 100644 2020-04-09-113822-7129-cppcheck@37cc19e547b1_shadow/0.html create mode 100644 2020-04-09-113822-7129-cppcheck@37cc19e547b1_shadow/index.html create mode 100644 2020-04-09-113822-7129-cppcheck@37cc19e547b1_shadow/stats.html create mode 100644 2020-04-09-113822-7129-cppcheck@37cc19e547b1_shadow/style.css create mode 100644 2020-04-09-123617-6853-1@4b55003793c9_master/index.html create mode 100644 2020-04-09-123617-6853-1@4b55003793c9_master/report-207019.html create mode 100644 2020-04-09-123617-6853-1@4b55003793c9_master/report-5948e2.html create mode 100644 2020-04-09-123617-6853-1@4b55003793c9_master/report-5ba708.html create mode 100644 2020-04-09-123617-6853-1@4b55003793c9_master/report-9fcfe1.html create mode 100644 2020-04-09-123617-6853-1@4b55003793c9_master/report-a3a98b.html create mode 100644 2020-04-09-123617-6853-1@4b55003793c9_master/report-b4f74e.html create mode 100644 2020-04-09-123617-6853-1@4b55003793c9_master/scanview.css create mode 100644 2020-04-09-123617-6853-1@4b55003793c9_master/sorttable.js create mode 100644 2020-04-09-123647-2786-cppcheck@4b55003793c9_master/0.html create mode 100644 2020-04-09-123647-2786-cppcheck@4b55003793c9_master/1.html create mode 100644 2020-04-09-123647-2786-cppcheck@4b55003793c9_master/index.html create mode 100644 2020-04-09-123647-2786-cppcheck@4b55003793c9_master/stats.html create mode 100644 2020-04-09-123647-2786-cppcheck@4b55003793c9_master/style.css create mode 100644 2020-04-09-124840-6850-1@e69dd120803f_shadow/index.html create mode 100644 2020-04-09-124840-6850-1@e69dd120803f_shadow/report-21a122.html create mode 100644 2020-04-09-124840-6850-1@e69dd120803f_shadow/report-29810e.html create mode 100644 2020-04-09-124840-6850-1@e69dd120803f_shadow/report-2cd880.html create mode 100644 2020-04-09-124840-6850-1@e69dd120803f_shadow/report-73d269.html create mode 100644 2020-04-09-124840-6850-1@e69dd120803f_shadow/report-918ee7.html create mode 100644 2020-04-09-124840-6850-1@e69dd120803f_shadow/report-ed246f.html create mode 100644 2020-04-09-124840-6850-1@e69dd120803f_shadow/scanview.css create mode 100644 2020-04-09-124840-6850-1@e69dd120803f_shadow/sorttable.js create mode 100644 2020-04-09-124910-1519-cppcheck@e69dd120803f_shadow/0.html create mode 100644 2020-04-09-124910-1519-cppcheck@e69dd120803f_shadow/index.html create mode 100644 2020-04-09-124910-1519-cppcheck@e69dd120803f_shadow/stats.html create mode 100644 2020-04-09-124910-1519-cppcheck@e69dd120803f_shadow/style.css create mode 100644 2020-04-09-125606-1816-cppcheck@42f0ae6627b3_unreachable-code/0.html create mode 100644 2020-04-09-125606-1816-cppcheck@42f0ae6627b3_unreachable-code/1.html create mode 100644 2020-04-09-125606-1816-cppcheck@42f0ae6627b3_unreachable-code/index.html create mode 100644 2020-04-09-125606-1816-cppcheck@42f0ae6627b3_unreachable-code/stats.html create mode 100644 2020-04-09-125606-1816-cppcheck@42f0ae6627b3_unreachable-code/style.css create mode 100644 2020-04-14-235716-6997-cppcheck@8f98359bb878_master/0.html create mode 100644 2020-04-14-235716-6997-cppcheck@8f98359bb878_master/1.html create mode 100644 2020-04-14-235716-6997-cppcheck@8f98359bb878_master/index.html create mode 100644 2020-04-14-235716-6997-cppcheck@8f98359bb878_master/stats.html create mode 100644 2020-04-14-235716-6997-cppcheck@8f98359bb878_master/style.css create mode 100644 2020-04-15-000052-4762-cppcheck@60c698e3785f_master/0.html create mode 100644 2020-04-15-000052-4762-cppcheck@60c698e3785f_master/index.html create mode 100644 2020-04-15-000052-4762-cppcheck@60c698e3785f_master/stats.html create mode 100644 2020-04-15-000052-4762-cppcheck@60c698e3785f_master/style.css create mode 100644 2020-04-19-140522-4361-cppcheck@5fe75ca1e48e_master/0.html create mode 100644 2020-04-19-140522-4361-cppcheck@5fe75ca1e48e_master/index.html create mode 100644 2020-04-19-140522-4361-cppcheck@5fe75ca1e48e_master/stats.html create mode 100644 2020-04-19-140522-4361-cppcheck@5fe75ca1e48e_master/style.css create mode 100644 2020-04-20-002519-7043-cppcheck@228991434623_travis/0.html create mode 100644 2020-04-20-002519-7043-cppcheck@228991434623_travis/index.html create mode 100644 2020-04-20-002519-7043-cppcheck@228991434623_travis/stats.html create mode 100644 2020-04-20-002519-7043-cppcheck@228991434623_travis/style.css create mode 100644 2020-04-20-003354-2536-cppcheck@272fb9d24d93_travis/0.html create mode 100644 2020-04-20-003354-2536-cppcheck@272fb9d24d93_travis/index.html create mode 100644 2020-04-20-003354-2536-cppcheck@272fb9d24d93_travis/stats.html create mode 100644 2020-04-20-003354-2536-cppcheck@272fb9d24d93_travis/style.css create mode 100644 2020-04-20-005310-1134-cppcheck@c4c5242e5827_master/0.html create mode 100644 2020-04-20-005310-1134-cppcheck@c4c5242e5827_master/index.html create mode 100644 2020-04-20-005310-1134-cppcheck@c4c5242e5827_master/stats.html create mode 100644 2020-04-20-005310-1134-cppcheck@c4c5242e5827_master/style.css create mode 100644 2020-04-20-194804-0062-cppcheck@fd5ae00d8191_travis/0.html create mode 100644 2020-04-20-194804-0062-cppcheck@fd5ae00d8191_travis/index.html create mode 100644 2020-04-20-194804-0062-cppcheck@fd5ae00d8191_travis/stats.html create mode 100644 2020-04-20-194804-0062-cppcheck@fd5ae00d8191_travis/style.css create mode 100644 2020-04-20-204711-9247-cppcheck@5155c763c825_master/0.html create mode 100644 2020-04-20-204711-9247-cppcheck@5155c763c825_master/index.html create mode 100644 2020-04-20-204711-9247-cppcheck@5155c763c825_master/stats.html create mode 100644 2020-04-20-204711-9247-cppcheck@5155c763c825_master/style.css create mode 100644 2020-06-22-162728-2181-cppcheck@9e512823070d_travis-ci/0.html create mode 100644 2020-06-22-162728-2181-cppcheck@9e512823070d_travis-ci/index.html create mode 100644 2020-06-22-162728-2181-cppcheck@9e512823070d_travis-ci/stats.html create mode 100644 2020-06-22-162728-2181-cppcheck@9e512823070d_travis-ci/style.css create mode 100644 2020-06-26-094257-4646-cppcheck@741c50ee9687_master/0.html create mode 100644 2020-06-26-094257-4646-cppcheck@741c50ee9687_master/index.html create mode 100644 2020-06-26-094257-4646-cppcheck@741c50ee9687_master/stats.html create mode 100644 2020-06-26-094257-4646-cppcheck@741c50ee9687_master/style.css create mode 100644 2020-07-06-000331-2607-cppcheck@418dae76ea9e_master/0.html create mode 100644 2020-07-06-000331-2607-cppcheck@418dae76ea9e_master/index.html create mode 100644 2020-07-06-000331-2607-cppcheck@418dae76ea9e_master/stats.html create mode 100644 2020-07-06-000331-2607-cppcheck@418dae76ea9e_master/style.css create mode 100644 2020-08-20-160620-0353-cppcheck@fb7b816f4a78_master/0.html create mode 100644 2020-08-20-160620-0353-cppcheck@fb7b816f4a78_master/index.html create mode 100644 2020-08-20-160620-0353-cppcheck@fb7b816f4a78_master/stats.html create mode 100644 2020-08-20-160620-0353-cppcheck@fb7b816f4a78_master/style.css create mode 100644 2020-08-20-161040-7825-cppcheck@fb7b816f4a78_v1.25.0/0.html create mode 100644 2020-08-20-161040-7825-cppcheck@fb7b816f4a78_v1.25.0/index.html create mode 100644 2020-08-20-161040-7825-cppcheck@fb7b816f4a78_v1.25.0/stats.html create mode 100644 2020-08-20-161040-7825-cppcheck@fb7b816f4a78_v1.25.0/style.css create mode 100644 CNAME create mode 100644 index.html diff --git a/2020-04-09-113756-6097-1@37cc19e547b1_shadow/index.html b/2020-04-09-113756-6097-1@37cc19e547b1_shadow/index.html new file mode 100644 index 0000000..7cb319e --- /dev/null +++ b/2020-04-09-113756-6097-1@37cc19e547b1_shadow/index.html @@ -0,0 +1,109 @@ + + +rootdir - scan-build results + + + + + + +

rootdir - scan-build results

+ + + + + + + +
User:root@f19c22957bf8
Working Directory:/rootdir
Command Line:make -j 2
Clang Version:clang version 9.0.1 (Fedora 9.0.1-2.fc31) +
Date:Thu Apr 9 11:37:56 2020
+

Bug Summary

+ + + + +
Bug TypeQuantityDisplay?
All Bugs6
Dead code
Unreachable code6
+

Reports

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Bug GroupBug Type ▾FileFunction/MethodLinePath Length
Dead codeUnreachable codeapplet-main.clog_to_file9411View Report
Dead codeUnreachable codeapplet-main.clog_to_file9291View Report
Dead codeUnreachable codeapplet-main.clog_to_file9411View Report
Dead codeUnreachable codeapplet-main.clog_to_file9411View Report
Dead codeUnreachable codeapplet-main.clog_to_file9291View Report
Dead codeUnreachable codeapplet-main.clog_to_file9291View Report
+ + diff --git a/2020-04-09-113756-6097-1@37cc19e547b1_shadow/report-164de5.html b/2020-04-09-113756-6097-1@37cc19e547b1_shadow/report-164de5.html new file mode 100644 index 0000000..d4a3cc8 --- /dev/null +++ b/2020-04-09-113756-6097-1@37cc19e547b1_shadow/report-164de5.html @@ -0,0 +1,1412 @@ + + + +applet-main.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:applet-main.c
Warning:line 929, column 5
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name applet-main.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -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 -mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -resource-dir /usr/lib64/clang/9.0.1 -D HAVE_CONFIG_H -I . -I .. -D G_LOG_DOMAIN="Indicator-Applet" -D DATADIR="/usr/local/share" -D INDICATOR_DIR="/usr/lib64/indicators3/7/" -D INDICATOR_ICONS_DIR="/usr/share/libindicator/icons/" -D INDICATOR_APPLET -I ./.. -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/fribidi -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gio-unix-2.0 -I /usr/include/libdrm -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-panel-4.0/libmate-panel-applet -I /usr/include/libindicator3-0.4 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/fribidi -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gio-unix-2.0 -I /usr/include/libdrm -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/9.0.1/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdebug-compilation-dir /rootdir/src -ferror-limit 19 -fmessage-length 0 -fobjc-runtime=gcc -fdiagnostics-show-option -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 -o /rootdir/html-report/2020-04-09-113756-6097-1 -x c applet-main.c +
+ + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2A small wrapper utility to load indicators and put them as menu items
3into the mate-panel using it's applet interface.
4
5Copyright 2009-2010 Canonical Ltd.
6
7Authors:
8 Ted Gould <ted@canonical.com>
9
10This program is free software: you can redistribute it and/or modify it
11under the terms of the GNU General Public License version 3, as published
12by the Free Software Foundation.
13
14This program is distributed in the hope that it will be useful, but
15WITHOUT ANY WARRANTY; without even the implied warranties of
16MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
17PURPOSE. See the GNU General Public License for more details.
18
19You should have received a copy of the GNU General Public License along
20with this program. If not, see <http://www.gnu.org/licenses/>.
21*/
22
23#include <stdlib.h>
24#include <string.h>
25#include <config.h>
26#include <glib/gi18n.h>
27#include <mate-panel-applet.h>
28#include <gdk/gdkkeysyms.h>
29#include <gtk/gtk.h>
30
31#if HAVE_UBUNTU_INDICATOR1
32
33#define INDICATOR_SERVICE_APPMENU"libappmenu.so" "libappmenu.so"
34#define INDICATOR_SERVICE_ME"libme.so" "libme.so"
35#define INDICATOR_SERVICE_DATETIME"libdatetime.so" "libdatetime.so"
36
37#define INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu" "com.canonical.indicator.appmenu"
38#define INDICATOR_SERVICE_ME_NG"com.canonical.indicator.me" "com.canonical.indicator.me"
39#define INDICATOR_SERVICE_DATETIME_NG"com.canonical.indicator.datetime" "com.canonical.indicator.datetime"
40
41#include <libindicator/indicator-object.h>
42#endif
43
44#if HAVE_AYATANA_INDICATOR
45
46#define INDICATOR_SERVICE_APPMENU"libappmenu.so" "libayatana-appmenu.so"
47#define INDICATOR_SERVICE_ME"libme.so" "libayatana-me.so"
48#define INDICATOR_SERVICE_DATETIME"libdatetime.so" "libayatana-datetime.so"
49
50#define INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu" "org.ayatana.indicator.appmenu"
51#define INDICATOR_SERVICE_ME_NG"com.canonical.indicator.me" "org.ayatana.indicator.me"
52#define INDICATOR_SERVICE_DATETIME_NG"com.canonical.indicator.datetime" "org.ayatana.indicator.datetime"
53
54#include <libayatana-indicator/indicator-object.h>
55#endif
56
57/* For new style indicators */
58
59#if HAVE_UBUNTU_INDICATOR1 && HAVE_UBUNTU_INDICATOR_NG
60
61#include <libido/libido.h>
62#include <libindicator/indicator-ng.h>
63
64#define INDICATOR_SERVICE_DIR "/usr/share/unity/indicators"
65
66#endif
67
68#if HAVE_AYATANA_INDICATOR && HAVE_AYATANA_INDICATOR_NG
69
70#include <libayatana-ido/libayatana-ido.h>
71#include <libayatana-indicator/indicator-ng.h>
72
73#define INDICATOR_SERVICE_DIR "/usr/share/ayatana/indicators"
74
75#endif
76
77#include "tomboykeybinder.h"
78
79static gchar * indicator_order[] = {
80#if HAVE_UBUNTU_INDICATOR1
81 "libapplication.so",
82 "libmessaging.so",
83 "libsoundmenu.so",
84 "libdatetime.so",
85 "libsession.so",
86#endif
87#if HAVE_AYATANA_INDICATOR
88 "libayatana-application.so",
89 "libayatana-messaging.so",
90 "libayatana-soundmenu.so",
91 "libayatana-datetime.so",
92 "libayatana-session.so",
93#endif
94 NULL((void*)0)
95};
96
97static GtkPackDirection packdirection;
98static MatePanelAppletOrient orient;
99static guint size;
100
101#define MENU_DATA_INDICATOR_OBJECT"indicator-object" "indicator-object"
102#define MENU_DATA_INDICATOR_ENTRY"indicator-entry" "indicator-entry"
103
104#define IO_DATA_ORDER_NUMBER"indicator-order-number" "indicator-order-number"
105
106static gboolean applet_fill_cb (MatePanelApplet * applet, const gchar * iid, gpointer data);
107
108static void update_accessible_desc (IndicatorObjectEntry * entry, GtkWidget * menuitem);
109
110/*************
111 * main
112 * ***********/
113
114#ifdef INDICATOR_APPLET1
115MATE_PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletFactory",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
116 PANEL_TYPE_APPLET,int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
117 "indicator-applet",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
118 applet_fill_cb, NULL)int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
;
119#endif
120#ifdef INDICATOR_APPLET_COMPLETE
121MATE_PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletCompleteFactory",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
122 PANEL_TYPE_APPLET,int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
123 "indicator-applet-complete",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
124 applet_fill_cb, NULL)int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
;
125#endif
126#ifdef INDICATOR_APPLET_APPMENU
127MATE_PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletAppmenuFactory",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
128 PANEL_TYPE_APPLET,int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
129 "indicator-applet-appmenu",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
130 applet_fill_cb, NULL)int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
;
131#endif
132
133/*************
134 * log files
135 * ***********/
136#ifdef INDICATOR_APPLET1
137#define LOG_FILE_NAME"indicator-applet.log" "indicator-applet.log"
138#endif
139#ifdef INDICATOR_APPLET_COMPLETE
140#define LOG_FILE_NAME"indicator-applet.log" "indicator-applet-complete.log"
141#endif
142#ifdef INDICATOR_APPLET_APPMENU
143#define LOG_FILE_NAME"indicator-applet.log" "indicator-applet-appmenu.log"
144#endif
145GOutputStream * log_file = NULL((void*)0);
146
147/*****************
148 * Hotkey support
149 * **************/
150#ifdef INDICATOR_APPLET1
151gchar * hotkey_keycode = "<Super>M";
152#endif
153#ifdef INDICATOR_APPLET_SESSION
154gchar * hotkey_keycode = "<Super>S";
155#endif
156#ifdef INDICATOR_APPLET_COMPLETE
157gchar * hotkey_keycode = "<Super>S";
158#endif
159#ifdef INDICATOR_APPLET_APPMENU
160gchar * hotkey_keycode = "<Super>F1";
161#endif
162
163/********************
164 * Environment Names
165 * *******************/
166#ifdef INDICATOR_APPLET1
167#define INDICATOR_SPECIFIC_ENV"indicator-applet-original" "indicator-applet-original"
168#endif
169#ifdef INDICATOR_APPLET_COMPLETE
170#define INDICATOR_SPECIFIC_ENV"indicator-applet-original" "indicator-applet-complete"
171#endif
172#ifdef INDICATOR_APPLET_APPMENU
173#define INDICATOR_SPECIFIC_ENV"indicator-applet-original" "indicator-applet-appmenu"
174#endif
175
176static const gchar * indicator_env[] = {
177 "indicator-applet",
178 INDICATOR_SPECIFIC_ENV"indicator-applet-original",
179 NULL((void*)0)
180};
181
182/*************
183 * init function
184 * ***********/
185
186static gint
187name2order (const gchar * name) {
188 int i;
189
190 for (i = 0; indicator_order[i] != NULL((void*)0); i++) {
191 if (g_strcmp0(name, indicator_order[i]) == 0) {
192 return i;
193 }
194 }
195
196 return -1;
197}
198
199typedef struct _incoming_position_t incoming_position_t;
200struct _incoming_position_t {
201 gint objposition;
202 gint entryposition;
203 gint menupos;
204 gboolean found;
205};
206
207/* This function helps by determining where in the menu list
208 this new entry should be placed. It compares the objects
209 that they're on, and then the individual entries. Each
210 is progressively more expensive. */
211static void
212place_in_menu (GtkWidget * widget, gpointer user_data)
213{
214 incoming_position_t * position = (incoming_position_t *)user_data;
215 if (position->found) {
216 /* We've already been placed, just finish the foreach */
217 return;
218 }
219
220 IndicatorObject * io = INDICATOR_OBJECT(g_object_get_data(G_OBJECT(widget), MENU_DATA_INDICATOR_OBJECT))((((IndicatorObject*) g_type_check_instance_cast ((GTypeInstance
*) ((g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((widget)), (((GType) ((20) << (2)))
))))), "indicator-object"))), ((indicator_object_get_type ())
)))))
;
221 g_assert(io != NULL)do { if (io != ((void*)0)) ; else g_assertion_message_expr ("Indicator-Applet"
, "applet-main.c", 221, ((const char*) (__func__)), "io != NULL"
); } while (0)
;
222
223 gint objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER))((gint) (glong) (g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
), "indicator-order-number")))
;
224 /* We've already passed it, well, then this is where
225 we should be be. Stop! */
226 if (objposition > position->objposition) {
227 position->found = TRUE(!(0));
228 return;
229 }
230
231 /* The objects don't match yet, keep looking */
232 if (objposition < position->objposition) {
233 position->menupos++;
234 return;
235 }
236
237 /* The objects are the same, let's start looking at entries. */
238 IndicatorObjectEntry * entry = (IndicatorObjectEntry *)g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
239 gint entryposition = indicator_object_get_location(io, entry);
240
241 if (entryposition > position->entryposition) {
242 position->found = TRUE(!(0));
243 return;
244 }
245
246 if (entryposition < position->entryposition) {
247 position->menupos++;
248 return;
249 }
250
251 /* We've got the same object and the same entry. Well,
252 let's just put it right here then. */
253 position->found = TRUE(!(0));
254 return;
255}
256
257static void
258something_shown (GtkWidget * widget, gpointer user_data)
259{
260 GtkWidget * menuitem = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
261 gtk_widget_show(menuitem);
262}
263
264static void
265something_hidden (GtkWidget * widget, gpointer user_data)
266{
267 GtkWidget * menuitem = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
268 gtk_widget_hide(menuitem);
269}
270
271static void
272sensitive_cb (GObject * obj, GParamSpec * pspec, gpointer user_data)
273{
274 g_return_if_fail(GTK_IS_WIDGET(obj))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((obj)); GType __t = ((gtk_widget_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 ("Indicator-Applet", ((const
char*) (__func__)), "GTK_IS_WIDGET(obj)"); return; } } while
(0)
;
275 g_return_if_fail(GTK_IS_WIDGET(user_data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((gtk_widget_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 ("Indicator-Applet", ((const
char*) (__func__)), "GTK_IS_WIDGET(user_data)"); return; } }
while (0)
;
276
277 gtk_widget_set_sensitive(GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
, gtk_widget_get_sensitive(GTK_WIDGET(obj)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(obj)), ((gtk_widget_get_type ()))))))
));
278 return;
279}
280
281static void
282entry_activated (GtkWidget * widget, gpointer user_data)
283{
284 g_return_if_fail(GTK_IS_WIDGET(widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((gtk_widget_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 ("Indicator-Applet", ((const
char*) (__func__)), "GTK_IS_WIDGET(widget)"); return; } } while
(0)
;
285 gpointer pio = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, "indicator");
286 g_return_if_fail(INDICATOR_IS_OBJECT(pio))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((pio)); GType __t = ((indicator_object_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 ("Indicator-Applet", ((const
char*) (__func__)), "INDICATOR_IS_OBJECT(pio)"); return; } }
while (0)
;
287 IndicatorObject * io = INDICATOR_OBJECT(pio)((((IndicatorObject*) g_type_check_instance_cast ((GTypeInstance
*) ((pio)), ((indicator_object_get_type ()))))))
;
288
289 return indicator_object_entry_activate(io, (IndicatorObjectEntry *)user_data, gtk_get_current_event_time());
290}
291
292static gboolean
293entry_scrolled (GtkWidget *menuitem, GdkEventScroll *event, gpointer data)
294{
295 IndicatorObject *io = g_object_get_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_OBJECT"indicator-object");
296 IndicatorObjectEntry *entry = g_object_get_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
297
298 g_return_val_if_fail(INDICATOR_IS_OBJECT(io), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((io)); GType __t = ((indicator_object_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 ("Indicator-Applet", ((const
char*) (__func__)), "INDICATOR_IS_OBJECT(io)"); return ((0))
; } } while (0)
;
299
300 g_signal_emit_by_name (io, "scroll", 1, event->direction);
301 g_signal_emit_by_name (io, "scroll-entry", entry, 1, event->direction);
302 g_signal_emit_by_name (io, INDICATOR_OBJECT_SIGNAL_ENTRY_SCROLLED"entry-scrolled", entry, 1, event->direction);
303
304 return FALSE(0);
305}
306
307static void
308accessible_desc_update_cb (GtkWidget * widget, gpointer userdata)
309{
310 gpointer data = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
311
312 if (data != userdata) {
313 return;
314 }
315
316 IndicatorObjectEntry * entry = (IndicatorObjectEntry *)data;
317 update_accessible_desc(entry, widget);
318}
319
320static void
321accessible_desc_update (IndicatorObject * io, IndicatorObjectEntry * entry, GtkWidget * menubar)
322{
323 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, accessible_desc_update_cb, entry);
324 return;
325}
326
327#define PANEL_PADDING8 8
328static gboolean
329entry_resized (GtkWidget *applet, guint newsize, gpointer data)
330{
331 IndicatorObject *io = (IndicatorObject *)data;
332
333 size = newsize;
334
335 /* Work on the entries */
336 GList * entries = indicator_object_get_entries(io);
337 GList * entry = NULL((void*)0);
338
339 for (entry = entries; entry != NULL((void*)0); entry = g_list_next(entry)((entry) ? (((GList *)(entry))->next) : ((void*)0))) {
340 IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)entry->data;
341 if (entrydata->image != NULL((void*)0)) {
342 /* Resize to fit panel */
343 gtk_image_set_pixel_size (entrydata->image, size - PANEL_PADDING8);
344 }
345 }
346
347 return FALSE(0);
348}
349
350static void
351entry_added (IndicatorObject * io, IndicatorObjectEntry * entry, GtkWidget * menubar)
352{
353 g_debug("Signal: Entry Added");
354 gboolean something_visible = FALSE(0);
355 gboolean something_sensitive = FALSE(0);
356
357 GtkWidget * menuitem = gtk_menu_item_new();
358 GtkWidget * box = (packdirection == GTK_PACK_DIRECTION_LTR) ?
359 gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3) : gtk_box_new(GTK_ORIENTATION_VERTICAL, 3);
360
361 /* Allows indicators to receive mouse scroll event */
362 gtk_widget_add_events(GTK_WIDGET(menuitem)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(menuitem)), ((gtk_widget_get_type ()))))))
, GDK_SCROLL_MASK);
363
364 g_object_set_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "indicator", io);
365 g_object_set_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "box", box);
366
367 g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(entry_activated), entry)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((menuitem)), (((GType) ((20) << (2)
)))))))), ("activate"), (((GCallback) (entry_activated))), (entry
), ((void*)0), (GConnectFlags) 0)
;
368 g_signal_connect(G_OBJECT(menuitem), "scroll-event", G_CALLBACK(entry_scrolled), entry)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((menuitem)), (((GType) ((20) << (2)
)))))))), ("scroll-event"), (((GCallback) (entry_scrolled))),
(entry), ((void*)0), (GConnectFlags) 0)
;
369
370 if (entry->image != NULL((void*)0)) {
371 /* Resize to fit panel */
372 gtk_image_set_pixel_size (entry->image, size - PANEL_PADDING8);
373 gtk_box_pack_start(GTK_BOX(box)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((box
)), ((gtk_box_get_type ()))))))
, GTK_WIDGET(entry->image)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->image)), ((gtk_widget_get_type ()))))))
, FALSE(0), FALSE(0), 1);
374 if (gtk_widget_get_visible(GTK_WIDGET(entry->image)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->image)), ((gtk_widget_get_type ()))))))
)) {
375 something_visible = TRUE(!(0));
376 }
377
378 if (gtk_widget_get_sensitive(GTK_WIDGET(entry->image)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->image)), ((gtk_widget_get_type ()))))))
)) {
379 something_sensitive = TRUE(!(0));
380 }
381
382 g_signal_connect(G_OBJECT(entry->image), "show", G_CALLBACK(something_shown), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), ("show"), (((GCallback) (something_shown))), (menuitem
), ((void*)0), (GConnectFlags) 0)
;
383 g_signal_connect(G_OBJECT(entry->image), "hide", G_CALLBACK(something_hidden), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), ("hide"), (((GCallback) (something_hidden))), (
menuitem), ((void*)0), (GConnectFlags) 0)
;
384
385 g_signal_connect(G_OBJECT(entry->image), "notify::sensitive", G_CALLBACK(sensitive_cb), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), ("notify::sensitive"), (((GCallback) (sensitive_cb
))), (menuitem), ((void*)0), (GConnectFlags) 0)
;
386 }
387 if (entry->label != NULL((void*)0)) {
388 switch(packdirection) {
389 case GTK_PACK_DIRECTION_LTR:
390 gtk_label_set_angle(GTK_LABEL(entry->label)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_label_get_type ()))))))
, 0.0);
391 break;
392 case GTK_PACK_DIRECTION_TTB:
393 gtk_label_set_angle(GTK_LABEL(entry->label)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_label_get_type ()))))))
,
394 (orient == MATE_PANEL_APPLET_ORIENT_LEFT) ?
395 270.0 : 90.0);
396 break;
397 default:
398 break;
399 }
400 gtk_box_pack_start(GTK_BOX(box)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((box
)), ((gtk_box_get_type ()))))))
, GTK_WIDGET(entry->label)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_widget_get_type ()))))))
, FALSE(0), FALSE(0), 1);
401
402 if (gtk_widget_get_visible(GTK_WIDGET(entry->label)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_widget_get_type ()))))))
)) {
403 something_visible = TRUE(!(0));
404 }
405
406 if (gtk_widget_get_sensitive(GTK_WIDGET(entry->label)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_widget_get_type ()))))))
)) {
407 something_sensitive = TRUE(!(0));
408 }
409
410 g_signal_connect(G_OBJECT(entry->label), "show", G_CALLBACK(something_shown), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), ("show"), (((GCallback) (something_shown))), (menuitem
), ((void*)0), (GConnectFlags) 0)
;
411 g_signal_connect(G_OBJECT(entry->label), "hide", G_CALLBACK(something_hidden), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), ("hide"), (((GCallback) (something_hidden))), (
menuitem), ((void*)0), (GConnectFlags) 0)
;
412
413 g_signal_connect(G_OBJECT(entry->label), "notify::sensitive", G_CALLBACK(sensitive_cb), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), ("notify::sensitive"), (((GCallback) (sensitive_cb
))), (menuitem), ((void*)0), (GConnectFlags) 0)
;
414 }
415 gtk_container_add(GTK_CONTAINER(menuitem)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menuitem)), ((gtk_container_get_type ()))))))
, box);
416 gtk_widget_show(box);
417
418 if (entry->menu != NULL((void*)0)) {
419 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem)((((GtkMenuItem*) g_type_check_instance_cast ((GTypeInstance*
) ((menuitem)), ((gtk_menu_item_get_type ()))))))
, GTK_WIDGET(entry->menu)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->menu)), ((gtk_widget_get_type ()))))))
);
420 }
421
422 incoming_position_t position;
423 position.objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER))((gint) (glong) (g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
), "indicator-order-number")))
;
424 position.entryposition = indicator_object_get_location(io, entry);
425 position.menupos = 0;
426 position.found = FALSE(0);
427
428 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, place_in_menu, &position);
429
430 gtk_menu_shell_insert(GTK_MENU_SHELL(menubar)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_menu_shell_get_type ()))))))
, menuitem, position.menupos);
431
432 if (something_visible) {
433 if (entry->accessible_desc != NULL((void*)0)) {
434 update_accessible_desc(entry, menuitem);
435 }
436 gtk_widget_show(menuitem);
437 }
438 gtk_widget_set_sensitive(menuitem, something_sensitive);
439
440 g_object_set_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry", entry);
441 g_object_set_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_OBJECT"indicator-object", io);
442
443 return;
444}
445
446static void
447entry_removed_cb (GtkWidget * widget, gpointer userdata)
448{
449 gpointer data = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
450
451 if (data != userdata) {
452 return;
453 }
454
455 IndicatorObjectEntry * entry = (IndicatorObjectEntry *)data;
456 if (entry->label != NULL((void*)0)) {
457 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(something_shown), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_shown))), (widget
))
;
458 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(something_hidden), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_hidden))), (widget
))
;
459 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(sensitive_cb), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (sensitive_cb))), (widget)
)
;
460 }
461 if (entry->image != NULL((void*)0)) {
462 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(something_shown), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_shown))), (widget
))
;
463 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(something_hidden), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_hidden))), (widget
))
;
464 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(sensitive_cb), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (sensitive_cb))), (widget)
)
;
465 }
466
467 gtk_widget_destroy(widget);
468 return;
469}
470
471static void
472entry_removed (IndicatorObject * io G_GNUC_UNUSED__attribute__((__unused__)), IndicatorObjectEntry * entry,
473 gpointer user_data)
474{
475 g_debug("Signal: Entry Removed");
476
477 gtk_container_foreach(GTK_CONTAINER(user_data)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((gtk_container_get_type ()))))))
, entry_removed_cb, entry);
478
479 return;
480}
481
482static void
483entry_moved_find_cb (GtkWidget * widget, gpointer userdata)
484{
485 gpointer * array = (gpointer *)userdata;
486 if (array[1] != NULL((void*)0)) {
487 return;
488 }
489
490 gpointer data = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
491
492 if (data != array[0]) {
493 return;
494 }
495
496 array[1] = widget;
497 return;
498}
499
500/* Gets called when an entry for an object was moved. */
501static void
502entry_moved (IndicatorObject * io, IndicatorObjectEntry * entry,
503 gint old G_GNUC_UNUSED__attribute__((__unused__)), gint new G_GNUC_UNUSED__attribute__((__unused__)), gpointer user_data)
504{
505 GtkWidget * menubar = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
506
507 gpointer array[2];
508 array[0] = entry;
509 array[1] = NULL((void*)0);
510
511 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, entry_moved_find_cb, array);
512 if (array[1] == NULL((void*)0)) {
513 g_warning("Moving an entry that isn't in our menus.");
514 return;
515 }
516
517 GtkWidget * mi = GTK_WIDGET(array[1])((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(array[1])), ((gtk_widget_get_type ()))))))
;
518 g_object_ref(G_OBJECT(mi)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
mi)), (((GType) ((20) << (2))))))))
);
519 gtk_container_remove(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, mi);
520
521 incoming_position_t position;
522 position.objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER))((gint) (glong) (g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
), "indicator-order-number")))
;
523 position.entryposition = indicator_object_get_location(io, entry);
524 position.menupos = 0;
525 position.found = FALSE(0);
526
527 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, place_in_menu, &position);
528
529 gtk_menu_shell_insert(GTK_MENU_SHELL(menubar)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_menu_shell_get_type ()))))))
, mi, position.menupos);
530 g_object_unref(G_OBJECT(mi)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
mi)), (((GType) ((20) << (2))))))))
);
531
532 return;
533}
534
535static void
536menu_show (IndicatorObject * io, IndicatorObjectEntry * entry,
537 guint32 timestamp, gpointer user_data)
538{
539 GtkWidget * menubar = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
540
541 if (entry == NULL((void*)0)) {
542 /* Close any open menus instead of opening one */
543 GList * entries = indicator_object_get_entries(io);
544 GList * iterator = NULL((void*)0);
545 for (iterator = entries; iterator != NULL((void*)0); iterator = g_list_next(iterator)((iterator) ? (((GList *)(iterator))->next) : ((void*)0))) {
546 IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)iterator->data;
547 gtk_menu_popdown(entrydata->menu);
548 }
549 g_list_free(entries);
550
551 /* And tell the menubar to exit activation mode too */
552 gtk_menu_shell_cancel(GTK_MENU_SHELL(menubar)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_menu_shell_get_type ()))))))
);
553 return;
554 }
555
556 // TODO: do something sensible here
557}
558
559static void
560update_accessible_desc(IndicatorObjectEntry * entry, GtkWidget * menuitem)
561{
562 /* FIXME: We need to deal with the use case where the contents of the
563 label overrides what is found in the atk object's name, or at least
564 orca speaks the label instead of the atk object name.
565 */
566 AtkObject * menuitem_obj = gtk_widget_get_accessible(menuitem);
567 if (menuitem_obj == NULL((void*)0)) {
568 /* Should there be an error printed here? */
569 return;
570 }
571
572 if (entry->accessible_desc != NULL((void*)0)) {
573 atk_object_set_name(menuitem_obj, entry->accessible_desc);
574 } else {
575 atk_object_set_name(menuitem_obj, "");
576 }
577 return;
578}
579
580static void
581load_indicator (MatePanelApplet *applet, GtkWidget * menubar, IndicatorObject *io, const gchar *name)
582{
583 /* Set the environment it's in */
584 indicator_object_set_environment(io, (const GStrv)indicator_env);
585
586 /* Attach the 'name' to the object */
587#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
588 int pos = 5000 - indicator_object_get_position(io);
589 if (pos > 5000) {
590 pos = name2order(name);
591 }
592#else
593 int pos = name2order(name);
594#endif
595
596 g_object_set_data(G_OBJECT(io)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
io)), (((GType) ((20) << (2))))))))
, IO_DATA_ORDER_NUMBER"indicator-order-number", GINT_TO_POINTER(pos)((gpointer) (glong) (pos)));
597
598 /* Connect to its signals */
599 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED, G_CALLBACK(entry_added), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("entry-added"), (((GCallback) (entry_added))), (menubar)
, ((void*)0), (GConnectFlags) 0)
;
600 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED, G_CALLBACK(entry_removed), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("entry-removed"), (((GCallback) (entry_removed))), (menubar
), ((void*)0), (GConnectFlags) 0)
;
601 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_MOVED, G_CALLBACK(entry_moved), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("entry-moved"), (((GCallback) (entry_moved))), (menubar)
, ((void*)0), (GConnectFlags) 0)
;
602 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_MENU_SHOW, G_CALLBACK(menu_show), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("menu-show"), (((GCallback) (menu_show))), (menubar), ((
void*)0), (GConnectFlags) 0)
;
603 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ACCESSIBLE_DESC_UPDATE, G_CALLBACK(accessible_desc_update), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("accessible-desc-update"), (((GCallback) (accessible_desc_update
))), (menubar), ((void*)0), (GConnectFlags) 0)
;
604
605 /* Track panel resize */
606 g_signal_connect_object(G_OBJECT(applet)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
applet)), (((GType) ((20) << (2))))))))
, "change-size", G_CALLBACK(entry_resized)((GCallback) (entry_resized)), G_OBJECT(io)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
io)), (((GType) ((20) << (2))))))))
, 0);
607
608 /* Work on the entries */
609 GList * entries = indicator_object_get_entries(io);
610 GList * entry = NULL((void*)0);
611
612 for (entry = entries; entry != NULL((void*)0); entry = g_list_next(entry)((entry) ? (((GList *)(entry))->next) : ((void*)0))) {
613 IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)entry->data;
614 entry_added(io, entrydata, menubar);
615 }
616
617 g_list_free(entries);
618}
619
620static gboolean
621load_module (const gchar * name, MatePanelApplet *applet, GtkWidget * menubar)
622{
623 g_debug("Looking at Module: %s", name);
624 g_return_val_if_fail(name != NULL, FALSE)do { if ((name != ((void*)0))) { } else { g_return_if_fail_warning
("Indicator-Applet", ((const char*) (__func__)), "name != NULL"
); return ((0)); } } while (0)
;
625
626 if (!g_str_has_suffix(name, G_MODULE_SUFFIX"so")) {
627 return FALSE(0);
628 }
629
630 g_debug("Loading Module: %s", name);
631
632 /* Build the object for the module */
633 gchar * fullpath = g_build_filename(INDICATOR_DIR"/usr/lib64/indicators3/7/", name, NULL((void*)0));
634 IndicatorObject * io = indicator_object_new_from_file(fullpath);
635 g_free(fullpath);
636
637 load_indicator(applet, menubar, io, name);
638
639 return TRUE(!(0));
640}
641
642static void
643load_modules (MatePanelApplet *applet, GtkWidget *menubar, gint *indicators_loaded)
644{
645 if (g_file_test(INDICATOR_DIR"/usr/lib64/indicators3/7/", (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))) {
646 GDir * dir = g_dir_open(INDICATOR_DIR"/usr/lib64/indicators3/7/", 0, NULL((void*)0));
647
648 const gchar * name;
649 gint count = 0;
650 while ((name = g_dir_read_name(dir)) != NULL((void*)0)) {
651#ifdef INDICATOR_APPLET_APPMENU
652 if (g_strcmp0(name, INDICATOR_SERVICE_APPMENU"libappmenu.so")) {
653 continue;
654 }
655#else
656 if (!g_strcmp0(name, INDICATOR_SERVICE_APPMENU"libappmenu.so")) {
657 continue;
658 }
659#endif
660#ifdef INDICATOR_APPLET1
661 if (!g_strcmp0(name, INDICATOR_SERVICE_ME"libme.so")) {
662 continue;
663 }
664 if (!g_strcmp0(name, INDICATOR_SERVICE_DATETIME"libdatetime.so")) {
665 continue;
666 }
667#endif
668 if (load_module(name, applet, menubar)) {
669 count++;
670 }
671 }
672
673 *indicators_loaded += count;
674
675 g_dir_close (dir);
676 }
677}
678
679#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
680
681static void
682load_indicators_from_indicator_files (MatePanelApplet *applet, GtkWidget *menubar, gint *indicators_loaded)
683{
684 GDir *dir;
685 const gchar *name;
686 GError *error = NULL((void*)0);
687
688 dir = g_dir_open (INDICATOR_SERVICE_DIR, 0, &error);
689
690 if (!dir) {
691 g_warning ("unable to open indicator service file directory: %s", error->message);
692 g_error_free (error);
693
694 return;
695 }
696
697 gint count = 0;
698 while ((name = g_dir_read_name (dir))) {
699 gchar *filename;
700 IndicatorNg *indicator;
701
702 filename = g_build_filename (INDICATOR_SERVICE_DIR, name, NULL((void*)0));
703 indicator = indicator_ng_new_for_profile (filename, "desktop", &error);
704 g_free (filename);
705
706#ifdef INDICATOR_APPLET_APPMENU
707 if (g_strcmp0(name, INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu")) {
708 continue;
709 }
710#else
711 if (!g_strcmp0(name, INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu")) {
712 continue;
713 }
714#endif
715#ifdef INDICATOR_APPLET1
716 if (!g_strcmp0(name, INDICATOR_SERVICE_ME_NG"com.canonical.indicator.me")) {
717 continue;
718 }
719 if (!g_strcmp0(name, INDICATOR_SERVICE_DATETIME_NG"com.canonical.indicator.datetime")) {
720 continue;
721 }
722#endif
723
724 if (indicator) {
725 load_indicator(applet, menubar, INDICATOR_OBJECT (indicator)((((IndicatorObject*) g_type_check_instance_cast ((GTypeInstance
*) ((indicator)), ((indicator_object_get_type ()))))))
, name);
726 count++;
727 }else{
728 g_warning ("unable to load '%s': %s", name, error->message);
729 g_clear_error (&error);
730 }
731 }
732
733 *indicators_loaded += count;
734
735 g_dir_close (dir);
736}
737#endif /* HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG */
738
739static void
740hotkey_filter (char * keystring G_GNUC_UNUSED__attribute__((__unused__)), gpointer data)
741{
742 g_return_if_fail(GTK_IS_MENU_SHELL(data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((data)); GType __t = ((gtk_menu_shell_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 ("Indicator-Applet", ((const
char*) (__func__)), "GTK_IS_MENU_SHELL(data)"); return; } } while
(0)
;
743
744 /* Oh, wow, it's us! */
745 GList * children = gtk_container_get_children(GTK_CONTAINER(data)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((gtk_container_get_type ()))))))
);
746 if (children == NULL((void*)0)) {
747 g_debug("Menubar has no children");
748 return;
749 }
750
751 gtk_menu_shell_select_item(GTK_MENU_SHELL(data)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((gtk_menu_shell_get_type ()))))))
, GTK_WIDGET(g_list_last(children)->data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(g_list_last(children)->data)), ((gtk_widget_get_type ()))
))))
);
752 g_list_free(children);
753 return;
754}
755
756static gboolean
757menubar_press (GtkWidget * widget,
758 GdkEventButton *event,
759 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
760{
761 if (event->button != 1) {
762 g_signal_stop_emission_by_name(widget, "button-press-event");
763 }
764
765 return FALSE(0);
766}
767
768static gboolean
769menubar_on_draw (GtkWidget * widget,
770 cairo_t * cr,
771 GtkWidget * menubar)
772{
773 /* FIXME: either port to gtk_render_focus or remove this function */
774 if (gtk_widget_has_focus(menubar))
775 gtk_paint_focus(gtk_widget_get_style(widget),
776 cr,
777 gtk_widget_get_state(menubar),
778 widget, "menubar-applet", 0, 0, -1, -1);
779
780 return FALSE(0);
781}
782
783static void
784about_cb (GtkAction *action G_GNUC_UNUSED__attribute__((__unused__)),
785 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
786{
787 static const gchar *authors[] = {
788 "Ted Gould <ted@canonical.com>",
789 NULL((void*)0)
790 };
791
792 static gchar *license[] = {
793 N_("This program is free software: you can redistribute it and/or modify it ""This program is free software: you can redistribute it and/or modify it "
"under the terms of the GNU General Public License version 3, as published "
"by the Free Software Foundation."
794 "under the terms of the GNU General Public License version 3, as published ""This program is free software: you can redistribute it and/or modify it "
"under the terms of the GNU General Public License version 3, as published "
"by the Free Software Foundation."
795 "by the Free Software Foundation.")"This program is free software: you can redistribute it and/or modify it "
"under the terms of the GNU General Public License version 3, as published "
"by the Free Software Foundation."
,
796 N_("This program is distributed in the hope that it will be useful, but ""This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
797 "WITHOUT ANY WARRANTY; without even the implied warranties of ""This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
798 "MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR ""This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
799 "PURPOSE. See the GNU General Public License for more details.")"This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
,
800 N_("You should have received a copy of the GNU General Public License along ""You should have received a copy of the GNU General Public License along "
"with this program. If not, see <http://www.gnu.org/licenses/>."
801 "with this program. If not, see <http://www.gnu.org/licenses/>.")"You should have received a copy of the GNU General Public License along "
"with this program. If not, see <http://www.gnu.org/licenses/>."
,
802 NULL((void*)0)
803 };
804 gchar *license_i18n;
805
806 license_i18n = g_strconcat (_(license[0])gettext (license[0]), "\n\n", _(license[1])gettext (license[1]), "\n\n", _(license[2])gettext (license[2]), NULL((void*)0));
807
808 gtk_show_about_dialog(NULL((void*)0),
809 "version", VERSION"1.24.0",
810 "copyright", _("Copyright \xc2\xa9 2009-2010 Canonical, Ltd.\n"gettext ("Copyright \xc2\xa9 2009-2010 Canonical, Ltd.\n" "Copyright \xc2\xa9 2011-2020 MATE developers"
)
811 "Copyright \xc2\xa9 2011-2020 MATE developers")gettext ("Copyright \xc2\xa9 2009-2010 Canonical, Ltd.\n" "Copyright \xc2\xa9 2011-2020 MATE developers"
)
,
812#ifdef INDICATOR_APPLET_APPMENU
813 "comments", _("An applet to hold your application menus.")gettext ("An applet to hold your application menus."),
814#endif
815 "comments", _("An applet to hold all of the system indicators.")gettext ("An applet to hold all of the system indicators."),
816 "authors", authors,
817 "license", license_i18n,
818 "wrap-license", TRUE(!(0)),
819 "translator-credits", _("translator-credits")gettext ("translator-credits"),
820 "logo-icon-name", "mate-indicator-applet",
821 "icon-name", "mate-indicator-applet",
822 "website", "https://mate-desktop.org",
823 "website-label", _("MATE Website")gettext ("MATE Website"),
824 NULL((void*)0)
825 );
826
827 g_free (license_i18n);
828
829 return;
830}
831
832static gboolean
833swap_orient_cb (GtkWidget *item, gpointer data)
834{
835 GtkWidget *from = (GtkWidget *) data;
836 GtkWidget *to = (GtkWidget *) g_object_get_data(G_OBJECT(from)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
from)), (((GType) ((20) << (2))))))))
, "to");
837 g_object_ref(G_OBJECT(item)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
item)), (((GType) ((20) << (2))))))))
);
838 gtk_container_remove(GTK_CONTAINER(from)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((from)), ((gtk_container_get_type ()))))))
, item);
839 if (GTK_IS_LABEL(item)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(item)); GType __t = ((gtk_label_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; }))))
) {
840 switch(packdirection) {
841 case GTK_PACK_DIRECTION_LTR:
842 gtk_label_set_angle(GTK_LABEL(item)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(item)), ((gtk_label_get_type ()))))))
, 0.0);
843 break;
844 case GTK_PACK_DIRECTION_TTB:
845 gtk_label_set_angle(GTK_LABEL(item)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(item)), ((gtk_label_get_type ()))))))
,
846 (orient == MATE_PANEL_APPLET_ORIENT_LEFT) ?
847 270.0 : 90.0);
848 break;
849 default:
850 break;
851 }
852 }
853 gtk_box_pack_start(GTK_BOX(to)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((to
)), ((gtk_box_get_type ()))))))
, item, FALSE(0), FALSE(0), 0);
854 return TRUE(!(0));
855}
856
857static gboolean
858reorient_box_cb (GtkWidget *menuitem, gpointer data)
859{
860 GtkWidget *from = g_object_get_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "box");
861 GtkWidget *to = (packdirection == GTK_PACK_DIRECTION_LTR) ?
862 gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0) : gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
863 g_object_set_data(G_OBJECT(from)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
from)), (((GType) ((20) << (2))))))))
, "to", to);
864 gtk_container_foreach(GTK_CONTAINER(from)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((from)), ((gtk_container_get_type ()))))))
, (GtkCallback)swap_orient_cb,
865 from);
866 gtk_container_remove(GTK_CONTAINER(menuitem)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menuitem)), ((gtk_container_get_type ()))))))
, from);
867 gtk_container_add(GTK_CONTAINER(menuitem)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menuitem)), ((gtk_container_get_type ()))))))
, to);
868 g_object_set_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "box", to);
869 gtk_widget_show_all(menuitem);
870 return TRUE(!(0));
871}
872
873static gboolean
874matepanelapplet_reorient_cb (GtkWidget *applet, MatePanelAppletOrient neworient,
875 gpointer data)
876{
877 GtkWidget *menubar = (GtkWidget *)data;
878 if ((((neworient == MATE_PANEL_APPLET_ORIENT_UP) ||
879 (neworient == MATE_PANEL_APPLET_ORIENT_DOWN)) &&
880 ((orient == MATE_PANEL_APPLET_ORIENT_LEFT) ||
881 (orient == MATE_PANEL_APPLET_ORIENT_RIGHT))) ||
882 (((neworient == MATE_PANEL_APPLET_ORIENT_LEFT) ||
883 (neworient == MATE_PANEL_APPLET_ORIENT_RIGHT)) &&
884 ((orient == MATE_PANEL_APPLET_ORIENT_UP) ||
885 (orient == MATE_PANEL_APPLET_ORIENT_DOWN)))) {
886 packdirection = (packdirection == GTK_PACK_DIRECTION_LTR) ?
887 GTK_PACK_DIRECTION_TTB : GTK_PACK_DIRECTION_LTR;
888 gtk_menu_bar_set_pack_direction(GTK_MENU_BAR(menubar)((((GtkMenuBar*) g_type_check_instance_cast ((GTypeInstance*)
((menubar)), ((gtk_menu_bar_get_type ()))))))
,
889 packdirection);
890 orient = neworient;
891 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
,
892 (GtkCallback)reorient_box_cb, NULL((void*)0));
893 }
894 orient = neworient;
895 return FALSE(0);
896}
897
898#ifdef N_
899#undef N_
900#endif
901#define N_(x)x x
902
903static void
904log_to_file_cb (GObject * source_obj G_GNUC_UNUSED__attribute__((__unused__)),
905 GAsyncResult * result G_GNUC_UNUSED__attribute__((__unused__)), gpointer user_data)
906{
907 g_free(user_data);
908 return;
909}
910
911static void
912log_to_file (const gchar * domain G_GNUC_UNUSED__attribute__((__unused__)),
913 GLogLevelFlags level G_GNUC_UNUSED__attribute__((__unused__)),
914 const gchar * message,
915 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
916{
917 if (log_file == NULL((void*)0)) {
918 GError * error = NULL((void*)0);
919 gchar * filename = g_build_filename(g_get_user_cache_dir(), LOG_FILE_NAME"indicator-applet.log", NULL((void*)0));
920 GFile * file = g_file_new_for_path(filename);
921 g_free(filename);
922
923 if (!g_file_test(g_get_user_cache_dir(), G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) {
924 GFile * cachedir = g_file_new_for_path(g_get_user_cache_dir());
925 g_file_make_directory_with_parents(cachedir, NULL((void*)0), &error);
926
927 if (error != NULL((void*)0)) {
928 g_error("Unable to make directory '%s' for log file: %s", g_get_user_cache_dir(), error->message);
929 return;
This statement is never executed
930 }
931 }
932
933 g_file_delete(file, NULL((void*)0), NULL((void*)0));
934
935 GFileIOStream * io = g_file_create_readwrite(file,
936 G_FILE_CREATE_REPLACE_DESTINATION, /* flags */
937 NULL((void*)0), /* cancelable */
938 &error); /* error */
939 if (error != NULL((void*)0)) {
940 g_error("Unable to replace file: %s", error->message);
941 return;
942 }
943
944 log_file = g_io_stream_get_output_stream(G_IO_STREAM(io)((((GIOStream*) g_type_check_instance_cast ((GTypeInstance*) (
(io)), ((g_io_stream_get_type ()))))))
);
945 }
946
947 gchar * outputstring = g_strdup_printf("%s\n", message);
948 g_output_stream_write_async(log_file,
949 outputstring, /* data */
950 strlen(outputstring), /* length */
951 G_PRIORITY_LOW300, /* priority */
952 NULL((void*)0), /* cancelable */
953 log_to_file_cb, /* callback */
954 outputstring); /* data */
955
956 return;
957}
958
959static gboolean
960applet_fill_cb (MatePanelApplet * applet, const gchar * iid G_GNUC_UNUSED__attribute__((__unused__)),
961 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
962{
963#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
964 ido_init();
965#endif
966
967 static const GtkActionEntry menu_actions[] = {
968 {"About", GTK_STOCK_ABOUT((GtkStock)"gtk-about"), N_("_About")"_About", NULL((void*)0), NULL((void*)0), G_CALLBACK(about_cb)((GCallback) (about_cb))}
969 };
970 static const gchar *menu_xml = "<menuitem name=\"About\" action=\"About\"/>";
971
972 static gboolean first_time = FALSE(0);
973 GtkWidget *menubar;
974 gint indicators_loaded = 0;
975 GtkActionGroup *action_group;
976
977 if (!first_time)
978 {
979 first_time = TRUE(!(0));
980#ifdef INDICATOR_APPLET1
981 g_set_application_name(_("Indicator Applet")gettext ("Indicator Applet"));
982#endif
983#ifdef INDICATOR_APPLET_COMPLETE
984 g_set_application_name(_("Indicator Applet Complete")gettext ("Indicator Applet Complete"));
985#endif
986#ifdef INDICATOR_APPLET_APPMENU
987 g_set_application_name(_("Indicator Applet Application Menu")gettext ("Indicator Applet Application Menu"));
988#endif
989
990 g_log_set_default_handler(log_to_file, NULL((void*)0));
991
992 tomboy_keybinder_init();
993 }
994
995 /* Set panel options */
996 gtk_container_set_border_width(GTK_CONTAINER (applet)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_container_get_type ()))))))
, 0);
997 mate_panel_applet_set_flags(applet, MATE_PANEL_APPLET_EXPAND_MINOR);
998 menubar = gtk_menu_bar_new();
999 action_group = gtk_action_group_new ("Indicator Applet Actions");
1000 gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE"mate-indicator-applet");
1001 gtk_action_group_add_actions (action_group, menu_actions,
1002 G_N_ELEMENTS (menu_actions)(sizeof (menu_actions) / sizeof ((menu_actions)[0])),
1003 menubar);
1004 mate_panel_applet_setup_menu(applet, menu_xml, action_group);
1005 g_object_unref(action_group);
1006#ifdef INDICATOR_APPLET1
1007 atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
),
1008 "indicator-applet");
1009#endif
1010#ifdef INDICATOR_APPLET_COMPLETE
1011 atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
),
1012 "indicator-applet-complete");
1013#endif
1014#ifdef INDICATOR_APPLET_APPMENU
1015 atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
),
1016 "indicator-applet-appmenu");
1017#endif
1018
1019 /* Init some theme/icon stuff */
1020 gtk_icon_theme_append_search_path(gtk_icon_theme_get_default(),
1021 INDICATOR_ICONS_DIR"/usr/share/libindicator/icons/");
1022 /* g_debug("Icons directory: %s", INDICATOR_ICONS_DIR); */
1023 gtk_widget_set_name(GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
, "fast-user-switch-applet");
1024
1025 /* Build menubar */
1026 size = (mate_panel_applet_get_size (applet));
1027 orient = (mate_panel_applet_get_orient(applet));
1028 packdirection = ((orient == MATE_PANEL_APPLET_ORIENT_UP) ||
1029 (orient == MATE_PANEL_APPLET_ORIENT_DOWN)) ?
1030 GTK_PACK_DIRECTION_LTR : GTK_PACK_DIRECTION_TTB;
1031 gtk_menu_bar_set_pack_direction(GTK_MENU_BAR(menubar)((((GtkMenuBar*) g_type_check_instance_cast ((GTypeInstance*)
((menubar)), ((gtk_menu_bar_get_type ()))))))
,
1032 packdirection);
1033 gtk_widget_set_can_focus (menubar, TRUE(!(0)));
1034 gtk_widget_set_name(GTK_WIDGET (menubar)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(menubar)), ((gtk_widget_get_type ()))))))
, "fast-user-switch-menubar");
1035 g_signal_connect(menubar, "button-press-event", G_CALLBACK(menubar_press), NULL)g_signal_connect_data ((menubar), ("button-press-event"), (((
GCallback) (menubar_press))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
;
1036 g_signal_connect_after(menubar, "draw", G_CALLBACK(menubar_on_draw), menubar)g_signal_connect_data ((menubar), ("draw"), (((GCallback) (menubar_on_draw
))), (menubar), ((void*)0), G_CONNECT_AFTER)
;
1037 g_signal_connect(applet, "change-orient",g_signal_connect_data ((applet), ("change-orient"), (((GCallback
) (matepanelapplet_reorient_cb))), (menubar), ((void*)0), (GConnectFlags
) 0)
1038 G_CALLBACK(matepanelapplet_reorient_cb), menubar)g_signal_connect_data ((applet), ("change-orient"), (((GCallback
) (matepanelapplet_reorient_cb))), (menubar), ((void*)0), (GConnectFlags
) 0)
;
1039 gtk_container_set_border_width(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, 0);
1040
1041 /* Add in filter func */
1042 tomboy_keybinder_bind(hotkey_keycode, hotkey_filter, menubar);
1043
1044 load_modules(applet, menubar, &indicators_loaded);
1045#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
1046 load_indicators_from_indicator_files(applet, menubar, &indicators_loaded);
1047#endif
1048
1049 if (indicators_loaded == 0) {
1050 /* A label to allow for click through */
1051 GtkWidget * item = gtk_label_new(_("No Indicators")gettext ("No Indicators"));
1052 mate_panel_applet_set_background_widget(applet, item);
1053 gtk_container_add(GTK_CONTAINER(applet)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_container_get_type ()))))))
, item);
1054 gtk_widget_show(item);
1055 } else {
1056 gtk_container_add(GTK_CONTAINER(applet)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_container_get_type ()))))))
, menubar);
1057 mate_panel_applet_set_background_widget(applet, menubar);
1058 gtk_widget_show(menubar);
1059 }
1060
1061 gtk_widget_show(GTK_WIDGET(applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
);
1062
1063 return TRUE(!(0));
1064
1065}
diff --git a/2020-04-09-113756-6097-1@37cc19e547b1_shadow/report-2e42e2.html b/2020-04-09-113756-6097-1@37cc19e547b1_shadow/report-2e42e2.html new file mode 100644 index 0000000..dbf0744 --- /dev/null +++ b/2020-04-09-113756-6097-1@37cc19e547b1_shadow/report-2e42e2.html @@ -0,0 +1,1412 @@ + + + +applet-main.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:applet-main.c
Warning:line 941, column 4
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name applet-main.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -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 -mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -resource-dir /usr/lib64/clang/9.0.1 -D HAVE_CONFIG_H -I . -I .. -D G_LOG_DOMAIN="Indicator-Applet" -D DATADIR="/usr/local/share" -D INDICATOR_DIR="/usr/lib64/indicators3/7/" -D INDICATOR_ICONS_DIR="/usr/share/libindicator/icons/" -D INDICATOR_APPLET -I ./.. -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/fribidi -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gio-unix-2.0 -I /usr/include/libdrm -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-panel-4.0/libmate-panel-applet -I /usr/include/libindicator3-0.4 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/fribidi -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gio-unix-2.0 -I /usr/include/libdrm -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/9.0.1/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdebug-compilation-dir /rootdir/src -ferror-limit 19 -fmessage-length 0 -fobjc-runtime=gcc -fdiagnostics-show-option -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 -o /rootdir/html-report/2020-04-09-113756-6097-1 -x c applet-main.c +
+ + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2A small wrapper utility to load indicators and put them as menu items
3into the mate-panel using it's applet interface.
4
5Copyright 2009-2010 Canonical Ltd.
6
7Authors:
8 Ted Gould <ted@canonical.com>
9
10This program is free software: you can redistribute it and/or modify it
11under the terms of the GNU General Public License version 3, as published
12by the Free Software Foundation.
13
14This program is distributed in the hope that it will be useful, but
15WITHOUT ANY WARRANTY; without even the implied warranties of
16MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
17PURPOSE. See the GNU General Public License for more details.
18
19You should have received a copy of the GNU General Public License along
20with this program. If not, see <http://www.gnu.org/licenses/>.
21*/
22
23#include <stdlib.h>
24#include <string.h>
25#include <config.h>
26#include <glib/gi18n.h>
27#include <mate-panel-applet.h>
28#include <gdk/gdkkeysyms.h>
29#include <gtk/gtk.h>
30
31#if HAVE_UBUNTU_INDICATOR1
32
33#define INDICATOR_SERVICE_APPMENU"libappmenu.so" "libappmenu.so"
34#define INDICATOR_SERVICE_ME"libme.so" "libme.so"
35#define INDICATOR_SERVICE_DATETIME"libdatetime.so" "libdatetime.so"
36
37#define INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu" "com.canonical.indicator.appmenu"
38#define INDICATOR_SERVICE_ME_NG"com.canonical.indicator.me" "com.canonical.indicator.me"
39#define INDICATOR_SERVICE_DATETIME_NG"com.canonical.indicator.datetime" "com.canonical.indicator.datetime"
40
41#include <libindicator/indicator-object.h>
42#endif
43
44#if HAVE_AYATANA_INDICATOR
45
46#define INDICATOR_SERVICE_APPMENU"libappmenu.so" "libayatana-appmenu.so"
47#define INDICATOR_SERVICE_ME"libme.so" "libayatana-me.so"
48#define INDICATOR_SERVICE_DATETIME"libdatetime.so" "libayatana-datetime.so"
49
50#define INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu" "org.ayatana.indicator.appmenu"
51#define INDICATOR_SERVICE_ME_NG"com.canonical.indicator.me" "org.ayatana.indicator.me"
52#define INDICATOR_SERVICE_DATETIME_NG"com.canonical.indicator.datetime" "org.ayatana.indicator.datetime"
53
54#include <libayatana-indicator/indicator-object.h>
55#endif
56
57/* For new style indicators */
58
59#if HAVE_UBUNTU_INDICATOR1 && HAVE_UBUNTU_INDICATOR_NG
60
61#include <libido/libido.h>
62#include <libindicator/indicator-ng.h>
63
64#define INDICATOR_SERVICE_DIR "/usr/share/unity/indicators"
65
66#endif
67
68#if HAVE_AYATANA_INDICATOR && HAVE_AYATANA_INDICATOR_NG
69
70#include <libayatana-ido/libayatana-ido.h>
71#include <libayatana-indicator/indicator-ng.h>
72
73#define INDICATOR_SERVICE_DIR "/usr/share/ayatana/indicators"
74
75#endif
76
77#include "tomboykeybinder.h"
78
79static gchar * indicator_order[] = {
80#if HAVE_UBUNTU_INDICATOR1
81 "libapplication.so",
82 "libmessaging.so",
83 "libsoundmenu.so",
84 "libdatetime.so",
85 "libsession.so",
86#endif
87#if HAVE_AYATANA_INDICATOR
88 "libayatana-application.so",
89 "libayatana-messaging.so",
90 "libayatana-soundmenu.so",
91 "libayatana-datetime.so",
92 "libayatana-session.so",
93#endif
94 NULL((void*)0)
95};
96
97static GtkPackDirection packdirection;
98static MatePanelAppletOrient orient;
99static guint size;
100
101#define MENU_DATA_INDICATOR_OBJECT"indicator-object" "indicator-object"
102#define MENU_DATA_INDICATOR_ENTRY"indicator-entry" "indicator-entry"
103
104#define IO_DATA_ORDER_NUMBER"indicator-order-number" "indicator-order-number"
105
106static gboolean applet_fill_cb (MatePanelApplet * applet, const gchar * iid, gpointer data);
107
108static void update_accessible_desc (IndicatorObjectEntry * entry, GtkWidget * menuitem);
109
110/*************
111 * main
112 * ***********/
113
114#ifdef INDICATOR_APPLET1
115MATE_PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletFactory",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
116 PANEL_TYPE_APPLET,int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
117 "indicator-applet",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
118 applet_fill_cb, NULL)int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
;
119#endif
120#ifdef INDICATOR_APPLET_COMPLETE
121MATE_PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletCompleteFactory",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
122 PANEL_TYPE_APPLET,int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
123 "indicator-applet-complete",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
124 applet_fill_cb, NULL)int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
;
125#endif
126#ifdef INDICATOR_APPLET_APPMENU
127MATE_PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletAppmenuFactory",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
128 PANEL_TYPE_APPLET,int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
129 "indicator-applet-appmenu",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
130 applet_fill_cb, NULL)int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
;
131#endif
132
133/*************
134 * log files
135 * ***********/
136#ifdef INDICATOR_APPLET1
137#define LOG_FILE_NAME"indicator-applet.log" "indicator-applet.log"
138#endif
139#ifdef INDICATOR_APPLET_COMPLETE
140#define LOG_FILE_NAME"indicator-applet.log" "indicator-applet-complete.log"
141#endif
142#ifdef INDICATOR_APPLET_APPMENU
143#define LOG_FILE_NAME"indicator-applet.log" "indicator-applet-appmenu.log"
144#endif
145GOutputStream * log_file = NULL((void*)0);
146
147/*****************
148 * Hotkey support
149 * **************/
150#ifdef INDICATOR_APPLET1
151gchar * hotkey_keycode = "<Super>M";
152#endif
153#ifdef INDICATOR_APPLET_SESSION
154gchar * hotkey_keycode = "<Super>S";
155#endif
156#ifdef INDICATOR_APPLET_COMPLETE
157gchar * hotkey_keycode = "<Super>S";
158#endif
159#ifdef INDICATOR_APPLET_APPMENU
160gchar * hotkey_keycode = "<Super>F1";
161#endif
162
163/********************
164 * Environment Names
165 * *******************/
166#ifdef INDICATOR_APPLET1
167#define INDICATOR_SPECIFIC_ENV"indicator-applet-original" "indicator-applet-original"
168#endif
169#ifdef INDICATOR_APPLET_COMPLETE
170#define INDICATOR_SPECIFIC_ENV"indicator-applet-original" "indicator-applet-complete"
171#endif
172#ifdef INDICATOR_APPLET_APPMENU
173#define INDICATOR_SPECIFIC_ENV"indicator-applet-original" "indicator-applet-appmenu"
174#endif
175
176static const gchar * indicator_env[] = {
177 "indicator-applet",
178 INDICATOR_SPECIFIC_ENV"indicator-applet-original",
179 NULL((void*)0)
180};
181
182/*************
183 * init function
184 * ***********/
185
186static gint
187name2order (const gchar * name) {
188 int i;
189
190 for (i = 0; indicator_order[i] != NULL((void*)0); i++) {
191 if (g_strcmp0(name, indicator_order[i]) == 0) {
192 return i;
193 }
194 }
195
196 return -1;
197}
198
199typedef struct _incoming_position_t incoming_position_t;
200struct _incoming_position_t {
201 gint objposition;
202 gint entryposition;
203 gint menupos;
204 gboolean found;
205};
206
207/* This function helps by determining where in the menu list
208 this new entry should be placed. It compares the objects
209 that they're on, and then the individual entries. Each
210 is progressively more expensive. */
211static void
212place_in_menu (GtkWidget * widget, gpointer user_data)
213{
214 incoming_position_t * position = (incoming_position_t *)user_data;
215 if (position->found) {
216 /* We've already been placed, just finish the foreach */
217 return;
218 }
219
220 IndicatorObject * io = INDICATOR_OBJECT(g_object_get_data(G_OBJECT(widget), MENU_DATA_INDICATOR_OBJECT))((((IndicatorObject*) g_type_check_instance_cast ((GTypeInstance
*) ((g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((widget)), (((GType) ((20) << (2)))
))))), "indicator-object"))), ((indicator_object_get_type ())
)))))
;
221 g_assert(io != NULL)do { if (io != ((void*)0)) ; else g_assertion_message_expr ("Indicator-Applet"
, "applet-main.c", 221, ((const char*) (__func__)), "io != NULL"
); } while (0)
;
222
223 gint objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER))((gint) (glong) (g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
), "indicator-order-number")))
;
224 /* We've already passed it, well, then this is where
225 we should be be. Stop! */
226 if (objposition > position->objposition) {
227 position->found = TRUE(!(0));
228 return;
229 }
230
231 /* The objects don't match yet, keep looking */
232 if (objposition < position->objposition) {
233 position->menupos++;
234 return;
235 }
236
237 /* The objects are the same, let's start looking at entries. */
238 IndicatorObjectEntry * entry = (IndicatorObjectEntry *)g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
239 gint entryposition = indicator_object_get_location(io, entry);
240
241 if (entryposition > position->entryposition) {
242 position->found = TRUE(!(0));
243 return;
244 }
245
246 if (entryposition < position->entryposition) {
247 position->menupos++;
248 return;
249 }
250
251 /* We've got the same object and the same entry. Well,
252 let's just put it right here then. */
253 position->found = TRUE(!(0));
254 return;
255}
256
257static void
258something_shown (GtkWidget * widget, gpointer user_data)
259{
260 GtkWidget * menuitem = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
261 gtk_widget_show(menuitem);
262}
263
264static void
265something_hidden (GtkWidget * widget, gpointer user_data)
266{
267 GtkWidget * menuitem = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
268 gtk_widget_hide(menuitem);
269}
270
271static void
272sensitive_cb (GObject * obj, GParamSpec * pspec, gpointer user_data)
273{
274 g_return_if_fail(GTK_IS_WIDGET(obj))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((obj)); GType __t = ((gtk_widget_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 ("Indicator-Applet", ((const
char*) (__func__)), "GTK_IS_WIDGET(obj)"); return; } } while
(0)
;
275 g_return_if_fail(GTK_IS_WIDGET(user_data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((gtk_widget_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 ("Indicator-Applet", ((const
char*) (__func__)), "GTK_IS_WIDGET(user_data)"); return; } }
while (0)
;
276
277 gtk_widget_set_sensitive(GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
, gtk_widget_get_sensitive(GTK_WIDGET(obj)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(obj)), ((gtk_widget_get_type ()))))))
));
278 return;
279}
280
281static void
282entry_activated (GtkWidget * widget, gpointer user_data)
283{
284 g_return_if_fail(GTK_IS_WIDGET(widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((gtk_widget_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 ("Indicator-Applet", ((const
char*) (__func__)), "GTK_IS_WIDGET(widget)"); return; } } while
(0)
;
285 gpointer pio = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, "indicator");
286 g_return_if_fail(INDICATOR_IS_OBJECT(pio))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((pio)); GType __t = ((indicator_object_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 ("Indicator-Applet", ((const
char*) (__func__)), "INDICATOR_IS_OBJECT(pio)"); return; } }
while (0)
;
287 IndicatorObject * io = INDICATOR_OBJECT(pio)((((IndicatorObject*) g_type_check_instance_cast ((GTypeInstance
*) ((pio)), ((indicator_object_get_type ()))))))
;
288
289 return indicator_object_entry_activate(io, (IndicatorObjectEntry *)user_data, gtk_get_current_event_time());
290}
291
292static gboolean
293entry_scrolled (GtkWidget *menuitem, GdkEventScroll *event, gpointer data)
294{
295 IndicatorObject *io = g_object_get_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_OBJECT"indicator-object");
296 IndicatorObjectEntry *entry = g_object_get_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
297
298 g_return_val_if_fail(INDICATOR_IS_OBJECT(io), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((io)); GType __t = ((indicator_object_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 ("Indicator-Applet", ((const
char*) (__func__)), "INDICATOR_IS_OBJECT(io)"); return ((0))
; } } while (0)
;
299
300 g_signal_emit_by_name (io, "scroll", 1, event->direction);
301 g_signal_emit_by_name (io, "scroll-entry", entry, 1, event->direction);
302 g_signal_emit_by_name (io, INDICATOR_OBJECT_SIGNAL_ENTRY_SCROLLED"entry-scrolled", entry, 1, event->direction);
303
304 return FALSE(0);
305}
306
307static void
308accessible_desc_update_cb (GtkWidget * widget, gpointer userdata)
309{
310 gpointer data = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
311
312 if (data != userdata) {
313 return;
314 }
315
316 IndicatorObjectEntry * entry = (IndicatorObjectEntry *)data;
317 update_accessible_desc(entry, widget);
318}
319
320static void
321accessible_desc_update (IndicatorObject * io, IndicatorObjectEntry * entry, GtkWidget * menubar)
322{
323 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, accessible_desc_update_cb, entry);
324 return;
325}
326
327#define PANEL_PADDING8 8
328static gboolean
329entry_resized (GtkWidget *applet, guint newsize, gpointer data)
330{
331 IndicatorObject *io = (IndicatorObject *)data;
332
333 size = newsize;
334
335 /* Work on the entries */
336 GList * entries = indicator_object_get_entries(io);
337 GList * entry = NULL((void*)0);
338
339 for (entry = entries; entry != NULL((void*)0); entry = g_list_next(entry)((entry) ? (((GList *)(entry))->next) : ((void*)0))) {
340 IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)entry->data;
341 if (entrydata->image != NULL((void*)0)) {
342 /* Resize to fit panel */
343 gtk_image_set_pixel_size (entrydata->image, size - PANEL_PADDING8);
344 }
345 }
346
347 return FALSE(0);
348}
349
350static void
351entry_added (IndicatorObject * io, IndicatorObjectEntry * entry, GtkWidget * menubar)
352{
353 g_debug("Signal: Entry Added");
354 gboolean something_visible = FALSE(0);
355 gboolean something_sensitive = FALSE(0);
356
357 GtkWidget * menuitem = gtk_menu_item_new();
358 GtkWidget * box = (packdirection == GTK_PACK_DIRECTION_LTR) ?
359 gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3) : gtk_box_new(GTK_ORIENTATION_VERTICAL, 3);
360
361 /* Allows indicators to receive mouse scroll event */
362 gtk_widget_add_events(GTK_WIDGET(menuitem)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(menuitem)), ((gtk_widget_get_type ()))))))
, GDK_SCROLL_MASK);
363
364 g_object_set_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "indicator", io);
365 g_object_set_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "box", box);
366
367 g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(entry_activated), entry)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((menuitem)), (((GType) ((20) << (2)
)))))))), ("activate"), (((GCallback) (entry_activated))), (entry
), ((void*)0), (GConnectFlags) 0)
;
368 g_signal_connect(G_OBJECT(menuitem), "scroll-event", G_CALLBACK(entry_scrolled), entry)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((menuitem)), (((GType) ((20) << (2)
)))))))), ("scroll-event"), (((GCallback) (entry_scrolled))),
(entry), ((void*)0), (GConnectFlags) 0)
;
369
370 if (entry->image != NULL((void*)0)) {
371 /* Resize to fit panel */
372 gtk_image_set_pixel_size (entry->image, size - PANEL_PADDING8);
373 gtk_box_pack_start(GTK_BOX(box)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((box
)), ((gtk_box_get_type ()))))))
, GTK_WIDGET(entry->image)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->image)), ((gtk_widget_get_type ()))))))
, FALSE(0), FALSE(0), 1);
374 if (gtk_widget_get_visible(GTK_WIDGET(entry->image)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->image)), ((gtk_widget_get_type ()))))))
)) {
375 something_visible = TRUE(!(0));
376 }
377
378 if (gtk_widget_get_sensitive(GTK_WIDGET(entry->image)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->image)), ((gtk_widget_get_type ()))))))
)) {
379 something_sensitive = TRUE(!(0));
380 }
381
382 g_signal_connect(G_OBJECT(entry->image), "show", G_CALLBACK(something_shown), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), ("show"), (((GCallback) (something_shown))), (menuitem
), ((void*)0), (GConnectFlags) 0)
;
383 g_signal_connect(G_OBJECT(entry->image), "hide", G_CALLBACK(something_hidden), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), ("hide"), (((GCallback) (something_hidden))), (
menuitem), ((void*)0), (GConnectFlags) 0)
;
384
385 g_signal_connect(G_OBJECT(entry->image), "notify::sensitive", G_CALLBACK(sensitive_cb), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), ("notify::sensitive"), (((GCallback) (sensitive_cb
))), (menuitem), ((void*)0), (GConnectFlags) 0)
;
386 }
387 if (entry->label != NULL((void*)0)) {
388 switch(packdirection) {
389 case GTK_PACK_DIRECTION_LTR:
390 gtk_label_set_angle(GTK_LABEL(entry->label)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_label_get_type ()))))))
, 0.0);
391 break;
392 case GTK_PACK_DIRECTION_TTB:
393 gtk_label_set_angle(GTK_LABEL(entry->label)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_label_get_type ()))))))
,
394 (orient == MATE_PANEL_APPLET_ORIENT_LEFT) ?
395 270.0 : 90.0);
396 break;
397 default:
398 break;
399 }
400 gtk_box_pack_start(GTK_BOX(box)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((box
)), ((gtk_box_get_type ()))))))
, GTK_WIDGET(entry->label)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_widget_get_type ()))))))
, FALSE(0), FALSE(0), 1);
401
402 if (gtk_widget_get_visible(GTK_WIDGET(entry->label)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_widget_get_type ()))))))
)) {
403 something_visible = TRUE(!(0));
404 }
405
406 if (gtk_widget_get_sensitive(GTK_WIDGET(entry->label)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_widget_get_type ()))))))
)) {
407 something_sensitive = TRUE(!(0));
408 }
409
410 g_signal_connect(G_OBJECT(entry->label), "show", G_CALLBACK(something_shown), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), ("show"), (((GCallback) (something_shown))), (menuitem
), ((void*)0), (GConnectFlags) 0)
;
411 g_signal_connect(G_OBJECT(entry->label), "hide", G_CALLBACK(something_hidden), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), ("hide"), (((GCallback) (something_hidden))), (
menuitem), ((void*)0), (GConnectFlags) 0)
;
412
413 g_signal_connect(G_OBJECT(entry->label), "notify::sensitive", G_CALLBACK(sensitive_cb), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), ("notify::sensitive"), (((GCallback) (sensitive_cb
))), (menuitem), ((void*)0), (GConnectFlags) 0)
;
414 }
415 gtk_container_add(GTK_CONTAINER(menuitem)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menuitem)), ((gtk_container_get_type ()))))))
, box);
416 gtk_widget_show(box);
417
418 if (entry->menu != NULL((void*)0)) {
419 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem)((((GtkMenuItem*) g_type_check_instance_cast ((GTypeInstance*
) ((menuitem)), ((gtk_menu_item_get_type ()))))))
, GTK_WIDGET(entry->menu)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->menu)), ((gtk_widget_get_type ()))))))
);
420 }
421
422 incoming_position_t position;
423 position.objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER))((gint) (glong) (g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
), "indicator-order-number")))
;
424 position.entryposition = indicator_object_get_location(io, entry);
425 position.menupos = 0;
426 position.found = FALSE(0);
427
428 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, place_in_menu, &position);
429
430 gtk_menu_shell_insert(GTK_MENU_SHELL(menubar)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_menu_shell_get_type ()))))))
, menuitem, position.menupos);
431
432 if (something_visible) {
433 if (entry->accessible_desc != NULL((void*)0)) {
434 update_accessible_desc(entry, menuitem);
435 }
436 gtk_widget_show(menuitem);
437 }
438 gtk_widget_set_sensitive(menuitem, something_sensitive);
439
440 g_object_set_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry", entry);
441 g_object_set_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_OBJECT"indicator-object", io);
442
443 return;
444}
445
446static void
447entry_removed_cb (GtkWidget * widget, gpointer userdata)
448{
449 gpointer data = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
450
451 if (data != userdata) {
452 return;
453 }
454
455 IndicatorObjectEntry * entry = (IndicatorObjectEntry *)data;
456 if (entry->label != NULL((void*)0)) {
457 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(something_shown), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_shown))), (widget
))
;
458 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(something_hidden), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_hidden))), (widget
))
;
459 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(sensitive_cb), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (sensitive_cb))), (widget)
)
;
460 }
461 if (entry->image != NULL((void*)0)) {
462 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(something_shown), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_shown))), (widget
))
;
463 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(something_hidden), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_hidden))), (widget
))
;
464 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(sensitive_cb), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (sensitive_cb))), (widget)
)
;
465 }
466
467 gtk_widget_destroy(widget);
468 return;
469}
470
471static void
472entry_removed (IndicatorObject * io G_GNUC_UNUSED__attribute__((__unused__)), IndicatorObjectEntry * entry,
473 gpointer user_data)
474{
475 g_debug("Signal: Entry Removed");
476
477 gtk_container_foreach(GTK_CONTAINER(user_data)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((gtk_container_get_type ()))))))
, entry_removed_cb, entry);
478
479 return;
480}
481
482static void
483entry_moved_find_cb (GtkWidget * widget, gpointer userdata)
484{
485 gpointer * array = (gpointer *)userdata;
486 if (array[1] != NULL((void*)0)) {
487 return;
488 }
489
490 gpointer data = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
491
492 if (data != array[0]) {
493 return;
494 }
495
496 array[1] = widget;
497 return;
498}
499
500/* Gets called when an entry for an object was moved. */
501static void
502entry_moved (IndicatorObject * io, IndicatorObjectEntry * entry,
503 gint old G_GNUC_UNUSED__attribute__((__unused__)), gint new G_GNUC_UNUSED__attribute__((__unused__)), gpointer user_data)
504{
505 GtkWidget * menubar = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
506
507 gpointer array[2];
508 array[0] = entry;
509 array[1] = NULL((void*)0);
510
511 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, entry_moved_find_cb, array);
512 if (array[1] == NULL((void*)0)) {
513 g_warning("Moving an entry that isn't in our menus.");
514 return;
515 }
516
517 GtkWidget * mi = GTK_WIDGET(array[1])((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(array[1])), ((gtk_widget_get_type ()))))))
;
518 g_object_ref(G_OBJECT(mi)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
mi)), (((GType) ((20) << (2))))))))
);
519 gtk_container_remove(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, mi);
520
521 incoming_position_t position;
522 position.objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER))((gint) (glong) (g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
), "indicator-order-number")))
;
523 position.entryposition = indicator_object_get_location(io, entry);
524 position.menupos = 0;
525 position.found = FALSE(0);
526
527 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, place_in_menu, &position);
528
529 gtk_menu_shell_insert(GTK_MENU_SHELL(menubar)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_menu_shell_get_type ()))))))
, mi, position.menupos);
530 g_object_unref(G_OBJECT(mi)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
mi)), (((GType) ((20) << (2))))))))
);
531
532 return;
533}
534
535static void
536menu_show (IndicatorObject * io, IndicatorObjectEntry * entry,
537 guint32 timestamp, gpointer user_data)
538{
539 GtkWidget * menubar = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
540
541 if (entry == NULL((void*)0)) {
542 /* Close any open menus instead of opening one */
543 GList * entries = indicator_object_get_entries(io);
544 GList * iterator = NULL((void*)0);
545 for (iterator = entries; iterator != NULL((void*)0); iterator = g_list_next(iterator)((iterator) ? (((GList *)(iterator))->next) : ((void*)0))) {
546 IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)iterator->data;
547 gtk_menu_popdown(entrydata->menu);
548 }
549 g_list_free(entries);
550
551 /* And tell the menubar to exit activation mode too */
552 gtk_menu_shell_cancel(GTK_MENU_SHELL(menubar)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_menu_shell_get_type ()))))))
);
553 return;
554 }
555
556 // TODO: do something sensible here
557}
558
559static void
560update_accessible_desc(IndicatorObjectEntry * entry, GtkWidget * menuitem)
561{
562 /* FIXME: We need to deal with the use case where the contents of the
563 label overrides what is found in the atk object's name, or at least
564 orca speaks the label instead of the atk object name.
565 */
566 AtkObject * menuitem_obj = gtk_widget_get_accessible(menuitem);
567 if (menuitem_obj == NULL((void*)0)) {
568 /* Should there be an error printed here? */
569 return;
570 }
571
572 if (entry->accessible_desc != NULL((void*)0)) {
573 atk_object_set_name(menuitem_obj, entry->accessible_desc);
574 } else {
575 atk_object_set_name(menuitem_obj, "");
576 }
577 return;
578}
579
580static void
581load_indicator (MatePanelApplet *applet, GtkWidget * menubar, IndicatorObject *io, const gchar *name)
582{
583 /* Set the environment it's in */
584 indicator_object_set_environment(io, (const GStrv)indicator_env);
585
586 /* Attach the 'name' to the object */
587#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
588 int pos = 5000 - indicator_object_get_position(io);
589 if (pos > 5000) {
590 pos = name2order(name);
591 }
592#else
593 int pos = name2order(name);
594#endif
595
596 g_object_set_data(G_OBJECT(io)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
io)), (((GType) ((20) << (2))))))))
, IO_DATA_ORDER_NUMBER"indicator-order-number", GINT_TO_POINTER(pos)((gpointer) (glong) (pos)));
597
598 /* Connect to its signals */
599 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED, G_CALLBACK(entry_added), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("entry-added"), (((GCallback) (entry_added))), (menubar)
, ((void*)0), (GConnectFlags) 0)
;
600 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED, G_CALLBACK(entry_removed), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("entry-removed"), (((GCallback) (entry_removed))), (menubar
), ((void*)0), (GConnectFlags) 0)
;
601 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_MOVED, G_CALLBACK(entry_moved), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("entry-moved"), (((GCallback) (entry_moved))), (menubar)
, ((void*)0), (GConnectFlags) 0)
;
602 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_MENU_SHOW, G_CALLBACK(menu_show), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("menu-show"), (((GCallback) (menu_show))), (menubar), ((
void*)0), (GConnectFlags) 0)
;
603 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ACCESSIBLE_DESC_UPDATE, G_CALLBACK(accessible_desc_update), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("accessible-desc-update"), (((GCallback) (accessible_desc_update
))), (menubar), ((void*)0), (GConnectFlags) 0)
;
604
605 /* Track panel resize */
606 g_signal_connect_object(G_OBJECT(applet)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
applet)), (((GType) ((20) << (2))))))))
, "change-size", G_CALLBACK(entry_resized)((GCallback) (entry_resized)), G_OBJECT(io)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
io)), (((GType) ((20) << (2))))))))
, 0);
607
608 /* Work on the entries */
609 GList * entries = indicator_object_get_entries(io);
610 GList * entry = NULL((void*)0);
611
612 for (entry = entries; entry != NULL((void*)0); entry = g_list_next(entry)((entry) ? (((GList *)(entry))->next) : ((void*)0))) {
613 IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)entry->data;
614 entry_added(io, entrydata, menubar);
615 }
616
617 g_list_free(entries);
618}
619
620static gboolean
621load_module (const gchar * name, MatePanelApplet *applet, GtkWidget * menubar)
622{
623 g_debug("Looking at Module: %s", name);
624 g_return_val_if_fail(name != NULL, FALSE)do { if ((name != ((void*)0))) { } else { g_return_if_fail_warning
("Indicator-Applet", ((const char*) (__func__)), "name != NULL"
); return ((0)); } } while (0)
;
625
626 if (!g_str_has_suffix(name, G_MODULE_SUFFIX"so")) {
627 return FALSE(0);
628 }
629
630 g_debug("Loading Module: %s", name);
631
632 /* Build the object for the module */
633 gchar * fullpath = g_build_filename(INDICATOR_DIR"/usr/lib64/indicators3/7/", name, NULL((void*)0));
634 IndicatorObject * io = indicator_object_new_from_file(fullpath);
635 g_free(fullpath);
636
637 load_indicator(applet, menubar, io, name);
638
639 return TRUE(!(0));
640}
641
642static void
643load_modules (MatePanelApplet *applet, GtkWidget *menubar, gint *indicators_loaded)
644{
645 if (g_file_test(INDICATOR_DIR"/usr/lib64/indicators3/7/", (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))) {
646 GDir * dir = g_dir_open(INDICATOR_DIR"/usr/lib64/indicators3/7/", 0, NULL((void*)0));
647
648 const gchar * name;
649 gint count = 0;
650 while ((name = g_dir_read_name(dir)) != NULL((void*)0)) {
651#ifdef INDICATOR_APPLET_APPMENU
652 if (g_strcmp0(name, INDICATOR_SERVICE_APPMENU"libappmenu.so")) {
653 continue;
654 }
655#else
656 if (!g_strcmp0(name, INDICATOR_SERVICE_APPMENU"libappmenu.so")) {
657 continue;
658 }
659#endif
660#ifdef INDICATOR_APPLET1
661 if (!g_strcmp0(name, INDICATOR_SERVICE_ME"libme.so")) {
662 continue;
663 }
664 if (!g_strcmp0(name, INDICATOR_SERVICE_DATETIME"libdatetime.so")) {
665 continue;
666 }
667#endif
668 if (load_module(name, applet, menubar)) {
669 count++;
670 }
671 }
672
673 *indicators_loaded += count;
674
675 g_dir_close (dir);
676 }
677}
678
679#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
680
681static void
682load_indicators_from_indicator_files (MatePanelApplet *applet, GtkWidget *menubar, gint *indicators_loaded)
683{
684 GDir *dir;
685 const gchar *name;
686 GError *error = NULL((void*)0);
687
688 dir = g_dir_open (INDICATOR_SERVICE_DIR, 0, &error);
689
690 if (!dir) {
691 g_warning ("unable to open indicator service file directory: %s", error->message);
692 g_error_free (error);
693
694 return;
695 }
696
697 gint count = 0;
698 while ((name = g_dir_read_name (dir))) {
699 gchar *filename;
700 IndicatorNg *indicator;
701
702 filename = g_build_filename (INDICATOR_SERVICE_DIR, name, NULL((void*)0));
703 indicator = indicator_ng_new_for_profile (filename, "desktop", &error);
704 g_free (filename);
705
706#ifdef INDICATOR_APPLET_APPMENU
707 if (g_strcmp0(name, INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu")) {
708 continue;
709 }
710#else
711 if (!g_strcmp0(name, INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu")) {
712 continue;
713 }
714#endif
715#ifdef INDICATOR_APPLET1
716 if (!g_strcmp0(name, INDICATOR_SERVICE_ME_NG"com.canonical.indicator.me")) {
717 continue;
718 }
719 if (!g_strcmp0(name, INDICATOR_SERVICE_DATETIME_NG"com.canonical.indicator.datetime")) {
720 continue;
721 }
722#endif
723
724 if (indicator) {
725 load_indicator(applet, menubar, INDICATOR_OBJECT (indicator)((((IndicatorObject*) g_type_check_instance_cast ((GTypeInstance
*) ((indicator)), ((indicator_object_get_type ()))))))
, name);
726 count++;
727 }else{
728 g_warning ("unable to load '%s': %s", name, error->message);
729 g_clear_error (&error);
730 }
731 }
732
733 *indicators_loaded += count;
734
735 g_dir_close (dir);
736}
737#endif /* HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG */
738
739static void
740hotkey_filter (char * keystring G_GNUC_UNUSED__attribute__((__unused__)), gpointer data)
741{
742 g_return_if_fail(GTK_IS_MENU_SHELL(data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((data)); GType __t = ((gtk_menu_shell_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 ("Indicator-Applet", ((const
char*) (__func__)), "GTK_IS_MENU_SHELL(data)"); return; } } while
(0)
;
743
744 /* Oh, wow, it's us! */
745 GList * children = gtk_container_get_children(GTK_CONTAINER(data)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((gtk_container_get_type ()))))))
);
746 if (children == NULL((void*)0)) {
747 g_debug("Menubar has no children");
748 return;
749 }
750
751 gtk_menu_shell_select_item(GTK_MENU_SHELL(data)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((gtk_menu_shell_get_type ()))))))
, GTK_WIDGET(g_list_last(children)->data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(g_list_last(children)->data)), ((gtk_widget_get_type ()))
))))
);
752 g_list_free(children);
753 return;
754}
755
756static gboolean
757menubar_press (GtkWidget * widget,
758 GdkEventButton *event,
759 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
760{
761 if (event->button != 1) {
762 g_signal_stop_emission_by_name(widget, "button-press-event");
763 }
764
765 return FALSE(0);
766}
767
768static gboolean
769menubar_on_draw (GtkWidget * widget,
770 cairo_t * cr,
771 GtkWidget * menubar)
772{
773 /* FIXME: either port to gtk_render_focus or remove this function */
774 if (gtk_widget_has_focus(menubar))
775 gtk_paint_focus(gtk_widget_get_style(widget),
776 cr,
777 gtk_widget_get_state(menubar),
778 widget, "menubar-applet", 0, 0, -1, -1);
779
780 return FALSE(0);
781}
782
783static void
784about_cb (GtkAction *action G_GNUC_UNUSED__attribute__((__unused__)),
785 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
786{
787 static const gchar *authors[] = {
788 "Ted Gould <ted@canonical.com>",
789 NULL((void*)0)
790 };
791
792 static gchar *license[] = {
793 N_("This program is free software: you can redistribute it and/or modify it ""This program is free software: you can redistribute it and/or modify it "
"under the terms of the GNU General Public License version 3, as published "
"by the Free Software Foundation."
794 "under the terms of the GNU General Public License version 3, as published ""This program is free software: you can redistribute it and/or modify it "
"under the terms of the GNU General Public License version 3, as published "
"by the Free Software Foundation."
795 "by the Free Software Foundation.")"This program is free software: you can redistribute it and/or modify it "
"under the terms of the GNU General Public License version 3, as published "
"by the Free Software Foundation."
,
796 N_("This program is distributed in the hope that it will be useful, but ""This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
797 "WITHOUT ANY WARRANTY; without even the implied warranties of ""This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
798 "MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR ""This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
799 "PURPOSE. See the GNU General Public License for more details.")"This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
,
800 N_("You should have received a copy of the GNU General Public License along ""You should have received a copy of the GNU General Public License along "
"with this program. If not, see <http://www.gnu.org/licenses/>."
801 "with this program. If not, see <http://www.gnu.org/licenses/>.")"You should have received a copy of the GNU General Public License along "
"with this program. If not, see <http://www.gnu.org/licenses/>."
,
802 NULL((void*)0)
803 };
804 gchar *license_i18n;
805
806 license_i18n = g_strconcat (_(license[0])gettext (license[0]), "\n\n", _(license[1])gettext (license[1]), "\n\n", _(license[2])gettext (license[2]), NULL((void*)0));
807
808 gtk_show_about_dialog(NULL((void*)0),
809 "version", VERSION"1.24.0",
810 "copyright", _("Copyright \xc2\xa9 2009-2010 Canonical, Ltd.\n"gettext ("Copyright \xc2\xa9 2009-2010 Canonical, Ltd.\n" "Copyright \xc2\xa9 2011-2020 MATE developers"
)
811 "Copyright \xc2\xa9 2011-2020 MATE developers")gettext ("Copyright \xc2\xa9 2009-2010 Canonical, Ltd.\n" "Copyright \xc2\xa9 2011-2020 MATE developers"
)
,
812#ifdef INDICATOR_APPLET_APPMENU
813 "comments", _("An applet to hold your application menus.")gettext ("An applet to hold your application menus."),
814#endif
815 "comments", _("An applet to hold all of the system indicators.")gettext ("An applet to hold all of the system indicators."),
816 "authors", authors,
817 "license", license_i18n,
818 "wrap-license", TRUE(!(0)),
819 "translator-credits", _("translator-credits")gettext ("translator-credits"),
820 "logo-icon-name", "mate-indicator-applet",
821 "icon-name", "mate-indicator-applet",
822 "website", "https://mate-desktop.org",
823 "website-label", _("MATE Website")gettext ("MATE Website"),
824 NULL((void*)0)
825 );
826
827 g_free (license_i18n);
828
829 return;
830}
831
832static gboolean
833swap_orient_cb (GtkWidget *item, gpointer data)
834{
835 GtkWidget *from = (GtkWidget *) data;
836 GtkWidget *to = (GtkWidget *) g_object_get_data(G_OBJECT(from)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
from)), (((GType) ((20) << (2))))))))
, "to");
837 g_object_ref(G_OBJECT(item)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
item)), (((GType) ((20) << (2))))))))
);
838 gtk_container_remove(GTK_CONTAINER(from)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((from)), ((gtk_container_get_type ()))))))
, item);
839 if (GTK_IS_LABEL(item)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(item)); GType __t = ((gtk_label_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; }))))
) {
840 switch(packdirection) {
841 case GTK_PACK_DIRECTION_LTR:
842 gtk_label_set_angle(GTK_LABEL(item)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(item)), ((gtk_label_get_type ()))))))
, 0.0);
843 break;
844 case GTK_PACK_DIRECTION_TTB:
845 gtk_label_set_angle(GTK_LABEL(item)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(item)), ((gtk_label_get_type ()))))))
,
846 (orient == MATE_PANEL_APPLET_ORIENT_LEFT) ?
847 270.0 : 90.0);
848 break;
849 default:
850 break;
851 }
852 }
853 gtk_box_pack_start(GTK_BOX(to)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((to
)), ((gtk_box_get_type ()))))))
, item, FALSE(0), FALSE(0), 0);
854 return TRUE(!(0));
855}
856
857static gboolean
858reorient_box_cb (GtkWidget *menuitem, gpointer data)
859{
860 GtkWidget *from = g_object_get_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "box");
861 GtkWidget *to = (packdirection == GTK_PACK_DIRECTION_LTR) ?
862 gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0) : gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
863 g_object_set_data(G_OBJECT(from)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
from)), (((GType) ((20) << (2))))))))
, "to", to);
864 gtk_container_foreach(GTK_CONTAINER(from)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((from)), ((gtk_container_get_type ()))))))
, (GtkCallback)swap_orient_cb,
865 from);
866 gtk_container_remove(GTK_CONTAINER(menuitem)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menuitem)), ((gtk_container_get_type ()))))))
, from);
867 gtk_container_add(GTK_CONTAINER(menuitem)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menuitem)), ((gtk_container_get_type ()))))))
, to);
868 g_object_set_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "box", to);
869 gtk_widget_show_all(menuitem);
870 return TRUE(!(0));
871}
872
873static gboolean
874matepanelapplet_reorient_cb (GtkWidget *applet, MatePanelAppletOrient neworient,
875 gpointer data)
876{
877 GtkWidget *menubar = (GtkWidget *)data;
878 if ((((neworient == MATE_PANEL_APPLET_ORIENT_UP) ||
879 (neworient == MATE_PANEL_APPLET_ORIENT_DOWN)) &&
880 ((orient == MATE_PANEL_APPLET_ORIENT_LEFT) ||
881 (orient == MATE_PANEL_APPLET_ORIENT_RIGHT))) ||
882 (((neworient == MATE_PANEL_APPLET_ORIENT_LEFT) ||
883 (neworient == MATE_PANEL_APPLET_ORIENT_RIGHT)) &&
884 ((orient == MATE_PANEL_APPLET_ORIENT_UP) ||
885 (orient == MATE_PANEL_APPLET_ORIENT_DOWN)))) {
886 packdirection = (packdirection == GTK_PACK_DIRECTION_LTR) ?
887 GTK_PACK_DIRECTION_TTB : GTK_PACK_DIRECTION_LTR;
888 gtk_menu_bar_set_pack_direction(GTK_MENU_BAR(menubar)((((GtkMenuBar*) g_type_check_instance_cast ((GTypeInstance*)
((menubar)), ((gtk_menu_bar_get_type ()))))))
,
889 packdirection);
890 orient = neworient;
891 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
,
892 (GtkCallback)reorient_box_cb, NULL((void*)0));
893 }
894 orient = neworient;
895 return FALSE(0);
896}
897
898#ifdef N_
899#undef N_
900#endif
901#define N_(x)x x
902
903static void
904log_to_file_cb (GObject * source_obj G_GNUC_UNUSED__attribute__((__unused__)),
905 GAsyncResult * result G_GNUC_UNUSED__attribute__((__unused__)), gpointer user_data)
906{
907 g_free(user_data);
908 return;
909}
910
911static void
912log_to_file (const gchar * domain G_GNUC_UNUSED__attribute__((__unused__)),
913 GLogLevelFlags level G_GNUC_UNUSED__attribute__((__unused__)),
914 const gchar * message,
915 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
916{
917 if (log_file == NULL((void*)0)) {
918 GError * error = NULL((void*)0);
919 gchar * filename = g_build_filename(g_get_user_cache_dir(), LOG_FILE_NAME"indicator-applet.log", NULL((void*)0));
920 GFile * file = g_file_new_for_path(filename);
921 g_free(filename);
922
923 if (!g_file_test(g_get_user_cache_dir(), G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) {
924 GFile * cachedir = g_file_new_for_path(g_get_user_cache_dir());
925 g_file_make_directory_with_parents(cachedir, NULL((void*)0), &error);
926
927 if (error != NULL((void*)0)) {
928 g_error("Unable to make directory '%s' for log file: %s", g_get_user_cache_dir(), error->message);
929 return;
930 }
931 }
932
933 g_file_delete(file, NULL((void*)0), NULL((void*)0));
934
935 GFileIOStream * io = g_file_create_readwrite(file,
936 G_FILE_CREATE_REPLACE_DESTINATION, /* flags */
937 NULL((void*)0), /* cancelable */
938 &error); /* error */
939 if (error != NULL((void*)0)) {
940 g_error("Unable to replace file: %s", error->message);
941 return;
This statement is never executed
942 }
943
944 log_file = g_io_stream_get_output_stream(G_IO_STREAM(io)((((GIOStream*) g_type_check_instance_cast ((GTypeInstance*) (
(io)), ((g_io_stream_get_type ()))))))
);
945 }
946
947 gchar * outputstring = g_strdup_printf("%s\n", message);
948 g_output_stream_write_async(log_file,
949 outputstring, /* data */
950 strlen(outputstring), /* length */
951 G_PRIORITY_LOW300, /* priority */
952 NULL((void*)0), /* cancelable */
953 log_to_file_cb, /* callback */
954 outputstring); /* data */
955
956 return;
957}
958
959static gboolean
960applet_fill_cb (MatePanelApplet * applet, const gchar * iid G_GNUC_UNUSED__attribute__((__unused__)),
961 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
962{
963#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
964 ido_init();
965#endif
966
967 static const GtkActionEntry menu_actions[] = {
968 {"About", GTK_STOCK_ABOUT((GtkStock)"gtk-about"), N_("_About")"_About", NULL((void*)0), NULL((void*)0), G_CALLBACK(about_cb)((GCallback) (about_cb))}
969 };
970 static const gchar *menu_xml = "<menuitem name=\"About\" action=\"About\"/>";
971
972 static gboolean first_time = FALSE(0);
973 GtkWidget *menubar;
974 gint indicators_loaded = 0;
975 GtkActionGroup *action_group;
976
977 if (!first_time)
978 {
979 first_time = TRUE(!(0));
980#ifdef INDICATOR_APPLET1
981 g_set_application_name(_("Indicator Applet")gettext ("Indicator Applet"));
982#endif
983#ifdef INDICATOR_APPLET_COMPLETE
984 g_set_application_name(_("Indicator Applet Complete")gettext ("Indicator Applet Complete"));
985#endif
986#ifdef INDICATOR_APPLET_APPMENU
987 g_set_application_name(_("Indicator Applet Application Menu")gettext ("Indicator Applet Application Menu"));
988#endif
989
990 g_log_set_default_handler(log_to_file, NULL((void*)0));
991
992 tomboy_keybinder_init();
993 }
994
995 /* Set panel options */
996 gtk_container_set_border_width(GTK_CONTAINER (applet)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_container_get_type ()))))))
, 0);
997 mate_panel_applet_set_flags(applet, MATE_PANEL_APPLET_EXPAND_MINOR);
998 menubar = gtk_menu_bar_new();
999 action_group = gtk_action_group_new ("Indicator Applet Actions");
1000 gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE"mate-indicator-applet");
1001 gtk_action_group_add_actions (action_group, menu_actions,
1002 G_N_ELEMENTS (menu_actions)(sizeof (menu_actions) / sizeof ((menu_actions)[0])),
1003 menubar);
1004 mate_panel_applet_setup_menu(applet, menu_xml, action_group);
1005 g_object_unref(action_group);
1006#ifdef INDICATOR_APPLET1
1007 atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
),
1008 "indicator-applet");
1009#endif
1010#ifdef INDICATOR_APPLET_COMPLETE
1011 atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
),
1012 "indicator-applet-complete");
1013#endif
1014#ifdef INDICATOR_APPLET_APPMENU
1015 atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
),
1016 "indicator-applet-appmenu");
1017#endif
1018
1019 /* Init some theme/icon stuff */
1020 gtk_icon_theme_append_search_path(gtk_icon_theme_get_default(),
1021 INDICATOR_ICONS_DIR"/usr/share/libindicator/icons/");
1022 /* g_debug("Icons directory: %s", INDICATOR_ICONS_DIR); */
1023 gtk_widget_set_name(GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
, "fast-user-switch-applet");
1024
1025 /* Build menubar */
1026 size = (mate_panel_applet_get_size (applet));
1027 orient = (mate_panel_applet_get_orient(applet));
1028 packdirection = ((orient == MATE_PANEL_APPLET_ORIENT_UP) ||
1029 (orient == MATE_PANEL_APPLET_ORIENT_DOWN)) ?
1030 GTK_PACK_DIRECTION_LTR : GTK_PACK_DIRECTION_TTB;
1031 gtk_menu_bar_set_pack_direction(GTK_MENU_BAR(menubar)((((GtkMenuBar*) g_type_check_instance_cast ((GTypeInstance*)
((menubar)), ((gtk_menu_bar_get_type ()))))))
,
1032 packdirection);
1033 gtk_widget_set_can_focus (menubar, TRUE(!(0)));
1034 gtk_widget_set_name(GTK_WIDGET (menubar)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(menubar)), ((gtk_widget_get_type ()))))))
, "fast-user-switch-menubar");
1035 g_signal_connect(menubar, "button-press-event", G_CALLBACK(menubar_press), NULL)g_signal_connect_data ((menubar), ("button-press-event"), (((
GCallback) (menubar_press))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
;
1036 g_signal_connect_after(menubar, "draw", G_CALLBACK(menubar_on_draw), menubar)g_signal_connect_data ((menubar), ("draw"), (((GCallback) (menubar_on_draw
))), (menubar), ((void*)0), G_CONNECT_AFTER)
;
1037 g_signal_connect(applet, "change-orient",g_signal_connect_data ((applet), ("change-orient"), (((GCallback
) (matepanelapplet_reorient_cb))), (menubar), ((void*)0), (GConnectFlags
) 0)
1038 G_CALLBACK(matepanelapplet_reorient_cb), menubar)g_signal_connect_data ((applet), ("change-orient"), (((GCallback
) (matepanelapplet_reorient_cb))), (menubar), ((void*)0), (GConnectFlags
) 0)
;
1039 gtk_container_set_border_width(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, 0);
1040
1041 /* Add in filter func */
1042 tomboy_keybinder_bind(hotkey_keycode, hotkey_filter, menubar);
1043
1044 load_modules(applet, menubar, &indicators_loaded);
1045#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
1046 load_indicators_from_indicator_files(applet, menubar, &indicators_loaded);
1047#endif
1048
1049 if (indicators_loaded == 0) {
1050 /* A label to allow for click through */
1051 GtkWidget * item = gtk_label_new(_("No Indicators")gettext ("No Indicators"));
1052 mate_panel_applet_set_background_widget(applet, item);
1053 gtk_container_add(GTK_CONTAINER(applet)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_container_get_type ()))))))
, item);
1054 gtk_widget_show(item);
1055 } else {
1056 gtk_container_add(GTK_CONTAINER(applet)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_container_get_type ()))))))
, menubar);
1057 mate_panel_applet_set_background_widget(applet, menubar);
1058 gtk_widget_show(menubar);
1059 }
1060
1061 gtk_widget_show(GTK_WIDGET(applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
);
1062
1063 return TRUE(!(0));
1064
1065}
diff --git a/2020-04-09-113756-6097-1@37cc19e547b1_shadow/report-489a68.html b/2020-04-09-113756-6097-1@37cc19e547b1_shadow/report-489a68.html new file mode 100644 index 0000000..8038737 --- /dev/null +++ b/2020-04-09-113756-6097-1@37cc19e547b1_shadow/report-489a68.html @@ -0,0 +1,1412 @@ + + + +applet-main.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:applet-main.c
Warning:line 941, column 4
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name applet-main.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -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 -mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -resource-dir /usr/lib64/clang/9.0.1 -D HAVE_CONFIG_H -I . -I .. -D G_LOG_DOMAIN="Indicator-Applet-Complete" -D DATADIR="/usr/local/share" -D INDICATOR_DIR="/usr/lib64/indicators3/7/" -D INDICATOR_ICONS_DIR="/usr/share/libindicator/icons/" -D INDICATOR_APPLET_COMPLETE -I ./.. -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/fribidi -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gio-unix-2.0 -I /usr/include/libdrm -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-panel-4.0/libmate-panel-applet -I /usr/include/libindicator3-0.4 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/fribidi -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gio-unix-2.0 -I /usr/include/libdrm -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/9.0.1/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdebug-compilation-dir /rootdir/src -ferror-limit 19 -fmessage-length 0 -fobjc-runtime=gcc -fdiagnostics-show-option -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 -o /rootdir/html-report/2020-04-09-113756-6097-1 -x c applet-main.c +
+ + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2A small wrapper utility to load indicators and put them as menu items
3into the mate-panel using it's applet interface.
4
5Copyright 2009-2010 Canonical Ltd.
6
7Authors:
8 Ted Gould <ted@canonical.com>
9
10This program is free software: you can redistribute it and/or modify it
11under the terms of the GNU General Public License version 3, as published
12by the Free Software Foundation.
13
14This program is distributed in the hope that it will be useful, but
15WITHOUT ANY WARRANTY; without even the implied warranties of
16MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
17PURPOSE. See the GNU General Public License for more details.
18
19You should have received a copy of the GNU General Public License along
20with this program. If not, see <http://www.gnu.org/licenses/>.
21*/
22
23#include <stdlib.h>
24#include <string.h>
25#include <config.h>
26#include <glib/gi18n.h>
27#include <mate-panel-applet.h>
28#include <gdk/gdkkeysyms.h>
29#include <gtk/gtk.h>
30
31#if HAVE_UBUNTU_INDICATOR1
32
33#define INDICATOR_SERVICE_APPMENU"libappmenu.so" "libappmenu.so"
34#define INDICATOR_SERVICE_ME"libme.so" "libme.so"
35#define INDICATOR_SERVICE_DATETIME"libdatetime.so" "libdatetime.so"
36
37#define INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu" "com.canonical.indicator.appmenu"
38#define INDICATOR_SERVICE_ME_NG"com.canonical.indicator.me" "com.canonical.indicator.me"
39#define INDICATOR_SERVICE_DATETIME_NG"com.canonical.indicator.datetime" "com.canonical.indicator.datetime"
40
41#include <libindicator/indicator-object.h>
42#endif
43
44#if HAVE_AYATANA_INDICATOR
45
46#define INDICATOR_SERVICE_APPMENU"libappmenu.so" "libayatana-appmenu.so"
47#define INDICATOR_SERVICE_ME"libme.so" "libayatana-me.so"
48#define INDICATOR_SERVICE_DATETIME"libdatetime.so" "libayatana-datetime.so"
49
50#define INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu" "org.ayatana.indicator.appmenu"
51#define INDICATOR_SERVICE_ME_NG"com.canonical.indicator.me" "org.ayatana.indicator.me"
52#define INDICATOR_SERVICE_DATETIME_NG"com.canonical.indicator.datetime" "org.ayatana.indicator.datetime"
53
54#include <libayatana-indicator/indicator-object.h>
55#endif
56
57/* For new style indicators */
58
59#if HAVE_UBUNTU_INDICATOR1 && HAVE_UBUNTU_INDICATOR_NG
60
61#include <libido/libido.h>
62#include <libindicator/indicator-ng.h>
63
64#define INDICATOR_SERVICE_DIR "/usr/share/unity/indicators"
65
66#endif
67
68#if HAVE_AYATANA_INDICATOR && HAVE_AYATANA_INDICATOR_NG
69
70#include <libayatana-ido/libayatana-ido.h>
71#include <libayatana-indicator/indicator-ng.h>
72
73#define INDICATOR_SERVICE_DIR "/usr/share/ayatana/indicators"
74
75#endif
76
77#include "tomboykeybinder.h"
78
79static gchar * indicator_order[] = {
80#if HAVE_UBUNTU_INDICATOR1
81 "libapplication.so",
82 "libmessaging.so",
83 "libsoundmenu.so",
84 "libdatetime.so",
85 "libsession.so",
86#endif
87#if HAVE_AYATANA_INDICATOR
88 "libayatana-application.so",
89 "libayatana-messaging.so",
90 "libayatana-soundmenu.so",
91 "libayatana-datetime.so",
92 "libayatana-session.so",
93#endif
94 NULL((void*)0)
95};
96
97static GtkPackDirection packdirection;
98static MatePanelAppletOrient orient;
99static guint size;
100
101#define MENU_DATA_INDICATOR_OBJECT"indicator-object" "indicator-object"
102#define MENU_DATA_INDICATOR_ENTRY"indicator-entry" "indicator-entry"
103
104#define IO_DATA_ORDER_NUMBER"indicator-order-number" "indicator-order-number"
105
106static gboolean applet_fill_cb (MatePanelApplet * applet, const gchar * iid, gpointer data);
107
108static void update_accessible_desc (IndicatorObjectEntry * entry, GtkWidget * menuitem);
109
110/*************
111 * main
112 * ***********/
113
114#ifdef INDICATOR_APPLET
115MATE_PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletFactory",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
116 PANEL_TYPE_APPLET,int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
117 "indicator-applet",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
118 applet_fill_cb, NULL)int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
;
119#endif
120#ifdef INDICATOR_APPLET_COMPLETE1
121MATE_PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletCompleteFactory",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
122 PANEL_TYPE_APPLET,int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
123 "indicator-applet-complete",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
124 applet_fill_cb, NULL)int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
;
125#endif
126#ifdef INDICATOR_APPLET_APPMENU
127MATE_PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletAppmenuFactory",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
128 PANEL_TYPE_APPLET,int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
129 "indicator-applet-appmenu",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
130 applet_fill_cb, NULL)int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
;
131#endif
132
133/*************
134 * log files
135 * ***********/
136#ifdef INDICATOR_APPLET
137#define LOG_FILE_NAME"indicator-applet-complete.log" "indicator-applet.log"
138#endif
139#ifdef INDICATOR_APPLET_COMPLETE1
140#define LOG_FILE_NAME"indicator-applet-complete.log" "indicator-applet-complete.log"
141#endif
142#ifdef INDICATOR_APPLET_APPMENU
143#define LOG_FILE_NAME"indicator-applet-complete.log" "indicator-applet-appmenu.log"
144#endif
145GOutputStream * log_file = NULL((void*)0);
146
147/*****************
148 * Hotkey support
149 * **************/
150#ifdef INDICATOR_APPLET
151gchar * hotkey_keycode = "<Super>M";
152#endif
153#ifdef INDICATOR_APPLET_SESSION
154gchar * hotkey_keycode = "<Super>S";
155#endif
156#ifdef INDICATOR_APPLET_COMPLETE1
157gchar * hotkey_keycode = "<Super>S";
158#endif
159#ifdef INDICATOR_APPLET_APPMENU
160gchar * hotkey_keycode = "<Super>F1";
161#endif
162
163/********************
164 * Environment Names
165 * *******************/
166#ifdef INDICATOR_APPLET
167#define INDICATOR_SPECIFIC_ENV"indicator-applet-complete" "indicator-applet-original"
168#endif
169#ifdef INDICATOR_APPLET_COMPLETE1
170#define INDICATOR_SPECIFIC_ENV"indicator-applet-complete" "indicator-applet-complete"
171#endif
172#ifdef INDICATOR_APPLET_APPMENU
173#define INDICATOR_SPECIFIC_ENV"indicator-applet-complete" "indicator-applet-appmenu"
174#endif
175
176static const gchar * indicator_env[] = {
177 "indicator-applet",
178 INDICATOR_SPECIFIC_ENV"indicator-applet-complete",
179 NULL((void*)0)
180};
181
182/*************
183 * init function
184 * ***********/
185
186static gint
187name2order (const gchar * name) {
188 int i;
189
190 for (i = 0; indicator_order[i] != NULL((void*)0); i++) {
191 if (g_strcmp0(name, indicator_order[i]) == 0) {
192 return i;
193 }
194 }
195
196 return -1;
197}
198
199typedef struct _incoming_position_t incoming_position_t;
200struct _incoming_position_t {
201 gint objposition;
202 gint entryposition;
203 gint menupos;
204 gboolean found;
205};
206
207/* This function helps by determining where in the menu list
208 this new entry should be placed. It compares the objects
209 that they're on, and then the individual entries. Each
210 is progressively more expensive. */
211static void
212place_in_menu (GtkWidget * widget, gpointer user_data)
213{
214 incoming_position_t * position = (incoming_position_t *)user_data;
215 if (position->found) {
216 /* We've already been placed, just finish the foreach */
217 return;
218 }
219
220 IndicatorObject * io = INDICATOR_OBJECT(g_object_get_data(G_OBJECT(widget), MENU_DATA_INDICATOR_OBJECT))((((IndicatorObject*) g_type_check_instance_cast ((GTypeInstance
*) ((g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((widget)), (((GType) ((20) << (2)))
))))), "indicator-object"))), ((indicator_object_get_type ())
)))))
;
221 g_assert(io != NULL)do { if (io != ((void*)0)) ; else g_assertion_message_expr ("Indicator-Applet-Complete"
, "applet-main.c", 221, ((const char*) (__func__)), "io != NULL"
); } while (0)
;
222
223 gint objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER))((gint) (glong) (g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
), "indicator-order-number")))
;
224 /* We've already passed it, well, then this is where
225 we should be be. Stop! */
226 if (objposition > position->objposition) {
227 position->found = TRUE(!(0));
228 return;
229 }
230
231 /* The objects don't match yet, keep looking */
232 if (objposition < position->objposition) {
233 position->menupos++;
234 return;
235 }
236
237 /* The objects are the same, let's start looking at entries. */
238 IndicatorObjectEntry * entry = (IndicatorObjectEntry *)g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
239 gint entryposition = indicator_object_get_location(io, entry);
240
241 if (entryposition > position->entryposition) {
242 position->found = TRUE(!(0));
243 return;
244 }
245
246 if (entryposition < position->entryposition) {
247 position->menupos++;
248 return;
249 }
250
251 /* We've got the same object and the same entry. Well,
252 let's just put it right here then. */
253 position->found = TRUE(!(0));
254 return;
255}
256
257static void
258something_shown (GtkWidget * widget, gpointer user_data)
259{
260 GtkWidget * menuitem = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
261 gtk_widget_show(menuitem);
262}
263
264static void
265something_hidden (GtkWidget * widget, gpointer user_data)
266{
267 GtkWidget * menuitem = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
268 gtk_widget_hide(menuitem);
269}
270
271static void
272sensitive_cb (GObject * obj, GParamSpec * pspec, gpointer user_data)
273{
274 g_return_if_fail(GTK_IS_WIDGET(obj))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((obj)); GType __t = ((gtk_widget_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 ("Indicator-Applet-Complete"
, ((const char*) (__func__)), "GTK_IS_WIDGET(obj)"); return; }
} while (0)
;
275 g_return_if_fail(GTK_IS_WIDGET(user_data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((gtk_widget_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 ("Indicator-Applet-Complete"
, ((const char*) (__func__)), "GTK_IS_WIDGET(user_data)"); return
; } } while (0)
;
276
277 gtk_widget_set_sensitive(GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
, gtk_widget_get_sensitive(GTK_WIDGET(obj)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(obj)), ((gtk_widget_get_type ()))))))
));
278 return;
279}
280
281static void
282entry_activated (GtkWidget * widget, gpointer user_data)
283{
284 g_return_if_fail(GTK_IS_WIDGET(widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((gtk_widget_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 ("Indicator-Applet-Complete"
, ((const char*) (__func__)), "GTK_IS_WIDGET(widget)"); return
; } } while (0)
;
285 gpointer pio = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, "indicator");
286 g_return_if_fail(INDICATOR_IS_OBJECT(pio))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((pio)); GType __t = ((indicator_object_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 ("Indicator-Applet-Complete"
, ((const char*) (__func__)), "INDICATOR_IS_OBJECT(pio)"); return
; } } while (0)
;
287 IndicatorObject * io = INDICATOR_OBJECT(pio)((((IndicatorObject*) g_type_check_instance_cast ((GTypeInstance
*) ((pio)), ((indicator_object_get_type ()))))))
;
288
289 return indicator_object_entry_activate(io, (IndicatorObjectEntry *)user_data, gtk_get_current_event_time());
290}
291
292static gboolean
293entry_scrolled (GtkWidget *menuitem, GdkEventScroll *event, gpointer data)
294{
295 IndicatorObject *io = g_object_get_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_OBJECT"indicator-object");
296 IndicatorObjectEntry *entry = g_object_get_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
297
298 g_return_val_if_fail(INDICATOR_IS_OBJECT(io), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((io)); GType __t = ((indicator_object_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 ("Indicator-Applet-Complete"
, ((const char*) (__func__)), "INDICATOR_IS_OBJECT(io)"); return
((0)); } } while (0)
;
299
300 g_signal_emit_by_name (io, "scroll", 1, event->direction);
301 g_signal_emit_by_name (io, "scroll-entry", entry, 1, event->direction);
302 g_signal_emit_by_name (io, INDICATOR_OBJECT_SIGNAL_ENTRY_SCROLLED"entry-scrolled", entry, 1, event->direction);
303
304 return FALSE(0);
305}
306
307static void
308accessible_desc_update_cb (GtkWidget * widget, gpointer userdata)
309{
310 gpointer data = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
311
312 if (data != userdata) {
313 return;
314 }
315
316 IndicatorObjectEntry * entry = (IndicatorObjectEntry *)data;
317 update_accessible_desc(entry, widget);
318}
319
320static void
321accessible_desc_update (IndicatorObject * io, IndicatorObjectEntry * entry, GtkWidget * menubar)
322{
323 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, accessible_desc_update_cb, entry);
324 return;
325}
326
327#define PANEL_PADDING8 8
328static gboolean
329entry_resized (GtkWidget *applet, guint newsize, gpointer data)
330{
331 IndicatorObject *io = (IndicatorObject *)data;
332
333 size = newsize;
334
335 /* Work on the entries */
336 GList * entries = indicator_object_get_entries(io);
337 GList * entry = NULL((void*)0);
338
339 for (entry = entries; entry != NULL((void*)0); entry = g_list_next(entry)((entry) ? (((GList *)(entry))->next) : ((void*)0))) {
340 IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)entry->data;
341 if (entrydata->image != NULL((void*)0)) {
342 /* Resize to fit panel */
343 gtk_image_set_pixel_size (entrydata->image, size - PANEL_PADDING8);
344 }
345 }
346
347 return FALSE(0);
348}
349
350static void
351entry_added (IndicatorObject * io, IndicatorObjectEntry * entry, GtkWidget * menubar)
352{
353 g_debug("Signal: Entry Added");
354 gboolean something_visible = FALSE(0);
355 gboolean something_sensitive = FALSE(0);
356
357 GtkWidget * menuitem = gtk_menu_item_new();
358 GtkWidget * box = (packdirection == GTK_PACK_DIRECTION_LTR) ?
359 gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3) : gtk_box_new(GTK_ORIENTATION_VERTICAL, 3);
360
361 /* Allows indicators to receive mouse scroll event */
362 gtk_widget_add_events(GTK_WIDGET(menuitem)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(menuitem)), ((gtk_widget_get_type ()))))))
, GDK_SCROLL_MASK);
363
364 g_object_set_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "indicator", io);
365 g_object_set_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "box", box);
366
367 g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(entry_activated), entry)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((menuitem)), (((GType) ((20) << (2)
)))))))), ("activate"), (((GCallback) (entry_activated))), (entry
), ((void*)0), (GConnectFlags) 0)
;
368 g_signal_connect(G_OBJECT(menuitem), "scroll-event", G_CALLBACK(entry_scrolled), entry)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((menuitem)), (((GType) ((20) << (2)
)))))))), ("scroll-event"), (((GCallback) (entry_scrolled))),
(entry), ((void*)0), (GConnectFlags) 0)
;
369
370 if (entry->image != NULL((void*)0)) {
371 /* Resize to fit panel */
372 gtk_image_set_pixel_size (entry->image, size - PANEL_PADDING8);
373 gtk_box_pack_start(GTK_BOX(box)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((box
)), ((gtk_box_get_type ()))))))
, GTK_WIDGET(entry->image)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->image)), ((gtk_widget_get_type ()))))))
, FALSE(0), FALSE(0), 1);
374 if (gtk_widget_get_visible(GTK_WIDGET(entry->image)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->image)), ((gtk_widget_get_type ()))))))
)) {
375 something_visible = TRUE(!(0));
376 }
377
378 if (gtk_widget_get_sensitive(GTK_WIDGET(entry->image)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->image)), ((gtk_widget_get_type ()))))))
)) {
379 something_sensitive = TRUE(!(0));
380 }
381
382 g_signal_connect(G_OBJECT(entry->image), "show", G_CALLBACK(something_shown), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), ("show"), (((GCallback) (something_shown))), (menuitem
), ((void*)0), (GConnectFlags) 0)
;
383 g_signal_connect(G_OBJECT(entry->image), "hide", G_CALLBACK(something_hidden), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), ("hide"), (((GCallback) (something_hidden))), (
menuitem), ((void*)0), (GConnectFlags) 0)
;
384
385 g_signal_connect(G_OBJECT(entry->image), "notify::sensitive", G_CALLBACK(sensitive_cb), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), ("notify::sensitive"), (((GCallback) (sensitive_cb
))), (menuitem), ((void*)0), (GConnectFlags) 0)
;
386 }
387 if (entry->label != NULL((void*)0)) {
388 switch(packdirection) {
389 case GTK_PACK_DIRECTION_LTR:
390 gtk_label_set_angle(GTK_LABEL(entry->label)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_label_get_type ()))))))
, 0.0);
391 break;
392 case GTK_PACK_DIRECTION_TTB:
393 gtk_label_set_angle(GTK_LABEL(entry->label)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_label_get_type ()))))))
,
394 (orient == MATE_PANEL_APPLET_ORIENT_LEFT) ?
395 270.0 : 90.0);
396 break;
397 default:
398 break;
399 }
400 gtk_box_pack_start(GTK_BOX(box)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((box
)), ((gtk_box_get_type ()))))))
, GTK_WIDGET(entry->label)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_widget_get_type ()))))))
, FALSE(0), FALSE(0), 1);
401
402 if (gtk_widget_get_visible(GTK_WIDGET(entry->label)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_widget_get_type ()))))))
)) {
403 something_visible = TRUE(!(0));
404 }
405
406 if (gtk_widget_get_sensitive(GTK_WIDGET(entry->label)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_widget_get_type ()))))))
)) {
407 something_sensitive = TRUE(!(0));
408 }
409
410 g_signal_connect(G_OBJECT(entry->label), "show", G_CALLBACK(something_shown), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), ("show"), (((GCallback) (something_shown))), (menuitem
), ((void*)0), (GConnectFlags) 0)
;
411 g_signal_connect(G_OBJECT(entry->label), "hide", G_CALLBACK(something_hidden), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), ("hide"), (((GCallback) (something_hidden))), (
menuitem), ((void*)0), (GConnectFlags) 0)
;
412
413 g_signal_connect(G_OBJECT(entry->label), "notify::sensitive", G_CALLBACK(sensitive_cb), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), ("notify::sensitive"), (((GCallback) (sensitive_cb
))), (menuitem), ((void*)0), (GConnectFlags) 0)
;
414 }
415 gtk_container_add(GTK_CONTAINER(menuitem)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menuitem)), ((gtk_container_get_type ()))))))
, box);
416 gtk_widget_show(box);
417
418 if (entry->menu != NULL((void*)0)) {
419 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem)((((GtkMenuItem*) g_type_check_instance_cast ((GTypeInstance*
) ((menuitem)), ((gtk_menu_item_get_type ()))))))
, GTK_WIDGET(entry->menu)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->menu)), ((gtk_widget_get_type ()))))))
);
420 }
421
422 incoming_position_t position;
423 position.objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER))((gint) (glong) (g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
), "indicator-order-number")))
;
424 position.entryposition = indicator_object_get_location(io, entry);
425 position.menupos = 0;
426 position.found = FALSE(0);
427
428 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, place_in_menu, &position);
429
430 gtk_menu_shell_insert(GTK_MENU_SHELL(menubar)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_menu_shell_get_type ()))))))
, menuitem, position.menupos);
431
432 if (something_visible) {
433 if (entry->accessible_desc != NULL((void*)0)) {
434 update_accessible_desc(entry, menuitem);
435 }
436 gtk_widget_show(menuitem);
437 }
438 gtk_widget_set_sensitive(menuitem, something_sensitive);
439
440 g_object_set_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry", entry);
441 g_object_set_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_OBJECT"indicator-object", io);
442
443 return;
444}
445
446static void
447entry_removed_cb (GtkWidget * widget, gpointer userdata)
448{
449 gpointer data = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
450
451 if (data != userdata) {
452 return;
453 }
454
455 IndicatorObjectEntry * entry = (IndicatorObjectEntry *)data;
456 if (entry->label != NULL((void*)0)) {
457 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(something_shown), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_shown))), (widget
))
;
458 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(something_hidden), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_hidden))), (widget
))
;
459 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(sensitive_cb), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (sensitive_cb))), (widget)
)
;
460 }
461 if (entry->image != NULL((void*)0)) {
462 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(something_shown), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_shown))), (widget
))
;
463 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(something_hidden), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_hidden))), (widget
))
;
464 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(sensitive_cb), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (sensitive_cb))), (widget)
)
;
465 }
466
467 gtk_widget_destroy(widget);
468 return;
469}
470
471static void
472entry_removed (IndicatorObject * io G_GNUC_UNUSED__attribute__((__unused__)), IndicatorObjectEntry * entry,
473 gpointer user_data)
474{
475 g_debug("Signal: Entry Removed");
476
477 gtk_container_foreach(GTK_CONTAINER(user_data)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((gtk_container_get_type ()))))))
, entry_removed_cb, entry);
478
479 return;
480}
481
482static void
483entry_moved_find_cb (GtkWidget * widget, gpointer userdata)
484{
485 gpointer * array = (gpointer *)userdata;
486 if (array[1] != NULL((void*)0)) {
487 return;
488 }
489
490 gpointer data = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
491
492 if (data != array[0]) {
493 return;
494 }
495
496 array[1] = widget;
497 return;
498}
499
500/* Gets called when an entry for an object was moved. */
501static void
502entry_moved (IndicatorObject * io, IndicatorObjectEntry * entry,
503 gint old G_GNUC_UNUSED__attribute__((__unused__)), gint new G_GNUC_UNUSED__attribute__((__unused__)), gpointer user_data)
504{
505 GtkWidget * menubar = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
506
507 gpointer array[2];
508 array[0] = entry;
509 array[1] = NULL((void*)0);
510
511 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, entry_moved_find_cb, array);
512 if (array[1] == NULL((void*)0)) {
513 g_warning("Moving an entry that isn't in our menus.");
514 return;
515 }
516
517 GtkWidget * mi = GTK_WIDGET(array[1])((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(array[1])), ((gtk_widget_get_type ()))))))
;
518 g_object_ref(G_OBJECT(mi)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
mi)), (((GType) ((20) << (2))))))))
);
519 gtk_container_remove(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, mi);
520
521 incoming_position_t position;
522 position.objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER))((gint) (glong) (g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
), "indicator-order-number")))
;
523 position.entryposition = indicator_object_get_location(io, entry);
524 position.menupos = 0;
525 position.found = FALSE(0);
526
527 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, place_in_menu, &position);
528
529 gtk_menu_shell_insert(GTK_MENU_SHELL(menubar)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_menu_shell_get_type ()))))))
, mi, position.menupos);
530 g_object_unref(G_OBJECT(mi)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
mi)), (((GType) ((20) << (2))))))))
);
531
532 return;
533}
534
535static void
536menu_show (IndicatorObject * io, IndicatorObjectEntry * entry,
537 guint32 timestamp, gpointer user_data)
538{
539 GtkWidget * menubar = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
540
541 if (entry == NULL((void*)0)) {
542 /* Close any open menus instead of opening one */
543 GList * entries = indicator_object_get_entries(io);
544 GList * iterator = NULL((void*)0);
545 for (iterator = entries; iterator != NULL((void*)0); iterator = g_list_next(iterator)((iterator) ? (((GList *)(iterator))->next) : ((void*)0))) {
546 IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)iterator->data;
547 gtk_menu_popdown(entrydata->menu);
548 }
549 g_list_free(entries);
550
551 /* And tell the menubar to exit activation mode too */
552 gtk_menu_shell_cancel(GTK_MENU_SHELL(menubar)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_menu_shell_get_type ()))))))
);
553 return;
554 }
555
556 // TODO: do something sensible here
557}
558
559static void
560update_accessible_desc(IndicatorObjectEntry * entry, GtkWidget * menuitem)
561{
562 /* FIXME: We need to deal with the use case where the contents of the
563 label overrides what is found in the atk object's name, or at least
564 orca speaks the label instead of the atk object name.
565 */
566 AtkObject * menuitem_obj = gtk_widget_get_accessible(menuitem);
567 if (menuitem_obj == NULL((void*)0)) {
568 /* Should there be an error printed here? */
569 return;
570 }
571
572 if (entry->accessible_desc != NULL((void*)0)) {
573 atk_object_set_name(menuitem_obj, entry->accessible_desc);
574 } else {
575 atk_object_set_name(menuitem_obj, "");
576 }
577 return;
578}
579
580static void
581load_indicator (MatePanelApplet *applet, GtkWidget * menubar, IndicatorObject *io, const gchar *name)
582{
583 /* Set the environment it's in */
584 indicator_object_set_environment(io, (const GStrv)indicator_env);
585
586 /* Attach the 'name' to the object */
587#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
588 int pos = 5000 - indicator_object_get_position(io);
589 if (pos > 5000) {
590 pos = name2order(name);
591 }
592#else
593 int pos = name2order(name);
594#endif
595
596 g_object_set_data(G_OBJECT(io)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
io)), (((GType) ((20) << (2))))))))
, IO_DATA_ORDER_NUMBER"indicator-order-number", GINT_TO_POINTER(pos)((gpointer) (glong) (pos)));
597
598 /* Connect to its signals */
599 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED, G_CALLBACK(entry_added), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("entry-added"), (((GCallback) (entry_added))), (menubar)
, ((void*)0), (GConnectFlags) 0)
;
600 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED, G_CALLBACK(entry_removed), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("entry-removed"), (((GCallback) (entry_removed))), (menubar
), ((void*)0), (GConnectFlags) 0)
;
601 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_MOVED, G_CALLBACK(entry_moved), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("entry-moved"), (((GCallback) (entry_moved))), (menubar)
, ((void*)0), (GConnectFlags) 0)
;
602 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_MENU_SHOW, G_CALLBACK(menu_show), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("menu-show"), (((GCallback) (menu_show))), (menubar), ((
void*)0), (GConnectFlags) 0)
;
603 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ACCESSIBLE_DESC_UPDATE, G_CALLBACK(accessible_desc_update), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("accessible-desc-update"), (((GCallback) (accessible_desc_update
))), (menubar), ((void*)0), (GConnectFlags) 0)
;
604
605 /* Track panel resize */
606 g_signal_connect_object(G_OBJECT(applet)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
applet)), (((GType) ((20) << (2))))))))
, "change-size", G_CALLBACK(entry_resized)((GCallback) (entry_resized)), G_OBJECT(io)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
io)), (((GType) ((20) << (2))))))))
, 0);
607
608 /* Work on the entries */
609 GList * entries = indicator_object_get_entries(io);
610 GList * entry = NULL((void*)0);
611
612 for (entry = entries; entry != NULL((void*)0); entry = g_list_next(entry)((entry) ? (((GList *)(entry))->next) : ((void*)0))) {
613 IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)entry->data;
614 entry_added(io, entrydata, menubar);
615 }
616
617 g_list_free(entries);
618}
619
620static gboolean
621load_module (const gchar * name, MatePanelApplet *applet, GtkWidget * menubar)
622{
623 g_debug("Looking at Module: %s", name);
624 g_return_val_if_fail(name != NULL, FALSE)do { if ((name != ((void*)0))) { } else { g_return_if_fail_warning
("Indicator-Applet-Complete", ((const char*) (__func__)), "name != NULL"
); return ((0)); } } while (0)
;
625
626 if (!g_str_has_suffix(name, G_MODULE_SUFFIX"so")) {
627 return FALSE(0);
628 }
629
630 g_debug("Loading Module: %s", name);
631
632 /* Build the object for the module */
633 gchar * fullpath = g_build_filename(INDICATOR_DIR"/usr/lib64/indicators3/7/", name, NULL((void*)0));
634 IndicatorObject * io = indicator_object_new_from_file(fullpath);
635 g_free(fullpath);
636
637 load_indicator(applet, menubar, io, name);
638
639 return TRUE(!(0));
640}
641
642static void
643load_modules (MatePanelApplet *applet, GtkWidget *menubar, gint *indicators_loaded)
644{
645 if (g_file_test(INDICATOR_DIR"/usr/lib64/indicators3/7/", (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))) {
646 GDir * dir = g_dir_open(INDICATOR_DIR"/usr/lib64/indicators3/7/", 0, NULL((void*)0));
647
648 const gchar * name;
649 gint count = 0;
650 while ((name = g_dir_read_name(dir)) != NULL((void*)0)) {
651#ifdef INDICATOR_APPLET_APPMENU
652 if (g_strcmp0(name, INDICATOR_SERVICE_APPMENU"libappmenu.so")) {
653 continue;
654 }
655#else
656 if (!g_strcmp0(name, INDICATOR_SERVICE_APPMENU"libappmenu.so")) {
657 continue;
658 }
659#endif
660#ifdef INDICATOR_APPLET
661 if (!g_strcmp0(name, INDICATOR_SERVICE_ME"libme.so")) {
662 continue;
663 }
664 if (!g_strcmp0(name, INDICATOR_SERVICE_DATETIME"libdatetime.so")) {
665 continue;
666 }
667#endif
668 if (load_module(name, applet, menubar)) {
669 count++;
670 }
671 }
672
673 *indicators_loaded += count;
674
675 g_dir_close (dir);
676 }
677}
678
679#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
680
681static void
682load_indicators_from_indicator_files (MatePanelApplet *applet, GtkWidget *menubar, gint *indicators_loaded)
683{
684 GDir *dir;
685 const gchar *name;
686 GError *error = NULL((void*)0);
687
688 dir = g_dir_open (INDICATOR_SERVICE_DIR, 0, &error);
689
690 if (!dir) {
691 g_warning ("unable to open indicator service file directory: %s", error->message);
692 g_error_free (error);
693
694 return;
695 }
696
697 gint count = 0;
698 while ((name = g_dir_read_name (dir))) {
699 gchar *filename;
700 IndicatorNg *indicator;
701
702 filename = g_build_filename (INDICATOR_SERVICE_DIR, name, NULL((void*)0));
703 indicator = indicator_ng_new_for_profile (filename, "desktop", &error);
704 g_free (filename);
705
706#ifdef INDICATOR_APPLET_APPMENU
707 if (g_strcmp0(name, INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu")) {
708 continue;
709 }
710#else
711 if (!g_strcmp0(name, INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu")) {
712 continue;
713 }
714#endif
715#ifdef INDICATOR_APPLET
716 if (!g_strcmp0(name, INDICATOR_SERVICE_ME_NG"com.canonical.indicator.me")) {
717 continue;
718 }
719 if (!g_strcmp0(name, INDICATOR_SERVICE_DATETIME_NG"com.canonical.indicator.datetime")) {
720 continue;
721 }
722#endif
723
724 if (indicator) {
725 load_indicator(applet, menubar, INDICATOR_OBJECT (indicator)((((IndicatorObject*) g_type_check_instance_cast ((GTypeInstance
*) ((indicator)), ((indicator_object_get_type ()))))))
, name);
726 count++;
727 }else{
728 g_warning ("unable to load '%s': %s", name, error->message);
729 g_clear_error (&error);
730 }
731 }
732
733 *indicators_loaded += count;
734
735 g_dir_close (dir);
736}
737#endif /* HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG */
738
739static void
740hotkey_filter (char * keystring G_GNUC_UNUSED__attribute__((__unused__)), gpointer data)
741{
742 g_return_if_fail(GTK_IS_MENU_SHELL(data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((data)); GType __t = ((gtk_menu_shell_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 ("Indicator-Applet-Complete"
, ((const char*) (__func__)), "GTK_IS_MENU_SHELL(data)"); return
; } } while (0)
;
743
744 /* Oh, wow, it's us! */
745 GList * children = gtk_container_get_children(GTK_CONTAINER(data)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((gtk_container_get_type ()))))))
);
746 if (children == NULL((void*)0)) {
747 g_debug("Menubar has no children");
748 return;
749 }
750
751 gtk_menu_shell_select_item(GTK_MENU_SHELL(data)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((gtk_menu_shell_get_type ()))))))
, GTK_WIDGET(g_list_last(children)->data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(g_list_last(children)->data)), ((gtk_widget_get_type ()))
))))
);
752 g_list_free(children);
753 return;
754}
755
756static gboolean
757menubar_press (GtkWidget * widget,
758 GdkEventButton *event,
759 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
760{
761 if (event->button != 1) {
762 g_signal_stop_emission_by_name(widget, "button-press-event");
763 }
764
765 return FALSE(0);
766}
767
768static gboolean
769menubar_on_draw (GtkWidget * widget,
770 cairo_t * cr,
771 GtkWidget * menubar)
772{
773 /* FIXME: either port to gtk_render_focus or remove this function */
774 if (gtk_widget_has_focus(menubar))
775 gtk_paint_focus(gtk_widget_get_style(widget),
776 cr,
777 gtk_widget_get_state(menubar),
778 widget, "menubar-applet", 0, 0, -1, -1);
779
780 return FALSE(0);
781}
782
783static void
784about_cb (GtkAction *action G_GNUC_UNUSED__attribute__((__unused__)),
785 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
786{
787 static const gchar *authors[] = {
788 "Ted Gould <ted@canonical.com>",
789 NULL((void*)0)
790 };
791
792 static gchar *license[] = {
793 N_("This program is free software: you can redistribute it and/or modify it ""This program is free software: you can redistribute it and/or modify it "
"under the terms of the GNU General Public License version 3, as published "
"by the Free Software Foundation."
794 "under the terms of the GNU General Public License version 3, as published ""This program is free software: you can redistribute it and/or modify it "
"under the terms of the GNU General Public License version 3, as published "
"by the Free Software Foundation."
795 "by the Free Software Foundation.")"This program is free software: you can redistribute it and/or modify it "
"under the terms of the GNU General Public License version 3, as published "
"by the Free Software Foundation."
,
796 N_("This program is distributed in the hope that it will be useful, but ""This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
797 "WITHOUT ANY WARRANTY; without even the implied warranties of ""This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
798 "MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR ""This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
799 "PURPOSE. See the GNU General Public License for more details.")"This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
,
800 N_("You should have received a copy of the GNU General Public License along ""You should have received a copy of the GNU General Public License along "
"with this program. If not, see <http://www.gnu.org/licenses/>."
801 "with this program. If not, see <http://www.gnu.org/licenses/>.")"You should have received a copy of the GNU General Public License along "
"with this program. If not, see <http://www.gnu.org/licenses/>."
,
802 NULL((void*)0)
803 };
804 gchar *license_i18n;
805
806 license_i18n = g_strconcat (_(license[0])gettext (license[0]), "\n\n", _(license[1])gettext (license[1]), "\n\n", _(license[2])gettext (license[2]), NULL((void*)0));
807
808 gtk_show_about_dialog(NULL((void*)0),
809 "version", VERSION"1.24.0",
810 "copyright", _("Copyright \xc2\xa9 2009-2010 Canonical, Ltd.\n"gettext ("Copyright \xc2\xa9 2009-2010 Canonical, Ltd.\n" "Copyright \xc2\xa9 2011-2020 MATE developers"
)
811 "Copyright \xc2\xa9 2011-2020 MATE developers")gettext ("Copyright \xc2\xa9 2009-2010 Canonical, Ltd.\n" "Copyright \xc2\xa9 2011-2020 MATE developers"
)
,
812#ifdef INDICATOR_APPLET_APPMENU
813 "comments", _("An applet to hold your application menus.")gettext ("An applet to hold your application menus."),
814#endif
815 "comments", _("An applet to hold all of the system indicators.")gettext ("An applet to hold all of the system indicators."),
816 "authors", authors,
817 "license", license_i18n,
818 "wrap-license", TRUE(!(0)),
819 "translator-credits", _("translator-credits")gettext ("translator-credits"),
820 "logo-icon-name", "mate-indicator-applet",
821 "icon-name", "mate-indicator-applet",
822 "website", "https://mate-desktop.org",
823 "website-label", _("MATE Website")gettext ("MATE Website"),
824 NULL((void*)0)
825 );
826
827 g_free (license_i18n);
828
829 return;
830}
831
832static gboolean
833swap_orient_cb (GtkWidget *item, gpointer data)
834{
835 GtkWidget *from = (GtkWidget *) data;
836 GtkWidget *to = (GtkWidget *) g_object_get_data(G_OBJECT(from)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
from)), (((GType) ((20) << (2))))))))
, "to");
837 g_object_ref(G_OBJECT(item)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
item)), (((GType) ((20) << (2))))))))
);
838 gtk_container_remove(GTK_CONTAINER(from)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((from)), ((gtk_container_get_type ()))))))
, item);
839 if (GTK_IS_LABEL(item)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(item)); GType __t = ((gtk_label_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; }))))
) {
840 switch(packdirection) {
841 case GTK_PACK_DIRECTION_LTR:
842 gtk_label_set_angle(GTK_LABEL(item)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(item)), ((gtk_label_get_type ()))))))
, 0.0);
843 break;
844 case GTK_PACK_DIRECTION_TTB:
845 gtk_label_set_angle(GTK_LABEL(item)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(item)), ((gtk_label_get_type ()))))))
,
846 (orient == MATE_PANEL_APPLET_ORIENT_LEFT) ?
847 270.0 : 90.0);
848 break;
849 default:
850 break;
851 }
852 }
853 gtk_box_pack_start(GTK_BOX(to)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((to
)), ((gtk_box_get_type ()))))))
, item, FALSE(0), FALSE(0), 0);
854 return TRUE(!(0));
855}
856
857static gboolean
858reorient_box_cb (GtkWidget *menuitem, gpointer data)
859{
860 GtkWidget *from = g_object_get_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "box");
861 GtkWidget *to = (packdirection == GTK_PACK_DIRECTION_LTR) ?
862 gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0) : gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
863 g_object_set_data(G_OBJECT(from)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
from)), (((GType) ((20) << (2))))))))
, "to", to);
864 gtk_container_foreach(GTK_CONTAINER(from)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((from)), ((gtk_container_get_type ()))))))
, (GtkCallback)swap_orient_cb,
865 from);
866 gtk_container_remove(GTK_CONTAINER(menuitem)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menuitem)), ((gtk_container_get_type ()))))))
, from);
867 gtk_container_add(GTK_CONTAINER(menuitem)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menuitem)), ((gtk_container_get_type ()))))))
, to);
868 g_object_set_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "box", to);
869 gtk_widget_show_all(menuitem);
870 return TRUE(!(0));
871}
872
873static gboolean
874matepanelapplet_reorient_cb (GtkWidget *applet, MatePanelAppletOrient neworient,
875 gpointer data)
876{
877 GtkWidget *menubar = (GtkWidget *)data;
878 if ((((neworient == MATE_PANEL_APPLET_ORIENT_UP) ||
879 (neworient == MATE_PANEL_APPLET_ORIENT_DOWN)) &&
880 ((orient == MATE_PANEL_APPLET_ORIENT_LEFT) ||
881 (orient == MATE_PANEL_APPLET_ORIENT_RIGHT))) ||
882 (((neworient == MATE_PANEL_APPLET_ORIENT_LEFT) ||
883 (neworient == MATE_PANEL_APPLET_ORIENT_RIGHT)) &&
884 ((orient == MATE_PANEL_APPLET_ORIENT_UP) ||
885 (orient == MATE_PANEL_APPLET_ORIENT_DOWN)))) {
886 packdirection = (packdirection == GTK_PACK_DIRECTION_LTR) ?
887 GTK_PACK_DIRECTION_TTB : GTK_PACK_DIRECTION_LTR;
888 gtk_menu_bar_set_pack_direction(GTK_MENU_BAR(menubar)((((GtkMenuBar*) g_type_check_instance_cast ((GTypeInstance*)
((menubar)), ((gtk_menu_bar_get_type ()))))))
,
889 packdirection);
890 orient = neworient;
891 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
,
892 (GtkCallback)reorient_box_cb, NULL((void*)0));
893 }
894 orient = neworient;
895 return FALSE(0);
896}
897
898#ifdef N_
899#undef N_
900#endif
901#define N_(x)x x
902
903static void
904log_to_file_cb (GObject * source_obj G_GNUC_UNUSED__attribute__((__unused__)),
905 GAsyncResult * result G_GNUC_UNUSED__attribute__((__unused__)), gpointer user_data)
906{
907 g_free(user_data);
908 return;
909}
910
911static void
912log_to_file (const gchar * domain G_GNUC_UNUSED__attribute__((__unused__)),
913 GLogLevelFlags level G_GNUC_UNUSED__attribute__((__unused__)),
914 const gchar * message,
915 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
916{
917 if (log_file == NULL((void*)0)) {
918 GError * error = NULL((void*)0);
919 gchar * filename = g_build_filename(g_get_user_cache_dir(), LOG_FILE_NAME"indicator-applet-complete.log", NULL((void*)0));
920 GFile * file = g_file_new_for_path(filename);
921 g_free(filename);
922
923 if (!g_file_test(g_get_user_cache_dir(), G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) {
924 GFile * cachedir = g_file_new_for_path(g_get_user_cache_dir());
925 g_file_make_directory_with_parents(cachedir, NULL((void*)0), &error);
926
927 if (error != NULL((void*)0)) {
928 g_error("Unable to make directory '%s' for log file: %s", g_get_user_cache_dir(), error->message);
929 return;
930 }
931 }
932
933 g_file_delete(file, NULL((void*)0), NULL((void*)0));
934
935 GFileIOStream * io = g_file_create_readwrite(file,
936 G_FILE_CREATE_REPLACE_DESTINATION, /* flags */
937 NULL((void*)0), /* cancelable */
938 &error); /* error */
939 if (error != NULL((void*)0)) {
940 g_error("Unable to replace file: %s", error->message);
941 return;
This statement is never executed
942 }
943
944 log_file = g_io_stream_get_output_stream(G_IO_STREAM(io)((((GIOStream*) g_type_check_instance_cast ((GTypeInstance*) (
(io)), ((g_io_stream_get_type ()))))))
);
945 }
946
947 gchar * outputstring = g_strdup_printf("%s\n", message);
948 g_output_stream_write_async(log_file,
949 outputstring, /* data */
950 strlen(outputstring), /* length */
951 G_PRIORITY_LOW300, /* priority */
952 NULL((void*)0), /* cancelable */
953 log_to_file_cb, /* callback */
954 outputstring); /* data */
955
956 return;
957}
958
959static gboolean
960applet_fill_cb (MatePanelApplet * applet, const gchar * iid G_GNUC_UNUSED__attribute__((__unused__)),
961 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
962{
963#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
964 ido_init();
965#endif
966
967 static const GtkActionEntry menu_actions[] = {
968 {"About", GTK_STOCK_ABOUT((GtkStock)"gtk-about"), N_("_About")"_About", NULL((void*)0), NULL((void*)0), G_CALLBACK(about_cb)((GCallback) (about_cb))}
969 };
970 static const gchar *menu_xml = "<menuitem name=\"About\" action=\"About\"/>";
971
972 static gboolean first_time = FALSE(0);
973 GtkWidget *menubar;
974 gint indicators_loaded = 0;
975 GtkActionGroup *action_group;
976
977 if (!first_time)
978 {
979 first_time = TRUE(!(0));
980#ifdef INDICATOR_APPLET
981 g_set_application_name(_("Indicator Applet")gettext ("Indicator Applet"));
982#endif
983#ifdef INDICATOR_APPLET_COMPLETE1
984 g_set_application_name(_("Indicator Applet Complete")gettext ("Indicator Applet Complete"));
985#endif
986#ifdef INDICATOR_APPLET_APPMENU
987 g_set_application_name(_("Indicator Applet Application Menu")gettext ("Indicator Applet Application Menu"));
988#endif
989
990 g_log_set_default_handler(log_to_file, NULL((void*)0));
991
992 tomboy_keybinder_init();
993 }
994
995 /* Set panel options */
996 gtk_container_set_border_width(GTK_CONTAINER (applet)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_container_get_type ()))))))
, 0);
997 mate_panel_applet_set_flags(applet, MATE_PANEL_APPLET_EXPAND_MINOR);
998 menubar = gtk_menu_bar_new();
999 action_group = gtk_action_group_new ("Indicator Applet Actions");
1000 gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE"mate-indicator-applet");
1001 gtk_action_group_add_actions (action_group, menu_actions,
1002 G_N_ELEMENTS (menu_actions)(sizeof (menu_actions) / sizeof ((menu_actions)[0])),
1003 menubar);
1004 mate_panel_applet_setup_menu(applet, menu_xml, action_group);
1005 g_object_unref(action_group);
1006#ifdef INDICATOR_APPLET
1007 atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
),
1008 "indicator-applet");
1009#endif
1010#ifdef INDICATOR_APPLET_COMPLETE1
1011 atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
),
1012 "indicator-applet-complete");
1013#endif
1014#ifdef INDICATOR_APPLET_APPMENU
1015 atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
),
1016 "indicator-applet-appmenu");
1017#endif
1018
1019 /* Init some theme/icon stuff */
1020 gtk_icon_theme_append_search_path(gtk_icon_theme_get_default(),
1021 INDICATOR_ICONS_DIR"/usr/share/libindicator/icons/");
1022 /* g_debug("Icons directory: %s", INDICATOR_ICONS_DIR); */
1023 gtk_widget_set_name(GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
, "fast-user-switch-applet");
1024
1025 /* Build menubar */
1026 size = (mate_panel_applet_get_size (applet));
1027 orient = (mate_panel_applet_get_orient(applet));
1028 packdirection = ((orient == MATE_PANEL_APPLET_ORIENT_UP) ||
1029 (orient == MATE_PANEL_APPLET_ORIENT_DOWN)) ?
1030 GTK_PACK_DIRECTION_LTR : GTK_PACK_DIRECTION_TTB;
1031 gtk_menu_bar_set_pack_direction(GTK_MENU_BAR(menubar)((((GtkMenuBar*) g_type_check_instance_cast ((GTypeInstance*)
((menubar)), ((gtk_menu_bar_get_type ()))))))
,
1032 packdirection);
1033 gtk_widget_set_can_focus (menubar, TRUE(!(0)));
1034 gtk_widget_set_name(GTK_WIDGET (menubar)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(menubar)), ((gtk_widget_get_type ()))))))
, "fast-user-switch-menubar");
1035 g_signal_connect(menubar, "button-press-event", G_CALLBACK(menubar_press), NULL)g_signal_connect_data ((menubar), ("button-press-event"), (((
GCallback) (menubar_press))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
;
1036 g_signal_connect_after(menubar, "draw", G_CALLBACK(menubar_on_draw), menubar)g_signal_connect_data ((menubar), ("draw"), (((GCallback) (menubar_on_draw
))), (menubar), ((void*)0), G_CONNECT_AFTER)
;
1037 g_signal_connect(applet, "change-orient",g_signal_connect_data ((applet), ("change-orient"), (((GCallback
) (matepanelapplet_reorient_cb))), (menubar), ((void*)0), (GConnectFlags
) 0)
1038 G_CALLBACK(matepanelapplet_reorient_cb), menubar)g_signal_connect_data ((applet), ("change-orient"), (((GCallback
) (matepanelapplet_reorient_cb))), (menubar), ((void*)0), (GConnectFlags
) 0)
;
1039 gtk_container_set_border_width(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, 0);
1040
1041 /* Add in filter func */
1042 tomboy_keybinder_bind(hotkey_keycode, hotkey_filter, menubar);
1043
1044 load_modules(applet, menubar, &indicators_loaded);
1045#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
1046 load_indicators_from_indicator_files(applet, menubar, &indicators_loaded);
1047#endif
1048
1049 if (indicators_loaded == 0) {
1050 /* A label to allow for click through */
1051 GtkWidget * item = gtk_label_new(_("No Indicators")gettext ("No Indicators"));
1052 mate_panel_applet_set_background_widget(applet, item);
1053 gtk_container_add(GTK_CONTAINER(applet)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_container_get_type ()))))))
, item);
1054 gtk_widget_show(item);
1055 } else {
1056 gtk_container_add(GTK_CONTAINER(applet)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_container_get_type ()))))))
, menubar);
1057 mate_panel_applet_set_background_widget(applet, menubar);
1058 gtk_widget_show(menubar);
1059 }
1060
1061 gtk_widget_show(GTK_WIDGET(applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
);
1062
1063 return TRUE(!(0));
1064
1065}
diff --git a/2020-04-09-113756-6097-1@37cc19e547b1_shadow/report-53540c.html b/2020-04-09-113756-6097-1@37cc19e547b1_shadow/report-53540c.html new file mode 100644 index 0000000..6ea54ef --- /dev/null +++ b/2020-04-09-113756-6097-1@37cc19e547b1_shadow/report-53540c.html @@ -0,0 +1,1412 @@ + + + +applet-main.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:applet-main.c
Warning:line 929, column 5
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name applet-main.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -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 -mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -resource-dir /usr/lib64/clang/9.0.1 -D HAVE_CONFIG_H -I . -I .. -D G_LOG_DOMAIN="Indicator-Applet-Complete" -D DATADIR="/usr/local/share" -D INDICATOR_DIR="/usr/lib64/indicators3/7/" -D INDICATOR_ICONS_DIR="/usr/share/libindicator/icons/" -D INDICATOR_APPLET_COMPLETE -I ./.. -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/fribidi -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gio-unix-2.0 -I /usr/include/libdrm -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-panel-4.0/libmate-panel-applet -I /usr/include/libindicator3-0.4 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/fribidi -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gio-unix-2.0 -I /usr/include/libdrm -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/9.0.1/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdebug-compilation-dir /rootdir/src -ferror-limit 19 -fmessage-length 0 -fobjc-runtime=gcc -fdiagnostics-show-option -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 -o /rootdir/html-report/2020-04-09-113756-6097-1 -x c applet-main.c +
+ + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2A small wrapper utility to load indicators and put them as menu items
3into the mate-panel using it's applet interface.
4
5Copyright 2009-2010 Canonical Ltd.
6
7Authors:
8 Ted Gould <ted@canonical.com>
9
10This program is free software: you can redistribute it and/or modify it
11under the terms of the GNU General Public License version 3, as published
12by the Free Software Foundation.
13
14This program is distributed in the hope that it will be useful, but
15WITHOUT ANY WARRANTY; without even the implied warranties of
16MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
17PURPOSE. See the GNU General Public License for more details.
18
19You should have received a copy of the GNU General Public License along
20with this program. If not, see <http://www.gnu.org/licenses/>.
21*/
22
23#include <stdlib.h>
24#include <string.h>
25#include <config.h>
26#include <glib/gi18n.h>
27#include <mate-panel-applet.h>
28#include <gdk/gdkkeysyms.h>
29#include <gtk/gtk.h>
30
31#if HAVE_UBUNTU_INDICATOR1
32
33#define INDICATOR_SERVICE_APPMENU"libappmenu.so" "libappmenu.so"
34#define INDICATOR_SERVICE_ME"libme.so" "libme.so"
35#define INDICATOR_SERVICE_DATETIME"libdatetime.so" "libdatetime.so"
36
37#define INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu" "com.canonical.indicator.appmenu"
38#define INDICATOR_SERVICE_ME_NG"com.canonical.indicator.me" "com.canonical.indicator.me"
39#define INDICATOR_SERVICE_DATETIME_NG"com.canonical.indicator.datetime" "com.canonical.indicator.datetime"
40
41#include <libindicator/indicator-object.h>
42#endif
43
44#if HAVE_AYATANA_INDICATOR
45
46#define INDICATOR_SERVICE_APPMENU"libappmenu.so" "libayatana-appmenu.so"
47#define INDICATOR_SERVICE_ME"libme.so" "libayatana-me.so"
48#define INDICATOR_SERVICE_DATETIME"libdatetime.so" "libayatana-datetime.so"
49
50#define INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu" "org.ayatana.indicator.appmenu"
51#define INDICATOR_SERVICE_ME_NG"com.canonical.indicator.me" "org.ayatana.indicator.me"
52#define INDICATOR_SERVICE_DATETIME_NG"com.canonical.indicator.datetime" "org.ayatana.indicator.datetime"
53
54#include <libayatana-indicator/indicator-object.h>
55#endif
56
57/* For new style indicators */
58
59#if HAVE_UBUNTU_INDICATOR1 && HAVE_UBUNTU_INDICATOR_NG
60
61#include <libido/libido.h>
62#include <libindicator/indicator-ng.h>
63
64#define INDICATOR_SERVICE_DIR "/usr/share/unity/indicators"
65
66#endif
67
68#if HAVE_AYATANA_INDICATOR && HAVE_AYATANA_INDICATOR_NG
69
70#include <libayatana-ido/libayatana-ido.h>
71#include <libayatana-indicator/indicator-ng.h>
72
73#define INDICATOR_SERVICE_DIR "/usr/share/ayatana/indicators"
74
75#endif
76
77#include "tomboykeybinder.h"
78
79static gchar * indicator_order[] = {
80#if HAVE_UBUNTU_INDICATOR1
81 "libapplication.so",
82 "libmessaging.so",
83 "libsoundmenu.so",
84 "libdatetime.so",
85 "libsession.so",
86#endif
87#if HAVE_AYATANA_INDICATOR
88 "libayatana-application.so",
89 "libayatana-messaging.so",
90 "libayatana-soundmenu.so",
91 "libayatana-datetime.so",
92 "libayatana-session.so",
93#endif
94 NULL((void*)0)
95};
96
97static GtkPackDirection packdirection;
98static MatePanelAppletOrient orient;
99static guint size;
100
101#define MENU_DATA_INDICATOR_OBJECT"indicator-object" "indicator-object"
102#define MENU_DATA_INDICATOR_ENTRY"indicator-entry" "indicator-entry"
103
104#define IO_DATA_ORDER_NUMBER"indicator-order-number" "indicator-order-number"
105
106static gboolean applet_fill_cb (MatePanelApplet * applet, const gchar * iid, gpointer data);
107
108static void update_accessible_desc (IndicatorObjectEntry * entry, GtkWidget * menuitem);
109
110/*************
111 * main
112 * ***********/
113
114#ifdef INDICATOR_APPLET
115MATE_PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletFactory",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
116 PANEL_TYPE_APPLET,int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
117 "indicator-applet",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
118 applet_fill_cb, NULL)int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
;
119#endif
120#ifdef INDICATOR_APPLET_COMPLETE1
121MATE_PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletCompleteFactory",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
122 PANEL_TYPE_APPLET,int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
123 "indicator-applet-complete",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
124 applet_fill_cb, NULL)int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
;
125#endif
126#ifdef INDICATOR_APPLET_APPMENU
127MATE_PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletAppmenuFactory",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
128 PANEL_TYPE_APPLET,int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
129 "indicator-applet-appmenu",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
130 applet_fill_cb, NULL)int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
;
131#endif
132
133/*************
134 * log files
135 * ***********/
136#ifdef INDICATOR_APPLET
137#define LOG_FILE_NAME"indicator-applet-complete.log" "indicator-applet.log"
138#endif
139#ifdef INDICATOR_APPLET_COMPLETE1
140#define LOG_FILE_NAME"indicator-applet-complete.log" "indicator-applet-complete.log"
141#endif
142#ifdef INDICATOR_APPLET_APPMENU
143#define LOG_FILE_NAME"indicator-applet-complete.log" "indicator-applet-appmenu.log"
144#endif
145GOutputStream * log_file = NULL((void*)0);
146
147/*****************
148 * Hotkey support
149 * **************/
150#ifdef INDICATOR_APPLET
151gchar * hotkey_keycode = "<Super>M";
152#endif
153#ifdef INDICATOR_APPLET_SESSION
154gchar * hotkey_keycode = "<Super>S";
155#endif
156#ifdef INDICATOR_APPLET_COMPLETE1
157gchar * hotkey_keycode = "<Super>S";
158#endif
159#ifdef INDICATOR_APPLET_APPMENU
160gchar * hotkey_keycode = "<Super>F1";
161#endif
162
163/********************
164 * Environment Names
165 * *******************/
166#ifdef INDICATOR_APPLET
167#define INDICATOR_SPECIFIC_ENV"indicator-applet-complete" "indicator-applet-original"
168#endif
169#ifdef INDICATOR_APPLET_COMPLETE1
170#define INDICATOR_SPECIFIC_ENV"indicator-applet-complete" "indicator-applet-complete"
171#endif
172#ifdef INDICATOR_APPLET_APPMENU
173#define INDICATOR_SPECIFIC_ENV"indicator-applet-complete" "indicator-applet-appmenu"
174#endif
175
176static const gchar * indicator_env[] = {
177 "indicator-applet",
178 INDICATOR_SPECIFIC_ENV"indicator-applet-complete",
179 NULL((void*)0)
180};
181
182/*************
183 * init function
184 * ***********/
185
186static gint
187name2order (const gchar * name) {
188 int i;
189
190 for (i = 0; indicator_order[i] != NULL((void*)0); i++) {
191 if (g_strcmp0(name, indicator_order[i]) == 0) {
192 return i;
193 }
194 }
195
196 return -1;
197}
198
199typedef struct _incoming_position_t incoming_position_t;
200struct _incoming_position_t {
201 gint objposition;
202 gint entryposition;
203 gint menupos;
204 gboolean found;
205};
206
207/* This function helps by determining where in the menu list
208 this new entry should be placed. It compares the objects
209 that they're on, and then the individual entries. Each
210 is progressively more expensive. */
211static void
212place_in_menu (GtkWidget * widget, gpointer user_data)
213{
214 incoming_position_t * position = (incoming_position_t *)user_data;
215 if (position->found) {
216 /* We've already been placed, just finish the foreach */
217 return;
218 }
219
220 IndicatorObject * io = INDICATOR_OBJECT(g_object_get_data(G_OBJECT(widget), MENU_DATA_INDICATOR_OBJECT))((((IndicatorObject*) g_type_check_instance_cast ((GTypeInstance
*) ((g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((widget)), (((GType) ((20) << (2)))
))))), "indicator-object"))), ((indicator_object_get_type ())
)))))
;
221 g_assert(io != NULL)do { if (io != ((void*)0)) ; else g_assertion_message_expr ("Indicator-Applet-Complete"
, "applet-main.c", 221, ((const char*) (__func__)), "io != NULL"
); } while (0)
;
222
223 gint objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER))((gint) (glong) (g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
), "indicator-order-number")))
;
224 /* We've already passed it, well, then this is where
225 we should be be. Stop! */
226 if (objposition > position->objposition) {
227 position->found = TRUE(!(0));
228 return;
229 }
230
231 /* The objects don't match yet, keep looking */
232 if (objposition < position->objposition) {
233 position->menupos++;
234 return;
235 }
236
237 /* The objects are the same, let's start looking at entries. */
238 IndicatorObjectEntry * entry = (IndicatorObjectEntry *)g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
239 gint entryposition = indicator_object_get_location(io, entry);
240
241 if (entryposition > position->entryposition) {
242 position->found = TRUE(!(0));
243 return;
244 }
245
246 if (entryposition < position->entryposition) {
247 position->menupos++;
248 return;
249 }
250
251 /* We've got the same object and the same entry. Well,
252 let's just put it right here then. */
253 position->found = TRUE(!(0));
254 return;
255}
256
257static void
258something_shown (GtkWidget * widget, gpointer user_data)
259{
260 GtkWidget * menuitem = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
261 gtk_widget_show(menuitem);
262}
263
264static void
265something_hidden (GtkWidget * widget, gpointer user_data)
266{
267 GtkWidget * menuitem = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
268 gtk_widget_hide(menuitem);
269}
270
271static void
272sensitive_cb (GObject * obj, GParamSpec * pspec, gpointer user_data)
273{
274 g_return_if_fail(GTK_IS_WIDGET(obj))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((obj)); GType __t = ((gtk_widget_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 ("Indicator-Applet-Complete"
, ((const char*) (__func__)), "GTK_IS_WIDGET(obj)"); return; }
} while (0)
;
275 g_return_if_fail(GTK_IS_WIDGET(user_data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((gtk_widget_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 ("Indicator-Applet-Complete"
, ((const char*) (__func__)), "GTK_IS_WIDGET(user_data)"); return
; } } while (0)
;
276
277 gtk_widget_set_sensitive(GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
, gtk_widget_get_sensitive(GTK_WIDGET(obj)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(obj)), ((gtk_widget_get_type ()))))))
));
278 return;
279}
280
281static void
282entry_activated (GtkWidget * widget, gpointer user_data)
283{
284 g_return_if_fail(GTK_IS_WIDGET(widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((gtk_widget_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 ("Indicator-Applet-Complete"
, ((const char*) (__func__)), "GTK_IS_WIDGET(widget)"); return
; } } while (0)
;
285 gpointer pio = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, "indicator");
286 g_return_if_fail(INDICATOR_IS_OBJECT(pio))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((pio)); GType __t = ((indicator_object_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 ("Indicator-Applet-Complete"
, ((const char*) (__func__)), "INDICATOR_IS_OBJECT(pio)"); return
; } } while (0)
;
287 IndicatorObject * io = INDICATOR_OBJECT(pio)((((IndicatorObject*) g_type_check_instance_cast ((GTypeInstance
*) ((pio)), ((indicator_object_get_type ()))))))
;
288
289 return indicator_object_entry_activate(io, (IndicatorObjectEntry *)user_data, gtk_get_current_event_time());
290}
291
292static gboolean
293entry_scrolled (GtkWidget *menuitem, GdkEventScroll *event, gpointer data)
294{
295 IndicatorObject *io = g_object_get_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_OBJECT"indicator-object");
296 IndicatorObjectEntry *entry = g_object_get_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
297
298 g_return_val_if_fail(INDICATOR_IS_OBJECT(io), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((io)); GType __t = ((indicator_object_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 ("Indicator-Applet-Complete"
, ((const char*) (__func__)), "INDICATOR_IS_OBJECT(io)"); return
((0)); } } while (0)
;
299
300 g_signal_emit_by_name (io, "scroll", 1, event->direction);
301 g_signal_emit_by_name (io, "scroll-entry", entry, 1, event->direction);
302 g_signal_emit_by_name (io, INDICATOR_OBJECT_SIGNAL_ENTRY_SCROLLED"entry-scrolled", entry, 1, event->direction);
303
304 return FALSE(0);
305}
306
307static void
308accessible_desc_update_cb (GtkWidget * widget, gpointer userdata)
309{
310 gpointer data = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
311
312 if (data != userdata) {
313 return;
314 }
315
316 IndicatorObjectEntry * entry = (IndicatorObjectEntry *)data;
317 update_accessible_desc(entry, widget);
318}
319
320static void
321accessible_desc_update (IndicatorObject * io, IndicatorObjectEntry * entry, GtkWidget * menubar)
322{
323 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, accessible_desc_update_cb, entry);
324 return;
325}
326
327#define PANEL_PADDING8 8
328static gboolean
329entry_resized (GtkWidget *applet, guint newsize, gpointer data)
330{
331 IndicatorObject *io = (IndicatorObject *)data;
332
333 size = newsize;
334
335 /* Work on the entries */
336 GList * entries = indicator_object_get_entries(io);
337 GList * entry = NULL((void*)0);
338
339 for (entry = entries; entry != NULL((void*)0); entry = g_list_next(entry)((entry) ? (((GList *)(entry))->next) : ((void*)0))) {
340 IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)entry->data;
341 if (entrydata->image != NULL((void*)0)) {
342 /* Resize to fit panel */
343 gtk_image_set_pixel_size (entrydata->image, size - PANEL_PADDING8);
344 }
345 }
346
347 return FALSE(0);
348}
349
350static void
351entry_added (IndicatorObject * io, IndicatorObjectEntry * entry, GtkWidget * menubar)
352{
353 g_debug("Signal: Entry Added");
354 gboolean something_visible = FALSE(0);
355 gboolean something_sensitive = FALSE(0);
356
357 GtkWidget * menuitem = gtk_menu_item_new();
358 GtkWidget * box = (packdirection == GTK_PACK_DIRECTION_LTR) ?
359 gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3) : gtk_box_new(GTK_ORIENTATION_VERTICAL, 3);
360
361 /* Allows indicators to receive mouse scroll event */
362 gtk_widget_add_events(GTK_WIDGET(menuitem)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(menuitem)), ((gtk_widget_get_type ()))))))
, GDK_SCROLL_MASK);
363
364 g_object_set_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "indicator", io);
365 g_object_set_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "box", box);
366
367 g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(entry_activated), entry)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((menuitem)), (((GType) ((20) << (2)
)))))))), ("activate"), (((GCallback) (entry_activated))), (entry
), ((void*)0), (GConnectFlags) 0)
;
368 g_signal_connect(G_OBJECT(menuitem), "scroll-event", G_CALLBACK(entry_scrolled), entry)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((menuitem)), (((GType) ((20) << (2)
)))))))), ("scroll-event"), (((GCallback) (entry_scrolled))),
(entry), ((void*)0), (GConnectFlags) 0)
;
369
370 if (entry->image != NULL((void*)0)) {
371 /* Resize to fit panel */
372 gtk_image_set_pixel_size (entry->image, size - PANEL_PADDING8);
373 gtk_box_pack_start(GTK_BOX(box)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((box
)), ((gtk_box_get_type ()))))))
, GTK_WIDGET(entry->image)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->image)), ((gtk_widget_get_type ()))))))
, FALSE(0), FALSE(0), 1);
374 if (gtk_widget_get_visible(GTK_WIDGET(entry->image)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->image)), ((gtk_widget_get_type ()))))))
)) {
375 something_visible = TRUE(!(0));
376 }
377
378 if (gtk_widget_get_sensitive(GTK_WIDGET(entry->image)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->image)), ((gtk_widget_get_type ()))))))
)) {
379 something_sensitive = TRUE(!(0));
380 }
381
382 g_signal_connect(G_OBJECT(entry->image), "show", G_CALLBACK(something_shown), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), ("show"), (((GCallback) (something_shown))), (menuitem
), ((void*)0), (GConnectFlags) 0)
;
383 g_signal_connect(G_OBJECT(entry->image), "hide", G_CALLBACK(something_hidden), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), ("hide"), (((GCallback) (something_hidden))), (
menuitem), ((void*)0), (GConnectFlags) 0)
;
384
385 g_signal_connect(G_OBJECT(entry->image), "notify::sensitive", G_CALLBACK(sensitive_cb), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), ("notify::sensitive"), (((GCallback) (sensitive_cb
))), (menuitem), ((void*)0), (GConnectFlags) 0)
;
386 }
387 if (entry->label != NULL((void*)0)) {
388 switch(packdirection) {
389 case GTK_PACK_DIRECTION_LTR:
390 gtk_label_set_angle(GTK_LABEL(entry->label)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_label_get_type ()))))))
, 0.0);
391 break;
392 case GTK_PACK_DIRECTION_TTB:
393 gtk_label_set_angle(GTK_LABEL(entry->label)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_label_get_type ()))))))
,
394 (orient == MATE_PANEL_APPLET_ORIENT_LEFT) ?
395 270.0 : 90.0);
396 break;
397 default:
398 break;
399 }
400 gtk_box_pack_start(GTK_BOX(box)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((box
)), ((gtk_box_get_type ()))))))
, GTK_WIDGET(entry->label)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_widget_get_type ()))))))
, FALSE(0), FALSE(0), 1);
401
402 if (gtk_widget_get_visible(GTK_WIDGET(entry->label)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_widget_get_type ()))))))
)) {
403 something_visible = TRUE(!(0));
404 }
405
406 if (gtk_widget_get_sensitive(GTK_WIDGET(entry->label)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_widget_get_type ()))))))
)) {
407 something_sensitive = TRUE(!(0));
408 }
409
410 g_signal_connect(G_OBJECT(entry->label), "show", G_CALLBACK(something_shown), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), ("show"), (((GCallback) (something_shown))), (menuitem
), ((void*)0), (GConnectFlags) 0)
;
411 g_signal_connect(G_OBJECT(entry->label), "hide", G_CALLBACK(something_hidden), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), ("hide"), (((GCallback) (something_hidden))), (
menuitem), ((void*)0), (GConnectFlags) 0)
;
412
413 g_signal_connect(G_OBJECT(entry->label), "notify::sensitive", G_CALLBACK(sensitive_cb), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), ("notify::sensitive"), (((GCallback) (sensitive_cb
))), (menuitem), ((void*)0), (GConnectFlags) 0)
;
414 }
415 gtk_container_add(GTK_CONTAINER(menuitem)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menuitem)), ((gtk_container_get_type ()))))))
, box);
416 gtk_widget_show(box);
417
418 if (entry->menu != NULL((void*)0)) {
419 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem)((((GtkMenuItem*) g_type_check_instance_cast ((GTypeInstance*
) ((menuitem)), ((gtk_menu_item_get_type ()))))))
, GTK_WIDGET(entry->menu)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->menu)), ((gtk_widget_get_type ()))))))
);
420 }
421
422 incoming_position_t position;
423 position.objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER))((gint) (glong) (g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
), "indicator-order-number")))
;
424 position.entryposition = indicator_object_get_location(io, entry);
425 position.menupos = 0;
426 position.found = FALSE(0);
427
428 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, place_in_menu, &position);
429
430 gtk_menu_shell_insert(GTK_MENU_SHELL(menubar)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_menu_shell_get_type ()))))))
, menuitem, position.menupos);
431
432 if (something_visible) {
433 if (entry->accessible_desc != NULL((void*)0)) {
434 update_accessible_desc(entry, menuitem);
435 }
436 gtk_widget_show(menuitem);
437 }
438 gtk_widget_set_sensitive(menuitem, something_sensitive);
439
440 g_object_set_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry", entry);
441 g_object_set_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_OBJECT"indicator-object", io);
442
443 return;
444}
445
446static void
447entry_removed_cb (GtkWidget * widget, gpointer userdata)
448{
449 gpointer data = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
450
451 if (data != userdata) {
452 return;
453 }
454
455 IndicatorObjectEntry * entry = (IndicatorObjectEntry *)data;
456 if (entry->label != NULL((void*)0)) {
457 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(something_shown), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_shown))), (widget
))
;
458 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(something_hidden), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_hidden))), (widget
))
;
459 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(sensitive_cb), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (sensitive_cb))), (widget)
)
;
460 }
461 if (entry->image != NULL((void*)0)) {
462 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(something_shown), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_shown))), (widget
))
;
463 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(something_hidden), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_hidden))), (widget
))
;
464 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(sensitive_cb), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (sensitive_cb))), (widget)
)
;
465 }
466
467 gtk_widget_destroy(widget);
468 return;
469}
470
471static void
472entry_removed (IndicatorObject * io G_GNUC_UNUSED__attribute__((__unused__)), IndicatorObjectEntry * entry,
473 gpointer user_data)
474{
475 g_debug("Signal: Entry Removed");
476
477 gtk_container_foreach(GTK_CONTAINER(user_data)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((gtk_container_get_type ()))))))
, entry_removed_cb, entry);
478
479 return;
480}
481
482static void
483entry_moved_find_cb (GtkWidget * widget, gpointer userdata)
484{
485 gpointer * array = (gpointer *)userdata;
486 if (array[1] != NULL((void*)0)) {
487 return;
488 }
489
490 gpointer data = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
491
492 if (data != array[0]) {
493 return;
494 }
495
496 array[1] = widget;
497 return;
498}
499
500/* Gets called when an entry for an object was moved. */
501static void
502entry_moved (IndicatorObject * io, IndicatorObjectEntry * entry,
503 gint old G_GNUC_UNUSED__attribute__((__unused__)), gint new G_GNUC_UNUSED__attribute__((__unused__)), gpointer user_data)
504{
505 GtkWidget * menubar = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
506
507 gpointer array[2];
508 array[0] = entry;
509 array[1] = NULL((void*)0);
510
511 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, entry_moved_find_cb, array);
512 if (array[1] == NULL((void*)0)) {
513 g_warning("Moving an entry that isn't in our menus.");
514 return;
515 }
516
517 GtkWidget * mi = GTK_WIDGET(array[1])((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(array[1])), ((gtk_widget_get_type ()))))))
;
518 g_object_ref(G_OBJECT(mi)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
mi)), (((GType) ((20) << (2))))))))
);
519 gtk_container_remove(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, mi);
520
521 incoming_position_t position;
522 position.objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER))((gint) (glong) (g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
), "indicator-order-number")))
;
523 position.entryposition = indicator_object_get_location(io, entry);
524 position.menupos = 0;
525 position.found = FALSE(0);
526
527 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, place_in_menu, &position);
528
529 gtk_menu_shell_insert(GTK_MENU_SHELL(menubar)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_menu_shell_get_type ()))))))
, mi, position.menupos);
530 g_object_unref(G_OBJECT(mi)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
mi)), (((GType) ((20) << (2))))))))
);
531
532 return;
533}
534
535static void
536menu_show (IndicatorObject * io, IndicatorObjectEntry * entry,
537 guint32 timestamp, gpointer user_data)
538{
539 GtkWidget * menubar = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
540
541 if (entry == NULL((void*)0)) {
542 /* Close any open menus instead of opening one */
543 GList * entries = indicator_object_get_entries(io);
544 GList * iterator = NULL((void*)0);
545 for (iterator = entries; iterator != NULL((void*)0); iterator = g_list_next(iterator)((iterator) ? (((GList *)(iterator))->next) : ((void*)0))) {
546 IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)iterator->data;
547 gtk_menu_popdown(entrydata->menu);
548 }
549 g_list_free(entries);
550
551 /* And tell the menubar to exit activation mode too */
552 gtk_menu_shell_cancel(GTK_MENU_SHELL(menubar)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_menu_shell_get_type ()))))))
);
553 return;
554 }
555
556 // TODO: do something sensible here
557}
558
559static void
560update_accessible_desc(IndicatorObjectEntry * entry, GtkWidget * menuitem)
561{
562 /* FIXME: We need to deal with the use case where the contents of the
563 label overrides what is found in the atk object's name, or at least
564 orca speaks the label instead of the atk object name.
565 */
566 AtkObject * menuitem_obj = gtk_widget_get_accessible(menuitem);
567 if (menuitem_obj == NULL((void*)0)) {
568 /* Should there be an error printed here? */
569 return;
570 }
571
572 if (entry->accessible_desc != NULL((void*)0)) {
573 atk_object_set_name(menuitem_obj, entry->accessible_desc);
574 } else {
575 atk_object_set_name(menuitem_obj, "");
576 }
577 return;
578}
579
580static void
581load_indicator (MatePanelApplet *applet, GtkWidget * menubar, IndicatorObject *io, const gchar *name)
582{
583 /* Set the environment it's in */
584 indicator_object_set_environment(io, (const GStrv)indicator_env);
585
586 /* Attach the 'name' to the object */
587#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
588 int pos = 5000 - indicator_object_get_position(io);
589 if (pos > 5000) {
590 pos = name2order(name);
591 }
592#else
593 int pos = name2order(name);
594#endif
595
596 g_object_set_data(G_OBJECT(io)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
io)), (((GType) ((20) << (2))))))))
, IO_DATA_ORDER_NUMBER"indicator-order-number", GINT_TO_POINTER(pos)((gpointer) (glong) (pos)));
597
598 /* Connect to its signals */
599 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED, G_CALLBACK(entry_added), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("entry-added"), (((GCallback) (entry_added))), (menubar)
, ((void*)0), (GConnectFlags) 0)
;
600 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED, G_CALLBACK(entry_removed), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("entry-removed"), (((GCallback) (entry_removed))), (menubar
), ((void*)0), (GConnectFlags) 0)
;
601 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_MOVED, G_CALLBACK(entry_moved), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("entry-moved"), (((GCallback) (entry_moved))), (menubar)
, ((void*)0), (GConnectFlags) 0)
;
602 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_MENU_SHOW, G_CALLBACK(menu_show), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("menu-show"), (((GCallback) (menu_show))), (menubar), ((
void*)0), (GConnectFlags) 0)
;
603 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ACCESSIBLE_DESC_UPDATE, G_CALLBACK(accessible_desc_update), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("accessible-desc-update"), (((GCallback) (accessible_desc_update
))), (menubar), ((void*)0), (GConnectFlags) 0)
;
604
605 /* Track panel resize */
606 g_signal_connect_object(G_OBJECT(applet)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
applet)), (((GType) ((20) << (2))))))))
, "change-size", G_CALLBACK(entry_resized)((GCallback) (entry_resized)), G_OBJECT(io)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
io)), (((GType) ((20) << (2))))))))
, 0);
607
608 /* Work on the entries */
609 GList * entries = indicator_object_get_entries(io);
610 GList * entry = NULL((void*)0);
611
612 for (entry = entries; entry != NULL((void*)0); entry = g_list_next(entry)((entry) ? (((GList *)(entry))->next) : ((void*)0))) {
613 IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)entry->data;
614 entry_added(io, entrydata, menubar);
615 }
616
617 g_list_free(entries);
618}
619
620static gboolean
621load_module (const gchar * name, MatePanelApplet *applet, GtkWidget * menubar)
622{
623 g_debug("Looking at Module: %s", name);
624 g_return_val_if_fail(name != NULL, FALSE)do { if ((name != ((void*)0))) { } else { g_return_if_fail_warning
("Indicator-Applet-Complete", ((const char*) (__func__)), "name != NULL"
); return ((0)); } } while (0)
;
625
626 if (!g_str_has_suffix(name, G_MODULE_SUFFIX"so")) {
627 return FALSE(0);
628 }
629
630 g_debug("Loading Module: %s", name);
631
632 /* Build the object for the module */
633 gchar * fullpath = g_build_filename(INDICATOR_DIR"/usr/lib64/indicators3/7/", name, NULL((void*)0));
634 IndicatorObject * io = indicator_object_new_from_file(fullpath);
635 g_free(fullpath);
636
637 load_indicator(applet, menubar, io, name);
638
639 return TRUE(!(0));
640}
641
642static void
643load_modules (MatePanelApplet *applet, GtkWidget *menubar, gint *indicators_loaded)
644{
645 if (g_file_test(INDICATOR_DIR"/usr/lib64/indicators3/7/", (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))) {
646 GDir * dir = g_dir_open(INDICATOR_DIR"/usr/lib64/indicators3/7/", 0, NULL((void*)0));
647
648 const gchar * name;
649 gint count = 0;
650 while ((name = g_dir_read_name(dir)) != NULL((void*)0)) {
651#ifdef INDICATOR_APPLET_APPMENU
652 if (g_strcmp0(name, INDICATOR_SERVICE_APPMENU"libappmenu.so")) {
653 continue;
654 }
655#else
656 if (!g_strcmp0(name, INDICATOR_SERVICE_APPMENU"libappmenu.so")) {
657 continue;
658 }
659#endif
660#ifdef INDICATOR_APPLET
661 if (!g_strcmp0(name, INDICATOR_SERVICE_ME"libme.so")) {
662 continue;
663 }
664 if (!g_strcmp0(name, INDICATOR_SERVICE_DATETIME"libdatetime.so")) {
665 continue;
666 }
667#endif
668 if (load_module(name, applet, menubar)) {
669 count++;
670 }
671 }
672
673 *indicators_loaded += count;
674
675 g_dir_close (dir);
676 }
677}
678
679#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
680
681static void
682load_indicators_from_indicator_files (MatePanelApplet *applet, GtkWidget *menubar, gint *indicators_loaded)
683{
684 GDir *dir;
685 const gchar *name;
686 GError *error = NULL((void*)0);
687
688 dir = g_dir_open (INDICATOR_SERVICE_DIR, 0, &error);
689
690 if (!dir) {
691 g_warning ("unable to open indicator service file directory: %s", error->message);
692 g_error_free (error);
693
694 return;
695 }
696
697 gint count = 0;
698 while ((name = g_dir_read_name (dir))) {
699 gchar *filename;
700 IndicatorNg *indicator;
701
702 filename = g_build_filename (INDICATOR_SERVICE_DIR, name, NULL((void*)0));
703 indicator = indicator_ng_new_for_profile (filename, "desktop", &error);
704 g_free (filename);
705
706#ifdef INDICATOR_APPLET_APPMENU
707 if (g_strcmp0(name, INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu")) {
708 continue;
709 }
710#else
711 if (!g_strcmp0(name, INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu")) {
712 continue;
713 }
714#endif
715#ifdef INDICATOR_APPLET
716 if (!g_strcmp0(name, INDICATOR_SERVICE_ME_NG"com.canonical.indicator.me")) {
717 continue;
718 }
719 if (!g_strcmp0(name, INDICATOR_SERVICE_DATETIME_NG"com.canonical.indicator.datetime")) {
720 continue;
721 }
722#endif
723
724 if (indicator) {
725 load_indicator(applet, menubar, INDICATOR_OBJECT (indicator)((((IndicatorObject*) g_type_check_instance_cast ((GTypeInstance
*) ((indicator)), ((indicator_object_get_type ()))))))
, name);
726 count++;
727 }else{
728 g_warning ("unable to load '%s': %s", name, error->message);
729 g_clear_error (&error);
730 }
731 }
732
733 *indicators_loaded += count;
734
735 g_dir_close (dir);
736}
737#endif /* HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG */
738
739static void
740hotkey_filter (char * keystring G_GNUC_UNUSED__attribute__((__unused__)), gpointer data)
741{
742 g_return_if_fail(GTK_IS_MENU_SHELL(data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((data)); GType __t = ((gtk_menu_shell_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 ("Indicator-Applet-Complete"
, ((const char*) (__func__)), "GTK_IS_MENU_SHELL(data)"); return
; } } while (0)
;
743
744 /* Oh, wow, it's us! */
745 GList * children = gtk_container_get_children(GTK_CONTAINER(data)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((gtk_container_get_type ()))))))
);
746 if (children == NULL((void*)0)) {
747 g_debug("Menubar has no children");
748 return;
749 }
750
751 gtk_menu_shell_select_item(GTK_MENU_SHELL(data)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((gtk_menu_shell_get_type ()))))))
, GTK_WIDGET(g_list_last(children)->data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(g_list_last(children)->data)), ((gtk_widget_get_type ()))
))))
);
752 g_list_free(children);
753 return;
754}
755
756static gboolean
757menubar_press (GtkWidget * widget,
758 GdkEventButton *event,
759 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
760{
761 if (event->button != 1) {
762 g_signal_stop_emission_by_name(widget, "button-press-event");
763 }
764
765 return FALSE(0);
766}
767
768static gboolean
769menubar_on_draw (GtkWidget * widget,
770 cairo_t * cr,
771 GtkWidget * menubar)
772{
773 /* FIXME: either port to gtk_render_focus or remove this function */
774 if (gtk_widget_has_focus(menubar))
775 gtk_paint_focus(gtk_widget_get_style(widget),
776 cr,
777 gtk_widget_get_state(menubar),
778 widget, "menubar-applet", 0, 0, -1, -1);
779
780 return FALSE(0);
781}
782
783static void
784about_cb (GtkAction *action G_GNUC_UNUSED__attribute__((__unused__)),
785 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
786{
787 static const gchar *authors[] = {
788 "Ted Gould <ted@canonical.com>",
789 NULL((void*)0)
790 };
791
792 static gchar *license[] = {
793 N_("This program is free software: you can redistribute it and/or modify it ""This program is free software: you can redistribute it and/or modify it "
"under the terms of the GNU General Public License version 3, as published "
"by the Free Software Foundation."
794 "under the terms of the GNU General Public License version 3, as published ""This program is free software: you can redistribute it and/or modify it "
"under the terms of the GNU General Public License version 3, as published "
"by the Free Software Foundation."
795 "by the Free Software Foundation.")"This program is free software: you can redistribute it and/or modify it "
"under the terms of the GNU General Public License version 3, as published "
"by the Free Software Foundation."
,
796 N_("This program is distributed in the hope that it will be useful, but ""This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
797 "WITHOUT ANY WARRANTY; without even the implied warranties of ""This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
798 "MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR ""This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
799 "PURPOSE. See the GNU General Public License for more details.")"This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
,
800 N_("You should have received a copy of the GNU General Public License along ""You should have received a copy of the GNU General Public License along "
"with this program. If not, see <http://www.gnu.org/licenses/>."
801 "with this program. If not, see <http://www.gnu.org/licenses/>.")"You should have received a copy of the GNU General Public License along "
"with this program. If not, see <http://www.gnu.org/licenses/>."
,
802 NULL((void*)0)
803 };
804 gchar *license_i18n;
805
806 license_i18n = g_strconcat (_(license[0])gettext (license[0]), "\n\n", _(license[1])gettext (license[1]), "\n\n", _(license[2])gettext (license[2]), NULL((void*)0));
807
808 gtk_show_about_dialog(NULL((void*)0),
809 "version", VERSION"1.24.0",
810 "copyright", _("Copyright \xc2\xa9 2009-2010 Canonical, Ltd.\n"gettext ("Copyright \xc2\xa9 2009-2010 Canonical, Ltd.\n" "Copyright \xc2\xa9 2011-2020 MATE developers"
)
811 "Copyright \xc2\xa9 2011-2020 MATE developers")gettext ("Copyright \xc2\xa9 2009-2010 Canonical, Ltd.\n" "Copyright \xc2\xa9 2011-2020 MATE developers"
)
,
812#ifdef INDICATOR_APPLET_APPMENU
813 "comments", _("An applet to hold your application menus.")gettext ("An applet to hold your application menus."),
814#endif
815 "comments", _("An applet to hold all of the system indicators.")gettext ("An applet to hold all of the system indicators."),
816 "authors", authors,
817 "license", license_i18n,
818 "wrap-license", TRUE(!(0)),
819 "translator-credits", _("translator-credits")gettext ("translator-credits"),
820 "logo-icon-name", "mate-indicator-applet",
821 "icon-name", "mate-indicator-applet",
822 "website", "https://mate-desktop.org",
823 "website-label", _("MATE Website")gettext ("MATE Website"),
824 NULL((void*)0)
825 );
826
827 g_free (license_i18n);
828
829 return;
830}
831
832static gboolean
833swap_orient_cb (GtkWidget *item, gpointer data)
834{
835 GtkWidget *from = (GtkWidget *) data;
836 GtkWidget *to = (GtkWidget *) g_object_get_data(G_OBJECT(from)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
from)), (((GType) ((20) << (2))))))))
, "to");
837 g_object_ref(G_OBJECT(item)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
item)), (((GType) ((20) << (2))))))))
);
838 gtk_container_remove(GTK_CONTAINER(from)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((from)), ((gtk_container_get_type ()))))))
, item);
839 if (GTK_IS_LABEL(item)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(item)); GType __t = ((gtk_label_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; }))))
) {
840 switch(packdirection) {
841 case GTK_PACK_DIRECTION_LTR:
842 gtk_label_set_angle(GTK_LABEL(item)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(item)), ((gtk_label_get_type ()))))))
, 0.0);
843 break;
844 case GTK_PACK_DIRECTION_TTB:
845 gtk_label_set_angle(GTK_LABEL(item)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(item)), ((gtk_label_get_type ()))))))
,
846 (orient == MATE_PANEL_APPLET_ORIENT_LEFT) ?
847 270.0 : 90.0);
848 break;
849 default:
850 break;
851 }
852 }
853 gtk_box_pack_start(GTK_BOX(to)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((to
)), ((gtk_box_get_type ()))))))
, item, FALSE(0), FALSE(0), 0);
854 return TRUE(!(0));
855}
856
857static gboolean
858reorient_box_cb (GtkWidget *menuitem, gpointer data)
859{
860 GtkWidget *from = g_object_get_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "box");
861 GtkWidget *to = (packdirection == GTK_PACK_DIRECTION_LTR) ?
862 gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0) : gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
863 g_object_set_data(G_OBJECT(from)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
from)), (((GType) ((20) << (2))))))))
, "to", to);
864 gtk_container_foreach(GTK_CONTAINER(from)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((from)), ((gtk_container_get_type ()))))))
, (GtkCallback)swap_orient_cb,
865 from);
866 gtk_container_remove(GTK_CONTAINER(menuitem)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menuitem)), ((gtk_container_get_type ()))))))
, from);
867 gtk_container_add(GTK_CONTAINER(menuitem)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menuitem)), ((gtk_container_get_type ()))))))
, to);
868 g_object_set_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "box", to);
869 gtk_widget_show_all(menuitem);
870 return TRUE(!(0));
871}
872
873static gboolean
874matepanelapplet_reorient_cb (GtkWidget *applet, MatePanelAppletOrient neworient,
875 gpointer data)
876{
877 GtkWidget *menubar = (GtkWidget *)data;
878 if ((((neworient == MATE_PANEL_APPLET_ORIENT_UP) ||
879 (neworient == MATE_PANEL_APPLET_ORIENT_DOWN)) &&
880 ((orient == MATE_PANEL_APPLET_ORIENT_LEFT) ||
881 (orient == MATE_PANEL_APPLET_ORIENT_RIGHT))) ||
882 (((neworient == MATE_PANEL_APPLET_ORIENT_LEFT) ||
883 (neworient == MATE_PANEL_APPLET_ORIENT_RIGHT)) &&
884 ((orient == MATE_PANEL_APPLET_ORIENT_UP) ||
885 (orient == MATE_PANEL_APPLET_ORIENT_DOWN)))) {
886 packdirection = (packdirection == GTK_PACK_DIRECTION_LTR) ?
887 GTK_PACK_DIRECTION_TTB : GTK_PACK_DIRECTION_LTR;
888 gtk_menu_bar_set_pack_direction(GTK_MENU_BAR(menubar)((((GtkMenuBar*) g_type_check_instance_cast ((GTypeInstance*)
((menubar)), ((gtk_menu_bar_get_type ()))))))
,
889 packdirection);
890 orient = neworient;
891 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
,
892 (GtkCallback)reorient_box_cb, NULL((void*)0));
893 }
894 orient = neworient;
895 return FALSE(0);
896}
897
898#ifdef N_
899#undef N_
900#endif
901#define N_(x)x x
902
903static void
904log_to_file_cb (GObject * source_obj G_GNUC_UNUSED__attribute__((__unused__)),
905 GAsyncResult * result G_GNUC_UNUSED__attribute__((__unused__)), gpointer user_data)
906{
907 g_free(user_data);
908 return;
909}
910
911static void
912log_to_file (const gchar * domain G_GNUC_UNUSED__attribute__((__unused__)),
913 GLogLevelFlags level G_GNUC_UNUSED__attribute__((__unused__)),
914 const gchar * message,
915 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
916{
917 if (log_file == NULL((void*)0)) {
918 GError * error = NULL((void*)0);
919 gchar * filename = g_build_filename(g_get_user_cache_dir(), LOG_FILE_NAME"indicator-applet-complete.log", NULL((void*)0));
920 GFile * file = g_file_new_for_path(filename);
921 g_free(filename);
922
923 if (!g_file_test(g_get_user_cache_dir(), G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) {
924 GFile * cachedir = g_file_new_for_path(g_get_user_cache_dir());
925 g_file_make_directory_with_parents(cachedir, NULL((void*)0), &error);
926
927 if (error != NULL((void*)0)) {
928 g_error("Unable to make directory '%s' for log file: %s", g_get_user_cache_dir(), error->message);
929 return;
This statement is never executed
930 }
931 }
932
933 g_file_delete(file, NULL((void*)0), NULL((void*)0));
934
935 GFileIOStream * io = g_file_create_readwrite(file,
936 G_FILE_CREATE_REPLACE_DESTINATION, /* flags */
937 NULL((void*)0), /* cancelable */
938 &error); /* error */
939 if (error != NULL((void*)0)) {
940 g_error("Unable to replace file: %s", error->message);
941 return;
942 }
943
944 log_file = g_io_stream_get_output_stream(G_IO_STREAM(io)((((GIOStream*) g_type_check_instance_cast ((GTypeInstance*) (
(io)), ((g_io_stream_get_type ()))))))
);
945 }
946
947 gchar * outputstring = g_strdup_printf("%s\n", message);
948 g_output_stream_write_async(log_file,
949 outputstring, /* data */
950 strlen(outputstring), /* length */
951 G_PRIORITY_LOW300, /* priority */
952 NULL((void*)0), /* cancelable */
953 log_to_file_cb, /* callback */
954 outputstring); /* data */
955
956 return;
957}
958
959static gboolean
960applet_fill_cb (MatePanelApplet * applet, const gchar * iid G_GNUC_UNUSED__attribute__((__unused__)),
961 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
962{
963#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
964 ido_init();
965#endif
966
967 static const GtkActionEntry menu_actions[] = {
968 {"About", GTK_STOCK_ABOUT((GtkStock)"gtk-about"), N_("_About")"_About", NULL((void*)0), NULL((void*)0), G_CALLBACK(about_cb)((GCallback) (about_cb))}
969 };
970 static const gchar *menu_xml = "<menuitem name=\"About\" action=\"About\"/>";
971
972 static gboolean first_time = FALSE(0);
973 GtkWidget *menubar;
974 gint indicators_loaded = 0;
975 GtkActionGroup *action_group;
976
977 if (!first_time)
978 {
979 first_time = TRUE(!(0));
980#ifdef INDICATOR_APPLET
981 g_set_application_name(_("Indicator Applet")gettext ("Indicator Applet"));
982#endif
983#ifdef INDICATOR_APPLET_COMPLETE1
984 g_set_application_name(_("Indicator Applet Complete")gettext ("Indicator Applet Complete"));
985#endif
986#ifdef INDICATOR_APPLET_APPMENU
987 g_set_application_name(_("Indicator Applet Application Menu")gettext ("Indicator Applet Application Menu"));
988#endif
989
990 g_log_set_default_handler(log_to_file, NULL((void*)0));
991
992 tomboy_keybinder_init();
993 }
994
995 /* Set panel options */
996 gtk_container_set_border_width(GTK_CONTAINER (applet)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_container_get_type ()))))))
, 0);
997 mate_panel_applet_set_flags(applet, MATE_PANEL_APPLET_EXPAND_MINOR);
998 menubar = gtk_menu_bar_new();
999 action_group = gtk_action_group_new ("Indicator Applet Actions");
1000 gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE"mate-indicator-applet");
1001 gtk_action_group_add_actions (action_group, menu_actions,
1002 G_N_ELEMENTS (menu_actions)(sizeof (menu_actions) / sizeof ((menu_actions)[0])),
1003 menubar);
1004 mate_panel_applet_setup_menu(applet, menu_xml, action_group);
1005 g_object_unref(action_group);
1006#ifdef INDICATOR_APPLET
1007 atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
),
1008 "indicator-applet");
1009#endif
1010#ifdef INDICATOR_APPLET_COMPLETE1
1011 atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
),
1012 "indicator-applet-complete");
1013#endif
1014#ifdef INDICATOR_APPLET_APPMENU
1015 atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
),
1016 "indicator-applet-appmenu");
1017#endif
1018
1019 /* Init some theme/icon stuff */
1020 gtk_icon_theme_append_search_path(gtk_icon_theme_get_default(),
1021 INDICATOR_ICONS_DIR"/usr/share/libindicator/icons/");
1022 /* g_debug("Icons directory: %s", INDICATOR_ICONS_DIR); */
1023 gtk_widget_set_name(GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
, "fast-user-switch-applet");
1024
1025 /* Build menubar */
1026 size = (mate_panel_applet_get_size (applet));
1027 orient = (mate_panel_applet_get_orient(applet));
1028 packdirection = ((orient == MATE_PANEL_APPLET_ORIENT_UP) ||
1029 (orient == MATE_PANEL_APPLET_ORIENT_DOWN)) ?
1030 GTK_PACK_DIRECTION_LTR : GTK_PACK_DIRECTION_TTB;
1031 gtk_menu_bar_set_pack_direction(GTK_MENU_BAR(menubar)((((GtkMenuBar*) g_type_check_instance_cast ((GTypeInstance*)
((menubar)), ((gtk_menu_bar_get_type ()))))))
,
1032 packdirection);
1033 gtk_widget_set_can_focus (menubar, TRUE(!(0)));
1034 gtk_widget_set_name(GTK_WIDGET (menubar)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(menubar)), ((gtk_widget_get_type ()))))))
, "fast-user-switch-menubar");
1035 g_signal_connect(menubar, "button-press-event", G_CALLBACK(menubar_press), NULL)g_signal_connect_data ((menubar), ("button-press-event"), (((
GCallback) (menubar_press))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
;
1036 g_signal_connect_after(menubar, "draw", G_CALLBACK(menubar_on_draw), menubar)g_signal_connect_data ((menubar), ("draw"), (((GCallback) (menubar_on_draw
))), (menubar), ((void*)0), G_CONNECT_AFTER)
;
1037 g_signal_connect(applet, "change-orient",g_signal_connect_data ((applet), ("change-orient"), (((GCallback
) (matepanelapplet_reorient_cb))), (menubar), ((void*)0), (GConnectFlags
) 0)
1038 G_CALLBACK(matepanelapplet_reorient_cb), menubar)g_signal_connect_data ((applet), ("change-orient"), (((GCallback
) (matepanelapplet_reorient_cb))), (menubar), ((void*)0), (GConnectFlags
) 0)
;
1039 gtk_container_set_border_width(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, 0);
1040
1041 /* Add in filter func */
1042 tomboy_keybinder_bind(hotkey_keycode, hotkey_filter, menubar);
1043
1044 load_modules(applet, menubar, &indicators_loaded);
1045#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
1046 load_indicators_from_indicator_files(applet, menubar, &indicators_loaded);
1047#endif
1048
1049 if (indicators_loaded == 0) {
1050 /* A label to allow for click through */
1051 GtkWidget * item = gtk_label_new(_("No Indicators")gettext ("No Indicators"));
1052 mate_panel_applet_set_background_widget(applet, item);
1053 gtk_container_add(GTK_CONTAINER(applet)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_container_get_type ()))))))
, item);
1054 gtk_widget_show(item);
1055 } else {
1056 gtk_container_add(GTK_CONTAINER(applet)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_container_get_type ()))))))
, menubar);
1057 mate_panel_applet_set_background_widget(applet, menubar);
1058 gtk_widget_show(menubar);
1059 }
1060
1061 gtk_widget_show(GTK_WIDGET(applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
);
1062
1063 return TRUE(!(0));
1064
1065}
diff --git a/2020-04-09-113756-6097-1@37cc19e547b1_shadow/report-8becd0.html b/2020-04-09-113756-6097-1@37cc19e547b1_shadow/report-8becd0.html new file mode 100644 index 0000000..fc0dc7e --- /dev/null +++ b/2020-04-09-113756-6097-1@37cc19e547b1_shadow/report-8becd0.html @@ -0,0 +1,1412 @@ + + + +applet-main.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:applet-main.c
Warning:line 929, column 5
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name applet-main.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -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 -mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -resource-dir /usr/lib64/clang/9.0.1 -D HAVE_CONFIG_H -I . -I .. -D G_LOG_DOMAIN="Indicator-Applet-Appmenu" -D DATADIR="/usr/local/share" -D INDICATOR_DIR="/usr/lib64/indicators3/7/" -D INDICATOR_ICONS_DIR="/usr/share/libindicator/icons/" -D INDICATOR_APPLET_APPMENU -I ./.. -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/fribidi -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gio-unix-2.0 -I /usr/include/libdrm -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-panel-4.0/libmate-panel-applet -I /usr/include/libindicator3-0.4 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/fribidi -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gio-unix-2.0 -I /usr/include/libdrm -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/9.0.1/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdebug-compilation-dir /rootdir/src -ferror-limit 19 -fmessage-length 0 -fobjc-runtime=gcc -fdiagnostics-show-option -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 -o /rootdir/html-report/2020-04-09-113756-6097-1 -x c applet-main.c +
+ + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2A small wrapper utility to load indicators and put them as menu items
3into the mate-panel using it's applet interface.
4
5Copyright 2009-2010 Canonical Ltd.
6
7Authors:
8 Ted Gould <ted@canonical.com>
9
10This program is free software: you can redistribute it and/or modify it
11under the terms of the GNU General Public License version 3, as published
12by the Free Software Foundation.
13
14This program is distributed in the hope that it will be useful, but
15WITHOUT ANY WARRANTY; without even the implied warranties of
16MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
17PURPOSE. See the GNU General Public License for more details.
18
19You should have received a copy of the GNU General Public License along
20with this program. If not, see <http://www.gnu.org/licenses/>.
21*/
22
23#include <stdlib.h>
24#include <string.h>
25#include <config.h>
26#include <glib/gi18n.h>
27#include <mate-panel-applet.h>
28#include <gdk/gdkkeysyms.h>
29#include <gtk/gtk.h>
30
31#if HAVE_UBUNTU_INDICATOR1
32
33#define INDICATOR_SERVICE_APPMENU"libappmenu.so" "libappmenu.so"
34#define INDICATOR_SERVICE_ME"libme.so" "libme.so"
35#define INDICATOR_SERVICE_DATETIME"libdatetime.so" "libdatetime.so"
36
37#define INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu" "com.canonical.indicator.appmenu"
38#define INDICATOR_SERVICE_ME_NG"com.canonical.indicator.me" "com.canonical.indicator.me"
39#define INDICATOR_SERVICE_DATETIME_NG"com.canonical.indicator.datetime" "com.canonical.indicator.datetime"
40
41#include <libindicator/indicator-object.h>
42#endif
43
44#if HAVE_AYATANA_INDICATOR
45
46#define INDICATOR_SERVICE_APPMENU"libappmenu.so" "libayatana-appmenu.so"
47#define INDICATOR_SERVICE_ME"libme.so" "libayatana-me.so"
48#define INDICATOR_SERVICE_DATETIME"libdatetime.so" "libayatana-datetime.so"
49
50#define INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu" "org.ayatana.indicator.appmenu"
51#define INDICATOR_SERVICE_ME_NG"com.canonical.indicator.me" "org.ayatana.indicator.me"
52#define INDICATOR_SERVICE_DATETIME_NG"com.canonical.indicator.datetime" "org.ayatana.indicator.datetime"
53
54#include <libayatana-indicator/indicator-object.h>
55#endif
56
57/* For new style indicators */
58
59#if HAVE_UBUNTU_INDICATOR1 && HAVE_UBUNTU_INDICATOR_NG
60
61#include <libido/libido.h>
62#include <libindicator/indicator-ng.h>
63
64#define INDICATOR_SERVICE_DIR "/usr/share/unity/indicators"
65
66#endif
67
68#if HAVE_AYATANA_INDICATOR && HAVE_AYATANA_INDICATOR_NG
69
70#include <libayatana-ido/libayatana-ido.h>
71#include <libayatana-indicator/indicator-ng.h>
72
73#define INDICATOR_SERVICE_DIR "/usr/share/ayatana/indicators"
74
75#endif
76
77#include "tomboykeybinder.h"
78
79static gchar * indicator_order[] = {
80#if HAVE_UBUNTU_INDICATOR1
81 "libapplication.so",
82 "libmessaging.so",
83 "libsoundmenu.so",
84 "libdatetime.so",
85 "libsession.so",
86#endif
87#if HAVE_AYATANA_INDICATOR
88 "libayatana-application.so",
89 "libayatana-messaging.so",
90 "libayatana-soundmenu.so",
91 "libayatana-datetime.so",
92 "libayatana-session.so",
93#endif
94 NULL((void*)0)
95};
96
97static GtkPackDirection packdirection;
98static MatePanelAppletOrient orient;
99static guint size;
100
101#define MENU_DATA_INDICATOR_OBJECT"indicator-object" "indicator-object"
102#define MENU_DATA_INDICATOR_ENTRY"indicator-entry" "indicator-entry"
103
104#define IO_DATA_ORDER_NUMBER"indicator-order-number" "indicator-order-number"
105
106static gboolean applet_fill_cb (MatePanelApplet * applet, const gchar * iid, gpointer data);
107
108static void update_accessible_desc (IndicatorObjectEntry * entry, GtkWidget * menuitem);
109
110/*************
111 * main
112 * ***********/
113
114#ifdef INDICATOR_APPLET
115MATE_PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletFactory",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
116 PANEL_TYPE_APPLET,int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
117 "indicator-applet",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
118 applet_fill_cb, NULL)int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
;
119#endif
120#ifdef INDICATOR_APPLET_COMPLETE
121MATE_PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletCompleteFactory",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
122 PANEL_TYPE_APPLET,int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
123 "indicator-applet-complete",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
124 applet_fill_cb, NULL)int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
;
125#endif
126#ifdef INDICATOR_APPLET_APPMENU1
127MATE_PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletAppmenuFactory",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
128 PANEL_TYPE_APPLET,int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
129 "indicator-applet-appmenu",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
130 applet_fill_cb, NULL)int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
;
131#endif
132
133/*************
134 * log files
135 * ***********/
136#ifdef INDICATOR_APPLET
137#define LOG_FILE_NAME"indicator-applet-appmenu.log" "indicator-applet.log"
138#endif
139#ifdef INDICATOR_APPLET_COMPLETE
140#define LOG_FILE_NAME"indicator-applet-appmenu.log" "indicator-applet-complete.log"
141#endif
142#ifdef INDICATOR_APPLET_APPMENU1
143#define LOG_FILE_NAME"indicator-applet-appmenu.log" "indicator-applet-appmenu.log"
144#endif
145GOutputStream * log_file = NULL((void*)0);
146
147/*****************
148 * Hotkey support
149 * **************/
150#ifdef INDICATOR_APPLET
151gchar * hotkey_keycode = "<Super>M";
152#endif
153#ifdef INDICATOR_APPLET_SESSION
154gchar * hotkey_keycode = "<Super>S";
155#endif
156#ifdef INDICATOR_APPLET_COMPLETE
157gchar * hotkey_keycode = "<Super>S";
158#endif
159#ifdef INDICATOR_APPLET_APPMENU1
160gchar * hotkey_keycode = "<Super>F1";
161#endif
162
163/********************
164 * Environment Names
165 * *******************/
166#ifdef INDICATOR_APPLET
167#define INDICATOR_SPECIFIC_ENV"indicator-applet-appmenu" "indicator-applet-original"
168#endif
169#ifdef INDICATOR_APPLET_COMPLETE
170#define INDICATOR_SPECIFIC_ENV"indicator-applet-appmenu" "indicator-applet-complete"
171#endif
172#ifdef INDICATOR_APPLET_APPMENU1
173#define INDICATOR_SPECIFIC_ENV"indicator-applet-appmenu" "indicator-applet-appmenu"
174#endif
175
176static const gchar * indicator_env[] = {
177 "indicator-applet",
178 INDICATOR_SPECIFIC_ENV"indicator-applet-appmenu",
179 NULL((void*)0)
180};
181
182/*************
183 * init function
184 * ***********/
185
186static gint
187name2order (const gchar * name) {
188 int i;
189
190 for (i = 0; indicator_order[i] != NULL((void*)0); i++) {
191 if (g_strcmp0(name, indicator_order[i]) == 0) {
192 return i;
193 }
194 }
195
196 return -1;
197}
198
199typedef struct _incoming_position_t incoming_position_t;
200struct _incoming_position_t {
201 gint objposition;
202 gint entryposition;
203 gint menupos;
204 gboolean found;
205};
206
207/* This function helps by determining where in the menu list
208 this new entry should be placed. It compares the objects
209 that they're on, and then the individual entries. Each
210 is progressively more expensive. */
211static void
212place_in_menu (GtkWidget * widget, gpointer user_data)
213{
214 incoming_position_t * position = (incoming_position_t *)user_data;
215 if (position->found) {
216 /* We've already been placed, just finish the foreach */
217 return;
218 }
219
220 IndicatorObject * io = INDICATOR_OBJECT(g_object_get_data(G_OBJECT(widget), MENU_DATA_INDICATOR_OBJECT))((((IndicatorObject*) g_type_check_instance_cast ((GTypeInstance
*) ((g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((widget)), (((GType) ((20) << (2)))
))))), "indicator-object"))), ((indicator_object_get_type ())
)))))
;
221 g_assert(io != NULL)do { if (io != ((void*)0)) ; else g_assertion_message_expr ("Indicator-Applet-Appmenu"
, "applet-main.c", 221, ((const char*) (__func__)), "io != NULL"
); } while (0)
;
222
223 gint objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER))((gint) (glong) (g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
), "indicator-order-number")))
;
224 /* We've already passed it, well, then this is where
225 we should be be. Stop! */
226 if (objposition > position->objposition) {
227 position->found = TRUE(!(0));
228 return;
229 }
230
231 /* The objects don't match yet, keep looking */
232 if (objposition < position->objposition) {
233 position->menupos++;
234 return;
235 }
236
237 /* The objects are the same, let's start looking at entries. */
238 IndicatorObjectEntry * entry = (IndicatorObjectEntry *)g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
239 gint entryposition = indicator_object_get_location(io, entry);
240
241 if (entryposition > position->entryposition) {
242 position->found = TRUE(!(0));
243 return;
244 }
245
246 if (entryposition < position->entryposition) {
247 position->menupos++;
248 return;
249 }
250
251 /* We've got the same object and the same entry. Well,
252 let's just put it right here then. */
253 position->found = TRUE(!(0));
254 return;
255}
256
257static void
258something_shown (GtkWidget * widget, gpointer user_data)
259{
260 GtkWidget * menuitem = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
261 gtk_widget_show(menuitem);
262}
263
264static void
265something_hidden (GtkWidget * widget, gpointer user_data)
266{
267 GtkWidget * menuitem = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
268 gtk_widget_hide(menuitem);
269}
270
271static void
272sensitive_cb (GObject * obj, GParamSpec * pspec, gpointer user_data)
273{
274 g_return_if_fail(GTK_IS_WIDGET(obj))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((obj)); GType __t = ((gtk_widget_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 ("Indicator-Applet-Appmenu",
((const char*) (__func__)), "GTK_IS_WIDGET(obj)"); return; }
} while (0)
;
275 g_return_if_fail(GTK_IS_WIDGET(user_data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((gtk_widget_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 ("Indicator-Applet-Appmenu",
((const char*) (__func__)), "GTK_IS_WIDGET(user_data)"); return
; } } while (0)
;
276
277 gtk_widget_set_sensitive(GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
, gtk_widget_get_sensitive(GTK_WIDGET(obj)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(obj)), ((gtk_widget_get_type ()))))))
));
278 return;
279}
280
281static void
282entry_activated (GtkWidget * widget, gpointer user_data)
283{
284 g_return_if_fail(GTK_IS_WIDGET(widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((gtk_widget_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 ("Indicator-Applet-Appmenu",
((const char*) (__func__)), "GTK_IS_WIDGET(widget)"); return
; } } while (0)
;
285 gpointer pio = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, "indicator");
286 g_return_if_fail(INDICATOR_IS_OBJECT(pio))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((pio)); GType __t = ((indicator_object_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 ("Indicator-Applet-Appmenu",
((const char*) (__func__)), "INDICATOR_IS_OBJECT(pio)"); return
; } } while (0)
;
287 IndicatorObject * io = INDICATOR_OBJECT(pio)((((IndicatorObject*) g_type_check_instance_cast ((GTypeInstance
*) ((pio)), ((indicator_object_get_type ()))))))
;
288
289 return indicator_object_entry_activate(io, (IndicatorObjectEntry *)user_data, gtk_get_current_event_time());
290}
291
292static gboolean
293entry_scrolled (GtkWidget *menuitem, GdkEventScroll *event, gpointer data)
294{
295 IndicatorObject *io = g_object_get_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_OBJECT"indicator-object");
296 IndicatorObjectEntry *entry = g_object_get_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
297
298 g_return_val_if_fail(INDICATOR_IS_OBJECT(io), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((io)); GType __t = ((indicator_object_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 ("Indicator-Applet-Appmenu",
((const char*) (__func__)), "INDICATOR_IS_OBJECT(io)"); return
((0)); } } while (0)
;
299
300 g_signal_emit_by_name (io, "scroll", 1, event->direction);
301 g_signal_emit_by_name (io, "scroll-entry", entry, 1, event->direction);
302 g_signal_emit_by_name (io, INDICATOR_OBJECT_SIGNAL_ENTRY_SCROLLED"entry-scrolled", entry, 1, event->direction);
303
304 return FALSE(0);
305}
306
307static void
308accessible_desc_update_cb (GtkWidget * widget, gpointer userdata)
309{
310 gpointer data = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
311
312 if (data != userdata) {
313 return;
314 }
315
316 IndicatorObjectEntry * entry = (IndicatorObjectEntry *)data;
317 update_accessible_desc(entry, widget);
318}
319
320static void
321accessible_desc_update (IndicatorObject * io, IndicatorObjectEntry * entry, GtkWidget * menubar)
322{
323 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, accessible_desc_update_cb, entry);
324 return;
325}
326
327#define PANEL_PADDING8 8
328static gboolean
329entry_resized (GtkWidget *applet, guint newsize, gpointer data)
330{
331 IndicatorObject *io = (IndicatorObject *)data;
332
333 size = newsize;
334
335 /* Work on the entries */
336 GList * entries = indicator_object_get_entries(io);
337 GList * entry = NULL((void*)0);
338
339 for (entry = entries; entry != NULL((void*)0); entry = g_list_next(entry)((entry) ? (((GList *)(entry))->next) : ((void*)0))) {
340 IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)entry->data;
341 if (entrydata->image != NULL((void*)0)) {
342 /* Resize to fit panel */
343 gtk_image_set_pixel_size (entrydata->image, size - PANEL_PADDING8);
344 }
345 }
346
347 return FALSE(0);
348}
349
350static void
351entry_added (IndicatorObject * io, IndicatorObjectEntry * entry, GtkWidget * menubar)
352{
353 g_debug("Signal: Entry Added");
354 gboolean something_visible = FALSE(0);
355 gboolean something_sensitive = FALSE(0);
356
357 GtkWidget * menuitem = gtk_menu_item_new();
358 GtkWidget * box = (packdirection == GTK_PACK_DIRECTION_LTR) ?
359 gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3) : gtk_box_new(GTK_ORIENTATION_VERTICAL, 3);
360
361 /* Allows indicators to receive mouse scroll event */
362 gtk_widget_add_events(GTK_WIDGET(menuitem)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(menuitem)), ((gtk_widget_get_type ()))))))
, GDK_SCROLL_MASK);
363
364 g_object_set_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "indicator", io);
365 g_object_set_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "box", box);
366
367 g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(entry_activated), entry)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((menuitem)), (((GType) ((20) << (2)
)))))))), ("activate"), (((GCallback) (entry_activated))), (entry
), ((void*)0), (GConnectFlags) 0)
;
368 g_signal_connect(G_OBJECT(menuitem), "scroll-event", G_CALLBACK(entry_scrolled), entry)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((menuitem)), (((GType) ((20) << (2)
)))))))), ("scroll-event"), (((GCallback) (entry_scrolled))),
(entry), ((void*)0), (GConnectFlags) 0)
;
369
370 if (entry->image != NULL((void*)0)) {
371 /* Resize to fit panel */
372 gtk_image_set_pixel_size (entry->image, size - PANEL_PADDING8);
373 gtk_box_pack_start(GTK_BOX(box)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((box
)), ((gtk_box_get_type ()))))))
, GTK_WIDGET(entry->image)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->image)), ((gtk_widget_get_type ()))))))
, FALSE(0), FALSE(0), 1);
374 if (gtk_widget_get_visible(GTK_WIDGET(entry->image)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->image)), ((gtk_widget_get_type ()))))))
)) {
375 something_visible = TRUE(!(0));
376 }
377
378 if (gtk_widget_get_sensitive(GTK_WIDGET(entry->image)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->image)), ((gtk_widget_get_type ()))))))
)) {
379 something_sensitive = TRUE(!(0));
380 }
381
382 g_signal_connect(G_OBJECT(entry->image), "show", G_CALLBACK(something_shown), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), ("show"), (((GCallback) (something_shown))), (menuitem
), ((void*)0), (GConnectFlags) 0)
;
383 g_signal_connect(G_OBJECT(entry->image), "hide", G_CALLBACK(something_hidden), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), ("hide"), (((GCallback) (something_hidden))), (
menuitem), ((void*)0), (GConnectFlags) 0)
;
384
385 g_signal_connect(G_OBJECT(entry->image), "notify::sensitive", G_CALLBACK(sensitive_cb), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), ("notify::sensitive"), (((GCallback) (sensitive_cb
))), (menuitem), ((void*)0), (GConnectFlags) 0)
;
386 }
387 if (entry->label != NULL((void*)0)) {
388 switch(packdirection) {
389 case GTK_PACK_DIRECTION_LTR:
390 gtk_label_set_angle(GTK_LABEL(entry->label)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_label_get_type ()))))))
, 0.0);
391 break;
392 case GTK_PACK_DIRECTION_TTB:
393 gtk_label_set_angle(GTK_LABEL(entry->label)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_label_get_type ()))))))
,
394 (orient == MATE_PANEL_APPLET_ORIENT_LEFT) ?
395 270.0 : 90.0);
396 break;
397 default:
398 break;
399 }
400 gtk_box_pack_start(GTK_BOX(box)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((box
)), ((gtk_box_get_type ()))))))
, GTK_WIDGET(entry->label)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_widget_get_type ()))))))
, FALSE(0), FALSE(0), 1);
401
402 if (gtk_widget_get_visible(GTK_WIDGET(entry->label)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_widget_get_type ()))))))
)) {
403 something_visible = TRUE(!(0));
404 }
405
406 if (gtk_widget_get_sensitive(GTK_WIDGET(entry->label)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_widget_get_type ()))))))
)) {
407 something_sensitive = TRUE(!(0));
408 }
409
410 g_signal_connect(G_OBJECT(entry->label), "show", G_CALLBACK(something_shown), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), ("show"), (((GCallback) (something_shown))), (menuitem
), ((void*)0), (GConnectFlags) 0)
;
411 g_signal_connect(G_OBJECT(entry->label), "hide", G_CALLBACK(something_hidden), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), ("hide"), (((GCallback) (something_hidden))), (
menuitem), ((void*)0), (GConnectFlags) 0)
;
412
413 g_signal_connect(G_OBJECT(entry->label), "notify::sensitive", G_CALLBACK(sensitive_cb), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), ("notify::sensitive"), (((GCallback) (sensitive_cb
))), (menuitem), ((void*)0), (GConnectFlags) 0)
;
414 }
415 gtk_container_add(GTK_CONTAINER(menuitem)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menuitem)), ((gtk_container_get_type ()))))))
, box);
416 gtk_widget_show(box);
417
418 if (entry->menu != NULL((void*)0)) {
419 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem)((((GtkMenuItem*) g_type_check_instance_cast ((GTypeInstance*
) ((menuitem)), ((gtk_menu_item_get_type ()))))))
, GTK_WIDGET(entry->menu)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->menu)), ((gtk_widget_get_type ()))))))
);
420 }
421
422 incoming_position_t position;
423 position.objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER))((gint) (glong) (g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
), "indicator-order-number")))
;
424 position.entryposition = indicator_object_get_location(io, entry);
425 position.menupos = 0;
426 position.found = FALSE(0);
427
428 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, place_in_menu, &position);
429
430 gtk_menu_shell_insert(GTK_MENU_SHELL(menubar)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_menu_shell_get_type ()))))))
, menuitem, position.menupos);
431
432 if (something_visible) {
433 if (entry->accessible_desc != NULL((void*)0)) {
434 update_accessible_desc(entry, menuitem);
435 }
436 gtk_widget_show(menuitem);
437 }
438 gtk_widget_set_sensitive(menuitem, something_sensitive);
439
440 g_object_set_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry", entry);
441 g_object_set_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_OBJECT"indicator-object", io);
442
443 return;
444}
445
446static void
447entry_removed_cb (GtkWidget * widget, gpointer userdata)
448{
449 gpointer data = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
450
451 if (data != userdata) {
452 return;
453 }
454
455 IndicatorObjectEntry * entry = (IndicatorObjectEntry *)data;
456 if (entry->label != NULL((void*)0)) {
457 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(something_shown), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_shown))), (widget
))
;
458 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(something_hidden), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_hidden))), (widget
))
;
459 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(sensitive_cb), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (sensitive_cb))), (widget)
)
;
460 }
461 if (entry->image != NULL((void*)0)) {
462 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(something_shown), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_shown))), (widget
))
;
463 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(something_hidden), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_hidden))), (widget
))
;
464 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(sensitive_cb), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (sensitive_cb))), (widget)
)
;
465 }
466
467 gtk_widget_destroy(widget);
468 return;
469}
470
471static void
472entry_removed (IndicatorObject * io G_GNUC_UNUSED__attribute__((__unused__)), IndicatorObjectEntry * entry,
473 gpointer user_data)
474{
475 g_debug("Signal: Entry Removed");
476
477 gtk_container_foreach(GTK_CONTAINER(user_data)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((gtk_container_get_type ()))))))
, entry_removed_cb, entry);
478
479 return;
480}
481
482static void
483entry_moved_find_cb (GtkWidget * widget, gpointer userdata)
484{
485 gpointer * array = (gpointer *)userdata;
486 if (array[1] != NULL((void*)0)) {
487 return;
488 }
489
490 gpointer data = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
491
492 if (data != array[0]) {
493 return;
494 }
495
496 array[1] = widget;
497 return;
498}
499
500/* Gets called when an entry for an object was moved. */
501static void
502entry_moved (IndicatorObject * io, IndicatorObjectEntry * entry,
503 gint old G_GNUC_UNUSED__attribute__((__unused__)), gint new G_GNUC_UNUSED__attribute__((__unused__)), gpointer user_data)
504{
505 GtkWidget * menubar = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
506
507 gpointer array[2];
508 array[0] = entry;
509 array[1] = NULL((void*)0);
510
511 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, entry_moved_find_cb, array);
512 if (array[1] == NULL((void*)0)) {
513 g_warning("Moving an entry that isn't in our menus.");
514 return;
515 }
516
517 GtkWidget * mi = GTK_WIDGET(array[1])((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(array[1])), ((gtk_widget_get_type ()))))))
;
518 g_object_ref(G_OBJECT(mi)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
mi)), (((GType) ((20) << (2))))))))
);
519 gtk_container_remove(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, mi);
520
521 incoming_position_t position;
522 position.objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER))((gint) (glong) (g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
), "indicator-order-number")))
;
523 position.entryposition = indicator_object_get_location(io, entry);
524 position.menupos = 0;
525 position.found = FALSE(0);
526
527 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, place_in_menu, &position);
528
529 gtk_menu_shell_insert(GTK_MENU_SHELL(menubar)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_menu_shell_get_type ()))))))
, mi, position.menupos);
530 g_object_unref(G_OBJECT(mi)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
mi)), (((GType) ((20) << (2))))))))
);
531
532 return;
533}
534
535static void
536menu_show (IndicatorObject * io, IndicatorObjectEntry * entry,
537 guint32 timestamp, gpointer user_data)
538{
539 GtkWidget * menubar = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
540
541 if (entry == NULL((void*)0)) {
542 /* Close any open menus instead of opening one */
543 GList * entries = indicator_object_get_entries(io);
544 GList * iterator = NULL((void*)0);
545 for (iterator = entries; iterator != NULL((void*)0); iterator = g_list_next(iterator)((iterator) ? (((GList *)(iterator))->next) : ((void*)0))) {
546 IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)iterator->data;
547 gtk_menu_popdown(entrydata->menu);
548 }
549 g_list_free(entries);
550
551 /* And tell the menubar to exit activation mode too */
552 gtk_menu_shell_cancel(GTK_MENU_SHELL(menubar)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_menu_shell_get_type ()))))))
);
553 return;
554 }
555
556 // TODO: do something sensible here
557}
558
559static void
560update_accessible_desc(IndicatorObjectEntry * entry, GtkWidget * menuitem)
561{
562 /* FIXME: We need to deal with the use case where the contents of the
563 label overrides what is found in the atk object's name, or at least
564 orca speaks the label instead of the atk object name.
565 */
566 AtkObject * menuitem_obj = gtk_widget_get_accessible(menuitem);
567 if (menuitem_obj == NULL((void*)0)) {
568 /* Should there be an error printed here? */
569 return;
570 }
571
572 if (entry->accessible_desc != NULL((void*)0)) {
573 atk_object_set_name(menuitem_obj, entry->accessible_desc);
574 } else {
575 atk_object_set_name(menuitem_obj, "");
576 }
577 return;
578}
579
580static void
581load_indicator (MatePanelApplet *applet, GtkWidget * menubar, IndicatorObject *io, const gchar *name)
582{
583 /* Set the environment it's in */
584 indicator_object_set_environment(io, (const GStrv)indicator_env);
585
586 /* Attach the 'name' to the object */
587#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
588 int pos = 5000 - indicator_object_get_position(io);
589 if (pos > 5000) {
590 pos = name2order(name);
591 }
592#else
593 int pos = name2order(name);
594#endif
595
596 g_object_set_data(G_OBJECT(io)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
io)), (((GType) ((20) << (2))))))))
, IO_DATA_ORDER_NUMBER"indicator-order-number", GINT_TO_POINTER(pos)((gpointer) (glong) (pos)));
597
598 /* Connect to its signals */
599 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED, G_CALLBACK(entry_added), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("entry-added"), (((GCallback) (entry_added))), (menubar)
, ((void*)0), (GConnectFlags) 0)
;
600 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED, G_CALLBACK(entry_removed), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("entry-removed"), (((GCallback) (entry_removed))), (menubar
), ((void*)0), (GConnectFlags) 0)
;
601 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_MOVED, G_CALLBACK(entry_moved), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("entry-moved"), (((GCallback) (entry_moved))), (menubar)
, ((void*)0), (GConnectFlags) 0)
;
602 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_MENU_SHOW, G_CALLBACK(menu_show), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("menu-show"), (((GCallback) (menu_show))), (menubar), ((
void*)0), (GConnectFlags) 0)
;
603 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ACCESSIBLE_DESC_UPDATE, G_CALLBACK(accessible_desc_update), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("accessible-desc-update"), (((GCallback) (accessible_desc_update
))), (menubar), ((void*)0), (GConnectFlags) 0)
;
604
605 /* Track panel resize */
606 g_signal_connect_object(G_OBJECT(applet)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
applet)), (((GType) ((20) << (2))))))))
, "change-size", G_CALLBACK(entry_resized)((GCallback) (entry_resized)), G_OBJECT(io)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
io)), (((GType) ((20) << (2))))))))
, 0);
607
608 /* Work on the entries */
609 GList * entries = indicator_object_get_entries(io);
610 GList * entry = NULL((void*)0);
611
612 for (entry = entries; entry != NULL((void*)0); entry = g_list_next(entry)((entry) ? (((GList *)(entry))->next) : ((void*)0))) {
613 IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)entry->data;
614 entry_added(io, entrydata, menubar);
615 }
616
617 g_list_free(entries);
618}
619
620static gboolean
621load_module (const gchar * name, MatePanelApplet *applet, GtkWidget * menubar)
622{
623 g_debug("Looking at Module: %s", name);
624 g_return_val_if_fail(name != NULL, FALSE)do { if ((name != ((void*)0))) { } else { g_return_if_fail_warning
("Indicator-Applet-Appmenu", ((const char*) (__func__)), "name != NULL"
); return ((0)); } } while (0)
;
625
626 if (!g_str_has_suffix(name, G_MODULE_SUFFIX"so")) {
627 return FALSE(0);
628 }
629
630 g_debug("Loading Module: %s", name);
631
632 /* Build the object for the module */
633 gchar * fullpath = g_build_filename(INDICATOR_DIR"/usr/lib64/indicators3/7/", name, NULL((void*)0));
634 IndicatorObject * io = indicator_object_new_from_file(fullpath);
635 g_free(fullpath);
636
637 load_indicator(applet, menubar, io, name);
638
639 return TRUE(!(0));
640}
641
642static void
643load_modules (MatePanelApplet *applet, GtkWidget *menubar, gint *indicators_loaded)
644{
645 if (g_file_test(INDICATOR_DIR"/usr/lib64/indicators3/7/", (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))) {
646 GDir * dir = g_dir_open(INDICATOR_DIR"/usr/lib64/indicators3/7/", 0, NULL((void*)0));
647
648 const gchar * name;
649 gint count = 0;
650 while ((name = g_dir_read_name(dir)) != NULL((void*)0)) {
651#ifdef INDICATOR_APPLET_APPMENU1
652 if (g_strcmp0(name, INDICATOR_SERVICE_APPMENU"libappmenu.so")) {
653 continue;
654 }
655#else
656 if (!g_strcmp0(name, INDICATOR_SERVICE_APPMENU"libappmenu.so")) {
657 continue;
658 }
659#endif
660#ifdef INDICATOR_APPLET
661 if (!g_strcmp0(name, INDICATOR_SERVICE_ME"libme.so")) {
662 continue;
663 }
664 if (!g_strcmp0(name, INDICATOR_SERVICE_DATETIME"libdatetime.so")) {
665 continue;
666 }
667#endif
668 if (load_module(name, applet, menubar)) {
669 count++;
670 }
671 }
672
673 *indicators_loaded += count;
674
675 g_dir_close (dir);
676 }
677}
678
679#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
680
681static void
682load_indicators_from_indicator_files (MatePanelApplet *applet, GtkWidget *menubar, gint *indicators_loaded)
683{
684 GDir *dir;
685 const gchar *name;
686 GError *error = NULL((void*)0);
687
688 dir = g_dir_open (INDICATOR_SERVICE_DIR, 0, &error);
689
690 if (!dir) {
691 g_warning ("unable to open indicator service file directory: %s", error->message);
692 g_error_free (error);
693
694 return;
695 }
696
697 gint count = 0;
698 while ((name = g_dir_read_name (dir))) {
699 gchar *filename;
700 IndicatorNg *indicator;
701
702 filename = g_build_filename (INDICATOR_SERVICE_DIR, name, NULL((void*)0));
703 indicator = indicator_ng_new_for_profile (filename, "desktop", &error);
704 g_free (filename);
705
706#ifdef INDICATOR_APPLET_APPMENU1
707 if (g_strcmp0(name, INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu")) {
708 continue;
709 }
710#else
711 if (!g_strcmp0(name, INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu")) {
712 continue;
713 }
714#endif
715#ifdef INDICATOR_APPLET
716 if (!g_strcmp0(name, INDICATOR_SERVICE_ME_NG"com.canonical.indicator.me")) {
717 continue;
718 }
719 if (!g_strcmp0(name, INDICATOR_SERVICE_DATETIME_NG"com.canonical.indicator.datetime")) {
720 continue;
721 }
722#endif
723
724 if (indicator) {
725 load_indicator(applet, menubar, INDICATOR_OBJECT (indicator)((((IndicatorObject*) g_type_check_instance_cast ((GTypeInstance
*) ((indicator)), ((indicator_object_get_type ()))))))
, name);
726 count++;
727 }else{
728 g_warning ("unable to load '%s': %s", name, error->message);
729 g_clear_error (&error);
730 }
731 }
732
733 *indicators_loaded += count;
734
735 g_dir_close (dir);
736}
737#endif /* HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG */
738
739static void
740hotkey_filter (char * keystring G_GNUC_UNUSED__attribute__((__unused__)), gpointer data)
741{
742 g_return_if_fail(GTK_IS_MENU_SHELL(data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((data)); GType __t = ((gtk_menu_shell_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 ("Indicator-Applet-Appmenu",
((const char*) (__func__)), "GTK_IS_MENU_SHELL(data)"); return
; } } while (0)
;
743
744 /* Oh, wow, it's us! */
745 GList * children = gtk_container_get_children(GTK_CONTAINER(data)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((gtk_container_get_type ()))))))
);
746 if (children == NULL((void*)0)) {
747 g_debug("Menubar has no children");
748 return;
749 }
750
751 gtk_menu_shell_select_item(GTK_MENU_SHELL(data)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((gtk_menu_shell_get_type ()))))))
, GTK_WIDGET(g_list_last(children)->data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(g_list_last(children)->data)), ((gtk_widget_get_type ()))
))))
);
752 g_list_free(children);
753 return;
754}
755
756static gboolean
757menubar_press (GtkWidget * widget,
758 GdkEventButton *event,
759 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
760{
761 if (event->button != 1) {
762 g_signal_stop_emission_by_name(widget, "button-press-event");
763 }
764
765 return FALSE(0);
766}
767
768static gboolean
769menubar_on_draw (GtkWidget * widget,
770 cairo_t * cr,
771 GtkWidget * menubar)
772{
773 /* FIXME: either port to gtk_render_focus or remove this function */
774 if (gtk_widget_has_focus(menubar))
775 gtk_paint_focus(gtk_widget_get_style(widget),
776 cr,
777 gtk_widget_get_state(menubar),
778 widget, "menubar-applet", 0, 0, -1, -1);
779
780 return FALSE(0);
781}
782
783static void
784about_cb (GtkAction *action G_GNUC_UNUSED__attribute__((__unused__)),
785 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
786{
787 static const gchar *authors[] = {
788 "Ted Gould <ted@canonical.com>",
789 NULL((void*)0)
790 };
791
792 static gchar *license[] = {
793 N_("This program is free software: you can redistribute it and/or modify it ""This program is free software: you can redistribute it and/or modify it "
"under the terms of the GNU General Public License version 3, as published "
"by the Free Software Foundation."
794 "under the terms of the GNU General Public License version 3, as published ""This program is free software: you can redistribute it and/or modify it "
"under the terms of the GNU General Public License version 3, as published "
"by the Free Software Foundation."
795 "by the Free Software Foundation.")"This program is free software: you can redistribute it and/or modify it "
"under the terms of the GNU General Public License version 3, as published "
"by the Free Software Foundation."
,
796 N_("This program is distributed in the hope that it will be useful, but ""This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
797 "WITHOUT ANY WARRANTY; without even the implied warranties of ""This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
798 "MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR ""This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
799 "PURPOSE. See the GNU General Public License for more details.")"This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
,
800 N_("You should have received a copy of the GNU General Public License along ""You should have received a copy of the GNU General Public License along "
"with this program. If not, see <http://www.gnu.org/licenses/>."
801 "with this program. If not, see <http://www.gnu.org/licenses/>.")"You should have received a copy of the GNU General Public License along "
"with this program. If not, see <http://www.gnu.org/licenses/>."
,
802 NULL((void*)0)
803 };
804 gchar *license_i18n;
805
806 license_i18n = g_strconcat (_(license[0])gettext (license[0]), "\n\n", _(license[1])gettext (license[1]), "\n\n", _(license[2])gettext (license[2]), NULL((void*)0));
807
808 gtk_show_about_dialog(NULL((void*)0),
809 "version", VERSION"1.24.0",
810 "copyright", _("Copyright \xc2\xa9 2009-2010 Canonical, Ltd.\n"gettext ("Copyright \xc2\xa9 2009-2010 Canonical, Ltd.\n" "Copyright \xc2\xa9 2011-2020 MATE developers"
)
811 "Copyright \xc2\xa9 2011-2020 MATE developers")gettext ("Copyright \xc2\xa9 2009-2010 Canonical, Ltd.\n" "Copyright \xc2\xa9 2011-2020 MATE developers"
)
,
812#ifdef INDICATOR_APPLET_APPMENU1
813 "comments", _("An applet to hold your application menus.")gettext ("An applet to hold your application menus."),
814#endif
815 "comments", _("An applet to hold all of the system indicators.")gettext ("An applet to hold all of the system indicators."),
816 "authors", authors,
817 "license", license_i18n,
818 "wrap-license", TRUE(!(0)),
819 "translator-credits", _("translator-credits")gettext ("translator-credits"),
820 "logo-icon-name", "mate-indicator-applet",
821 "icon-name", "mate-indicator-applet",
822 "website", "https://mate-desktop.org",
823 "website-label", _("MATE Website")gettext ("MATE Website"),
824 NULL((void*)0)
825 );
826
827 g_free (license_i18n);
828
829 return;
830}
831
832static gboolean
833swap_orient_cb (GtkWidget *item, gpointer data)
834{
835 GtkWidget *from = (GtkWidget *) data;
836 GtkWidget *to = (GtkWidget *) g_object_get_data(G_OBJECT(from)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
from)), (((GType) ((20) << (2))))))))
, "to");
837 g_object_ref(G_OBJECT(item)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
item)), (((GType) ((20) << (2))))))))
);
838 gtk_container_remove(GTK_CONTAINER(from)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((from)), ((gtk_container_get_type ()))))))
, item);
839 if (GTK_IS_LABEL(item)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(item)); GType __t = ((gtk_label_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; }))))
) {
840 switch(packdirection) {
841 case GTK_PACK_DIRECTION_LTR:
842 gtk_label_set_angle(GTK_LABEL(item)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(item)), ((gtk_label_get_type ()))))))
, 0.0);
843 break;
844 case GTK_PACK_DIRECTION_TTB:
845 gtk_label_set_angle(GTK_LABEL(item)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(item)), ((gtk_label_get_type ()))))))
,
846 (orient == MATE_PANEL_APPLET_ORIENT_LEFT) ?
847 270.0 : 90.0);
848 break;
849 default:
850 break;
851 }
852 }
853 gtk_box_pack_start(GTK_BOX(to)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((to
)), ((gtk_box_get_type ()))))))
, item, FALSE(0), FALSE(0), 0);
854 return TRUE(!(0));
855}
856
857static gboolean
858reorient_box_cb (GtkWidget *menuitem, gpointer data)
859{
860 GtkWidget *from = g_object_get_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "box");
861 GtkWidget *to = (packdirection == GTK_PACK_DIRECTION_LTR) ?
862 gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0) : gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
863 g_object_set_data(G_OBJECT(from)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
from)), (((GType) ((20) << (2))))))))
, "to", to);
864 gtk_container_foreach(GTK_CONTAINER(from)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((from)), ((gtk_container_get_type ()))))))
, (GtkCallback)swap_orient_cb,
865 from);
866 gtk_container_remove(GTK_CONTAINER(menuitem)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menuitem)), ((gtk_container_get_type ()))))))
, from);
867 gtk_container_add(GTK_CONTAINER(menuitem)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menuitem)), ((gtk_container_get_type ()))))))
, to);
868 g_object_set_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "box", to);
869 gtk_widget_show_all(menuitem);
870 return TRUE(!(0));
871}
872
873static gboolean
874matepanelapplet_reorient_cb (GtkWidget *applet, MatePanelAppletOrient neworient,
875 gpointer data)
876{
877 GtkWidget *menubar = (GtkWidget *)data;
878 if ((((neworient == MATE_PANEL_APPLET_ORIENT_UP) ||
879 (neworient == MATE_PANEL_APPLET_ORIENT_DOWN)) &&
880 ((orient == MATE_PANEL_APPLET_ORIENT_LEFT) ||
881 (orient == MATE_PANEL_APPLET_ORIENT_RIGHT))) ||
882 (((neworient == MATE_PANEL_APPLET_ORIENT_LEFT) ||
883 (neworient == MATE_PANEL_APPLET_ORIENT_RIGHT)) &&
884 ((orient == MATE_PANEL_APPLET_ORIENT_UP) ||
885 (orient == MATE_PANEL_APPLET_ORIENT_DOWN)))) {
886 packdirection = (packdirection == GTK_PACK_DIRECTION_LTR) ?
887 GTK_PACK_DIRECTION_TTB : GTK_PACK_DIRECTION_LTR;
888 gtk_menu_bar_set_pack_direction(GTK_MENU_BAR(menubar)((((GtkMenuBar*) g_type_check_instance_cast ((GTypeInstance*)
((menubar)), ((gtk_menu_bar_get_type ()))))))
,
889 packdirection);
890 orient = neworient;
891 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
,
892 (GtkCallback)reorient_box_cb, NULL((void*)0));
893 }
894 orient = neworient;
895 return FALSE(0);
896}
897
898#ifdef N_
899#undef N_
900#endif
901#define N_(x)x x
902
903static void
904log_to_file_cb (GObject * source_obj G_GNUC_UNUSED__attribute__((__unused__)),
905 GAsyncResult * result G_GNUC_UNUSED__attribute__((__unused__)), gpointer user_data)
906{
907 g_free(user_data);
908 return;
909}
910
911static void
912log_to_file (const gchar * domain G_GNUC_UNUSED__attribute__((__unused__)),
913 GLogLevelFlags level G_GNUC_UNUSED__attribute__((__unused__)),
914 const gchar * message,
915 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
916{
917 if (log_file == NULL((void*)0)) {
918 GError * error = NULL((void*)0);
919 gchar * filename = g_build_filename(g_get_user_cache_dir(), LOG_FILE_NAME"indicator-applet-appmenu.log", NULL((void*)0));
920 GFile * file = g_file_new_for_path(filename);
921 g_free(filename);
922
923 if (!g_file_test(g_get_user_cache_dir(), G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) {
924 GFile * cachedir = g_file_new_for_path(g_get_user_cache_dir());
925 g_file_make_directory_with_parents(cachedir, NULL((void*)0), &error);
926
927 if (error != NULL((void*)0)) {
928 g_error("Unable to make directory '%s' for log file: %s", g_get_user_cache_dir(), error->message);
929 return;
This statement is never executed
930 }
931 }
932
933 g_file_delete(file, NULL((void*)0), NULL((void*)0));
934
935 GFileIOStream * io = g_file_create_readwrite(file,
936 G_FILE_CREATE_REPLACE_DESTINATION, /* flags */
937 NULL((void*)0), /* cancelable */
938 &error); /* error */
939 if (error != NULL((void*)0)) {
940 g_error("Unable to replace file: %s", error->message);
941 return;
942 }
943
944 log_file = g_io_stream_get_output_stream(G_IO_STREAM(io)((((GIOStream*) g_type_check_instance_cast ((GTypeInstance*) (
(io)), ((g_io_stream_get_type ()))))))
);
945 }
946
947 gchar * outputstring = g_strdup_printf("%s\n", message);
948 g_output_stream_write_async(log_file,
949 outputstring, /* data */
950 strlen(outputstring), /* length */
951 G_PRIORITY_LOW300, /* priority */
952 NULL((void*)0), /* cancelable */
953 log_to_file_cb, /* callback */
954 outputstring); /* data */
955
956 return;
957}
958
959static gboolean
960applet_fill_cb (MatePanelApplet * applet, const gchar * iid G_GNUC_UNUSED__attribute__((__unused__)),
961 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
962{
963#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
964 ido_init();
965#endif
966
967 static const GtkActionEntry menu_actions[] = {
968 {"About", GTK_STOCK_ABOUT((GtkStock)"gtk-about"), N_("_About")"_About", NULL((void*)0), NULL((void*)0), G_CALLBACK(about_cb)((GCallback) (about_cb))}
969 };
970 static const gchar *menu_xml = "<menuitem name=\"About\" action=\"About\"/>";
971
972 static gboolean first_time = FALSE(0);
973 GtkWidget *menubar;
974 gint indicators_loaded = 0;
975 GtkActionGroup *action_group;
976
977 if (!first_time)
978 {
979 first_time = TRUE(!(0));
980#ifdef INDICATOR_APPLET
981 g_set_application_name(_("Indicator Applet")gettext ("Indicator Applet"));
982#endif
983#ifdef INDICATOR_APPLET_COMPLETE
984 g_set_application_name(_("Indicator Applet Complete")gettext ("Indicator Applet Complete"));
985#endif
986#ifdef INDICATOR_APPLET_APPMENU1
987 g_set_application_name(_("Indicator Applet Application Menu")gettext ("Indicator Applet Application Menu"));
988#endif
989
990 g_log_set_default_handler(log_to_file, NULL((void*)0));
991
992 tomboy_keybinder_init();
993 }
994
995 /* Set panel options */
996 gtk_container_set_border_width(GTK_CONTAINER (applet)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_container_get_type ()))))))
, 0);
997 mate_panel_applet_set_flags(applet, MATE_PANEL_APPLET_EXPAND_MINOR);
998 menubar = gtk_menu_bar_new();
999 action_group = gtk_action_group_new ("Indicator Applet Actions");
1000 gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE"mate-indicator-applet");
1001 gtk_action_group_add_actions (action_group, menu_actions,
1002 G_N_ELEMENTS (menu_actions)(sizeof (menu_actions) / sizeof ((menu_actions)[0])),
1003 menubar);
1004 mate_panel_applet_setup_menu(applet, menu_xml, action_group);
1005 g_object_unref(action_group);
1006#ifdef INDICATOR_APPLET
1007 atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
),
1008 "indicator-applet");
1009#endif
1010#ifdef INDICATOR_APPLET_COMPLETE
1011 atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
),
1012 "indicator-applet-complete");
1013#endif
1014#ifdef INDICATOR_APPLET_APPMENU1
1015 atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
),
1016 "indicator-applet-appmenu");
1017#endif
1018
1019 /* Init some theme/icon stuff */
1020 gtk_icon_theme_append_search_path(gtk_icon_theme_get_default(),
1021 INDICATOR_ICONS_DIR"/usr/share/libindicator/icons/");
1022 /* g_debug("Icons directory: %s", INDICATOR_ICONS_DIR); */
1023 gtk_widget_set_name(GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
, "fast-user-switch-applet");
1024
1025 /* Build menubar */
1026 size = (mate_panel_applet_get_size (applet));
1027 orient = (mate_panel_applet_get_orient(applet));
1028 packdirection = ((orient == MATE_PANEL_APPLET_ORIENT_UP) ||
1029 (orient == MATE_PANEL_APPLET_ORIENT_DOWN)) ?
1030 GTK_PACK_DIRECTION_LTR : GTK_PACK_DIRECTION_TTB;
1031 gtk_menu_bar_set_pack_direction(GTK_MENU_BAR(menubar)((((GtkMenuBar*) g_type_check_instance_cast ((GTypeInstance*)
((menubar)), ((gtk_menu_bar_get_type ()))))))
,
1032 packdirection);
1033 gtk_widget_set_can_focus (menubar, TRUE(!(0)));
1034 gtk_widget_set_name(GTK_WIDGET (menubar)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(menubar)), ((gtk_widget_get_type ()))))))
, "fast-user-switch-menubar");
1035 g_signal_connect(menubar, "button-press-event", G_CALLBACK(menubar_press), NULL)g_signal_connect_data ((menubar), ("button-press-event"), (((
GCallback) (menubar_press))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
;
1036 g_signal_connect_after(menubar, "draw", G_CALLBACK(menubar_on_draw), menubar)g_signal_connect_data ((menubar), ("draw"), (((GCallback) (menubar_on_draw
))), (menubar), ((void*)0), G_CONNECT_AFTER)
;
1037 g_signal_connect(applet, "change-orient",g_signal_connect_data ((applet), ("change-orient"), (((GCallback
) (matepanelapplet_reorient_cb))), (menubar), ((void*)0), (GConnectFlags
) 0)
1038 G_CALLBACK(matepanelapplet_reorient_cb), menubar)g_signal_connect_data ((applet), ("change-orient"), (((GCallback
) (matepanelapplet_reorient_cb))), (menubar), ((void*)0), (GConnectFlags
) 0)
;
1039 gtk_container_set_border_width(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, 0);
1040
1041 /* Add in filter func */
1042 tomboy_keybinder_bind(hotkey_keycode, hotkey_filter, menubar);
1043
1044 load_modules(applet, menubar, &indicators_loaded);
1045#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
1046 load_indicators_from_indicator_files(applet, menubar, &indicators_loaded);
1047#endif
1048
1049 if (indicators_loaded == 0) {
1050 /* A label to allow for click through */
1051 GtkWidget * item = gtk_label_new(_("No Indicators")gettext ("No Indicators"));
1052 mate_panel_applet_set_background_widget(applet, item);
1053 gtk_container_add(GTK_CONTAINER(applet)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_container_get_type ()))))))
, item);
1054 gtk_widget_show(item);
1055 } else {
1056 gtk_container_add(GTK_CONTAINER(applet)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_container_get_type ()))))))
, menubar);
1057 mate_panel_applet_set_background_widget(applet, menubar);
1058 gtk_widget_show(menubar);
1059 }
1060
1061 gtk_widget_show(GTK_WIDGET(applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
);
1062
1063 return TRUE(!(0));
1064
1065}
diff --git a/2020-04-09-113756-6097-1@37cc19e547b1_shadow/report-90b424.html b/2020-04-09-113756-6097-1@37cc19e547b1_shadow/report-90b424.html new file mode 100644 index 0000000..6c38170 --- /dev/null +++ b/2020-04-09-113756-6097-1@37cc19e547b1_shadow/report-90b424.html @@ -0,0 +1,1412 @@ + + + +applet-main.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:applet-main.c
Warning:line 941, column 4
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name applet-main.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -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 -mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -resource-dir /usr/lib64/clang/9.0.1 -D HAVE_CONFIG_H -I . -I .. -D G_LOG_DOMAIN="Indicator-Applet-Appmenu" -D DATADIR="/usr/local/share" -D INDICATOR_DIR="/usr/lib64/indicators3/7/" -D INDICATOR_ICONS_DIR="/usr/share/libindicator/icons/" -D INDICATOR_APPLET_APPMENU -I ./.. -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/fribidi -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gio-unix-2.0 -I /usr/include/libdrm -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-panel-4.0/libmate-panel-applet -I /usr/include/libindicator3-0.4 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/fribidi -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gio-unix-2.0 -I /usr/include/libdrm -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/9.0.1/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdebug-compilation-dir /rootdir/src -ferror-limit 19 -fmessage-length 0 -fobjc-runtime=gcc -fdiagnostics-show-option -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 -o /rootdir/html-report/2020-04-09-113756-6097-1 -x c applet-main.c +
+ + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2A small wrapper utility to load indicators and put them as menu items
3into the mate-panel using it's applet interface.
4
5Copyright 2009-2010 Canonical Ltd.
6
7Authors:
8 Ted Gould <ted@canonical.com>
9
10This program is free software: you can redistribute it and/or modify it
11under the terms of the GNU General Public License version 3, as published
12by the Free Software Foundation.
13
14This program is distributed in the hope that it will be useful, but
15WITHOUT ANY WARRANTY; without even the implied warranties of
16MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
17PURPOSE. See the GNU General Public License for more details.
18
19You should have received a copy of the GNU General Public License along
20with this program. If not, see <http://www.gnu.org/licenses/>.
21*/
22
23#include <stdlib.h>
24#include <string.h>
25#include <config.h>
26#include <glib/gi18n.h>
27#include <mate-panel-applet.h>
28#include <gdk/gdkkeysyms.h>
29#include <gtk/gtk.h>
30
31#if HAVE_UBUNTU_INDICATOR1
32
33#define INDICATOR_SERVICE_APPMENU"libappmenu.so" "libappmenu.so"
34#define INDICATOR_SERVICE_ME"libme.so" "libme.so"
35#define INDICATOR_SERVICE_DATETIME"libdatetime.so" "libdatetime.so"
36
37#define INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu" "com.canonical.indicator.appmenu"
38#define INDICATOR_SERVICE_ME_NG"com.canonical.indicator.me" "com.canonical.indicator.me"
39#define INDICATOR_SERVICE_DATETIME_NG"com.canonical.indicator.datetime" "com.canonical.indicator.datetime"
40
41#include <libindicator/indicator-object.h>
42#endif
43
44#if HAVE_AYATANA_INDICATOR
45
46#define INDICATOR_SERVICE_APPMENU"libappmenu.so" "libayatana-appmenu.so"
47#define INDICATOR_SERVICE_ME"libme.so" "libayatana-me.so"
48#define INDICATOR_SERVICE_DATETIME"libdatetime.so" "libayatana-datetime.so"
49
50#define INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu" "org.ayatana.indicator.appmenu"
51#define INDICATOR_SERVICE_ME_NG"com.canonical.indicator.me" "org.ayatana.indicator.me"
52#define INDICATOR_SERVICE_DATETIME_NG"com.canonical.indicator.datetime" "org.ayatana.indicator.datetime"
53
54#include <libayatana-indicator/indicator-object.h>
55#endif
56
57/* For new style indicators */
58
59#if HAVE_UBUNTU_INDICATOR1 && HAVE_UBUNTU_INDICATOR_NG
60
61#include <libido/libido.h>
62#include <libindicator/indicator-ng.h>
63
64#define INDICATOR_SERVICE_DIR "/usr/share/unity/indicators"
65
66#endif
67
68#if HAVE_AYATANA_INDICATOR && HAVE_AYATANA_INDICATOR_NG
69
70#include <libayatana-ido/libayatana-ido.h>
71#include <libayatana-indicator/indicator-ng.h>
72
73#define INDICATOR_SERVICE_DIR "/usr/share/ayatana/indicators"
74
75#endif
76
77#include "tomboykeybinder.h"
78
79static gchar * indicator_order[] = {
80#if HAVE_UBUNTU_INDICATOR1
81 "libapplication.so",
82 "libmessaging.so",
83 "libsoundmenu.so",
84 "libdatetime.so",
85 "libsession.so",
86#endif
87#if HAVE_AYATANA_INDICATOR
88 "libayatana-application.so",
89 "libayatana-messaging.so",
90 "libayatana-soundmenu.so",
91 "libayatana-datetime.so",
92 "libayatana-session.so",
93#endif
94 NULL((void*)0)
95};
96
97static GtkPackDirection packdirection;
98static MatePanelAppletOrient orient;
99static guint size;
100
101#define MENU_DATA_INDICATOR_OBJECT"indicator-object" "indicator-object"
102#define MENU_DATA_INDICATOR_ENTRY"indicator-entry" "indicator-entry"
103
104#define IO_DATA_ORDER_NUMBER"indicator-order-number" "indicator-order-number"
105
106static gboolean applet_fill_cb (MatePanelApplet * applet, const gchar * iid, gpointer data);
107
108static void update_accessible_desc (IndicatorObjectEntry * entry, GtkWidget * menuitem);
109
110/*************
111 * main
112 * ***********/
113
114#ifdef INDICATOR_APPLET
115MATE_PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletFactory",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
116 PANEL_TYPE_APPLET,int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
117 "indicator-applet",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
118 applet_fill_cb, NULL)int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
;
119#endif
120#ifdef INDICATOR_APPLET_COMPLETE
121MATE_PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletCompleteFactory",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
122 PANEL_TYPE_APPLET,int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
123 "indicator-applet-complete",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
124 applet_fill_cb, NULL)int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
;
125#endif
126#ifdef INDICATOR_APPLET_APPMENU1
127MATE_PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletAppmenuFactory",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
128 PANEL_TYPE_APPLET,int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
129 "indicator-applet-appmenu",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
130 applet_fill_cb, NULL)int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
;
131#endif
132
133/*************
134 * log files
135 * ***********/
136#ifdef INDICATOR_APPLET
137#define LOG_FILE_NAME"indicator-applet-appmenu.log" "indicator-applet.log"
138#endif
139#ifdef INDICATOR_APPLET_COMPLETE
140#define LOG_FILE_NAME"indicator-applet-appmenu.log" "indicator-applet-complete.log"
141#endif
142#ifdef INDICATOR_APPLET_APPMENU1
143#define LOG_FILE_NAME"indicator-applet-appmenu.log" "indicator-applet-appmenu.log"
144#endif
145GOutputStream * log_file = NULL((void*)0);
146
147/*****************
148 * Hotkey support
149 * **************/
150#ifdef INDICATOR_APPLET
151gchar * hotkey_keycode = "<Super>M";
152#endif
153#ifdef INDICATOR_APPLET_SESSION
154gchar * hotkey_keycode = "<Super>S";
155#endif
156#ifdef INDICATOR_APPLET_COMPLETE
157gchar * hotkey_keycode = "<Super>S";
158#endif
159#ifdef INDICATOR_APPLET_APPMENU1
160gchar * hotkey_keycode = "<Super>F1";
161#endif
162
163/********************
164 * Environment Names
165 * *******************/
166#ifdef INDICATOR_APPLET
167#define INDICATOR_SPECIFIC_ENV"indicator-applet-appmenu" "indicator-applet-original"
168#endif
169#ifdef INDICATOR_APPLET_COMPLETE
170#define INDICATOR_SPECIFIC_ENV"indicator-applet-appmenu" "indicator-applet-complete"
171#endif
172#ifdef INDICATOR_APPLET_APPMENU1
173#define INDICATOR_SPECIFIC_ENV"indicator-applet-appmenu" "indicator-applet-appmenu"
174#endif
175
176static const gchar * indicator_env[] = {
177 "indicator-applet",
178 INDICATOR_SPECIFIC_ENV"indicator-applet-appmenu",
179 NULL((void*)0)
180};
181
182/*************
183 * init function
184 * ***********/
185
186static gint
187name2order (const gchar * name) {
188 int i;
189
190 for (i = 0; indicator_order[i] != NULL((void*)0); i++) {
191 if (g_strcmp0(name, indicator_order[i]) == 0) {
192 return i;
193 }
194 }
195
196 return -1;
197}
198
199typedef struct _incoming_position_t incoming_position_t;
200struct _incoming_position_t {
201 gint objposition;
202 gint entryposition;
203 gint menupos;
204 gboolean found;
205};
206
207/* This function helps by determining where in the menu list
208 this new entry should be placed. It compares the objects
209 that they're on, and then the individual entries. Each
210 is progressively more expensive. */
211static void
212place_in_menu (GtkWidget * widget, gpointer user_data)
213{
214 incoming_position_t * position = (incoming_position_t *)user_data;
215 if (position->found) {
216 /* We've already been placed, just finish the foreach */
217 return;
218 }
219
220 IndicatorObject * io = INDICATOR_OBJECT(g_object_get_data(G_OBJECT(widget), MENU_DATA_INDICATOR_OBJECT))((((IndicatorObject*) g_type_check_instance_cast ((GTypeInstance
*) ((g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((widget)), (((GType) ((20) << (2)))
))))), "indicator-object"))), ((indicator_object_get_type ())
)))))
;
221 g_assert(io != NULL)do { if (io != ((void*)0)) ; else g_assertion_message_expr ("Indicator-Applet-Appmenu"
, "applet-main.c", 221, ((const char*) (__func__)), "io != NULL"
); } while (0)
;
222
223 gint objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER))((gint) (glong) (g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
), "indicator-order-number")))
;
224 /* We've already passed it, well, then this is where
225 we should be be. Stop! */
226 if (objposition > position->objposition) {
227 position->found = TRUE(!(0));
228 return;
229 }
230
231 /* The objects don't match yet, keep looking */
232 if (objposition < position->objposition) {
233 position->menupos++;
234 return;
235 }
236
237 /* The objects are the same, let's start looking at entries. */
238 IndicatorObjectEntry * entry = (IndicatorObjectEntry *)g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
239 gint entryposition = indicator_object_get_location(io, entry);
240
241 if (entryposition > position->entryposition) {
242 position->found = TRUE(!(0));
243 return;
244 }
245
246 if (entryposition < position->entryposition) {
247 position->menupos++;
248 return;
249 }
250
251 /* We've got the same object and the same entry. Well,
252 let's just put it right here then. */
253 position->found = TRUE(!(0));
254 return;
255}
256
257static void
258something_shown (GtkWidget * widget, gpointer user_data)
259{
260 GtkWidget * menuitem = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
261 gtk_widget_show(menuitem);
262}
263
264static void
265something_hidden (GtkWidget * widget, gpointer user_data)
266{
267 GtkWidget * menuitem = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
268 gtk_widget_hide(menuitem);
269}
270
271static void
272sensitive_cb (GObject * obj, GParamSpec * pspec, gpointer user_data)
273{
274 g_return_if_fail(GTK_IS_WIDGET(obj))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((obj)); GType __t = ((gtk_widget_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 ("Indicator-Applet-Appmenu",
((const char*) (__func__)), "GTK_IS_WIDGET(obj)"); return; }
} while (0)
;
275 g_return_if_fail(GTK_IS_WIDGET(user_data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((gtk_widget_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 ("Indicator-Applet-Appmenu",
((const char*) (__func__)), "GTK_IS_WIDGET(user_data)"); return
; } } while (0)
;
276
277 gtk_widget_set_sensitive(GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
, gtk_widget_get_sensitive(GTK_WIDGET(obj)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(obj)), ((gtk_widget_get_type ()))))))
));
278 return;
279}
280
281static void
282entry_activated (GtkWidget * widget, gpointer user_data)
283{
284 g_return_if_fail(GTK_IS_WIDGET(widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((gtk_widget_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 ("Indicator-Applet-Appmenu",
((const char*) (__func__)), "GTK_IS_WIDGET(widget)"); return
; } } while (0)
;
285 gpointer pio = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, "indicator");
286 g_return_if_fail(INDICATOR_IS_OBJECT(pio))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((pio)); GType __t = ((indicator_object_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 ("Indicator-Applet-Appmenu",
((const char*) (__func__)), "INDICATOR_IS_OBJECT(pio)"); return
; } } while (0)
;
287 IndicatorObject * io = INDICATOR_OBJECT(pio)((((IndicatorObject*) g_type_check_instance_cast ((GTypeInstance
*) ((pio)), ((indicator_object_get_type ()))))))
;
288
289 return indicator_object_entry_activate(io, (IndicatorObjectEntry *)user_data, gtk_get_current_event_time());
290}
291
292static gboolean
293entry_scrolled (GtkWidget *menuitem, GdkEventScroll *event, gpointer data)
294{
295 IndicatorObject *io = g_object_get_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_OBJECT"indicator-object");
296 IndicatorObjectEntry *entry = g_object_get_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
297
298 g_return_val_if_fail(INDICATOR_IS_OBJECT(io), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((io)); GType __t = ((indicator_object_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 ("Indicator-Applet-Appmenu",
((const char*) (__func__)), "INDICATOR_IS_OBJECT(io)"); return
((0)); } } while (0)
;
299
300 g_signal_emit_by_name (io, "scroll", 1, event->direction);
301 g_signal_emit_by_name (io, "scroll-entry", entry, 1, event->direction);
302 g_signal_emit_by_name (io, INDICATOR_OBJECT_SIGNAL_ENTRY_SCROLLED"entry-scrolled", entry, 1, event->direction);
303
304 return FALSE(0);
305}
306
307static void
308accessible_desc_update_cb (GtkWidget * widget, gpointer userdata)
309{
310 gpointer data = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
311
312 if (data != userdata) {
313 return;
314 }
315
316 IndicatorObjectEntry * entry = (IndicatorObjectEntry *)data;
317 update_accessible_desc(entry, widget);
318}
319
320static void
321accessible_desc_update (IndicatorObject * io, IndicatorObjectEntry * entry, GtkWidget * menubar)
322{
323 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, accessible_desc_update_cb, entry);
324 return;
325}
326
327#define PANEL_PADDING8 8
328static gboolean
329entry_resized (GtkWidget *applet, guint newsize, gpointer data)
330{
331 IndicatorObject *io = (IndicatorObject *)data;
332
333 size = newsize;
334
335 /* Work on the entries */
336 GList * entries = indicator_object_get_entries(io);
337 GList * entry = NULL((void*)0);
338
339 for (entry = entries; entry != NULL((void*)0); entry = g_list_next(entry)((entry) ? (((GList *)(entry))->next) : ((void*)0))) {
340 IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)entry->data;
341 if (entrydata->image != NULL((void*)0)) {
342 /* Resize to fit panel */
343 gtk_image_set_pixel_size (entrydata->image, size - PANEL_PADDING8);
344 }
345 }
346
347 return FALSE(0);
348}
349
350static void
351entry_added (IndicatorObject * io, IndicatorObjectEntry * entry, GtkWidget * menubar)
352{
353 g_debug("Signal: Entry Added");
354 gboolean something_visible = FALSE(0);
355 gboolean something_sensitive = FALSE(0);
356
357 GtkWidget * menuitem = gtk_menu_item_new();
358 GtkWidget * box = (packdirection == GTK_PACK_DIRECTION_LTR) ?
359 gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3) : gtk_box_new(GTK_ORIENTATION_VERTICAL, 3);
360
361 /* Allows indicators to receive mouse scroll event */
362 gtk_widget_add_events(GTK_WIDGET(menuitem)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(menuitem)), ((gtk_widget_get_type ()))))))
, GDK_SCROLL_MASK);
363
364 g_object_set_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "indicator", io);
365 g_object_set_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "box", box);
366
367 g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(entry_activated), entry)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((menuitem)), (((GType) ((20) << (2)
)))))))), ("activate"), (((GCallback) (entry_activated))), (entry
), ((void*)0), (GConnectFlags) 0)
;
368 g_signal_connect(G_OBJECT(menuitem), "scroll-event", G_CALLBACK(entry_scrolled), entry)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((menuitem)), (((GType) ((20) << (2)
)))))))), ("scroll-event"), (((GCallback) (entry_scrolled))),
(entry), ((void*)0), (GConnectFlags) 0)
;
369
370 if (entry->image != NULL((void*)0)) {
371 /* Resize to fit panel */
372 gtk_image_set_pixel_size (entry->image, size - PANEL_PADDING8);
373 gtk_box_pack_start(GTK_BOX(box)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((box
)), ((gtk_box_get_type ()))))))
, GTK_WIDGET(entry->image)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->image)), ((gtk_widget_get_type ()))))))
, FALSE(0), FALSE(0), 1);
374 if (gtk_widget_get_visible(GTK_WIDGET(entry->image)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->image)), ((gtk_widget_get_type ()))))))
)) {
375 something_visible = TRUE(!(0));
376 }
377
378 if (gtk_widget_get_sensitive(GTK_WIDGET(entry->image)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->image)), ((gtk_widget_get_type ()))))))
)) {
379 something_sensitive = TRUE(!(0));
380 }
381
382 g_signal_connect(G_OBJECT(entry->image), "show", G_CALLBACK(something_shown), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), ("show"), (((GCallback) (something_shown))), (menuitem
), ((void*)0), (GConnectFlags) 0)
;
383 g_signal_connect(G_OBJECT(entry->image), "hide", G_CALLBACK(something_hidden), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), ("hide"), (((GCallback) (something_hidden))), (
menuitem), ((void*)0), (GConnectFlags) 0)
;
384
385 g_signal_connect(G_OBJECT(entry->image), "notify::sensitive", G_CALLBACK(sensitive_cb), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), ("notify::sensitive"), (((GCallback) (sensitive_cb
))), (menuitem), ((void*)0), (GConnectFlags) 0)
;
386 }
387 if (entry->label != NULL((void*)0)) {
388 switch(packdirection) {
389 case GTK_PACK_DIRECTION_LTR:
390 gtk_label_set_angle(GTK_LABEL(entry->label)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_label_get_type ()))))))
, 0.0);
391 break;
392 case GTK_PACK_DIRECTION_TTB:
393 gtk_label_set_angle(GTK_LABEL(entry->label)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_label_get_type ()))))))
,
394 (orient == MATE_PANEL_APPLET_ORIENT_LEFT) ?
395 270.0 : 90.0);
396 break;
397 default:
398 break;
399 }
400 gtk_box_pack_start(GTK_BOX(box)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((box
)), ((gtk_box_get_type ()))))))
, GTK_WIDGET(entry->label)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_widget_get_type ()))))))
, FALSE(0), FALSE(0), 1);
401
402 if (gtk_widget_get_visible(GTK_WIDGET(entry->label)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_widget_get_type ()))))))
)) {
403 something_visible = TRUE(!(0));
404 }
405
406 if (gtk_widget_get_sensitive(GTK_WIDGET(entry->label)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_widget_get_type ()))))))
)) {
407 something_sensitive = TRUE(!(0));
408 }
409
410 g_signal_connect(G_OBJECT(entry->label), "show", G_CALLBACK(something_shown), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), ("show"), (((GCallback) (something_shown))), (menuitem
), ((void*)0), (GConnectFlags) 0)
;
411 g_signal_connect(G_OBJECT(entry->label), "hide", G_CALLBACK(something_hidden), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), ("hide"), (((GCallback) (something_hidden))), (
menuitem), ((void*)0), (GConnectFlags) 0)
;
412
413 g_signal_connect(G_OBJECT(entry->label), "notify::sensitive", G_CALLBACK(sensitive_cb), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), ("notify::sensitive"), (((GCallback) (sensitive_cb
))), (menuitem), ((void*)0), (GConnectFlags) 0)
;
414 }
415 gtk_container_add(GTK_CONTAINER(menuitem)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menuitem)), ((gtk_container_get_type ()))))))
, box);
416 gtk_widget_show(box);
417
418 if (entry->menu != NULL((void*)0)) {
419 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem)((((GtkMenuItem*) g_type_check_instance_cast ((GTypeInstance*
) ((menuitem)), ((gtk_menu_item_get_type ()))))))
, GTK_WIDGET(entry->menu)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->menu)), ((gtk_widget_get_type ()))))))
);
420 }
421
422 incoming_position_t position;
423 position.objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER))((gint) (glong) (g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
), "indicator-order-number")))
;
424 position.entryposition = indicator_object_get_location(io, entry);
425 position.menupos = 0;
426 position.found = FALSE(0);
427
428 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, place_in_menu, &position);
429
430 gtk_menu_shell_insert(GTK_MENU_SHELL(menubar)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_menu_shell_get_type ()))))))
, menuitem, position.menupos);
431
432 if (something_visible) {
433 if (entry->accessible_desc != NULL((void*)0)) {
434 update_accessible_desc(entry, menuitem);
435 }
436 gtk_widget_show(menuitem);
437 }
438 gtk_widget_set_sensitive(menuitem, something_sensitive);
439
440 g_object_set_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry", entry);
441 g_object_set_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_OBJECT"indicator-object", io);
442
443 return;
444}
445
446static void
447entry_removed_cb (GtkWidget * widget, gpointer userdata)
448{
449 gpointer data = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
450
451 if (data != userdata) {
452 return;
453 }
454
455 IndicatorObjectEntry * entry = (IndicatorObjectEntry *)data;
456 if (entry->label != NULL((void*)0)) {
457 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(something_shown), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_shown))), (widget
))
;
458 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(something_hidden), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_hidden))), (widget
))
;
459 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(sensitive_cb), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (sensitive_cb))), (widget)
)
;
460 }
461 if (entry->image != NULL((void*)0)) {
462 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(something_shown), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_shown))), (widget
))
;
463 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(something_hidden), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_hidden))), (widget
))
;
464 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(sensitive_cb), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (sensitive_cb))), (widget)
)
;
465 }
466
467 gtk_widget_destroy(widget);
468 return;
469}
470
471static void
472entry_removed (IndicatorObject * io G_GNUC_UNUSED__attribute__((__unused__)), IndicatorObjectEntry * entry,
473 gpointer user_data)
474{
475 g_debug("Signal: Entry Removed");
476
477 gtk_container_foreach(GTK_CONTAINER(user_data)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((gtk_container_get_type ()))))))
, entry_removed_cb, entry);
478
479 return;
480}
481
482static void
483entry_moved_find_cb (GtkWidget * widget, gpointer userdata)
484{
485 gpointer * array = (gpointer *)userdata;
486 if (array[1] != NULL((void*)0)) {
487 return;
488 }
489
490 gpointer data = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
491
492 if (data != array[0]) {
493 return;
494 }
495
496 array[1] = widget;
497 return;
498}
499
500/* Gets called when an entry for an object was moved. */
501static void
502entry_moved (IndicatorObject * io, IndicatorObjectEntry * entry,
503 gint old G_GNUC_UNUSED__attribute__((__unused__)), gint new G_GNUC_UNUSED__attribute__((__unused__)), gpointer user_data)
504{
505 GtkWidget * menubar = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
506
507 gpointer array[2];
508 array[0] = entry;
509 array[1] = NULL((void*)0);
510
511 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, entry_moved_find_cb, array);
512 if (array[1] == NULL((void*)0)) {
513 g_warning("Moving an entry that isn't in our menus.");
514 return;
515 }
516
517 GtkWidget * mi = GTK_WIDGET(array[1])((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(array[1])), ((gtk_widget_get_type ()))))))
;
518 g_object_ref(G_OBJECT(mi)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
mi)), (((GType) ((20) << (2))))))))
);
519 gtk_container_remove(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, mi);
520
521 incoming_position_t position;
522 position.objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER))((gint) (glong) (g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
), "indicator-order-number")))
;
523 position.entryposition = indicator_object_get_location(io, entry);
524 position.menupos = 0;
525 position.found = FALSE(0);
526
527 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, place_in_menu, &position);
528
529 gtk_menu_shell_insert(GTK_MENU_SHELL(menubar)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_menu_shell_get_type ()))))))
, mi, position.menupos);
530 g_object_unref(G_OBJECT(mi)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
mi)), (((GType) ((20) << (2))))))))
);
531
532 return;
533}
534
535static void
536menu_show (IndicatorObject * io, IndicatorObjectEntry * entry,
537 guint32 timestamp, gpointer user_data)
538{
539 GtkWidget * menubar = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
540
541 if (entry == NULL((void*)0)) {
542 /* Close any open menus instead of opening one */
543 GList * entries = indicator_object_get_entries(io);
544 GList * iterator = NULL((void*)0);
545 for (iterator = entries; iterator != NULL((void*)0); iterator = g_list_next(iterator)((iterator) ? (((GList *)(iterator))->next) : ((void*)0))) {
546 IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)iterator->data;
547 gtk_menu_popdown(entrydata->menu);
548 }
549 g_list_free(entries);
550
551 /* And tell the menubar to exit activation mode too */
552 gtk_menu_shell_cancel(GTK_MENU_SHELL(menubar)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_menu_shell_get_type ()))))))
);
553 return;
554 }
555
556 // TODO: do something sensible here
557}
558
559static void
560update_accessible_desc(IndicatorObjectEntry * entry, GtkWidget * menuitem)
561{
562 /* FIXME: We need to deal with the use case where the contents of the
563 label overrides what is found in the atk object's name, or at least
564 orca speaks the label instead of the atk object name.
565 */
566 AtkObject * menuitem_obj = gtk_widget_get_accessible(menuitem);
567 if (menuitem_obj == NULL((void*)0)) {
568 /* Should there be an error printed here? */
569 return;
570 }
571
572 if (entry->accessible_desc != NULL((void*)0)) {
573 atk_object_set_name(menuitem_obj, entry->accessible_desc);
574 } else {
575 atk_object_set_name(menuitem_obj, "");
576 }
577 return;
578}
579
580static void
581load_indicator (MatePanelApplet *applet, GtkWidget * menubar, IndicatorObject *io, const gchar *name)
582{
583 /* Set the environment it's in */
584 indicator_object_set_environment(io, (const GStrv)indicator_env);
585
586 /* Attach the 'name' to the object */
587#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
588 int pos = 5000 - indicator_object_get_position(io);
589 if (pos > 5000) {
590 pos = name2order(name);
591 }
592#else
593 int pos = name2order(name);
594#endif
595
596 g_object_set_data(G_OBJECT(io)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
io)), (((GType) ((20) << (2))))))))
, IO_DATA_ORDER_NUMBER"indicator-order-number", GINT_TO_POINTER(pos)((gpointer) (glong) (pos)));
597
598 /* Connect to its signals */
599 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED, G_CALLBACK(entry_added), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("entry-added"), (((GCallback) (entry_added))), (menubar)
, ((void*)0), (GConnectFlags) 0)
;
600 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED, G_CALLBACK(entry_removed), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("entry-removed"), (((GCallback) (entry_removed))), (menubar
), ((void*)0), (GConnectFlags) 0)
;
601 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_MOVED, G_CALLBACK(entry_moved), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("entry-moved"), (((GCallback) (entry_moved))), (menubar)
, ((void*)0), (GConnectFlags) 0)
;
602 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_MENU_SHOW, G_CALLBACK(menu_show), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("menu-show"), (((GCallback) (menu_show))), (menubar), ((
void*)0), (GConnectFlags) 0)
;
603 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ACCESSIBLE_DESC_UPDATE, G_CALLBACK(accessible_desc_update), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("accessible-desc-update"), (((GCallback) (accessible_desc_update
))), (menubar), ((void*)0), (GConnectFlags) 0)
;
604
605 /* Track panel resize */
606 g_signal_connect_object(G_OBJECT(applet)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
applet)), (((GType) ((20) << (2))))))))
, "change-size", G_CALLBACK(entry_resized)((GCallback) (entry_resized)), G_OBJECT(io)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
io)), (((GType) ((20) << (2))))))))
, 0);
607
608 /* Work on the entries */
609 GList * entries = indicator_object_get_entries(io);
610 GList * entry = NULL((void*)0);
611
612 for (entry = entries; entry != NULL((void*)0); entry = g_list_next(entry)((entry) ? (((GList *)(entry))->next) : ((void*)0))) {
613 IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)entry->data;
614 entry_added(io, entrydata, menubar);
615 }
616
617 g_list_free(entries);
618}
619
620static gboolean
621load_module (const gchar * name, MatePanelApplet *applet, GtkWidget * menubar)
622{
623 g_debug("Looking at Module: %s", name);
624 g_return_val_if_fail(name != NULL, FALSE)do { if ((name != ((void*)0))) { } else { g_return_if_fail_warning
("Indicator-Applet-Appmenu", ((const char*) (__func__)), "name != NULL"
); return ((0)); } } while (0)
;
625
626 if (!g_str_has_suffix(name, G_MODULE_SUFFIX"so")) {
627 return FALSE(0);
628 }
629
630 g_debug("Loading Module: %s", name);
631
632 /* Build the object for the module */
633 gchar * fullpath = g_build_filename(INDICATOR_DIR"/usr/lib64/indicators3/7/", name, NULL((void*)0));
634 IndicatorObject * io = indicator_object_new_from_file(fullpath);
635 g_free(fullpath);
636
637 load_indicator(applet, menubar, io, name);
638
639 return TRUE(!(0));
640}
641
642static void
643load_modules (MatePanelApplet *applet, GtkWidget *menubar, gint *indicators_loaded)
644{
645 if (g_file_test(INDICATOR_DIR"/usr/lib64/indicators3/7/", (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))) {
646 GDir * dir = g_dir_open(INDICATOR_DIR"/usr/lib64/indicators3/7/", 0, NULL((void*)0));
647
648 const gchar * name;
649 gint count = 0;
650 while ((name = g_dir_read_name(dir)) != NULL((void*)0)) {
651#ifdef INDICATOR_APPLET_APPMENU1
652 if (g_strcmp0(name, INDICATOR_SERVICE_APPMENU"libappmenu.so")) {
653 continue;
654 }
655#else
656 if (!g_strcmp0(name, INDICATOR_SERVICE_APPMENU"libappmenu.so")) {
657 continue;
658 }
659#endif
660#ifdef INDICATOR_APPLET
661 if (!g_strcmp0(name, INDICATOR_SERVICE_ME"libme.so")) {
662 continue;
663 }
664 if (!g_strcmp0(name, INDICATOR_SERVICE_DATETIME"libdatetime.so")) {
665 continue;
666 }
667#endif
668 if (load_module(name, applet, menubar)) {
669 count++;
670 }
671 }
672
673 *indicators_loaded += count;
674
675 g_dir_close (dir);
676 }
677}
678
679#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
680
681static void
682load_indicators_from_indicator_files (MatePanelApplet *applet, GtkWidget *menubar, gint *indicators_loaded)
683{
684 GDir *dir;
685 const gchar *name;
686 GError *error = NULL((void*)0);
687
688 dir = g_dir_open (INDICATOR_SERVICE_DIR, 0, &error);
689
690 if (!dir) {
691 g_warning ("unable to open indicator service file directory: %s", error->message);
692 g_error_free (error);
693
694 return;
695 }
696
697 gint count = 0;
698 while ((name = g_dir_read_name (dir))) {
699 gchar *filename;
700 IndicatorNg *indicator;
701
702 filename = g_build_filename (INDICATOR_SERVICE_DIR, name, NULL((void*)0));
703 indicator = indicator_ng_new_for_profile (filename, "desktop", &error);
704 g_free (filename);
705
706#ifdef INDICATOR_APPLET_APPMENU1
707 if (g_strcmp0(name, INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu")) {
708 continue;
709 }
710#else
711 if (!g_strcmp0(name, INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu")) {
712 continue;
713 }
714#endif
715#ifdef INDICATOR_APPLET
716 if (!g_strcmp0(name, INDICATOR_SERVICE_ME_NG"com.canonical.indicator.me")) {
717 continue;
718 }
719 if (!g_strcmp0(name, INDICATOR_SERVICE_DATETIME_NG"com.canonical.indicator.datetime")) {
720 continue;
721 }
722#endif
723
724 if (indicator) {
725 load_indicator(applet, menubar, INDICATOR_OBJECT (indicator)((((IndicatorObject*) g_type_check_instance_cast ((GTypeInstance
*) ((indicator)), ((indicator_object_get_type ()))))))
, name);
726 count++;
727 }else{
728 g_warning ("unable to load '%s': %s", name, error->message);
729 g_clear_error (&error);
730 }
731 }
732
733 *indicators_loaded += count;
734
735 g_dir_close (dir);
736}
737#endif /* HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG */
738
739static void
740hotkey_filter (char * keystring G_GNUC_UNUSED__attribute__((__unused__)), gpointer data)
741{
742 g_return_if_fail(GTK_IS_MENU_SHELL(data))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((data)); GType __t = ((gtk_menu_shell_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 ("Indicator-Applet-Appmenu",
((const char*) (__func__)), "GTK_IS_MENU_SHELL(data)"); return
; } } while (0)
;
743
744 /* Oh, wow, it's us! */
745 GList * children = gtk_container_get_children(GTK_CONTAINER(data)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((gtk_container_get_type ()))))))
);
746 if (children == NULL((void*)0)) {
747 g_debug("Menubar has no children");
748 return;
749 }
750
751 gtk_menu_shell_select_item(GTK_MENU_SHELL(data)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((gtk_menu_shell_get_type ()))))))
, GTK_WIDGET(g_list_last(children)->data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(g_list_last(children)->data)), ((gtk_widget_get_type ()))
))))
);
752 g_list_free(children);
753 return;
754}
755
756static gboolean
757menubar_press (GtkWidget * widget,
758 GdkEventButton *event,
759 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
760{
761 if (event->button != 1) {
762 g_signal_stop_emission_by_name(widget, "button-press-event");
763 }
764
765 return FALSE(0);
766}
767
768static gboolean
769menubar_on_draw (GtkWidget * widget,
770 cairo_t * cr,
771 GtkWidget * menubar)
772{
773 /* FIXME: either port to gtk_render_focus or remove this function */
774 if (gtk_widget_has_focus(menubar))
775 gtk_paint_focus(gtk_widget_get_style(widget),
776 cr,
777 gtk_widget_get_state(menubar),
778 widget, "menubar-applet", 0, 0, -1, -1);
779
780 return FALSE(0);
781}
782
783static void
784about_cb (GtkAction *action G_GNUC_UNUSED__attribute__((__unused__)),
785 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
786{
787 static const gchar *authors[] = {
788 "Ted Gould <ted@canonical.com>",
789 NULL((void*)0)
790 };
791
792 static gchar *license[] = {
793 N_("This program is free software: you can redistribute it and/or modify it ""This program is free software: you can redistribute it and/or modify it "
"under the terms of the GNU General Public License version 3, as published "
"by the Free Software Foundation."
794 "under the terms of the GNU General Public License version 3, as published ""This program is free software: you can redistribute it and/or modify it "
"under the terms of the GNU General Public License version 3, as published "
"by the Free Software Foundation."
795 "by the Free Software Foundation.")"This program is free software: you can redistribute it and/or modify it "
"under the terms of the GNU General Public License version 3, as published "
"by the Free Software Foundation."
,
796 N_("This program is distributed in the hope that it will be useful, but ""This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
797 "WITHOUT ANY WARRANTY; without even the implied warranties of ""This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
798 "MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR ""This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
799 "PURPOSE. See the GNU General Public License for more details.")"This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
,
800 N_("You should have received a copy of the GNU General Public License along ""You should have received a copy of the GNU General Public License along "
"with this program. If not, see <http://www.gnu.org/licenses/>."
801 "with this program. If not, see <http://www.gnu.org/licenses/>.")"You should have received a copy of the GNU General Public License along "
"with this program. If not, see <http://www.gnu.org/licenses/>."
,
802 NULL((void*)0)
803 };
804 gchar *license_i18n;
805
806 license_i18n = g_strconcat (_(license[0])gettext (license[0]), "\n\n", _(license[1])gettext (license[1]), "\n\n", _(license[2])gettext (license[2]), NULL((void*)0));
807
808 gtk_show_about_dialog(NULL((void*)0),
809 "version", VERSION"1.24.0",
810 "copyright", _("Copyright \xc2\xa9 2009-2010 Canonical, Ltd.\n"gettext ("Copyright \xc2\xa9 2009-2010 Canonical, Ltd.\n" "Copyright \xc2\xa9 2011-2020 MATE developers"
)
811 "Copyright \xc2\xa9 2011-2020 MATE developers")gettext ("Copyright \xc2\xa9 2009-2010 Canonical, Ltd.\n" "Copyright \xc2\xa9 2011-2020 MATE developers"
)
,
812#ifdef INDICATOR_APPLET_APPMENU1
813 "comments", _("An applet to hold your application menus.")gettext ("An applet to hold your application menus."),
814#endif
815 "comments", _("An applet to hold all of the system indicators.")gettext ("An applet to hold all of the system indicators."),
816 "authors", authors,
817 "license", license_i18n,
818 "wrap-license", TRUE(!(0)),
819 "translator-credits", _("translator-credits")gettext ("translator-credits"),
820 "logo-icon-name", "mate-indicator-applet",
821 "icon-name", "mate-indicator-applet",
822 "website", "https://mate-desktop.org",
823 "website-label", _("MATE Website")gettext ("MATE Website"),
824 NULL((void*)0)
825 );
826
827 g_free (license_i18n);
828
829 return;
830}
831
832static gboolean
833swap_orient_cb (GtkWidget *item, gpointer data)
834{
835 GtkWidget *from = (GtkWidget *) data;
836 GtkWidget *to = (GtkWidget *) g_object_get_data(G_OBJECT(from)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
from)), (((GType) ((20) << (2))))))))
, "to");
837 g_object_ref(G_OBJECT(item)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
item)), (((GType) ((20) << (2))))))))
);
838 gtk_container_remove(GTK_CONTAINER(from)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((from)), ((gtk_container_get_type ()))))))
, item);
839 if (GTK_IS_LABEL(item)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(item)); GType __t = ((gtk_label_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; }))))
) {
840 switch(packdirection) {
841 case GTK_PACK_DIRECTION_LTR:
842 gtk_label_set_angle(GTK_LABEL(item)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(item)), ((gtk_label_get_type ()))))))
, 0.0);
843 break;
844 case GTK_PACK_DIRECTION_TTB:
845 gtk_label_set_angle(GTK_LABEL(item)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(item)), ((gtk_label_get_type ()))))))
,
846 (orient == MATE_PANEL_APPLET_ORIENT_LEFT) ?
847 270.0 : 90.0);
848 break;
849 default:
850 break;
851 }
852 }
853 gtk_box_pack_start(GTK_BOX(to)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((to
)), ((gtk_box_get_type ()))))))
, item, FALSE(0), FALSE(0), 0);
854 return TRUE(!(0));
855}
856
857static gboolean
858reorient_box_cb (GtkWidget *menuitem, gpointer data)
859{
860 GtkWidget *from = g_object_get_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "box");
861 GtkWidget *to = (packdirection == GTK_PACK_DIRECTION_LTR) ?
862 gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0) : gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
863 g_object_set_data(G_OBJECT(from)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
from)), (((GType) ((20) << (2))))))))
, "to", to);
864 gtk_container_foreach(GTK_CONTAINER(from)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((from)), ((gtk_container_get_type ()))))))
, (GtkCallback)swap_orient_cb,
865 from);
866 gtk_container_remove(GTK_CONTAINER(menuitem)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menuitem)), ((gtk_container_get_type ()))))))
, from);
867 gtk_container_add(GTK_CONTAINER(menuitem)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menuitem)), ((gtk_container_get_type ()))))))
, to);
868 g_object_set_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "box", to);
869 gtk_widget_show_all(menuitem);
870 return TRUE(!(0));
871}
872
873static gboolean
874matepanelapplet_reorient_cb (GtkWidget *applet, MatePanelAppletOrient neworient,
875 gpointer data)
876{
877 GtkWidget *menubar = (GtkWidget *)data;
878 if ((((neworient == MATE_PANEL_APPLET_ORIENT_UP) ||
879 (neworient == MATE_PANEL_APPLET_ORIENT_DOWN)) &&
880 ((orient == MATE_PANEL_APPLET_ORIENT_LEFT) ||
881 (orient == MATE_PANEL_APPLET_ORIENT_RIGHT))) ||
882 (((neworient == MATE_PANEL_APPLET_ORIENT_LEFT) ||
883 (neworient == MATE_PANEL_APPLET_ORIENT_RIGHT)) &&
884 ((orient == MATE_PANEL_APPLET_ORIENT_UP) ||
885 (orient == MATE_PANEL_APPLET_ORIENT_DOWN)))) {
886 packdirection = (packdirection == GTK_PACK_DIRECTION_LTR) ?
887 GTK_PACK_DIRECTION_TTB : GTK_PACK_DIRECTION_LTR;
888 gtk_menu_bar_set_pack_direction(GTK_MENU_BAR(menubar)((((GtkMenuBar*) g_type_check_instance_cast ((GTypeInstance*)
((menubar)), ((gtk_menu_bar_get_type ()))))))
,
889 packdirection);
890 orient = neworient;
891 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
,
892 (GtkCallback)reorient_box_cb, NULL((void*)0));
893 }
894 orient = neworient;
895 return FALSE(0);
896}
897
898#ifdef N_
899#undef N_
900#endif
901#define N_(x)x x
902
903static void
904log_to_file_cb (GObject * source_obj G_GNUC_UNUSED__attribute__((__unused__)),
905 GAsyncResult * result G_GNUC_UNUSED__attribute__((__unused__)), gpointer user_data)
906{
907 g_free(user_data);
908 return;
909}
910
911static void
912log_to_file (const gchar * domain G_GNUC_UNUSED__attribute__((__unused__)),
913 GLogLevelFlags level G_GNUC_UNUSED__attribute__((__unused__)),
914 const gchar * message,
915 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
916{
917 if (log_file == NULL((void*)0)) {
918 GError * error = NULL((void*)0);
919 gchar * filename = g_build_filename(g_get_user_cache_dir(), LOG_FILE_NAME"indicator-applet-appmenu.log", NULL((void*)0));
920 GFile * file = g_file_new_for_path(filename);
921 g_free(filename);
922
923 if (!g_file_test(g_get_user_cache_dir(), G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) {
924 GFile * cachedir = g_file_new_for_path(g_get_user_cache_dir());
925 g_file_make_directory_with_parents(cachedir, NULL((void*)0), &error);
926
927 if (error != NULL((void*)0)) {
928 g_error("Unable to make directory '%s' for log file: %s", g_get_user_cache_dir(), error->message);
929 return;
930 }
931 }
932
933 g_file_delete(file, NULL((void*)0), NULL((void*)0));
934
935 GFileIOStream * io = g_file_create_readwrite(file,
936 G_FILE_CREATE_REPLACE_DESTINATION, /* flags */
937 NULL((void*)0), /* cancelable */
938 &error); /* error */
939 if (error != NULL((void*)0)) {
940 g_error("Unable to replace file: %s", error->message);
941 return;
This statement is never executed
942 }
943
944 log_file = g_io_stream_get_output_stream(G_IO_STREAM(io)((((GIOStream*) g_type_check_instance_cast ((GTypeInstance*) (
(io)), ((g_io_stream_get_type ()))))))
);
945 }
946
947 gchar * outputstring = g_strdup_printf("%s\n", message);
948 g_output_stream_write_async(log_file,
949 outputstring, /* data */
950 strlen(outputstring), /* length */
951 G_PRIORITY_LOW300, /* priority */
952 NULL((void*)0), /* cancelable */
953 log_to_file_cb, /* callback */
954 outputstring); /* data */
955
956 return;
957}
958
959static gboolean
960applet_fill_cb (MatePanelApplet * applet, const gchar * iid G_GNUC_UNUSED__attribute__((__unused__)),
961 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
962{
963#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
964 ido_init();
965#endif
966
967 static const GtkActionEntry menu_actions[] = {
968 {"About", GTK_STOCK_ABOUT((GtkStock)"gtk-about"), N_("_About")"_About", NULL((void*)0), NULL((void*)0), G_CALLBACK(about_cb)((GCallback) (about_cb))}
969 };
970 static const gchar *menu_xml = "<menuitem name=\"About\" action=\"About\"/>";
971
972 static gboolean first_time = FALSE(0);
973 GtkWidget *menubar;
974 gint indicators_loaded = 0;
975 GtkActionGroup *action_group;
976
977 if (!first_time)
978 {
979 first_time = TRUE(!(0));
980#ifdef INDICATOR_APPLET
981 g_set_application_name(_("Indicator Applet")gettext ("Indicator Applet"));
982#endif
983#ifdef INDICATOR_APPLET_COMPLETE
984 g_set_application_name(_("Indicator Applet Complete")gettext ("Indicator Applet Complete"));
985#endif
986#ifdef INDICATOR_APPLET_APPMENU1
987 g_set_application_name(_("Indicator Applet Application Menu")gettext ("Indicator Applet Application Menu"));
988#endif
989
990 g_log_set_default_handler(log_to_file, NULL((void*)0));
991
992 tomboy_keybinder_init();
993 }
994
995 /* Set panel options */
996 gtk_container_set_border_width(GTK_CONTAINER (applet)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_container_get_type ()))))))
, 0);
997 mate_panel_applet_set_flags(applet, MATE_PANEL_APPLET_EXPAND_MINOR);
998 menubar = gtk_menu_bar_new();
999 action_group = gtk_action_group_new ("Indicator Applet Actions");
1000 gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE"mate-indicator-applet");
1001 gtk_action_group_add_actions (action_group, menu_actions,
1002 G_N_ELEMENTS (menu_actions)(sizeof (menu_actions) / sizeof ((menu_actions)[0])),
1003 menubar);
1004 mate_panel_applet_setup_menu(applet, menu_xml, action_group);
1005 g_object_unref(action_group);
1006#ifdef INDICATOR_APPLET
1007 atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
),
1008 "indicator-applet");
1009#endif
1010#ifdef INDICATOR_APPLET_COMPLETE
1011 atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
),
1012 "indicator-applet-complete");
1013#endif
1014#ifdef INDICATOR_APPLET_APPMENU1
1015 atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
),
1016 "indicator-applet-appmenu");
1017#endif
1018
1019 /* Init some theme/icon stuff */
1020 gtk_icon_theme_append_search_path(gtk_icon_theme_get_default(),
1021 INDICATOR_ICONS_DIR"/usr/share/libindicator/icons/");
1022 /* g_debug("Icons directory: %s", INDICATOR_ICONS_DIR); */
1023 gtk_widget_set_name(GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
, "fast-user-switch-applet");
1024
1025 /* Build menubar */
1026 size = (mate_panel_applet_get_size (applet));
1027 orient = (mate_panel_applet_get_orient(applet));
1028 packdirection = ((orient == MATE_PANEL_APPLET_ORIENT_UP) ||
1029 (orient == MATE_PANEL_APPLET_ORIENT_DOWN)) ?
1030 GTK_PACK_DIRECTION_LTR : GTK_PACK_DIRECTION_TTB;
1031 gtk_menu_bar_set_pack_direction(GTK_MENU_BAR(menubar)((((GtkMenuBar*) g_type_check_instance_cast ((GTypeInstance*)
((menubar)), ((gtk_menu_bar_get_type ()))))))
,
1032 packdirection);
1033 gtk_widget_set_can_focus (menubar, TRUE(!(0)));
1034 gtk_widget_set_name(GTK_WIDGET (menubar)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(menubar)), ((gtk_widget_get_type ()))))))
, "fast-user-switch-menubar");
1035 g_signal_connect(menubar, "button-press-event", G_CALLBACK(menubar_press), NULL)g_signal_connect_data ((menubar), ("button-press-event"), (((
GCallback) (menubar_press))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
;
1036 g_signal_connect_after(menubar, "draw", G_CALLBACK(menubar_on_draw), menubar)g_signal_connect_data ((menubar), ("draw"), (((GCallback) (menubar_on_draw
))), (menubar), ((void*)0), G_CONNECT_AFTER)
;
1037 g_signal_connect(applet, "change-orient",g_signal_connect_data ((applet), ("change-orient"), (((GCallback
) (matepanelapplet_reorient_cb))), (menubar), ((void*)0), (GConnectFlags
) 0)
1038 G_CALLBACK(matepanelapplet_reorient_cb), menubar)g_signal_connect_data ((applet), ("change-orient"), (((GCallback
) (matepanelapplet_reorient_cb))), (menubar), ((void*)0), (GConnectFlags
) 0)
;
1039 gtk_container_set_border_width(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, 0);
1040
1041 /* Add in filter func */
1042 tomboy_keybinder_bind(hotkey_keycode, hotkey_filter, menubar);
1043
1044 load_modules(applet, menubar, &indicators_loaded);
1045#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
1046 load_indicators_from_indicator_files(applet, menubar, &indicators_loaded);
1047#endif
1048
1049 if (indicators_loaded == 0) {
1050 /* A label to allow for click through */
1051 GtkWidget * item = gtk_label_new(_("No Indicators")gettext ("No Indicators"));
1052 mate_panel_applet_set_background_widget(applet, item);
1053 gtk_container_add(GTK_CONTAINER(applet)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_container_get_type ()))))))
, item);
1054 gtk_widget_show(item);
1055 } else {
1056 gtk_container_add(GTK_CONTAINER(applet)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_container_get_type ()))))))
, menubar);
1057 mate_panel_applet_set_background_widget(applet, menubar);
1058 gtk_widget_show(menubar);
1059 }
1060
1061 gtk_widget_show(GTK_WIDGET(applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
);
1062
1063 return TRUE(!(0));
1064
1065}
diff --git a/2020-04-09-113756-6097-1@37cc19e547b1_shadow/scanview.css b/2020-04-09-113756-6097-1@37cc19e547b1_shadow/scanview.css new file mode 100644 index 0000000..cf8a5a6 --- /dev/null +++ b/2020-04-09-113756-6097-1@37cc19e547b1_shadow/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/2020-04-09-113756-6097-1@37cc19e547b1_shadow/sorttable.js b/2020-04-09-113756-6097-1@37cc19e547b1_shadow/sorttable.js new file mode 100644 index 0000000..32faa07 --- /dev/null +++ b/2020-04-09-113756-6097-1@37cc19e547b1_shadow/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(" + + + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
/* eggaccelerators.c
+ * Copyright (C) 2002  Red Hat, Inc.; Copyright 1998, 2001 Tim Janik
+ * Developed by Havoc Pennington, Tim Janik
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
+ */
+
+#include "eggaccelerators.h"
+
+#include <string.h>
+#include <gdk/gdkx.h>
+#include <gdk/gdkkeysyms.h>
+
+enum
+{
+  EGG_MODMAP_ENTRY_SHIFT   = 0,
+  EGG_MODMAP_ENTRY_LOCK    = 1,
+  EGG_MODMAP_ENTRY_CONTROL = 2,
+  EGG_MODMAP_ENTRY_MOD1    = 3,
+  EGG_MODMAP_ENTRY_MOD2    = 4,
+  EGG_MODMAP_ENTRY_MOD3    = 5,
+  EGG_MODMAP_ENTRY_MOD4    = 6,
+  EGG_MODMAP_ENTRY_MOD5    = 7,
+  EGG_MODMAP_ENTRY_LAST    = 8
+};
+
+#define MODMAP_ENTRY_TO_MODIFIER(x) (1 << (x))
+
+typedef struct
+{
+  EggVirtualModifierType mapping[EGG_MODMAP_ENTRY_LAST];
+
+} EggModmap;
+
+const EggModmap* egg_keymap_get_modmap (GdkKeymap *keymap);
+
+static inline gboolean
+is_alt (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'a' || string[1] == 'A') &&
+	  (string[2] == 'l' || string[2] == 'L') &&
+	  (string[3] == 't' || string[3] == 'T') &&
+	  (string[4] == '>'));
+}
+
+static inline gboolean
+is_ctl (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'c' || string[1] == 'C') &&
+	  (string[2] == 't' || string[2] == 'T') &&
+	  (string[3] == 'l' || string[3] == 'L') &&
+	  (string[4] == '>'));
+}
+
+static inline gboolean
+is_modx (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'm' || string[1] == 'M') &&
+	  (string[2] == 'o' || string[2] == 'O') &&
+	  (string[3] == 'd' || string[3] == 'D') &&
+	  (string[4] >= '1' && string[4] <= '5') &&
+	  (string[5] == '>'));
+}
+
+static inline gboolean
+is_ctrl (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'c' || string[1] == 'C') &&
+	  (string[2] == 't' || string[2] == 'T') &&
+	  (string[3] == 'r' || string[3] == 'R') &&
+	  (string[4] == 'l' || string[4] == 'L') &&
+	  (string[5] == '>'));
+}
+
+static inline gboolean
+is_shft (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 's' || string[1] == 'S') &&
+	  (string[2] == 'h' || string[2] == 'H') &&
+	  (string[3] == 'f' || string[3] == 'F') &&
+	  (string[4] == 't' || string[4] == 'T') &&
+	  (string[5] == '>'));
+}
+
+static inline gboolean
+is_shift (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 's' || string[1] == 'S') &&
+	  (string[2] == 'h' || string[2] == 'H') &&
+	  (string[3] == 'i' || string[3] == 'I') &&
+	  (string[4] == 'f' || string[4] == 'F') &&
+	  (string[5] == 't' || string[5] == 'T') &&
+	  (string[6] == '>'));
+}
+
+static inline gboolean
+is_control (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'c' || string[1] == 'C') &&
+	  (string[2] == 'o' || string[2] == 'O') &&
+	  (string[3] == 'n' || string[3] == 'N') &&
+	  (string[4] == 't' || string[4] == 'T') &&
+	  (string[5] == 'r' || string[5] == 'R') &&
+	  (string[6] == 'o' || string[6] == 'O') &&
+	  (string[7] == 'l' || string[7] == 'L') &&
+	  (string[8] == '>'));
+}
+
+static inline gboolean
+is_release (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'r' || string[1] == 'R') &&
+	  (string[2] == 'e' || string[2] == 'E') &&
+	  (string[3] == 'l' || string[3] == 'L') &&
+	  (string[4] == 'e' || string[4] == 'E') &&
+	  (string[5] == 'a' || string[5] == 'A') &&
+	  (string[6] == 's' || string[6] == 'S') &&
+	  (string[7] == 'e' || string[7] == 'E') &&
+	  (string[8] == '>'));
+}
+
+static inline gboolean
+is_meta (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'm' || string[1] == 'M') &&
+	  (string[2] == 'e' || string[2] == 'E') &&
+	  (string[3] == 't' || string[3] == 'T') &&
+	  (string[4] == 'a' || string[4] == 'A') &&
+	  (string[5] == '>'));
+}
+
+static inline gboolean
+is_super (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 's' || string[1] == 'S') &&
+	  (string[2] == 'u' || string[2] == 'U') &&
+	  (string[3] == 'p' || string[3] == 'P') &&
+	  (string[4] == 'e' || string[4] == 'E') &&
+	  (string[5] == 'r' || string[5] == 'R') &&
+	  (string[6] == '>'));
+}
+
+static inline gboolean
+is_hyper (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'h' || string[1] == 'H') &&
+	  (string[2] == 'y' || string[2] == 'Y') &&
+	  (string[3] == 'p' || string[3] == 'P') &&
+	  (string[4] == 'e' || string[4] == 'E') &&
+	  (string[5] == 'r' || string[5] == 'R') &&
+	  (string[6] == '>'));
+}
+
+/**
+ * egg_accelerator_parse_virtual:
+ * @accelerator:      string representing an accelerator
+ * @accelerator_key:  return location for accelerator keyval
+ * @accelerator_mods: return location for accelerator modifier mask
+ *
+ * Parses a string representing a virtual accelerator. The format
+ * looks like "&lt;Control&gt;a" or "&lt;Shift&gt;&lt;Alt&gt;F1" or
+ * "&lt;Release&gt;z" (the last one is for key release).  The parser
+ * is fairly liberal and allows lower or upper case, and also
+ * abbreviations such as "&lt;Ctl&gt;" and "&lt;Ctrl&gt;".
+ *
+ * If the parse fails, @accelerator_key and @accelerator_mods will
+ * be set to 0 (zero) and %FALSE will be returned. If the string contains
+ * only modifiers, @accelerator_key will be set to 0 but %TRUE will be
+ * returned.
+ *
+ * The virtual vs. concrete accelerator distinction is a relic of
+ * how the X Window System works; there are modifiers Mod2-Mod5 that
+ * can represent various keyboard keys (numlock, meta, hyper, etc.),
+ * the virtual modifier represents the keyboard key, the concrete
+ * modifier the actual Mod2-Mod5 bits in the key press event.
+ *
+ * Returns: %TRUE on success.
+ */
+gboolean
+egg_accelerator_parse_virtual (const gchar            *accelerator,
+                               guint                  *accelerator_key,
+                               EggVirtualModifierType *accelerator_mods)
+{
+  guint keyval;
+  GdkModifierType mods;
+  gint len;
+  gboolean bad_keyval;
+
+  if (accelerator_key)
+    *accelerator_key = 0;
+  if (accelerator_mods)
+    *accelerator_mods = 0;
+
+  g_return_val_if_fail (accelerator != NULL, FALSE);
+
+  bad_keyval = FALSE;
+
+  keyval = 0;
+  mods = 0;
+  len = strlen (accelerator);
+  while (len)
+    {
+      if (*accelerator == '<')
+	{
+	  if (len >= 9 && is_release (accelerator))
+	    {
+	      accelerator += 9;
+	      len -= 9;
+	      mods |= EGG_VIRTUAL_RELEASE_MASK;
+	    }
+	  else if (len >= 9 && is_control (accelerator))
+	    {
+	      accelerator += 9;
+	      len -= 9;
+	      mods |= EGG_VIRTUAL_CONTROL_MASK;
+	    }
+	  else if (len >= 7 && is_shift (accelerator))
+	    {
+	      accelerator += 7;
+	      len -= 7;
+	      mods |= EGG_VIRTUAL_SHIFT_MASK;
+	    }
+	  else if (len >= 6 && is_shft (accelerator))
+	    {
+	      accelerator += 6;
+	      len -= 6;
+	      mods |= EGG_VIRTUAL_SHIFT_MASK;
+	    }
+	  else if (len >= 6 && is_ctrl (accelerator))
+	    {
+	      accelerator += 6;
+	      len -= 6;
+	      mods |= EGG_VIRTUAL_CONTROL_MASK;
+	    }
+	  else if (len >= 6 && is_modx (accelerator))
+	    {
+	      static const guint mod_vals[] = {
+		EGG_VIRTUAL_ALT_MASK, EGG_VIRTUAL_MOD2_MASK, EGG_VIRTUAL_MOD3_MASK,
+		EGG_VIRTUAL_MOD4_MASK, EGG_VIRTUAL_MOD5_MASK
+	      };
+
+	      len -= 6;
+	      accelerator += 4;
+	      mods |= mod_vals[*accelerator - '1'];
+	      accelerator += 2;
+	    }
+	  else if (len >= 5 && is_ctl (accelerator))
+	    {
+	      accelerator += 5;
+	      len -= 5;
+	      mods |= EGG_VIRTUAL_CONTROL_MASK;
+	    }
+	  else if (len >= 5 && is_alt (accelerator))
+	    {
+	      accelerator += 5;
+	      len -= 5;
+	      mods |= EGG_VIRTUAL_ALT_MASK;
+	    }
+          else if (len >= 6 && is_meta (accelerator))
+	    {
+	      accelerator += 6;
+	      len -= 6;
+	      mods |= EGG_VIRTUAL_META_MASK;
+	    }
+          else if (len >= 7 && is_hyper (accelerator))
+	    {
+	      accelerator += 7;
+	      len -= 7;
+	      mods |= EGG_VIRTUAL_HYPER_MASK;
+	    }
+          else if (len >= 7 && is_super (accelerator))
+	    {
+	      accelerator += 7;
+	      len -= 7;
+	      mods |= EGG_VIRTUAL_SUPER_MASK;
+	    }
+	  else
+	    {
+	      gchar last_ch;
+
+	      last_ch = *accelerator;
+	      while (last_ch && last_ch != '>')
+		{
+		  last_ch = *accelerator;
+		  accelerator += 1;
+		  len -= 1;
+		}
+	    }
+	}
+      else
+	{
+          keyval = gdk_keyval_from_name (accelerator);
+
+          if (keyval == 0)
+            bad_keyval = TRUE;
+
+          accelerator += len;
+          len -= len;
+	}
+    }
+
+  if (accelerator_key)
+    *accelerator_key = gdk_keyval_to_lower (keyval);
+  if (accelerator_mods)
+    *accelerator_mods = mods;
+
+  return !bad_keyval;
+}
+
+void
+egg_keymap_resolve_virtual_modifiers (GdkKeymap              *keymap,
+                                      EggVirtualModifierType  virtual_mods,
+                                      GdkModifierType        *concrete_mods)
+{
+  GdkModifierType concrete;
+  int i;
+  const EggModmap *modmap;
+
+  g_return_if_fail (GDK_IS_KEYMAP (keymap));
+  g_return_if_fail (concrete_mods != NULL);
+
+  modmap = egg_keymap_get_modmap (keymap);
+
+  /* Not so sure about this algorithm. */
+
+  concrete = 0;
+  i = 0;
+  while (i < EGG_MODMAP_ENTRY_LAST)
+    {
+      if (modmap->mapping[i] & virtual_mods)
+        concrete |= (1 << i);
+
+      ++i;
+    }
+
+  *concrete_mods = concrete;
+}
+
+void
+egg_keymap_virtualize_modifiers (GdkKeymap              *keymap,
+                                 GdkModifierType         concrete_mods,
+                                 EggVirtualModifierType *virtual_mods)
+{
+  GdkModifierType virtual;
+  int i;
+  const EggModmap *modmap;
+
+  g_return_if_fail (GDK_IS_KEYMAP (keymap));
+  g_return_if_fail (virtual_mods != NULL);
+
+  modmap = egg_keymap_get_modmap (keymap);
+
+  /* Not so sure about this algorithm. */
+
+  virtual = 0;
+  i = 0;
+  while (i < EGG_MODMAP_ENTRY_LAST)
+    {
+      if ((1 << i) & concrete_mods)
+        {
+          EggVirtualModifierType cleaned;
+
+          cleaned = modmap->mapping[i] & ~(EGG_VIRTUAL_MOD2_MASK |
+                                           EGG_VIRTUAL_MOD3_MASK |
+                                           EGG_VIRTUAL_MOD4_MASK |
+                                           EGG_VIRTUAL_MOD5_MASK);
+
+          if (cleaned != 0)
+            {
+              virtual |= cleaned;
+            }
+          else
+            {
+              /* Rather than dropping mod2->mod5 if not bound,
+               * go ahead and use the concrete names
+               */
+              virtual |= modmap->mapping[i];
+            }
+        }
+
+      ++i;
+    }
+
+  *virtual_mods = virtual;
+}
+
+static void
+reload_modmap (GdkKeymap *keymap,
+               EggModmap *modmap)
+{
+  XModifierKeymap *xmodmap;
+  int map_size;
+  int i;
+
+  /* FIXME multihead */
+  xmodmap = XGetModifierMapping (gdk_x11_get_default_xdisplay ());
+
+  memset (modmap->mapping, 0, sizeof (modmap->mapping));
+
+  /* there are 8 modifiers, and the first 3 are shift, shift lock,
+   * and control
+   */
+  map_size = 8 * xmodmap->max_keypermod;
+  i = 3 * xmodmap->max_keypermod;
+  while (i < map_size)
+    {
+      /* get the key code at this point in the map,
+       * see if its keysym is one we're interested in
+       */
+      int keycode = xmodmap->modifiermap[i];
+      GdkKeymapKey *keys;
+      guint *keyvals;
+      int n_entries;
+      int j;
+      EggVirtualModifierType mask;
+
+      keys = NULL;
+      keyvals = NULL;
+      n_entries = 0;
+
+      gdk_keymap_get_entries_for_keycode (keymap,
+                                          keycode,
+                                          &keys, &keyvals, &n_entries);
+
+      mask = 0;
+      j = 0;
+      while (j < n_entries)
+        {
+          if (keyvals[j] == GDK_KEY_Num_Lock)
+            mask |= EGG_VIRTUAL_NUM_LOCK_MASK;
+          else if (keyvals[j] == GDK_KEY_Scroll_Lock)
+            mask |= EGG_VIRTUAL_SCROLL_LOCK_MASK;
+          else if (keyvals[j] == GDK_KEY_Meta_L ||
+                   keyvals[j] == GDK_KEY_Meta_R)
+            mask |= EGG_VIRTUAL_META_MASK;
+          else if (keyvals[j] == GDK_KEY_Hyper_L ||
+                   keyvals[j] == GDK_KEY_Hyper_R)
+            mask |= EGG_VIRTUAL_HYPER_MASK;
+          else if (keyvals[j] == GDK_KEY_Super_L ||
+                   keyvals[j] == GDK_KEY_Super_R)
+            mask |= EGG_VIRTUAL_SUPER_MASK;
+          else if (keyvals[j] == GDK_KEY_Mode_switch)
+            mask |= EGG_VIRTUAL_MODE_SWITCH_MASK;
+
+          ++j;
+        }
+
+      /* Mod1Mask is 1 << 3 for example, i.e. the
+       * fourth modifier, i / keyspermod is the modifier
+       * index
+       */
+      modmap->mapping[i/xmodmap->max_keypermod] |= mask;
+
+      g_free (keyvals);
+      g_free (keys);
+
+      ++i;
+    }
+
+  /* Add in the not-really-virtual fixed entries */
+  modmap->mapping[EGG_MODMAP_ENTRY_SHIFT] |= EGG_VIRTUAL_SHIFT_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_CONTROL] |= EGG_VIRTUAL_CONTROL_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_LOCK] |= EGG_VIRTUAL_LOCK_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD1] |= EGG_VIRTUAL_ALT_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD2] |= EGG_VIRTUAL_MOD2_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD3] |= EGG_VIRTUAL_MOD3_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD4] |= EGG_VIRTUAL_MOD4_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD5] |= EGG_VIRTUAL_MOD5_MASK;
+
+  XFreeModifiermap (xmodmap);
+}
+
+const EggModmap*
+egg_keymap_get_modmap (GdkKeymap *keymap)
+{
+  EggModmap *modmap;
+
+  /* This is all a hack, much simpler when we can just
+   * modify GDK directly.
+   */
+
+  modmap = g_object_get_data (G_OBJECT (keymap),
+                              "egg-modmap");
+
+  if (modmap == NULL)
+    {
+      modmap = g_new0 (EggModmap, 1);
+
+      /* FIXME modify keymap change events with an event filter
+       * and force a reload if we get one
+       */
+
+      reload_modmap (keymap, modmap);
+
+      g_object_set_data_full (G_OBJECT (keymap),
+                              "egg-modmap",
+                              modmap,
+                              g_free);
+    }
+
+  g_assert (modmap != NULL);
+
+  return modmap;
+}
+
+
+
+ + + diff --git a/2020-04-09-113822-7129-cppcheck@37cc19e547b1_shadow/index.html b/2020-04-09-113822-7129-cppcheck@37cc19e547b1_shadow/index.html new file mode 100644 index 0000000..812f8b5 --- /dev/null +++ b/2020-04-09-113822-7129-cppcheck@37cc19e547b1_shadow/index.html @@ -0,0 +1,101 @@ + + + + + + Cppcheck - HTML report - mate-indicator-applet + + + + + + + +
+ + + + + + + +
LineIdCWESeverityMessage
0missingIncludeSysteminformationCppcheck cannot find all the include files (use --check-config for details)
src/eggaccelerators.c
321duplicateExpression398styleSame expression on both sides of '-='.
+
+ + + diff --git a/2020-04-09-113822-7129-cppcheck@37cc19e547b1_shadow/stats.html b/2020-04-09-113822-7129-cppcheck@37cc19e547b1_shadow/stats.html new file mode 100644 index 0000000..14ae0d4 --- /dev/null +++ b/2020-04-09-113822-7129-cppcheck@37cc19e547b1_shadow/stats.html @@ -0,0 +1,89 @@ + + + + + + Cppcheck - HTML report - mate-indicator-applet + + + + + + + +
+

Top 10 files for style severity, total findings: 1
+   1  src/eggaccelerators.c
+

+ +
+ + + diff --git a/2020-04-09-113822-7129-cppcheck@37cc19e547b1_shadow/style.css b/2020-04-09-113822-7129-cppcheck@37cc19e547b1_shadow/style.css new file mode 100644 index 0000000..c39571c --- /dev/null +++ b/2020-04-09-113822-7129-cppcheck@37cc19e547b1_shadow/style.css @@ -0,0 +1,149 @@ + +body { + font: 13px Arial, Verdana, Sans-Serif; + margin: 0; + width: auto; +} + +h1 { + margin: 10px; +} + +#footer > p { + margin: 4px; +} + +.error { + background-color: #ffb7b7; +} + +.error2 { + background-color: #faa; + border: 1px dotted black; + display: inline-block; + margin-left: 4px; +} + +.inconclusive { + background-color: #B6B6B4; +} + +.inconclusive2 { + background-color: #B6B6B4; + border: 1px dotted black; + display: inline-block; + margin-left: 4px; +} + +div.verbose { + display: inline-block; + vertical-align: top; + cursor: help; +} + +div.verbose div.content { + display: none; + position: absolute; + padding: 10px; + margin: 4px; + max-width: 40%; + white-space: pre-wrap; + border: 1px solid black; + background-color: #FFFFCC; + cursor: auto; +} + +.highlight .hll { + padding: 1px; +} + +#header { + border-bottom: thin solid #aaa; +} + +#menu { + float: left; + margin-top: 5px; + text-align: left; + width: 150px; + /*height: 75%;*/ + position: fixed; + overflow: auto; + z-index: 1; +} + +#menu_index { + float: left; + margin-top: 5px; + padding-left: 5px; + text-align: left; + width: 300px; + /*height: 75%;*/ + position: fixed; + overflow: auto; + z-index: 1; +} + +#menu > a { + display: block; + margin-left: 10px; + font: 12px; + z-index: 1; +} + +#filename { + margin-left: 10px; + font: 12px; + z-index: 1; +} + +.highlighttable { + background-color:white; + z-index: 10; + position: relative; + margin: -10 px; +} + +#content { + background-color: white; + -webkit-box-sizing: content-box; + -moz-box-sizing: content-box; + box-sizing: content-box; + float: left; + margin: 5px; + margin-left: 10px; + padding: 0 10px 10px 10px; + width: 80%; + padding-left: 150px; +} + +#content_index { + background-color: white; + -webkit-box-sizing: content-box; + -moz-box-sizing: content-box; + box-sizing: content-box; + float: left; + margin: 5px; + margin-left: 10px; + padding: 0 10px 10px 10px; + width: 80%; + padding-left: 300px; +} + +.linenos { + border-right: thin solid #aaa; + color: lightgray; + padding-right: 6px; +} + +#footer { + border-top: thin solid #aaa; + clear: both; + font-size: 90%; + margin-top: 5px; +} + +#footer ul { + list-style-type: none; + padding-left: 0; +} diff --git a/2020-04-09-123617-6853-1@4b55003793c9_master/index.html b/2020-04-09-123617-6853-1@4b55003793c9_master/index.html new file mode 100644 index 0000000..18081c1 --- /dev/null +++ b/2020-04-09-123617-6853-1@4b55003793c9_master/index.html @@ -0,0 +1,109 @@ + + +rootdir - scan-build results + + + + + + +

rootdir - scan-build results

+ + + + + + + +
User:root@a208dbfd09ca
Working Directory:/rootdir
Command Line:make -j 2
Clang Version:clang version 9.0.1 (Fedora 9.0.1-2.fc31) +
Date:Thu Apr 9 12:36:17 2020
+

Bug Summary

+ + + + +
Bug TypeQuantityDisplay?
All Bugs6
Dead code
Unreachable code6
+

Reports

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Bug GroupBug Type ▾FileFunction/MethodLinePath Length
Dead codeUnreachable codeapplet-main.clog_to_file9411View Report
Dead codeUnreachable codeapplet-main.clog_to_file9291View Report
Dead codeUnreachable codeapplet-main.clog_to_file9291View Report
Dead codeUnreachable codeapplet-main.clog_to_file9291View Report
Dead codeUnreachable codeapplet-main.clog_to_file9411View Report
Dead codeUnreachable codeapplet-main.clog_to_file9411View Report
+ + diff --git a/2020-04-09-123617-6853-1@4b55003793c9_master/report-207019.html b/2020-04-09-123617-6853-1@4b55003793c9_master/report-207019.html new file mode 100644 index 0000000..f6e97a3 --- /dev/null +++ b/2020-04-09-123617-6853-1@4b55003793c9_master/report-207019.html @@ -0,0 +1,1412 @@ + + + +applet-main.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:applet-main.c
Warning:line 941, column 4
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name applet-main.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -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 -mrelocation-model static -mthread-model posix -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -momit-leaf-frame-pointer -resource-dir /usr/lib64/clang/9.0.1 -D HAVE_CONFIG_H -I . -I .. -D G_LOG_DOMAIN="Indicator-Applet-Complete" -D DATADIR="/usr/local/share" -D INDICATOR_DIR="/usr/lib64/indicators3/7/" -D INDICATOR_ICONS_DIR="/usr/share/libindicator/icons/" -D INDICATOR_APPLET_COMPLETE -I ./.. -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/fribidi -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gio-unix-2.0 -I /usr/include/libdrm -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-panel-4.0/libmate-panel-applet -I /usr/include/libindicator3-0.4 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/fribidi -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gio-unix-2.0 -I /usr/include/libdrm -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/9.0.1/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wno-unused-parameter -Wno-sign-compare -fdebug-compilation-dir /rootdir/src -ferror-limit 19 -fmessage-length 0 -fobjc-runtime=gcc -fdiagnostics-show-option -vectorize-loops -vectorize-slp -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 -o /rootdir/html-report/2020-04-09-123617-6853-1 -x c applet-main.c +
+ + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2A small wrapper utility to load indicators and put them as menu items
3into the mate-panel using it's applet interface.
4
5Copyright 2009-2010 Canonical Ltd.
6
7Authors:
8 Ted Gould <ted@canonical.com>
9
10This program is free software: you can redistribute it and/or modify it
11under the terms of the GNU General Public License version 3, as published
12by the Free Software Foundation.
13
14This program is distributed in the hope that it will be useful, but
15WITHOUT ANY WARRANTY; without even the implied warranties of
16MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
17PURPOSE. See the GNU General Public License for more details.
18
19You should have received a copy of the GNU General Public License along
20with this program. If not, see <http://www.gnu.org/licenses/>.
21*/
22
23#include <stdlib.h>
24#include <string.h>
25#include <config.h>
26#include <glib/gi18n.h>
27#include <mate-panel-applet.h>
28#include <gdk/gdkkeysyms.h>
29#include <gtk/gtk.h>
30
31#if HAVE_UBUNTU_INDICATOR1
32
33#define INDICATOR_SERVICE_APPMENU"libappmenu.so" "libappmenu.so"
34#define INDICATOR_SERVICE_ME"libme.so" "libme.so"
35#define INDICATOR_SERVICE_DATETIME"libdatetime.so" "libdatetime.so"
36
37#define INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu" "com.canonical.indicator.appmenu"
38#define INDICATOR_SERVICE_ME_NG"com.canonical.indicator.me" "com.canonical.indicator.me"
39#define INDICATOR_SERVICE_DATETIME_NG"com.canonical.indicator.datetime" "com.canonical.indicator.datetime"
40
41#include <libindicator/indicator-object.h>
42#endif
43
44#if HAVE_AYATANA_INDICATOR
45
46#define INDICATOR_SERVICE_APPMENU"libappmenu.so" "libayatana-appmenu.so"
47#define INDICATOR_SERVICE_ME"libme.so" "libayatana-me.so"
48#define INDICATOR_SERVICE_DATETIME"libdatetime.so" "libayatana-datetime.so"
49
50#define INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu" "org.ayatana.indicator.appmenu"
51#define INDICATOR_SERVICE_ME_NG"com.canonical.indicator.me" "org.ayatana.indicator.me"
52#define INDICATOR_SERVICE_DATETIME_NG"com.canonical.indicator.datetime" "org.ayatana.indicator.datetime"
53
54#include <libayatana-indicator/indicator-object.h>
55#endif
56
57/* For new style indicators */
58
59#if HAVE_UBUNTU_INDICATOR1 && HAVE_UBUNTU_INDICATOR_NG
60
61#include <libido/libido.h>
62#include <libindicator/indicator-ng.h>
63
64#define INDICATOR_SERVICE_DIR "/usr/share/unity/indicators"
65
66#endif
67
68#if HAVE_AYATANA_INDICATOR && HAVE_AYATANA_INDICATOR_NG
69
70#include <libayatana-ido/libayatana-ido.h>
71#include <libayatana-indicator/indicator-ng.h>
72
73#define INDICATOR_SERVICE_DIR "/usr/share/ayatana/indicators"
74
75#endif
76
77#include "tomboykeybinder.h"
78
79static gchar * indicator_order[] = {
80#if HAVE_UBUNTU_INDICATOR1
81 "libapplication.so",
82 "libmessaging.so",
83 "libsoundmenu.so",
84 "libdatetime.so",
85 "libsession.so",
86#endif
87#if HAVE_AYATANA_INDICATOR
88 "libayatana-application.so",
89 "libayatana-messaging.so",
90 "libayatana-soundmenu.so",
91 "libayatana-datetime.so",
92 "libayatana-session.so",
93#endif
94 NULL((void*)0)
95};
96
97static GtkPackDirection packdirection;
98static MatePanelAppletOrient orient;
99static guint size;
100
101#define MENU_DATA_INDICATOR_OBJECT"indicator-object" "indicator-object"
102#define MENU_DATA_INDICATOR_ENTRY"indicator-entry" "indicator-entry"
103
104#define IO_DATA_ORDER_NUMBER"indicator-order-number" "indicator-order-number"
105
106static gboolean applet_fill_cb (MatePanelApplet * applet, const gchar * iid, gpointer data);
107
108static void update_accessible_desc (IndicatorObjectEntry * entry, GtkWidget * menuitem);
109
110/*************
111 * main
112 * ***********/
113
114#ifdef INDICATOR_APPLET
115MATE_PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletFactory",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
116 PANEL_TYPE_APPLET,int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
117 "indicator-applet",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
118 applet_fill_cb, NULL)int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
;
119#endif
120#ifdef INDICATOR_APPLET_COMPLETE1
121MATE_PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletCompleteFactory",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
122 PANEL_TYPE_APPLET,int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
123 "indicator-applet-complete",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
124 applet_fill_cb, NULL)int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
;
125#endif
126#ifdef INDICATOR_APPLET_APPMENU
127MATE_PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletAppmenuFactory",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
128 PANEL_TYPE_APPLET,int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
129 "indicator-applet-appmenu",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
130 applet_fill_cb, NULL)int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
;
131#endif
132
133/*************
134 * log files
135 * ***********/
136#ifdef INDICATOR_APPLET
137#define LOG_FILE_NAME"indicator-applet-complete.log" "indicator-applet.log"
138#endif
139#ifdef INDICATOR_APPLET_COMPLETE1
140#define LOG_FILE_NAME"indicator-applet-complete.log" "indicator-applet-complete.log"
141#endif
142#ifdef INDICATOR_APPLET_APPMENU
143#define LOG_FILE_NAME"indicator-applet-complete.log" "indicator-applet-appmenu.log"
144#endif
145GOutputStream * log_file = NULL((void*)0);
146
147/*****************
148 * Hotkey support
149 * **************/
150#ifdef INDICATOR_APPLET
151gchar * hotkey_keycode = "<Super>M";
152#endif
153#ifdef INDICATOR_APPLET_SESSION
154gchar * hotkey_keycode = "<Super>S";
155#endif
156#ifdef INDICATOR_APPLET_COMPLETE1
157gchar * hotkey_keycode = "<Super>S";
158#endif
159#ifdef INDICATOR_APPLET_APPMENU
160gchar * hotkey_keycode = "<Super>F1";
161#endif
162
163/********************
164 * Environment Names
165 * *******************/
166#ifdef INDICATOR_APPLET
167#define INDICATOR_SPECIFIC_ENV"indicator-applet-complete" "indicator-applet-original"
168#endif
169#ifdef INDICATOR_APPLET_COMPLETE1
170#define INDICATOR_SPECIFIC_ENV"indicator-applet-complete" "indicator-applet-complete"
171#endif
172#ifdef INDICATOR_APPLET_APPMENU
173#define INDICATOR_SPECIFIC_ENV"indicator-applet-complete" "indicator-applet-appmenu"
174#endif
175
176static const gchar * indicator_env[] = {
177 "indicator-applet",
178 INDICATOR_SPECIFIC_ENV"indicator-applet-complete",
179 NULL((void*)0)
180};
181
182/*************
183 * init function
184 * ***********/
185
186static gint
187name2order (const gchar * name) {
188 int i;
189
190 for (i = 0; indicator_order[i] != NULL((void*)0); i++) {
191 if (g_strcmp0(name, indicator_order[i]) == 0) {
192 return i;
193 }
194 }
195
196 return -1;
197}
198
199typedef struct _incoming_position_t incoming_position_t;
200struct _incoming_position_t {
201 gint objposition;
202 gint entryposition;
203 gint menupos;
204 gboolean found;
205};
206
207/* This function helps by determining where in the menu list
208 this new entry should be placed. It compares the objects
209 that they're on, and then the individual entries. Each
210 is progressively more expensive. */
211static void
212place_in_menu (GtkWidget * widget, gpointer user_data)
213{
214 incoming_position_t * position = (incoming_position_t *)user_data;
215 if (position->found) {
216 /* We've already been placed, just finish the foreach */
217 return;
218 }
219
220 IndicatorObject * io = INDICATOR_OBJECT(g_object_get_data(G_OBJECT(widget), MENU_DATA_INDICATOR_OBJECT))((((IndicatorObject*) g_type_check_instance_cast ((GTypeInstance
*) ((g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((widget)), (((GType) ((20) << (2)))
))))), "indicator-object"))), ((indicator_object_get_type ())
)))))
;
221 g_assert(io != NULL)do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_
; if (io != ((void*)0)) _g_boolean_var_ = 1; else _g_boolean_var_
= 0; _g_boolean_var_; }), 1)) ; else g_assertion_message_expr
("Indicator-Applet-Complete", "applet-main.c", 221, ((const char
*) (__func__)), "io != NULL"); } while (0)
;
222
223 gint objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER))((gint) (glong) (g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
), "indicator-order-number")))
;
224 /* We've already passed it, well, then this is where
225 we should be be. Stop! */
226 if (objposition > position->objposition) {
227 position->found = TRUE(!(0));
228 return;
229 }
230
231 /* The objects don't match yet, keep looking */
232 if (objposition < position->objposition) {
233 position->menupos++;
234 return;
235 }
236
237 /* The objects are the same, let's start looking at entries. */
238 IndicatorObjectEntry * entry = (IndicatorObjectEntry *)g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
239 gint entryposition = indicator_object_get_location(io, entry);
240
241 if (entryposition > position->entryposition) {
242 position->found = TRUE(!(0));
243 return;
244 }
245
246 if (entryposition < position->entryposition) {
247 position->menupos++;
248 return;
249 }
250
251 /* We've got the same object and the same entry. Well,
252 let's just put it right here then. */
253 position->found = TRUE(!(0));
254 return;
255}
256
257static void
258something_shown (GtkWidget * widget, gpointer user_data)
259{
260 GtkWidget * menuitem = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
261 gtk_widget_show(menuitem);
262}
263
264static void
265something_hidden (GtkWidget * widget, gpointer user_data)
266{
267 GtkWidget * menuitem = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
268 gtk_widget_hide(menuitem);
269}
270
271static void
272sensitive_cb (GObject * obj, GParamSpec * pspec, gpointer user_data)
273{
274 g_return_if_fail(GTK_IS_WIDGET(obj))do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((obj)); GType __t = ((gtk_widget_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet-Complete"
, ((const char*) (__func__)), "GTK_IS_WIDGET(obj)"); return; }
} while (0)
;
275 g_return_if_fail(GTK_IS_WIDGET(user_data))do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((gtk_widget_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet-Complete"
, ((const char*) (__func__)), "GTK_IS_WIDGET(user_data)"); return
; } } while (0)
;
276
277 gtk_widget_set_sensitive(GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
, gtk_widget_get_sensitive(GTK_WIDGET(obj)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(obj)), ((gtk_widget_get_type ()))))))
));
278 return;
279}
280
281static void
282entry_activated (GtkWidget * widget, gpointer user_data)
283{
284 g_return_if_fail(GTK_IS_WIDGET(widget))do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((gtk_widget_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet-Complete"
, ((const char*) (__func__)), "GTK_IS_WIDGET(widget)"); return
; } } while (0)
;
285 gpointer pio = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, "indicator");
286 g_return_if_fail(INDICATOR_IS_OBJECT(pio))do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((pio)); GType __t = ((indicator_object_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet-Complete"
, ((const char*) (__func__)), "INDICATOR_IS_OBJECT(pio)"); return
; } } while (0)
;
287 IndicatorObject * io = INDICATOR_OBJECT(pio)((((IndicatorObject*) g_type_check_instance_cast ((GTypeInstance
*) ((pio)), ((indicator_object_get_type ()))))))
;
288
289 return indicator_object_entry_activate(io, (IndicatorObjectEntry *)user_data, gtk_get_current_event_time());
290}
291
292static gboolean
293entry_scrolled (GtkWidget *menuitem, GdkEventScroll *event, gpointer data)
294{
295 IndicatorObject *io = g_object_get_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_OBJECT"indicator-object");
296 IndicatorObjectEntry *entry = g_object_get_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
297
298 g_return_val_if_fail(INDICATOR_IS_OBJECT(io), FALSE)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((io)); GType __t = ((indicator_object_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet-Complete"
, ((const char*) (__func__)), "INDICATOR_IS_OBJECT(io)"); return
((0)); } } while (0)
;
299
300 g_signal_emit_by_name (io, "scroll", 1, event->direction);
301 g_signal_emit_by_name (io, "scroll-entry", entry, 1, event->direction);
302 g_signal_emit_by_name (io, INDICATOR_OBJECT_SIGNAL_ENTRY_SCROLLED"entry-scrolled", entry, 1, event->direction);
303
304 return FALSE(0);
305}
306
307static void
308accessible_desc_update_cb (GtkWidget * widget, gpointer userdata)
309{
310 gpointer data = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
311
312 if (data != userdata) {
313 return;
314 }
315
316 IndicatorObjectEntry * entry = (IndicatorObjectEntry *)data;
317 update_accessible_desc(entry, widget);
318}
319
320static void
321accessible_desc_update (IndicatorObject * io, IndicatorObjectEntry * entry, GtkWidget * menubar)
322{
323 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, accessible_desc_update_cb, entry);
324 return;
325}
326
327#define PANEL_PADDING8 8
328static gboolean
329entry_resized (GtkWidget *applet, guint newsize, gpointer data)
330{
331 IndicatorObject *io = (IndicatorObject *)data;
332
333 size = newsize;
334
335 /* Work on the entries */
336 GList * entries = indicator_object_get_entries(io);
337 GList * entry = NULL((void*)0);
338
339 for (entry = entries; entry != NULL((void*)0); entry = g_list_next(entry)((entry) ? (((GList *)(entry))->next) : ((void*)0))) {
340 IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)entry->data;
341 if (entrydata->image != NULL((void*)0)) {
342 /* Resize to fit panel */
343 gtk_image_set_pixel_size (entrydata->image, size - PANEL_PADDING8);
344 }
345 }
346
347 return FALSE(0);
348}
349
350static void
351entry_added (IndicatorObject * io, IndicatorObjectEntry * entry, GtkWidget * menubar)
352{
353 g_debug("Signal: Entry Added");
354 gboolean something_visible = FALSE(0);
355 gboolean something_sensitive = FALSE(0);
356
357 GtkWidget * menuitem = gtk_menu_item_new();
358 GtkWidget * box = (packdirection == GTK_PACK_DIRECTION_LTR) ?
359 gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3) : gtk_box_new(GTK_ORIENTATION_VERTICAL, 3);
360
361 /* Allows indicators to receive mouse scroll event */
362 gtk_widget_add_events(GTK_WIDGET(menuitem)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(menuitem)), ((gtk_widget_get_type ()))))))
, GDK_SCROLL_MASK);
363
364 g_object_set_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "indicator", io);
365 g_object_set_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "box", box);
366
367 g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(entry_activated), entry)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((menuitem)), (((GType) ((20) << (2)
)))))))), ("activate"), (((GCallback) (entry_activated))), (entry
), ((void*)0), (GConnectFlags) 0)
;
368 g_signal_connect(G_OBJECT(menuitem), "scroll-event", G_CALLBACK(entry_scrolled), entry)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((menuitem)), (((GType) ((20) << (2)
)))))))), ("scroll-event"), (((GCallback) (entry_scrolled))),
(entry), ((void*)0), (GConnectFlags) 0)
;
369
370 if (entry->image != NULL((void*)0)) {
371 /* Resize to fit panel */
372 gtk_image_set_pixel_size (entry->image, size - PANEL_PADDING8);
373 gtk_box_pack_start(GTK_BOX(box)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((box
)), ((gtk_box_get_type ()))))))
, GTK_WIDGET(entry->image)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->image)), ((gtk_widget_get_type ()))))))
, FALSE(0), FALSE(0), 1);
374 if (gtk_widget_get_visible(GTK_WIDGET(entry->image)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->image)), ((gtk_widget_get_type ()))))))
)) {
375 something_visible = TRUE(!(0));
376 }
377
378 if (gtk_widget_get_sensitive(GTK_WIDGET(entry->image)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->image)), ((gtk_widget_get_type ()))))))
)) {
379 something_sensitive = TRUE(!(0));
380 }
381
382 g_signal_connect(G_OBJECT(entry->image), "show", G_CALLBACK(something_shown), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), ("show"), (((GCallback) (something_shown))), (menuitem
), ((void*)0), (GConnectFlags) 0)
;
383 g_signal_connect(G_OBJECT(entry->image), "hide", G_CALLBACK(something_hidden), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), ("hide"), (((GCallback) (something_hidden))), (
menuitem), ((void*)0), (GConnectFlags) 0)
;
384
385 g_signal_connect(G_OBJECT(entry->image), "notify::sensitive", G_CALLBACK(sensitive_cb), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), ("notify::sensitive"), (((GCallback) (sensitive_cb
))), (menuitem), ((void*)0), (GConnectFlags) 0)
;
386 }
387 if (entry->label != NULL((void*)0)) {
388 switch(packdirection) {
389 case GTK_PACK_DIRECTION_LTR:
390 gtk_label_set_angle(GTK_LABEL(entry->label)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_label_get_type ()))))))
, 0.0);
391 break;
392 case GTK_PACK_DIRECTION_TTB:
393 gtk_label_set_angle(GTK_LABEL(entry->label)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_label_get_type ()))))))
,
394 (orient == MATE_PANEL_APPLET_ORIENT_LEFT) ?
395 270.0 : 90.0);
396 break;
397 default:
398 break;
399 }
400 gtk_box_pack_start(GTK_BOX(box)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((box
)), ((gtk_box_get_type ()))))))
, GTK_WIDGET(entry->label)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_widget_get_type ()))))))
, FALSE(0), FALSE(0), 1);
401
402 if (gtk_widget_get_visible(GTK_WIDGET(entry->label)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_widget_get_type ()))))))
)) {
403 something_visible = TRUE(!(0));
404 }
405
406 if (gtk_widget_get_sensitive(GTK_WIDGET(entry->label)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_widget_get_type ()))))))
)) {
407 something_sensitive = TRUE(!(0));
408 }
409
410 g_signal_connect(G_OBJECT(entry->label), "show", G_CALLBACK(something_shown), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), ("show"), (((GCallback) (something_shown))), (menuitem
), ((void*)0), (GConnectFlags) 0)
;
411 g_signal_connect(G_OBJECT(entry->label), "hide", G_CALLBACK(something_hidden), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), ("hide"), (((GCallback) (something_hidden))), (
menuitem), ((void*)0), (GConnectFlags) 0)
;
412
413 g_signal_connect(G_OBJECT(entry->label), "notify::sensitive", G_CALLBACK(sensitive_cb), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), ("notify::sensitive"), (((GCallback) (sensitive_cb
))), (menuitem), ((void*)0), (GConnectFlags) 0)
;
414 }
415 gtk_container_add(GTK_CONTAINER(menuitem)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menuitem)), ((gtk_container_get_type ()))))))
, box);
416 gtk_widget_show(box);
417
418 if (entry->menu != NULL((void*)0)) {
419 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem)((((GtkMenuItem*) g_type_check_instance_cast ((GTypeInstance*
) ((menuitem)), ((gtk_menu_item_get_type ()))))))
, GTK_WIDGET(entry->menu)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->menu)), ((gtk_widget_get_type ()))))))
);
420 }
421
422 incoming_position_t position;
423 position.objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER))((gint) (glong) (g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
), "indicator-order-number")))
;
424 position.entryposition = indicator_object_get_location(io, entry);
425 position.menupos = 0;
426 position.found = FALSE(0);
427
428 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, place_in_menu, &position);
429
430 gtk_menu_shell_insert(GTK_MENU_SHELL(menubar)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_menu_shell_get_type ()))))))
, menuitem, position.menupos);
431
432 if (something_visible) {
433 if (entry->accessible_desc != NULL((void*)0)) {
434 update_accessible_desc(entry, menuitem);
435 }
436 gtk_widget_show(menuitem);
437 }
438 gtk_widget_set_sensitive(menuitem, something_sensitive);
439
440 g_object_set_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry", entry);
441 g_object_set_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_OBJECT"indicator-object", io);
442
443 return;
444}
445
446static void
447entry_removed_cb (GtkWidget * widget, gpointer userdata)
448{
449 gpointer data = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
450
451 if (data != userdata) {
452 return;
453 }
454
455 IndicatorObjectEntry * entry = (IndicatorObjectEntry *)data;
456 if (entry->label != NULL((void*)0)) {
457 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(something_shown), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_shown))), (widget
))
;
458 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(something_hidden), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_hidden))), (widget
))
;
459 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(sensitive_cb), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (sensitive_cb))), (widget)
)
;
460 }
461 if (entry->image != NULL((void*)0)) {
462 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(something_shown), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_shown))), (widget
))
;
463 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(something_hidden), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_hidden))), (widget
))
;
464 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(sensitive_cb), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (sensitive_cb))), (widget)
)
;
465 }
466
467 gtk_widget_destroy(widget);
468 return;
469}
470
471static void
472entry_removed (IndicatorObject * io G_GNUC_UNUSED__attribute__((__unused__)), IndicatorObjectEntry * entry,
473 gpointer user_data)
474{
475 g_debug("Signal: Entry Removed");
476
477 gtk_container_foreach(GTK_CONTAINER(user_data)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((gtk_container_get_type ()))))))
, entry_removed_cb, entry);
478
479 return;
480}
481
482static void
483entry_moved_find_cb (GtkWidget * widget, gpointer userdata)
484{
485 gpointer * array = (gpointer *)userdata;
486 if (array[1] != NULL((void*)0)) {
487 return;
488 }
489
490 gpointer data = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
491
492 if (data != array[0]) {
493 return;
494 }
495
496 array[1] = widget;
497 return;
498}
499
500/* Gets called when an entry for an object was moved. */
501static void
502entry_moved (IndicatorObject * io, IndicatorObjectEntry * entry,
503 gint old G_GNUC_UNUSED__attribute__((__unused__)), gint new G_GNUC_UNUSED__attribute__((__unused__)), gpointer user_data)
504{
505 GtkWidget * menubar = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
506
507 gpointer array[2];
508 array[0] = entry;
509 array[1] = NULL((void*)0);
510
511 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, entry_moved_find_cb, array);
512 if (array[1] == NULL((void*)0)) {
513 g_warning("Moving an entry that isn't in our menus.");
514 return;
515 }
516
517 GtkWidget * mi = GTK_WIDGET(array[1])((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(array[1])), ((gtk_widget_get_type ()))))))
;
518 g_object_ref(G_OBJECT(mi)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
mi)), (((GType) ((20) << (2))))))))
);
519 gtk_container_remove(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, mi);
520
521 incoming_position_t position;
522 position.objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER))((gint) (glong) (g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
), "indicator-order-number")))
;
523 position.entryposition = indicator_object_get_location(io, entry);
524 position.menupos = 0;
525 position.found = FALSE(0);
526
527 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, place_in_menu, &position);
528
529 gtk_menu_shell_insert(GTK_MENU_SHELL(menubar)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_menu_shell_get_type ()))))))
, mi, position.menupos);
530 g_object_unref(G_OBJECT(mi)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
mi)), (((GType) ((20) << (2))))))))
);
531
532 return;
533}
534
535static void
536menu_show (IndicatorObject * io, IndicatorObjectEntry * entry,
537 guint32 timestamp, gpointer user_data)
538{
539 GtkWidget * menubar = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
540
541 if (entry == NULL((void*)0)) {
542 /* Close any open menus instead of opening one */
543 GList * entries = indicator_object_get_entries(io);
544 GList * entry = NULL((void*)0);
545 for (entry = entries; entry != NULL((void*)0); entry = g_list_next(entry)((entry) ? (((GList *)(entry))->next) : ((void*)0))) {
546 IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)entry->data;
547 gtk_menu_popdown(entrydata->menu);
548 }
549 g_list_free(entries);
550
551 /* And tell the menubar to exit activation mode too */
552 gtk_menu_shell_cancel(GTK_MENU_SHELL(menubar)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_menu_shell_get_type ()))))))
);
553 return;
554 }
555
556 // TODO: do something sensible here
557}
558
559static void
560update_accessible_desc(IndicatorObjectEntry * entry, GtkWidget * menuitem)
561{
562 /* FIXME: We need to deal with the use case where the contents of the
563 label overrides what is found in the atk object's name, or at least
564 orca speaks the label instead of the atk object name.
565 */
566 AtkObject * menuitem_obj = gtk_widget_get_accessible(menuitem);
567 if (menuitem_obj == NULL((void*)0)) {
568 /* Should there be an error printed here? */
569 return;
570 }
571
572 if (entry->accessible_desc != NULL((void*)0)) {
573 atk_object_set_name(menuitem_obj, entry->accessible_desc);
574 } else {
575 atk_object_set_name(menuitem_obj, "");
576 }
577 return;
578}
579
580static void
581load_indicator (MatePanelApplet *applet, GtkWidget * menubar, IndicatorObject *io, const gchar *name)
582{
583 /* Set the environment it's in */
584 indicator_object_set_environment(io, (const GStrv)indicator_env);
585
586 /* Attach the 'name' to the object */
587#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
588 int pos = 5000 - indicator_object_get_position(io);
589 if (pos > 5000) {
590 pos = name2order(name);
591 }
592#else
593 int pos = name2order(name);
594#endif
595
596 g_object_set_data(G_OBJECT(io)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
io)), (((GType) ((20) << (2))))))))
, IO_DATA_ORDER_NUMBER"indicator-order-number", GINT_TO_POINTER(pos)((gpointer) (glong) (pos)));
597
598 /* Connect to its signals */
599 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED, G_CALLBACK(entry_added), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("entry-added"), (((GCallback) (entry_added))), (menubar)
, ((void*)0), (GConnectFlags) 0)
;
600 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED, G_CALLBACK(entry_removed), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("entry-removed"), (((GCallback) (entry_removed))), (menubar
), ((void*)0), (GConnectFlags) 0)
;
601 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_MOVED, G_CALLBACK(entry_moved), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("entry-moved"), (((GCallback) (entry_moved))), (menubar)
, ((void*)0), (GConnectFlags) 0)
;
602 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_MENU_SHOW, G_CALLBACK(menu_show), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("menu-show"), (((GCallback) (menu_show))), (menubar), ((
void*)0), (GConnectFlags) 0)
;
603 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ACCESSIBLE_DESC_UPDATE, G_CALLBACK(accessible_desc_update), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("accessible-desc-update"), (((GCallback) (accessible_desc_update
))), (menubar), ((void*)0), (GConnectFlags) 0)
;
604
605 /* Track panel resize */
606 g_signal_connect_object(G_OBJECT(applet)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
applet)), (((GType) ((20) << (2))))))))
, "change-size", G_CALLBACK(entry_resized)((GCallback) (entry_resized)), G_OBJECT(io)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
io)), (((GType) ((20) << (2))))))))
, 0);
607
608 /* Work on the entries */
609 GList * entries = indicator_object_get_entries(io);
610 GList * entry = NULL((void*)0);
611
612 for (entry = entries; entry != NULL((void*)0); entry = g_list_next(entry)((entry) ? (((GList *)(entry))->next) : ((void*)0))) {
613 IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)entry->data;
614 entry_added(io, entrydata, menubar);
615 }
616
617 g_list_free(entries);
618}
619
620static gboolean
621load_module (const gchar * name, MatePanelApplet *applet, GtkWidget * menubar)
622{
623 g_debug("Looking at Module: %s", name);
624 g_return_val_if_fail(name != NULL, FALSE)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if (name != ((void*)0)) _g_boolean_var_ = 1; else _g_boolean_var_
= 0; _g_boolean_var_; }), 1))) { } else { g_return_if_fail_warning
("Indicator-Applet-Complete", ((const char*) (__func__)), "name != NULL"
); return ((0)); } } while (0)
;
625
626 if (!g_str_has_suffix(name, G_MODULE_SUFFIX"so")) {
627 return FALSE(0);
628 }
629
630 g_debug("Loading Module: %s", name);
631
632 /* Build the object for the module */
633 gchar * fullpath = g_build_filename(INDICATOR_DIR"/usr/lib64/indicators3/7/", name, NULL((void*)0));
634 IndicatorObject * io = indicator_object_new_from_file(fullpath);
635 g_free(fullpath);
636
637 load_indicator(applet, menubar, io, name);
638
639 return TRUE(!(0));
640}
641
642static void
643load_modules (MatePanelApplet *applet, GtkWidget *menubar, gint *indicators_loaded)
644{
645 if (g_file_test(INDICATOR_DIR"/usr/lib64/indicators3/7/", (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))) {
646 GDir * dir = g_dir_open(INDICATOR_DIR"/usr/lib64/indicators3/7/", 0, NULL((void*)0));
647
648 const gchar * name;
649 gint count = 0;
650 while ((name = g_dir_read_name(dir)) != NULL((void*)0)) {
651#ifdef INDICATOR_APPLET_APPMENU
652 if (g_strcmp0(name, INDICATOR_SERVICE_APPMENU"libappmenu.so")) {
653 continue;
654 }
655#else
656 if (!g_strcmp0(name, INDICATOR_SERVICE_APPMENU"libappmenu.so")) {
657 continue;
658 }
659#endif
660#ifdef INDICATOR_APPLET
661 if (!g_strcmp0(name, INDICATOR_SERVICE_ME"libme.so")) {
662 continue;
663 }
664 if (!g_strcmp0(name, INDICATOR_SERVICE_DATETIME"libdatetime.so")) {
665 continue;
666 }
667#endif
668 if (load_module(name, applet, menubar)) {
669 count++;
670 }
671 }
672
673 *indicators_loaded += count;
674
675 g_dir_close (dir);
676 }
677}
678
679#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
680
681static void
682load_indicators_from_indicator_files (MatePanelApplet *applet, GtkWidget *menubar, gint *indicators_loaded)
683{
684 GDir *dir;
685 const gchar *name;
686 GError *error = NULL((void*)0);
687
688 dir = g_dir_open (INDICATOR_SERVICE_DIR, 0, &error);
689
690 if (!dir) {
691 g_warning ("unable to open indicator service file directory: %s", error->message);
692 g_error_free (error);
693
694 return;
695 }
696
697 gint count = 0;
698 while ((name = g_dir_read_name (dir))) {
699 gchar *filename;
700 IndicatorNg *indicator;
701
702 filename = g_build_filename (INDICATOR_SERVICE_DIR, name, NULL((void*)0));
703 indicator = indicator_ng_new_for_profile (filename, "desktop", &error);
704 g_free (filename);
705
706#ifdef INDICATOR_APPLET_APPMENU
707 if (g_strcmp0(name, INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu")) {
708 continue;
709 }
710#else
711 if (!g_strcmp0(name, INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu")) {
712 continue;
713 }
714#endif
715#ifdef INDICATOR_APPLET
716 if (!g_strcmp0(name, INDICATOR_SERVICE_ME_NG"com.canonical.indicator.me")) {
717 continue;
718 }
719 if (!g_strcmp0(name, INDICATOR_SERVICE_DATETIME_NG"com.canonical.indicator.datetime")) {
720 continue;
721 }
722#endif
723
724 if (indicator) {
725 load_indicator(applet, menubar, INDICATOR_OBJECT (indicator)((((IndicatorObject*) g_type_check_instance_cast ((GTypeInstance
*) ((indicator)), ((indicator_object_get_type ()))))))
, name);
726 count++;
727 }else{
728 g_warning ("unable to load '%s': %s", name, error->message);
729 g_clear_error (&error);
730 }
731 }
732
733 *indicators_loaded += count;
734
735 g_dir_close (dir);
736}
737#endif /* HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG */
738
739static void
740hotkey_filter (char * keystring G_GNUC_UNUSED__attribute__((__unused__)), gpointer data)
741{
742 g_return_if_fail(GTK_IS_MENU_SHELL(data))do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((data)); GType __t = ((gtk_menu_shell_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet-Complete"
, ((const char*) (__func__)), "GTK_IS_MENU_SHELL(data)"); return
; } } while (0)
;
743
744 /* Oh, wow, it's us! */
745 GList * children = gtk_container_get_children(GTK_CONTAINER(data)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((gtk_container_get_type ()))))))
);
746 if (children == NULL((void*)0)) {
747 g_debug("Menubar has no children");
748 return;
749 }
750
751 gtk_menu_shell_select_item(GTK_MENU_SHELL(data)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((gtk_menu_shell_get_type ()))))))
, GTK_WIDGET(g_list_last(children)->data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(g_list_last(children)->data)), ((gtk_widget_get_type ()))
))))
);
752 g_list_free(children);
753 return;
754}
755
756static gboolean
757menubar_press (GtkWidget * widget,
758 GdkEventButton *event,
759 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
760{
761 if (event->button != 1) {
762 g_signal_stop_emission_by_name(widget, "button-press-event");
763 }
764
765 return FALSE(0);
766}
767
768static gboolean
769menubar_on_draw (GtkWidget * widget,
770 cairo_t * cr,
771 GtkWidget * menubar)
772{
773 /* FIXME: either port to gtk_render_focus or remove this function */
774 if (gtk_widget_has_focus(menubar))
775 gtk_paint_focus(gtk_widget_get_style(widget),
776 cr,
777 gtk_widget_get_state(menubar),
778 widget, "menubar-applet", 0, 0, -1, -1);
779
780 return FALSE(0);
781}
782
783static void
784about_cb (GtkAction *action G_GNUC_UNUSED__attribute__((__unused__)),
785 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
786{
787 static const gchar *authors[] = {
788 "Ted Gould <ted@canonical.com>",
789 NULL((void*)0)
790 };
791
792 static gchar *license[] = {
793 N_("This program is free software: you can redistribute it and/or modify it ""This program is free software: you can redistribute it and/or modify it "
"under the terms of the GNU General Public License version 3, as published "
"by the Free Software Foundation."
794 "under the terms of the GNU General Public License version 3, as published ""This program is free software: you can redistribute it and/or modify it "
"under the terms of the GNU General Public License version 3, as published "
"by the Free Software Foundation."
795 "by the Free Software Foundation.")"This program is free software: you can redistribute it and/or modify it "
"under the terms of the GNU General Public License version 3, as published "
"by the Free Software Foundation."
,
796 N_("This program is distributed in the hope that it will be useful, but ""This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
797 "WITHOUT ANY WARRANTY; without even the implied warranties of ""This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
798 "MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR ""This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
799 "PURPOSE. See the GNU General Public License for more details.")"This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
,
800 N_("You should have received a copy of the GNU General Public License along ""You should have received a copy of the GNU General Public License along "
"with this program. If not, see <http://www.gnu.org/licenses/>."
801 "with this program. If not, see <http://www.gnu.org/licenses/>.")"You should have received a copy of the GNU General Public License along "
"with this program. If not, see <http://www.gnu.org/licenses/>."
,
802 NULL((void*)0)
803 };
804 gchar *license_i18n;
805
806 license_i18n = g_strconcat (_(license[0])dcgettext (((void*)0), license[0], 5), "\n\n", _(license[1])dcgettext (((void*)0), license[1], 5), "\n\n", _(license[2])dcgettext (((void*)0), license[2], 5), NULL((void*)0));
807
808 gtk_show_about_dialog(NULL((void*)0),
809 "version", VERSION"1.24.0",
810 "copyright", _("Copyright \xc2\xa9 2009-2010 Canonical, Ltd.\n"dcgettext (((void*)0), "Copyright \xc2\xa9 2009-2010 Canonical, Ltd.\n"
"Copyright \xc2\xa9 2011-2020 MATE developers", 5)
811 "Copyright \xc2\xa9 2011-2020 MATE developers")dcgettext (((void*)0), "Copyright \xc2\xa9 2009-2010 Canonical, Ltd.\n"
"Copyright \xc2\xa9 2011-2020 MATE developers", 5)
,
812#ifdef INDICATOR_APPLET_APPMENU
813 "comments", _("An applet to hold your application menus.")dcgettext (((void*)0), "An applet to hold your application menus."
, 5)
,
814#endif
815 "comments", _("An applet to hold all of the system indicators.")dcgettext (((void*)0), "An applet to hold all of the system indicators."
, 5)
,
816 "authors", authors,
817 "license", license_i18n,
818 "wrap-license", TRUE(!(0)),
819 "translator-credits", _("translator-credits")dcgettext (((void*)0), "translator-credits", 5),
820 "logo-icon-name", "mate-indicator-applet",
821 "icon-name", "mate-indicator-applet",
822 "website", "https://mate-desktop.org",
823 "website-label", _("MATE Website")dcgettext (((void*)0), "MATE Website", 5),
824 NULL((void*)0)
825 );
826
827 g_free (license_i18n);
828
829 return;
830}
831
832static gboolean
833swap_orient_cb (GtkWidget *item, gpointer data)
834{
835 GtkWidget *from = (GtkWidget *) data;
836 GtkWidget *to = (GtkWidget *) g_object_get_data(G_OBJECT(from)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
from)), (((GType) ((20) << (2))))))))
, "to");
837 g_object_ref(G_OBJECT(item)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
item)), (((GType) ((20) << (2))))))))
);
838 gtk_container_remove(GTK_CONTAINER(from)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((from)), ((gtk_container_get_type ()))))))
, item);
839 if (GTK_IS_LABEL(item)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(item)); GType __t = ((gtk_label_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; }))))
) {
840 switch(packdirection) {
841 case GTK_PACK_DIRECTION_LTR:
842 gtk_label_set_angle(GTK_LABEL(item)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(item)), ((gtk_label_get_type ()))))))
, 0.0);
843 break;
844 case GTK_PACK_DIRECTION_TTB:
845 gtk_label_set_angle(GTK_LABEL(item)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(item)), ((gtk_label_get_type ()))))))
,
846 (orient == MATE_PANEL_APPLET_ORIENT_LEFT) ?
847 270.0 : 90.0);
848 break;
849 default:
850 break;
851 }
852 }
853 gtk_box_pack_start(GTK_BOX(to)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((to
)), ((gtk_box_get_type ()))))))
, item, FALSE(0), FALSE(0), 0);
854 return TRUE(!(0));
855}
856
857static gboolean
858reorient_box_cb (GtkWidget *menuitem, gpointer data)
859{
860 GtkWidget *from = g_object_get_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "box");
861 GtkWidget *to = (packdirection == GTK_PACK_DIRECTION_LTR) ?
862 gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0) : gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
863 g_object_set_data(G_OBJECT(from)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
from)), (((GType) ((20) << (2))))))))
, "to", to);
864 gtk_container_foreach(GTK_CONTAINER(from)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((from)), ((gtk_container_get_type ()))))))
, (GtkCallback)swap_orient_cb,
865 from);
866 gtk_container_remove(GTK_CONTAINER(menuitem)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menuitem)), ((gtk_container_get_type ()))))))
, from);
867 gtk_container_add(GTK_CONTAINER(menuitem)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menuitem)), ((gtk_container_get_type ()))))))
, to);
868 g_object_set_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "box", to);
869 gtk_widget_show_all(menuitem);
870 return TRUE(!(0));
871}
872
873static gboolean
874matepanelapplet_reorient_cb (GtkWidget *applet, MatePanelAppletOrient neworient,
875 gpointer data)
876{
877 GtkWidget *menubar = (GtkWidget *)data;
878 if ((((neworient == MATE_PANEL_APPLET_ORIENT_UP) ||
879 (neworient == MATE_PANEL_APPLET_ORIENT_DOWN)) &&
880 ((orient == MATE_PANEL_APPLET_ORIENT_LEFT) ||
881 (orient == MATE_PANEL_APPLET_ORIENT_RIGHT))) ||
882 (((neworient == MATE_PANEL_APPLET_ORIENT_LEFT) ||
883 (neworient == MATE_PANEL_APPLET_ORIENT_RIGHT)) &&
884 ((orient == MATE_PANEL_APPLET_ORIENT_UP) ||
885 (orient == MATE_PANEL_APPLET_ORIENT_DOWN)))) {
886 packdirection = (packdirection == GTK_PACK_DIRECTION_LTR) ?
887 GTK_PACK_DIRECTION_TTB : GTK_PACK_DIRECTION_LTR;
888 gtk_menu_bar_set_pack_direction(GTK_MENU_BAR(menubar)((((GtkMenuBar*) g_type_check_instance_cast ((GTypeInstance*)
((menubar)), ((gtk_menu_bar_get_type ()))))))
,
889 packdirection);
890 orient = neworient;
891 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
,
892 (GtkCallback)reorient_box_cb, NULL((void*)0));
893 }
894 orient = neworient;
895 return FALSE(0);
896}
897
898#ifdef N_
899#undef N_
900#endif
901#define N_(x)x x
902
903static void
904log_to_file_cb (GObject * source_obj G_GNUC_UNUSED__attribute__((__unused__)),
905 GAsyncResult * result G_GNUC_UNUSED__attribute__((__unused__)), gpointer user_data)
906{
907 g_free(user_data);
908 return;
909}
910
911static void
912log_to_file (const gchar * domain G_GNUC_UNUSED__attribute__((__unused__)),
913 GLogLevelFlags level G_GNUC_UNUSED__attribute__((__unused__)),
914 const gchar * message,
915 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
916{
917 if (log_file == NULL((void*)0)) {
918 GError * error = NULL((void*)0);
919 gchar * filename = g_build_filename(g_get_user_cache_dir(), LOG_FILE_NAME"indicator-applet-complete.log", NULL((void*)0));
920 GFile * file = g_file_new_for_path(filename);
921 g_free(filename);
922
923 if (!g_file_test(g_get_user_cache_dir(), G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) {
924 GFile * cachedir = g_file_new_for_path(g_get_user_cache_dir());
925 g_file_make_directory_with_parents(cachedir, NULL((void*)0), &error);
926
927 if (error != NULL((void*)0)) {
928 g_error("Unable to make directory '%s' for log file: %s", g_get_user_cache_dir(), error->message);
929 return;
930 }
931 }
932
933 g_file_delete(file, NULL((void*)0), NULL((void*)0));
934
935 GFileIOStream * io = g_file_create_readwrite(file,
936 G_FILE_CREATE_REPLACE_DESTINATION, /* flags */
937 NULL((void*)0), /* cancelable */
938 &error); /* error */
939 if (error != NULL((void*)0)) {
940 g_error("Unable to replace file: %s", error->message);
941 return;
This statement is never executed
942 }
943
944 log_file = g_io_stream_get_output_stream(G_IO_STREAM(io)((((GIOStream*) g_type_check_instance_cast ((GTypeInstance*) (
(io)), ((g_io_stream_get_type ()))))))
);
945 }
946
947 gchar * outputstring = g_strdup_printf("%s\n", message);
948 g_output_stream_write_async(log_file,
949 outputstring, /* data */
950 strlen(outputstring), /* length */
951 G_PRIORITY_LOW300, /* priority */
952 NULL((void*)0), /* cancelable */
953 log_to_file_cb, /* callback */
954 outputstring); /* data */
955
956 return;
957}
958
959static gboolean
960applet_fill_cb (MatePanelApplet * applet, const gchar * iid G_GNUC_UNUSED__attribute__((__unused__)),
961 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
962{
963#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
964 ido_init();
965#endif
966
967 static const GtkActionEntry menu_actions[] = {
968 {"About", GTK_STOCK_ABOUT((GtkStock)"gtk-about"), N_("_About")"_About", NULL((void*)0), NULL((void*)0), G_CALLBACK(about_cb)((GCallback) (about_cb))}
969 };
970 static const gchar *menu_xml = "<menuitem name=\"About\" action=\"About\"/>";
971
972 static gboolean first_time = FALSE(0);
973 GtkWidget *menubar;
974 gint indicators_loaded = 0;
975 GtkActionGroup *action_group;
976
977 if (!first_time)
978 {
979 first_time = TRUE(!(0));
980#ifdef INDICATOR_APPLET
981 g_set_application_name(_("Indicator Applet")dcgettext (((void*)0), "Indicator Applet", 5));
982#endif
983#ifdef INDICATOR_APPLET_COMPLETE1
984 g_set_application_name(_("Indicator Applet Complete")dcgettext (((void*)0), "Indicator Applet Complete", 5));
985#endif
986#ifdef INDICATOR_APPLET_APPMENU
987 g_set_application_name(_("Indicator Applet Application Menu")dcgettext (((void*)0), "Indicator Applet Application Menu", 5
)
);
988#endif
989
990 g_log_set_default_handler(log_to_file, NULL((void*)0));
991
992 tomboy_keybinder_init();
993 }
994
995 /* Set panel options */
996 gtk_container_set_border_width(GTK_CONTAINER (applet)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_container_get_type ()))))))
, 0);
997 mate_panel_applet_set_flags(applet, MATE_PANEL_APPLET_EXPAND_MINOR);
998 menubar = gtk_menu_bar_new();
999 action_group = gtk_action_group_new ("Indicator Applet Actions");
1000 gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE"mate-indicator-applet");
1001 gtk_action_group_add_actions (action_group, menu_actions,
1002 G_N_ELEMENTS (menu_actions)(sizeof (menu_actions) / sizeof ((menu_actions)[0])),
1003 menubar);
1004 mate_panel_applet_setup_menu(applet, menu_xml, action_group);
1005 g_object_unref(action_group);
1006#ifdef INDICATOR_APPLET
1007 atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
),
1008 "indicator-applet");
1009#endif
1010#ifdef INDICATOR_APPLET_COMPLETE1
1011 atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
),
1012 "indicator-applet-complete");
1013#endif
1014#ifdef INDICATOR_APPLET_APPMENU
1015 atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
),
1016 "indicator-applet-appmenu");
1017#endif
1018
1019 /* Init some theme/icon stuff */
1020 gtk_icon_theme_append_search_path(gtk_icon_theme_get_default(),
1021 INDICATOR_ICONS_DIR"/usr/share/libindicator/icons/");
1022 /* g_debug("Icons directory: %s", INDICATOR_ICONS_DIR); */
1023 gtk_widget_set_name(GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
, "fast-user-switch-applet");
1024
1025 /* Build menubar */
1026 size = (mate_panel_applet_get_size (applet));
1027 orient = (mate_panel_applet_get_orient(applet));
1028 packdirection = ((orient == MATE_PANEL_APPLET_ORIENT_UP) ||
1029 (orient == MATE_PANEL_APPLET_ORIENT_DOWN)) ?
1030 GTK_PACK_DIRECTION_LTR : GTK_PACK_DIRECTION_TTB;
1031 gtk_menu_bar_set_pack_direction(GTK_MENU_BAR(menubar)((((GtkMenuBar*) g_type_check_instance_cast ((GTypeInstance*)
((menubar)), ((gtk_menu_bar_get_type ()))))))
,
1032 packdirection);
1033 gtk_widget_set_can_focus (menubar, TRUE(!(0)));
1034 gtk_widget_set_name(GTK_WIDGET (menubar)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(menubar)), ((gtk_widget_get_type ()))))))
, "fast-user-switch-menubar");
1035 g_signal_connect(menubar, "button-press-event", G_CALLBACK(menubar_press), NULL)g_signal_connect_data ((menubar), ("button-press-event"), (((
GCallback) (menubar_press))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
;
1036 g_signal_connect_after(menubar, "draw", G_CALLBACK(menubar_on_draw), menubar)g_signal_connect_data ((menubar), ("draw"), (((GCallback) (menubar_on_draw
))), (menubar), ((void*)0), G_CONNECT_AFTER)
;
1037 g_signal_connect(applet, "change-orient",g_signal_connect_data ((applet), ("change-orient"), (((GCallback
) (matepanelapplet_reorient_cb))), (menubar), ((void*)0), (GConnectFlags
) 0)
1038 G_CALLBACK(matepanelapplet_reorient_cb), menubar)g_signal_connect_data ((applet), ("change-orient"), (((GCallback
) (matepanelapplet_reorient_cb))), (menubar), ((void*)0), (GConnectFlags
) 0)
;
1039 gtk_container_set_border_width(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, 0);
1040
1041 /* Add in filter func */
1042 tomboy_keybinder_bind(hotkey_keycode, hotkey_filter, menubar);
1043
1044 load_modules(applet, menubar, &indicators_loaded);
1045#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
1046 load_indicators_from_indicator_files(applet, menubar, &indicators_loaded);
1047#endif
1048
1049 if (indicators_loaded == 0) {
1050 /* A label to allow for click through */
1051 GtkWidget * item = gtk_label_new(_("No Indicators")dcgettext (((void*)0), "No Indicators", 5));
1052 mate_panel_applet_set_background_widget(applet, item);
1053 gtk_container_add(GTK_CONTAINER(applet)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_container_get_type ()))))))
, item);
1054 gtk_widget_show(item);
1055 } else {
1056 gtk_container_add(GTK_CONTAINER(applet)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_container_get_type ()))))))
, menubar);
1057 mate_panel_applet_set_background_widget(applet, menubar);
1058 gtk_widget_show(menubar);
1059 }
1060
1061 gtk_widget_show(GTK_WIDGET(applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
);
1062
1063 return TRUE(!(0));
1064
1065}
diff --git a/2020-04-09-123617-6853-1@4b55003793c9_master/report-5948e2.html b/2020-04-09-123617-6853-1@4b55003793c9_master/report-5948e2.html new file mode 100644 index 0000000..f24b6dd --- /dev/null +++ b/2020-04-09-123617-6853-1@4b55003793c9_master/report-5948e2.html @@ -0,0 +1,1412 @@ + + + +applet-main.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:applet-main.c
Warning:line 929, column 5
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name applet-main.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -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 -mrelocation-model static -mthread-model posix -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -momit-leaf-frame-pointer -resource-dir /usr/lib64/clang/9.0.1 -D HAVE_CONFIG_H -I . -I .. -D G_LOG_DOMAIN="Indicator-Applet" -D DATADIR="/usr/local/share" -D INDICATOR_DIR="/usr/lib64/indicators3/7/" -D INDICATOR_ICONS_DIR="/usr/share/libindicator/icons/" -D INDICATOR_APPLET -I ./.. -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/fribidi -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gio-unix-2.0 -I /usr/include/libdrm -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-panel-4.0/libmate-panel-applet -I /usr/include/libindicator3-0.4 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/fribidi -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gio-unix-2.0 -I /usr/include/libdrm -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/9.0.1/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wno-unused-parameter -Wno-sign-compare -fdebug-compilation-dir /rootdir/src -ferror-limit 19 -fmessage-length 0 -fobjc-runtime=gcc -fdiagnostics-show-option -vectorize-loops -vectorize-slp -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 -o /rootdir/html-report/2020-04-09-123617-6853-1 -x c applet-main.c +
+ + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2A small wrapper utility to load indicators and put them as menu items
3into the mate-panel using it's applet interface.
4
5Copyright 2009-2010 Canonical Ltd.
6
7Authors:
8 Ted Gould <ted@canonical.com>
9
10This program is free software: you can redistribute it and/or modify it
11under the terms of the GNU General Public License version 3, as published
12by the Free Software Foundation.
13
14This program is distributed in the hope that it will be useful, but
15WITHOUT ANY WARRANTY; without even the implied warranties of
16MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
17PURPOSE. See the GNU General Public License for more details.
18
19You should have received a copy of the GNU General Public License along
20with this program. If not, see <http://www.gnu.org/licenses/>.
21*/
22
23#include <stdlib.h>
24#include <string.h>
25#include <config.h>
26#include <glib/gi18n.h>
27#include <mate-panel-applet.h>
28#include <gdk/gdkkeysyms.h>
29#include <gtk/gtk.h>
30
31#if HAVE_UBUNTU_INDICATOR1
32
33#define INDICATOR_SERVICE_APPMENU"libappmenu.so" "libappmenu.so"
34#define INDICATOR_SERVICE_ME"libme.so" "libme.so"
35#define INDICATOR_SERVICE_DATETIME"libdatetime.so" "libdatetime.so"
36
37#define INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu" "com.canonical.indicator.appmenu"
38#define INDICATOR_SERVICE_ME_NG"com.canonical.indicator.me" "com.canonical.indicator.me"
39#define INDICATOR_SERVICE_DATETIME_NG"com.canonical.indicator.datetime" "com.canonical.indicator.datetime"
40
41#include <libindicator/indicator-object.h>
42#endif
43
44#if HAVE_AYATANA_INDICATOR
45
46#define INDICATOR_SERVICE_APPMENU"libappmenu.so" "libayatana-appmenu.so"
47#define INDICATOR_SERVICE_ME"libme.so" "libayatana-me.so"
48#define INDICATOR_SERVICE_DATETIME"libdatetime.so" "libayatana-datetime.so"
49
50#define INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu" "org.ayatana.indicator.appmenu"
51#define INDICATOR_SERVICE_ME_NG"com.canonical.indicator.me" "org.ayatana.indicator.me"
52#define INDICATOR_SERVICE_DATETIME_NG"com.canonical.indicator.datetime" "org.ayatana.indicator.datetime"
53
54#include <libayatana-indicator/indicator-object.h>
55#endif
56
57/* For new style indicators */
58
59#if HAVE_UBUNTU_INDICATOR1 && HAVE_UBUNTU_INDICATOR_NG
60
61#include <libido/libido.h>
62#include <libindicator/indicator-ng.h>
63
64#define INDICATOR_SERVICE_DIR "/usr/share/unity/indicators"
65
66#endif
67
68#if HAVE_AYATANA_INDICATOR && HAVE_AYATANA_INDICATOR_NG
69
70#include <libayatana-ido/libayatana-ido.h>
71#include <libayatana-indicator/indicator-ng.h>
72
73#define INDICATOR_SERVICE_DIR "/usr/share/ayatana/indicators"
74
75#endif
76
77#include "tomboykeybinder.h"
78
79static gchar * indicator_order[] = {
80#if HAVE_UBUNTU_INDICATOR1
81 "libapplication.so",
82 "libmessaging.so",
83 "libsoundmenu.so",
84 "libdatetime.so",
85 "libsession.so",
86#endif
87#if HAVE_AYATANA_INDICATOR
88 "libayatana-application.so",
89 "libayatana-messaging.so",
90 "libayatana-soundmenu.so",
91 "libayatana-datetime.so",
92 "libayatana-session.so",
93#endif
94 NULL((void*)0)
95};
96
97static GtkPackDirection packdirection;
98static MatePanelAppletOrient orient;
99static guint size;
100
101#define MENU_DATA_INDICATOR_OBJECT"indicator-object" "indicator-object"
102#define MENU_DATA_INDICATOR_ENTRY"indicator-entry" "indicator-entry"
103
104#define IO_DATA_ORDER_NUMBER"indicator-order-number" "indicator-order-number"
105
106static gboolean applet_fill_cb (MatePanelApplet * applet, const gchar * iid, gpointer data);
107
108static void update_accessible_desc (IndicatorObjectEntry * entry, GtkWidget * menuitem);
109
110/*************
111 * main
112 * ***********/
113
114#ifdef INDICATOR_APPLET1
115MATE_PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletFactory",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
116 PANEL_TYPE_APPLET,int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
117 "indicator-applet",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
118 applet_fill_cb, NULL)int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
;
119#endif
120#ifdef INDICATOR_APPLET_COMPLETE
121MATE_PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletCompleteFactory",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
122 PANEL_TYPE_APPLET,int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
123 "indicator-applet-complete",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
124 applet_fill_cb, NULL)int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
;
125#endif
126#ifdef INDICATOR_APPLET_APPMENU
127MATE_PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletAppmenuFactory",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
128 PANEL_TYPE_APPLET,int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
129 "indicator-applet-appmenu",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
130 applet_fill_cb, NULL)int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
;
131#endif
132
133/*************
134 * log files
135 * ***********/
136#ifdef INDICATOR_APPLET1
137#define LOG_FILE_NAME"indicator-applet.log" "indicator-applet.log"
138#endif
139#ifdef INDICATOR_APPLET_COMPLETE
140#define LOG_FILE_NAME"indicator-applet.log" "indicator-applet-complete.log"
141#endif
142#ifdef INDICATOR_APPLET_APPMENU
143#define LOG_FILE_NAME"indicator-applet.log" "indicator-applet-appmenu.log"
144#endif
145GOutputStream * log_file = NULL((void*)0);
146
147/*****************
148 * Hotkey support
149 * **************/
150#ifdef INDICATOR_APPLET1
151gchar * hotkey_keycode = "<Super>M";
152#endif
153#ifdef INDICATOR_APPLET_SESSION
154gchar * hotkey_keycode = "<Super>S";
155#endif
156#ifdef INDICATOR_APPLET_COMPLETE
157gchar * hotkey_keycode = "<Super>S";
158#endif
159#ifdef INDICATOR_APPLET_APPMENU
160gchar * hotkey_keycode = "<Super>F1";
161#endif
162
163/********************
164 * Environment Names
165 * *******************/
166#ifdef INDICATOR_APPLET1
167#define INDICATOR_SPECIFIC_ENV"indicator-applet-original" "indicator-applet-original"
168#endif
169#ifdef INDICATOR_APPLET_COMPLETE
170#define INDICATOR_SPECIFIC_ENV"indicator-applet-original" "indicator-applet-complete"
171#endif
172#ifdef INDICATOR_APPLET_APPMENU
173#define INDICATOR_SPECIFIC_ENV"indicator-applet-original" "indicator-applet-appmenu"
174#endif
175
176static const gchar * indicator_env[] = {
177 "indicator-applet",
178 INDICATOR_SPECIFIC_ENV"indicator-applet-original",
179 NULL((void*)0)
180};
181
182/*************
183 * init function
184 * ***********/
185
186static gint
187name2order (const gchar * name) {
188 int i;
189
190 for (i = 0; indicator_order[i] != NULL((void*)0); i++) {
191 if (g_strcmp0(name, indicator_order[i]) == 0) {
192 return i;
193 }
194 }
195
196 return -1;
197}
198
199typedef struct _incoming_position_t incoming_position_t;
200struct _incoming_position_t {
201 gint objposition;
202 gint entryposition;
203 gint menupos;
204 gboolean found;
205};
206
207/* This function helps by determining where in the menu list
208 this new entry should be placed. It compares the objects
209 that they're on, and then the individual entries. Each
210 is progressively more expensive. */
211static void
212place_in_menu (GtkWidget * widget, gpointer user_data)
213{
214 incoming_position_t * position = (incoming_position_t *)user_data;
215 if (position->found) {
216 /* We've already been placed, just finish the foreach */
217 return;
218 }
219
220 IndicatorObject * io = INDICATOR_OBJECT(g_object_get_data(G_OBJECT(widget), MENU_DATA_INDICATOR_OBJECT))((((IndicatorObject*) g_type_check_instance_cast ((GTypeInstance
*) ((g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((widget)), (((GType) ((20) << (2)))
))))), "indicator-object"))), ((indicator_object_get_type ())
)))))
;
221 g_assert(io != NULL)do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_
; if (io != ((void*)0)) _g_boolean_var_ = 1; else _g_boolean_var_
= 0; _g_boolean_var_; }), 1)) ; else g_assertion_message_expr
("Indicator-Applet", "applet-main.c", 221, ((const char*) (__func__
)), "io != NULL"); } while (0)
;
222
223 gint objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER))((gint) (glong) (g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
), "indicator-order-number")))
;
224 /* We've already passed it, well, then this is where
225 we should be be. Stop! */
226 if (objposition > position->objposition) {
227 position->found = TRUE(!(0));
228 return;
229 }
230
231 /* The objects don't match yet, keep looking */
232 if (objposition < position->objposition) {
233 position->menupos++;
234 return;
235 }
236
237 /* The objects are the same, let's start looking at entries. */
238 IndicatorObjectEntry * entry = (IndicatorObjectEntry *)g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
239 gint entryposition = indicator_object_get_location(io, entry);
240
241 if (entryposition > position->entryposition) {
242 position->found = TRUE(!(0));
243 return;
244 }
245
246 if (entryposition < position->entryposition) {
247 position->menupos++;
248 return;
249 }
250
251 /* We've got the same object and the same entry. Well,
252 let's just put it right here then. */
253 position->found = TRUE(!(0));
254 return;
255}
256
257static void
258something_shown (GtkWidget * widget, gpointer user_data)
259{
260 GtkWidget * menuitem = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
261 gtk_widget_show(menuitem);
262}
263
264static void
265something_hidden (GtkWidget * widget, gpointer user_data)
266{
267 GtkWidget * menuitem = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
268 gtk_widget_hide(menuitem);
269}
270
271static void
272sensitive_cb (GObject * obj, GParamSpec * pspec, gpointer user_data)
273{
274 g_return_if_fail(GTK_IS_WIDGET(obj))do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((obj)); GType __t = ((gtk_widget_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet", ((const
char*) (__func__)), "GTK_IS_WIDGET(obj)"); return; } } while
(0)
;
275 g_return_if_fail(GTK_IS_WIDGET(user_data))do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((gtk_widget_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet", ((const
char*) (__func__)), "GTK_IS_WIDGET(user_data)"); return; } }
while (0)
;
276
277 gtk_widget_set_sensitive(GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
, gtk_widget_get_sensitive(GTK_WIDGET(obj)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(obj)), ((gtk_widget_get_type ()))))))
));
278 return;
279}
280
281static void
282entry_activated (GtkWidget * widget, gpointer user_data)
283{
284 g_return_if_fail(GTK_IS_WIDGET(widget))do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((gtk_widget_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet", ((const
char*) (__func__)), "GTK_IS_WIDGET(widget)"); return; } } while
(0)
;
285 gpointer pio = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, "indicator");
286 g_return_if_fail(INDICATOR_IS_OBJECT(pio))do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((pio)); GType __t = ((indicator_object_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet", ((const
char*) (__func__)), "INDICATOR_IS_OBJECT(pio)"); return; } }
while (0)
;
287 IndicatorObject * io = INDICATOR_OBJECT(pio)((((IndicatorObject*) g_type_check_instance_cast ((GTypeInstance
*) ((pio)), ((indicator_object_get_type ()))))))
;
288
289 return indicator_object_entry_activate(io, (IndicatorObjectEntry *)user_data, gtk_get_current_event_time());
290}
291
292static gboolean
293entry_scrolled (GtkWidget *menuitem, GdkEventScroll *event, gpointer data)
294{
295 IndicatorObject *io = g_object_get_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_OBJECT"indicator-object");
296 IndicatorObjectEntry *entry = g_object_get_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
297
298 g_return_val_if_fail(INDICATOR_IS_OBJECT(io), FALSE)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((io)); GType __t = ((indicator_object_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet", ((const
char*) (__func__)), "INDICATOR_IS_OBJECT(io)"); return ((0))
; } } while (0)
;
299
300 g_signal_emit_by_name (io, "scroll", 1, event->direction);
301 g_signal_emit_by_name (io, "scroll-entry", entry, 1, event->direction);
302 g_signal_emit_by_name (io, INDICATOR_OBJECT_SIGNAL_ENTRY_SCROLLED"entry-scrolled", entry, 1, event->direction);
303
304 return FALSE(0);
305}
306
307static void
308accessible_desc_update_cb (GtkWidget * widget, gpointer userdata)
309{
310 gpointer data = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
311
312 if (data != userdata) {
313 return;
314 }
315
316 IndicatorObjectEntry * entry = (IndicatorObjectEntry *)data;
317 update_accessible_desc(entry, widget);
318}
319
320static void
321accessible_desc_update (IndicatorObject * io, IndicatorObjectEntry * entry, GtkWidget * menubar)
322{
323 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, accessible_desc_update_cb, entry);
324 return;
325}
326
327#define PANEL_PADDING8 8
328static gboolean
329entry_resized (GtkWidget *applet, guint newsize, gpointer data)
330{
331 IndicatorObject *io = (IndicatorObject *)data;
332
333 size = newsize;
334
335 /* Work on the entries */
336 GList * entries = indicator_object_get_entries(io);
337 GList * entry = NULL((void*)0);
338
339 for (entry = entries; entry != NULL((void*)0); entry = g_list_next(entry)((entry) ? (((GList *)(entry))->next) : ((void*)0))) {
340 IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)entry->data;
341 if (entrydata->image != NULL((void*)0)) {
342 /* Resize to fit panel */
343 gtk_image_set_pixel_size (entrydata->image, size - PANEL_PADDING8);
344 }
345 }
346
347 return FALSE(0);
348}
349
350static void
351entry_added (IndicatorObject * io, IndicatorObjectEntry * entry, GtkWidget * menubar)
352{
353 g_debug("Signal: Entry Added");
354 gboolean something_visible = FALSE(0);
355 gboolean something_sensitive = FALSE(0);
356
357 GtkWidget * menuitem = gtk_menu_item_new();
358 GtkWidget * box = (packdirection == GTK_PACK_DIRECTION_LTR) ?
359 gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3) : gtk_box_new(GTK_ORIENTATION_VERTICAL, 3);
360
361 /* Allows indicators to receive mouse scroll event */
362 gtk_widget_add_events(GTK_WIDGET(menuitem)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(menuitem)), ((gtk_widget_get_type ()))))))
, GDK_SCROLL_MASK);
363
364 g_object_set_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "indicator", io);
365 g_object_set_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "box", box);
366
367 g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(entry_activated), entry)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((menuitem)), (((GType) ((20) << (2)
)))))))), ("activate"), (((GCallback) (entry_activated))), (entry
), ((void*)0), (GConnectFlags) 0)
;
368 g_signal_connect(G_OBJECT(menuitem), "scroll-event", G_CALLBACK(entry_scrolled), entry)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((menuitem)), (((GType) ((20) << (2)
)))))))), ("scroll-event"), (((GCallback) (entry_scrolled))),
(entry), ((void*)0), (GConnectFlags) 0)
;
369
370 if (entry->image != NULL((void*)0)) {
371 /* Resize to fit panel */
372 gtk_image_set_pixel_size (entry->image, size - PANEL_PADDING8);
373 gtk_box_pack_start(GTK_BOX(box)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((box
)), ((gtk_box_get_type ()))))))
, GTK_WIDGET(entry->image)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->image)), ((gtk_widget_get_type ()))))))
, FALSE(0), FALSE(0), 1);
374 if (gtk_widget_get_visible(GTK_WIDGET(entry->image)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->image)), ((gtk_widget_get_type ()))))))
)) {
375 something_visible = TRUE(!(0));
376 }
377
378 if (gtk_widget_get_sensitive(GTK_WIDGET(entry->image)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->image)), ((gtk_widget_get_type ()))))))
)) {
379 something_sensitive = TRUE(!(0));
380 }
381
382 g_signal_connect(G_OBJECT(entry->image), "show", G_CALLBACK(something_shown), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), ("show"), (((GCallback) (something_shown))), (menuitem
), ((void*)0), (GConnectFlags) 0)
;
383 g_signal_connect(G_OBJECT(entry->image), "hide", G_CALLBACK(something_hidden), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), ("hide"), (((GCallback) (something_hidden))), (
menuitem), ((void*)0), (GConnectFlags) 0)
;
384
385 g_signal_connect(G_OBJECT(entry->image), "notify::sensitive", G_CALLBACK(sensitive_cb), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), ("notify::sensitive"), (((GCallback) (sensitive_cb
))), (menuitem), ((void*)0), (GConnectFlags) 0)
;
386 }
387 if (entry->label != NULL((void*)0)) {
388 switch(packdirection) {
389 case GTK_PACK_DIRECTION_LTR:
390 gtk_label_set_angle(GTK_LABEL(entry->label)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_label_get_type ()))))))
, 0.0);
391 break;
392 case GTK_PACK_DIRECTION_TTB:
393 gtk_label_set_angle(GTK_LABEL(entry->label)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_label_get_type ()))))))
,
394 (orient == MATE_PANEL_APPLET_ORIENT_LEFT) ?
395 270.0 : 90.0);
396 break;
397 default:
398 break;
399 }
400 gtk_box_pack_start(GTK_BOX(box)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((box
)), ((gtk_box_get_type ()))))))
, GTK_WIDGET(entry->label)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_widget_get_type ()))))))
, FALSE(0), FALSE(0), 1);
401
402 if (gtk_widget_get_visible(GTK_WIDGET(entry->label)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_widget_get_type ()))))))
)) {
403 something_visible = TRUE(!(0));
404 }
405
406 if (gtk_widget_get_sensitive(GTK_WIDGET(entry->label)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_widget_get_type ()))))))
)) {
407 something_sensitive = TRUE(!(0));
408 }
409
410 g_signal_connect(G_OBJECT(entry->label), "show", G_CALLBACK(something_shown), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), ("show"), (((GCallback) (something_shown))), (menuitem
), ((void*)0), (GConnectFlags) 0)
;
411 g_signal_connect(G_OBJECT(entry->label), "hide", G_CALLBACK(something_hidden), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), ("hide"), (((GCallback) (something_hidden))), (
menuitem), ((void*)0), (GConnectFlags) 0)
;
412
413 g_signal_connect(G_OBJECT(entry->label), "notify::sensitive", G_CALLBACK(sensitive_cb), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), ("notify::sensitive"), (((GCallback) (sensitive_cb
))), (menuitem), ((void*)0), (GConnectFlags) 0)
;
414 }
415 gtk_container_add(GTK_CONTAINER(menuitem)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menuitem)), ((gtk_container_get_type ()))))))
, box);
416 gtk_widget_show(box);
417
418 if (entry->menu != NULL((void*)0)) {
419 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem)((((GtkMenuItem*) g_type_check_instance_cast ((GTypeInstance*
) ((menuitem)), ((gtk_menu_item_get_type ()))))))
, GTK_WIDGET(entry->menu)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->menu)), ((gtk_widget_get_type ()))))))
);
420 }
421
422 incoming_position_t position;
423 position.objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER))((gint) (glong) (g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
), "indicator-order-number")))
;
424 position.entryposition = indicator_object_get_location(io, entry);
425 position.menupos = 0;
426 position.found = FALSE(0);
427
428 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, place_in_menu, &position);
429
430 gtk_menu_shell_insert(GTK_MENU_SHELL(menubar)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_menu_shell_get_type ()))))))
, menuitem, position.menupos);
431
432 if (something_visible) {
433 if (entry->accessible_desc != NULL((void*)0)) {
434 update_accessible_desc(entry, menuitem);
435 }
436 gtk_widget_show(menuitem);
437 }
438 gtk_widget_set_sensitive(menuitem, something_sensitive);
439
440 g_object_set_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry", entry);
441 g_object_set_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_OBJECT"indicator-object", io);
442
443 return;
444}
445
446static void
447entry_removed_cb (GtkWidget * widget, gpointer userdata)
448{
449 gpointer data = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
450
451 if (data != userdata) {
452 return;
453 }
454
455 IndicatorObjectEntry * entry = (IndicatorObjectEntry *)data;
456 if (entry->label != NULL((void*)0)) {
457 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(something_shown), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_shown))), (widget
))
;
458 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(something_hidden), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_hidden))), (widget
))
;
459 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(sensitive_cb), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (sensitive_cb))), (widget)
)
;
460 }
461 if (entry->image != NULL((void*)0)) {
462 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(something_shown), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_shown))), (widget
))
;
463 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(something_hidden), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_hidden))), (widget
))
;
464 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(sensitive_cb), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (sensitive_cb))), (widget)
)
;
465 }
466
467 gtk_widget_destroy(widget);
468 return;
469}
470
471static void
472entry_removed (IndicatorObject * io G_GNUC_UNUSED__attribute__((__unused__)), IndicatorObjectEntry * entry,
473 gpointer user_data)
474{
475 g_debug("Signal: Entry Removed");
476
477 gtk_container_foreach(GTK_CONTAINER(user_data)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((gtk_container_get_type ()))))))
, entry_removed_cb, entry);
478
479 return;
480}
481
482static void
483entry_moved_find_cb (GtkWidget * widget, gpointer userdata)
484{
485 gpointer * array = (gpointer *)userdata;
486 if (array[1] != NULL((void*)0)) {
487 return;
488 }
489
490 gpointer data = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
491
492 if (data != array[0]) {
493 return;
494 }
495
496 array[1] = widget;
497 return;
498}
499
500/* Gets called when an entry for an object was moved. */
501static void
502entry_moved (IndicatorObject * io, IndicatorObjectEntry * entry,
503 gint old G_GNUC_UNUSED__attribute__((__unused__)), gint new G_GNUC_UNUSED__attribute__((__unused__)), gpointer user_data)
504{
505 GtkWidget * menubar = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
506
507 gpointer array[2];
508 array[0] = entry;
509 array[1] = NULL((void*)0);
510
511 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, entry_moved_find_cb, array);
512 if (array[1] == NULL((void*)0)) {
513 g_warning("Moving an entry that isn't in our menus.");
514 return;
515 }
516
517 GtkWidget * mi = GTK_WIDGET(array[1])((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(array[1])), ((gtk_widget_get_type ()))))))
;
518 g_object_ref(G_OBJECT(mi)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
mi)), (((GType) ((20) << (2))))))))
);
519 gtk_container_remove(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, mi);
520
521 incoming_position_t position;
522 position.objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER))((gint) (glong) (g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
), "indicator-order-number")))
;
523 position.entryposition = indicator_object_get_location(io, entry);
524 position.menupos = 0;
525 position.found = FALSE(0);
526
527 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, place_in_menu, &position);
528
529 gtk_menu_shell_insert(GTK_MENU_SHELL(menubar)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_menu_shell_get_type ()))))))
, mi, position.menupos);
530 g_object_unref(G_OBJECT(mi)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
mi)), (((GType) ((20) << (2))))))))
);
531
532 return;
533}
534
535static void
536menu_show (IndicatorObject * io, IndicatorObjectEntry * entry,
537 guint32 timestamp, gpointer user_data)
538{
539 GtkWidget * menubar = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
540
541 if (entry == NULL((void*)0)) {
542 /* Close any open menus instead of opening one */
543 GList * entries = indicator_object_get_entries(io);
544 GList * entry = NULL((void*)0);
545 for (entry = entries; entry != NULL((void*)0); entry = g_list_next(entry)((entry) ? (((GList *)(entry))->next) : ((void*)0))) {
546 IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)entry->data;
547 gtk_menu_popdown(entrydata->menu);
548 }
549 g_list_free(entries);
550
551 /* And tell the menubar to exit activation mode too */
552 gtk_menu_shell_cancel(GTK_MENU_SHELL(menubar)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_menu_shell_get_type ()))))))
);
553 return;
554 }
555
556 // TODO: do something sensible here
557}
558
559static void
560update_accessible_desc(IndicatorObjectEntry * entry, GtkWidget * menuitem)
561{
562 /* FIXME: We need to deal with the use case where the contents of the
563 label overrides what is found in the atk object's name, or at least
564 orca speaks the label instead of the atk object name.
565 */
566 AtkObject * menuitem_obj = gtk_widget_get_accessible(menuitem);
567 if (menuitem_obj == NULL((void*)0)) {
568 /* Should there be an error printed here? */
569 return;
570 }
571
572 if (entry->accessible_desc != NULL((void*)0)) {
573 atk_object_set_name(menuitem_obj, entry->accessible_desc);
574 } else {
575 atk_object_set_name(menuitem_obj, "");
576 }
577 return;
578}
579
580static void
581load_indicator (MatePanelApplet *applet, GtkWidget * menubar, IndicatorObject *io, const gchar *name)
582{
583 /* Set the environment it's in */
584 indicator_object_set_environment(io, (const GStrv)indicator_env);
585
586 /* Attach the 'name' to the object */
587#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
588 int pos = 5000 - indicator_object_get_position(io);
589 if (pos > 5000) {
590 pos = name2order(name);
591 }
592#else
593 int pos = name2order(name);
594#endif
595
596 g_object_set_data(G_OBJECT(io)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
io)), (((GType) ((20) << (2))))))))
, IO_DATA_ORDER_NUMBER"indicator-order-number", GINT_TO_POINTER(pos)((gpointer) (glong) (pos)));
597
598 /* Connect to its signals */
599 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED, G_CALLBACK(entry_added), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("entry-added"), (((GCallback) (entry_added))), (menubar)
, ((void*)0), (GConnectFlags) 0)
;
600 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED, G_CALLBACK(entry_removed), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("entry-removed"), (((GCallback) (entry_removed))), (menubar
), ((void*)0), (GConnectFlags) 0)
;
601 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_MOVED, G_CALLBACK(entry_moved), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("entry-moved"), (((GCallback) (entry_moved))), (menubar)
, ((void*)0), (GConnectFlags) 0)
;
602 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_MENU_SHOW, G_CALLBACK(menu_show), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("menu-show"), (((GCallback) (menu_show))), (menubar), ((
void*)0), (GConnectFlags) 0)
;
603 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ACCESSIBLE_DESC_UPDATE, G_CALLBACK(accessible_desc_update), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("accessible-desc-update"), (((GCallback) (accessible_desc_update
))), (menubar), ((void*)0), (GConnectFlags) 0)
;
604
605 /* Track panel resize */
606 g_signal_connect_object(G_OBJECT(applet)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
applet)), (((GType) ((20) << (2))))))))
, "change-size", G_CALLBACK(entry_resized)((GCallback) (entry_resized)), G_OBJECT(io)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
io)), (((GType) ((20) << (2))))))))
, 0);
607
608 /* Work on the entries */
609 GList * entries = indicator_object_get_entries(io);
610 GList * entry = NULL((void*)0);
611
612 for (entry = entries; entry != NULL((void*)0); entry = g_list_next(entry)((entry) ? (((GList *)(entry))->next) : ((void*)0))) {
613 IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)entry->data;
614 entry_added(io, entrydata, menubar);
615 }
616
617 g_list_free(entries);
618}
619
620static gboolean
621load_module (const gchar * name, MatePanelApplet *applet, GtkWidget * menubar)
622{
623 g_debug("Looking at Module: %s", name);
624 g_return_val_if_fail(name != NULL, FALSE)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if (name != ((void*)0)) _g_boolean_var_ = 1; else _g_boolean_var_
= 0; _g_boolean_var_; }), 1))) { } else { g_return_if_fail_warning
("Indicator-Applet", ((const char*) (__func__)), "name != NULL"
); return ((0)); } } while (0)
;
625
626 if (!g_str_has_suffix(name, G_MODULE_SUFFIX"so")) {
627 return FALSE(0);
628 }
629
630 g_debug("Loading Module: %s", name);
631
632 /* Build the object for the module */
633 gchar * fullpath = g_build_filename(INDICATOR_DIR"/usr/lib64/indicators3/7/", name, NULL((void*)0));
634 IndicatorObject * io = indicator_object_new_from_file(fullpath);
635 g_free(fullpath);
636
637 load_indicator(applet, menubar, io, name);
638
639 return TRUE(!(0));
640}
641
642static void
643load_modules (MatePanelApplet *applet, GtkWidget *menubar, gint *indicators_loaded)
644{
645 if (g_file_test(INDICATOR_DIR"/usr/lib64/indicators3/7/", (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))) {
646 GDir * dir = g_dir_open(INDICATOR_DIR"/usr/lib64/indicators3/7/", 0, NULL((void*)0));
647
648 const gchar * name;
649 gint count = 0;
650 while ((name = g_dir_read_name(dir)) != NULL((void*)0)) {
651#ifdef INDICATOR_APPLET_APPMENU
652 if (g_strcmp0(name, INDICATOR_SERVICE_APPMENU"libappmenu.so")) {
653 continue;
654 }
655#else
656 if (!g_strcmp0(name, INDICATOR_SERVICE_APPMENU"libappmenu.so")) {
657 continue;
658 }
659#endif
660#ifdef INDICATOR_APPLET1
661 if (!g_strcmp0(name, INDICATOR_SERVICE_ME"libme.so")) {
662 continue;
663 }
664 if (!g_strcmp0(name, INDICATOR_SERVICE_DATETIME"libdatetime.so")) {
665 continue;
666 }
667#endif
668 if (load_module(name, applet, menubar)) {
669 count++;
670 }
671 }
672
673 *indicators_loaded += count;
674
675 g_dir_close (dir);
676 }
677}
678
679#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
680
681static void
682load_indicators_from_indicator_files (MatePanelApplet *applet, GtkWidget *menubar, gint *indicators_loaded)
683{
684 GDir *dir;
685 const gchar *name;
686 GError *error = NULL((void*)0);
687
688 dir = g_dir_open (INDICATOR_SERVICE_DIR, 0, &error);
689
690 if (!dir) {
691 g_warning ("unable to open indicator service file directory: %s", error->message);
692 g_error_free (error);
693
694 return;
695 }
696
697 gint count = 0;
698 while ((name = g_dir_read_name (dir))) {
699 gchar *filename;
700 IndicatorNg *indicator;
701
702 filename = g_build_filename (INDICATOR_SERVICE_DIR, name, NULL((void*)0));
703 indicator = indicator_ng_new_for_profile (filename, "desktop", &error);
704 g_free (filename);
705
706#ifdef INDICATOR_APPLET_APPMENU
707 if (g_strcmp0(name, INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu")) {
708 continue;
709 }
710#else
711 if (!g_strcmp0(name, INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu")) {
712 continue;
713 }
714#endif
715#ifdef INDICATOR_APPLET1
716 if (!g_strcmp0(name, INDICATOR_SERVICE_ME_NG"com.canonical.indicator.me")) {
717 continue;
718 }
719 if (!g_strcmp0(name, INDICATOR_SERVICE_DATETIME_NG"com.canonical.indicator.datetime")) {
720 continue;
721 }
722#endif
723
724 if (indicator) {
725 load_indicator(applet, menubar, INDICATOR_OBJECT (indicator)((((IndicatorObject*) g_type_check_instance_cast ((GTypeInstance
*) ((indicator)), ((indicator_object_get_type ()))))))
, name);
726 count++;
727 }else{
728 g_warning ("unable to load '%s': %s", name, error->message);
729 g_clear_error (&error);
730 }
731 }
732
733 *indicators_loaded += count;
734
735 g_dir_close (dir);
736}
737#endif /* HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG */
738
739static void
740hotkey_filter (char * keystring G_GNUC_UNUSED__attribute__((__unused__)), gpointer data)
741{
742 g_return_if_fail(GTK_IS_MENU_SHELL(data))do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((data)); GType __t = ((gtk_menu_shell_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet", ((const
char*) (__func__)), "GTK_IS_MENU_SHELL(data)"); return; } } while
(0)
;
743
744 /* Oh, wow, it's us! */
745 GList * children = gtk_container_get_children(GTK_CONTAINER(data)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((gtk_container_get_type ()))))))
);
746 if (children == NULL((void*)0)) {
747 g_debug("Menubar has no children");
748 return;
749 }
750
751 gtk_menu_shell_select_item(GTK_MENU_SHELL(data)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((gtk_menu_shell_get_type ()))))))
, GTK_WIDGET(g_list_last(children)->data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(g_list_last(children)->data)), ((gtk_widget_get_type ()))
))))
);
752 g_list_free(children);
753 return;
754}
755
756static gboolean
757menubar_press (GtkWidget * widget,
758 GdkEventButton *event,
759 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
760{
761 if (event->button != 1) {
762 g_signal_stop_emission_by_name(widget, "button-press-event");
763 }
764
765 return FALSE(0);
766}
767
768static gboolean
769menubar_on_draw (GtkWidget * widget,
770 cairo_t * cr,
771 GtkWidget * menubar)
772{
773 /* FIXME: either port to gtk_render_focus or remove this function */
774 if (gtk_widget_has_focus(menubar))
775 gtk_paint_focus(gtk_widget_get_style(widget),
776 cr,
777 gtk_widget_get_state(menubar),
778 widget, "menubar-applet", 0, 0, -1, -1);
779
780 return FALSE(0);
781}
782
783static void
784about_cb (GtkAction *action G_GNUC_UNUSED__attribute__((__unused__)),
785 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
786{
787 static const gchar *authors[] = {
788 "Ted Gould <ted@canonical.com>",
789 NULL((void*)0)
790 };
791
792 static gchar *license[] = {
793 N_("This program is free software: you can redistribute it and/or modify it ""This program is free software: you can redistribute it and/or modify it "
"under the terms of the GNU General Public License version 3, as published "
"by the Free Software Foundation."
794 "under the terms of the GNU General Public License version 3, as published ""This program is free software: you can redistribute it and/or modify it "
"under the terms of the GNU General Public License version 3, as published "
"by the Free Software Foundation."
795 "by the Free Software Foundation.")"This program is free software: you can redistribute it and/or modify it "
"under the terms of the GNU General Public License version 3, as published "
"by the Free Software Foundation."
,
796 N_("This program is distributed in the hope that it will be useful, but ""This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
797 "WITHOUT ANY WARRANTY; without even the implied warranties of ""This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
798 "MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR ""This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
799 "PURPOSE. See the GNU General Public License for more details.")"This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
,
800 N_("You should have received a copy of the GNU General Public License along ""You should have received a copy of the GNU General Public License along "
"with this program. If not, see <http://www.gnu.org/licenses/>."
801 "with this program. If not, see <http://www.gnu.org/licenses/>.")"You should have received a copy of the GNU General Public License along "
"with this program. If not, see <http://www.gnu.org/licenses/>."
,
802 NULL((void*)0)
803 };
804 gchar *license_i18n;
805
806 license_i18n = g_strconcat (_(license[0])dcgettext (((void*)0), license[0], 5), "\n\n", _(license[1])dcgettext (((void*)0), license[1], 5), "\n\n", _(license[2])dcgettext (((void*)0), license[2], 5), NULL((void*)0));
807
808 gtk_show_about_dialog(NULL((void*)0),
809 "version", VERSION"1.24.0",
810 "copyright", _("Copyright \xc2\xa9 2009-2010 Canonical, Ltd.\n"dcgettext (((void*)0), "Copyright \xc2\xa9 2009-2010 Canonical, Ltd.\n"
"Copyright \xc2\xa9 2011-2020 MATE developers", 5)
811 "Copyright \xc2\xa9 2011-2020 MATE developers")dcgettext (((void*)0), "Copyright \xc2\xa9 2009-2010 Canonical, Ltd.\n"
"Copyright \xc2\xa9 2011-2020 MATE developers", 5)
,
812#ifdef INDICATOR_APPLET_APPMENU
813 "comments", _("An applet to hold your application menus.")dcgettext (((void*)0), "An applet to hold your application menus."
, 5)
,
814#endif
815 "comments", _("An applet to hold all of the system indicators.")dcgettext (((void*)0), "An applet to hold all of the system indicators."
, 5)
,
816 "authors", authors,
817 "license", license_i18n,
818 "wrap-license", TRUE(!(0)),
819 "translator-credits", _("translator-credits")dcgettext (((void*)0), "translator-credits", 5),
820 "logo-icon-name", "mate-indicator-applet",
821 "icon-name", "mate-indicator-applet",
822 "website", "https://mate-desktop.org",
823 "website-label", _("MATE Website")dcgettext (((void*)0), "MATE Website", 5),
824 NULL((void*)0)
825 );
826
827 g_free (license_i18n);
828
829 return;
830}
831
832static gboolean
833swap_orient_cb (GtkWidget *item, gpointer data)
834{
835 GtkWidget *from = (GtkWidget *) data;
836 GtkWidget *to = (GtkWidget *) g_object_get_data(G_OBJECT(from)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
from)), (((GType) ((20) << (2))))))))
, "to");
837 g_object_ref(G_OBJECT(item)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
item)), (((GType) ((20) << (2))))))))
);
838 gtk_container_remove(GTK_CONTAINER(from)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((from)), ((gtk_container_get_type ()))))))
, item);
839 if (GTK_IS_LABEL(item)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(item)); GType __t = ((gtk_label_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; }))))
) {
840 switch(packdirection) {
841 case GTK_PACK_DIRECTION_LTR:
842 gtk_label_set_angle(GTK_LABEL(item)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(item)), ((gtk_label_get_type ()))))))
, 0.0);
843 break;
844 case GTK_PACK_DIRECTION_TTB:
845 gtk_label_set_angle(GTK_LABEL(item)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(item)), ((gtk_label_get_type ()))))))
,
846 (orient == MATE_PANEL_APPLET_ORIENT_LEFT) ?
847 270.0 : 90.0);
848 break;
849 default:
850 break;
851 }
852 }
853 gtk_box_pack_start(GTK_BOX(to)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((to
)), ((gtk_box_get_type ()))))))
, item, FALSE(0), FALSE(0), 0);
854 return TRUE(!(0));
855}
856
857static gboolean
858reorient_box_cb (GtkWidget *menuitem, gpointer data)
859{
860 GtkWidget *from = g_object_get_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "box");
861 GtkWidget *to = (packdirection == GTK_PACK_DIRECTION_LTR) ?
862 gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0) : gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
863 g_object_set_data(G_OBJECT(from)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
from)), (((GType) ((20) << (2))))))))
, "to", to);
864 gtk_container_foreach(GTK_CONTAINER(from)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((from)), ((gtk_container_get_type ()))))))
, (GtkCallback)swap_orient_cb,
865 from);
866 gtk_container_remove(GTK_CONTAINER(menuitem)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menuitem)), ((gtk_container_get_type ()))))))
, from);
867 gtk_container_add(GTK_CONTAINER(menuitem)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menuitem)), ((gtk_container_get_type ()))))))
, to);
868 g_object_set_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "box", to);
869 gtk_widget_show_all(menuitem);
870 return TRUE(!(0));
871}
872
873static gboolean
874matepanelapplet_reorient_cb (GtkWidget *applet, MatePanelAppletOrient neworient,
875 gpointer data)
876{
877 GtkWidget *menubar = (GtkWidget *)data;
878 if ((((neworient == MATE_PANEL_APPLET_ORIENT_UP) ||
879 (neworient == MATE_PANEL_APPLET_ORIENT_DOWN)) &&
880 ((orient == MATE_PANEL_APPLET_ORIENT_LEFT) ||
881 (orient == MATE_PANEL_APPLET_ORIENT_RIGHT))) ||
882 (((neworient == MATE_PANEL_APPLET_ORIENT_LEFT) ||
883 (neworient == MATE_PANEL_APPLET_ORIENT_RIGHT)) &&
884 ((orient == MATE_PANEL_APPLET_ORIENT_UP) ||
885 (orient == MATE_PANEL_APPLET_ORIENT_DOWN)))) {
886 packdirection = (packdirection == GTK_PACK_DIRECTION_LTR) ?
887 GTK_PACK_DIRECTION_TTB : GTK_PACK_DIRECTION_LTR;
888 gtk_menu_bar_set_pack_direction(GTK_MENU_BAR(menubar)((((GtkMenuBar*) g_type_check_instance_cast ((GTypeInstance*)
((menubar)), ((gtk_menu_bar_get_type ()))))))
,
889 packdirection);
890 orient = neworient;
891 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
,
892 (GtkCallback)reorient_box_cb, NULL((void*)0));
893 }
894 orient = neworient;
895 return FALSE(0);
896}
897
898#ifdef N_
899#undef N_
900#endif
901#define N_(x)x x
902
903static void
904log_to_file_cb (GObject * source_obj G_GNUC_UNUSED__attribute__((__unused__)),
905 GAsyncResult * result G_GNUC_UNUSED__attribute__((__unused__)), gpointer user_data)
906{
907 g_free(user_data);
908 return;
909}
910
911static void
912log_to_file (const gchar * domain G_GNUC_UNUSED__attribute__((__unused__)),
913 GLogLevelFlags level G_GNUC_UNUSED__attribute__((__unused__)),
914 const gchar * message,
915 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
916{
917 if (log_file == NULL((void*)0)) {
918 GError * error = NULL((void*)0);
919 gchar * filename = g_build_filename(g_get_user_cache_dir(), LOG_FILE_NAME"indicator-applet.log", NULL((void*)0));
920 GFile * file = g_file_new_for_path(filename);
921 g_free(filename);
922
923 if (!g_file_test(g_get_user_cache_dir(), G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) {
924 GFile * cachedir = g_file_new_for_path(g_get_user_cache_dir());
925 g_file_make_directory_with_parents(cachedir, NULL((void*)0), &error);
926
927 if (error != NULL((void*)0)) {
928 g_error("Unable to make directory '%s' for log file: %s", g_get_user_cache_dir(), error->message);
929 return;
This statement is never executed
930 }
931 }
932
933 g_file_delete(file, NULL((void*)0), NULL((void*)0));
934
935 GFileIOStream * io = g_file_create_readwrite(file,
936 G_FILE_CREATE_REPLACE_DESTINATION, /* flags */
937 NULL((void*)0), /* cancelable */
938 &error); /* error */
939 if (error != NULL((void*)0)) {
940 g_error("Unable to replace file: %s", error->message);
941 return;
942 }
943
944 log_file = g_io_stream_get_output_stream(G_IO_STREAM(io)((((GIOStream*) g_type_check_instance_cast ((GTypeInstance*) (
(io)), ((g_io_stream_get_type ()))))))
);
945 }
946
947 gchar * outputstring = g_strdup_printf("%s\n", message);
948 g_output_stream_write_async(log_file,
949 outputstring, /* data */
950 strlen(outputstring), /* length */
951 G_PRIORITY_LOW300, /* priority */
952 NULL((void*)0), /* cancelable */
953 log_to_file_cb, /* callback */
954 outputstring); /* data */
955
956 return;
957}
958
959static gboolean
960applet_fill_cb (MatePanelApplet * applet, const gchar * iid G_GNUC_UNUSED__attribute__((__unused__)),
961 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
962{
963#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
964 ido_init();
965#endif
966
967 static const GtkActionEntry menu_actions[] = {
968 {"About", GTK_STOCK_ABOUT((GtkStock)"gtk-about"), N_("_About")"_About", NULL((void*)0), NULL((void*)0), G_CALLBACK(about_cb)((GCallback) (about_cb))}
969 };
970 static const gchar *menu_xml = "<menuitem name=\"About\" action=\"About\"/>";
971
972 static gboolean first_time = FALSE(0);
973 GtkWidget *menubar;
974 gint indicators_loaded = 0;
975 GtkActionGroup *action_group;
976
977 if (!first_time)
978 {
979 first_time = TRUE(!(0));
980#ifdef INDICATOR_APPLET1
981 g_set_application_name(_("Indicator Applet")dcgettext (((void*)0), "Indicator Applet", 5));
982#endif
983#ifdef INDICATOR_APPLET_COMPLETE
984 g_set_application_name(_("Indicator Applet Complete")dcgettext (((void*)0), "Indicator Applet Complete", 5));
985#endif
986#ifdef INDICATOR_APPLET_APPMENU
987 g_set_application_name(_("Indicator Applet Application Menu")dcgettext (((void*)0), "Indicator Applet Application Menu", 5
)
);
988#endif
989
990 g_log_set_default_handler(log_to_file, NULL((void*)0));
991
992 tomboy_keybinder_init();
993 }
994
995 /* Set panel options */
996 gtk_container_set_border_width(GTK_CONTAINER (applet)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_container_get_type ()))))))
, 0);
997 mate_panel_applet_set_flags(applet, MATE_PANEL_APPLET_EXPAND_MINOR);
998 menubar = gtk_menu_bar_new();
999 action_group = gtk_action_group_new ("Indicator Applet Actions");
1000 gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE"mate-indicator-applet");
1001 gtk_action_group_add_actions (action_group, menu_actions,
1002 G_N_ELEMENTS (menu_actions)(sizeof (menu_actions) / sizeof ((menu_actions)[0])),
1003 menubar);
1004 mate_panel_applet_setup_menu(applet, menu_xml, action_group);
1005 g_object_unref(action_group);
1006#ifdef INDICATOR_APPLET1
1007 atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
),
1008 "indicator-applet");
1009#endif
1010#ifdef INDICATOR_APPLET_COMPLETE
1011 atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
),
1012 "indicator-applet-complete");
1013#endif
1014#ifdef INDICATOR_APPLET_APPMENU
1015 atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
),
1016 "indicator-applet-appmenu");
1017#endif
1018
1019 /* Init some theme/icon stuff */
1020 gtk_icon_theme_append_search_path(gtk_icon_theme_get_default(),
1021 INDICATOR_ICONS_DIR"/usr/share/libindicator/icons/");
1022 /* g_debug("Icons directory: %s", INDICATOR_ICONS_DIR); */
1023 gtk_widget_set_name(GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
, "fast-user-switch-applet");
1024
1025 /* Build menubar */
1026 size = (mate_panel_applet_get_size (applet));
1027 orient = (mate_panel_applet_get_orient(applet));
1028 packdirection = ((orient == MATE_PANEL_APPLET_ORIENT_UP) ||
1029 (orient == MATE_PANEL_APPLET_ORIENT_DOWN)) ?
1030 GTK_PACK_DIRECTION_LTR : GTK_PACK_DIRECTION_TTB;
1031 gtk_menu_bar_set_pack_direction(GTK_MENU_BAR(menubar)((((GtkMenuBar*) g_type_check_instance_cast ((GTypeInstance*)
((menubar)), ((gtk_menu_bar_get_type ()))))))
,
1032 packdirection);
1033 gtk_widget_set_can_focus (menubar, TRUE(!(0)));
1034 gtk_widget_set_name(GTK_WIDGET (menubar)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(menubar)), ((gtk_widget_get_type ()))))))
, "fast-user-switch-menubar");
1035 g_signal_connect(menubar, "button-press-event", G_CALLBACK(menubar_press), NULL)g_signal_connect_data ((menubar), ("button-press-event"), (((
GCallback) (menubar_press))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
;
1036 g_signal_connect_after(menubar, "draw", G_CALLBACK(menubar_on_draw), menubar)g_signal_connect_data ((menubar), ("draw"), (((GCallback) (menubar_on_draw
))), (menubar), ((void*)0), G_CONNECT_AFTER)
;
1037 g_signal_connect(applet, "change-orient",g_signal_connect_data ((applet), ("change-orient"), (((GCallback
) (matepanelapplet_reorient_cb))), (menubar), ((void*)0), (GConnectFlags
) 0)
1038 G_CALLBACK(matepanelapplet_reorient_cb), menubar)g_signal_connect_data ((applet), ("change-orient"), (((GCallback
) (matepanelapplet_reorient_cb))), (menubar), ((void*)0), (GConnectFlags
) 0)
;
1039 gtk_container_set_border_width(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, 0);
1040
1041 /* Add in filter func */
1042 tomboy_keybinder_bind(hotkey_keycode, hotkey_filter, menubar);
1043
1044 load_modules(applet, menubar, &indicators_loaded);
1045#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
1046 load_indicators_from_indicator_files(applet, menubar, &indicators_loaded);
1047#endif
1048
1049 if (indicators_loaded == 0) {
1050 /* A label to allow for click through */
1051 GtkWidget * item = gtk_label_new(_("No Indicators")dcgettext (((void*)0), "No Indicators", 5));
1052 mate_panel_applet_set_background_widget(applet, item);
1053 gtk_container_add(GTK_CONTAINER(applet)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_container_get_type ()))))))
, item);
1054 gtk_widget_show(item);
1055 } else {
1056 gtk_container_add(GTK_CONTAINER(applet)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_container_get_type ()))))))
, menubar);
1057 mate_panel_applet_set_background_widget(applet, menubar);
1058 gtk_widget_show(menubar);
1059 }
1060
1061 gtk_widget_show(GTK_WIDGET(applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
);
1062
1063 return TRUE(!(0));
1064
1065}
diff --git a/2020-04-09-123617-6853-1@4b55003793c9_master/report-5ba708.html b/2020-04-09-123617-6853-1@4b55003793c9_master/report-5ba708.html new file mode 100644 index 0000000..8f3f084 --- /dev/null +++ b/2020-04-09-123617-6853-1@4b55003793c9_master/report-5ba708.html @@ -0,0 +1,1412 @@ + + + +applet-main.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:applet-main.c
Warning:line 941, column 4
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name applet-main.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -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 -mrelocation-model static -mthread-model posix -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -momit-leaf-frame-pointer -resource-dir /usr/lib64/clang/9.0.1 -D HAVE_CONFIG_H -I . -I .. -D G_LOG_DOMAIN="Indicator-Applet" -D DATADIR="/usr/local/share" -D INDICATOR_DIR="/usr/lib64/indicators3/7/" -D INDICATOR_ICONS_DIR="/usr/share/libindicator/icons/" -D INDICATOR_APPLET -I ./.. -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/fribidi -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gio-unix-2.0 -I /usr/include/libdrm -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-panel-4.0/libmate-panel-applet -I /usr/include/libindicator3-0.4 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/fribidi -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gio-unix-2.0 -I /usr/include/libdrm -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/9.0.1/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wno-unused-parameter -Wno-sign-compare -fdebug-compilation-dir /rootdir/src -ferror-limit 19 -fmessage-length 0 -fobjc-runtime=gcc -fdiagnostics-show-option -vectorize-loops -vectorize-slp -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 -o /rootdir/html-report/2020-04-09-123617-6853-1 -x c applet-main.c +
+ + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2A small wrapper utility to load indicators and put them as menu items
3into the mate-panel using it's applet interface.
4
5Copyright 2009-2010 Canonical Ltd.
6
7Authors:
8 Ted Gould <ted@canonical.com>
9
10This program is free software: you can redistribute it and/or modify it
11under the terms of the GNU General Public License version 3, as published
12by the Free Software Foundation.
13
14This program is distributed in the hope that it will be useful, but
15WITHOUT ANY WARRANTY; without even the implied warranties of
16MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
17PURPOSE. See the GNU General Public License for more details.
18
19You should have received a copy of the GNU General Public License along
20with this program. If not, see <http://www.gnu.org/licenses/>.
21*/
22
23#include <stdlib.h>
24#include <string.h>
25#include <config.h>
26#include <glib/gi18n.h>
27#include <mate-panel-applet.h>
28#include <gdk/gdkkeysyms.h>
29#include <gtk/gtk.h>
30
31#if HAVE_UBUNTU_INDICATOR1
32
33#define INDICATOR_SERVICE_APPMENU"libappmenu.so" "libappmenu.so"
34#define INDICATOR_SERVICE_ME"libme.so" "libme.so"
35#define INDICATOR_SERVICE_DATETIME"libdatetime.so" "libdatetime.so"
36
37#define INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu" "com.canonical.indicator.appmenu"
38#define INDICATOR_SERVICE_ME_NG"com.canonical.indicator.me" "com.canonical.indicator.me"
39#define INDICATOR_SERVICE_DATETIME_NG"com.canonical.indicator.datetime" "com.canonical.indicator.datetime"
40
41#include <libindicator/indicator-object.h>
42#endif
43
44#if HAVE_AYATANA_INDICATOR
45
46#define INDICATOR_SERVICE_APPMENU"libappmenu.so" "libayatana-appmenu.so"
47#define INDICATOR_SERVICE_ME"libme.so" "libayatana-me.so"
48#define INDICATOR_SERVICE_DATETIME"libdatetime.so" "libayatana-datetime.so"
49
50#define INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu" "org.ayatana.indicator.appmenu"
51#define INDICATOR_SERVICE_ME_NG"com.canonical.indicator.me" "org.ayatana.indicator.me"
52#define INDICATOR_SERVICE_DATETIME_NG"com.canonical.indicator.datetime" "org.ayatana.indicator.datetime"
53
54#include <libayatana-indicator/indicator-object.h>
55#endif
56
57/* For new style indicators */
58
59#if HAVE_UBUNTU_INDICATOR1 && HAVE_UBUNTU_INDICATOR_NG
60
61#include <libido/libido.h>
62#include <libindicator/indicator-ng.h>
63
64#define INDICATOR_SERVICE_DIR "/usr/share/unity/indicators"
65
66#endif
67
68#if HAVE_AYATANA_INDICATOR && HAVE_AYATANA_INDICATOR_NG
69
70#include <libayatana-ido/libayatana-ido.h>
71#include <libayatana-indicator/indicator-ng.h>
72
73#define INDICATOR_SERVICE_DIR "/usr/share/ayatana/indicators"
74
75#endif
76
77#include "tomboykeybinder.h"
78
79static gchar * indicator_order[] = {
80#if HAVE_UBUNTU_INDICATOR1
81 "libapplication.so",
82 "libmessaging.so",
83 "libsoundmenu.so",
84 "libdatetime.so",
85 "libsession.so",
86#endif
87#if HAVE_AYATANA_INDICATOR
88 "libayatana-application.so",
89 "libayatana-messaging.so",
90 "libayatana-soundmenu.so",
91 "libayatana-datetime.so",
92 "libayatana-session.so",
93#endif
94 NULL((void*)0)
95};
96
97static GtkPackDirection packdirection;
98static MatePanelAppletOrient orient;
99static guint size;
100
101#define MENU_DATA_INDICATOR_OBJECT"indicator-object" "indicator-object"
102#define MENU_DATA_INDICATOR_ENTRY"indicator-entry" "indicator-entry"
103
104#define IO_DATA_ORDER_NUMBER"indicator-order-number" "indicator-order-number"
105
106static gboolean applet_fill_cb (MatePanelApplet * applet, const gchar * iid, gpointer data);
107
108static void update_accessible_desc (IndicatorObjectEntry * entry, GtkWidget * menuitem);
109
110/*************
111 * main
112 * ***********/
113
114#ifdef INDICATOR_APPLET1
115MATE_PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletFactory",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
116 PANEL_TYPE_APPLET,int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
117 "indicator-applet",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
118 applet_fill_cb, NULL)int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
;
119#endif
120#ifdef INDICATOR_APPLET_COMPLETE
121MATE_PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletCompleteFactory",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
122 PANEL_TYPE_APPLET,int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
123 "indicator-applet-complete",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
124 applet_fill_cb, NULL)int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
;
125#endif
126#ifdef INDICATOR_APPLET_APPMENU
127MATE_PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletAppmenuFactory",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
128 PANEL_TYPE_APPLET,int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
129 "indicator-applet-appmenu",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
130 applet_fill_cb, NULL)int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
;
131#endif
132
133/*************
134 * log files
135 * ***********/
136#ifdef INDICATOR_APPLET1
137#define LOG_FILE_NAME"indicator-applet.log" "indicator-applet.log"
138#endif
139#ifdef INDICATOR_APPLET_COMPLETE
140#define LOG_FILE_NAME"indicator-applet.log" "indicator-applet-complete.log"
141#endif
142#ifdef INDICATOR_APPLET_APPMENU
143#define LOG_FILE_NAME"indicator-applet.log" "indicator-applet-appmenu.log"
144#endif
145GOutputStream * log_file = NULL((void*)0);
146
147/*****************
148 * Hotkey support
149 * **************/
150#ifdef INDICATOR_APPLET1
151gchar * hotkey_keycode = "<Super>M";
152#endif
153#ifdef INDICATOR_APPLET_SESSION
154gchar * hotkey_keycode = "<Super>S";
155#endif
156#ifdef INDICATOR_APPLET_COMPLETE
157gchar * hotkey_keycode = "<Super>S";
158#endif
159#ifdef INDICATOR_APPLET_APPMENU
160gchar * hotkey_keycode = "<Super>F1";
161#endif
162
163/********************
164 * Environment Names
165 * *******************/
166#ifdef INDICATOR_APPLET1
167#define INDICATOR_SPECIFIC_ENV"indicator-applet-original" "indicator-applet-original"
168#endif
169#ifdef INDICATOR_APPLET_COMPLETE
170#define INDICATOR_SPECIFIC_ENV"indicator-applet-original" "indicator-applet-complete"
171#endif
172#ifdef INDICATOR_APPLET_APPMENU
173#define INDICATOR_SPECIFIC_ENV"indicator-applet-original" "indicator-applet-appmenu"
174#endif
175
176static const gchar * indicator_env[] = {
177 "indicator-applet",
178 INDICATOR_SPECIFIC_ENV"indicator-applet-original",
179 NULL((void*)0)
180};
181
182/*************
183 * init function
184 * ***********/
185
186static gint
187name2order (const gchar * name) {
188 int i;
189
190 for (i = 0; indicator_order[i] != NULL((void*)0); i++) {
191 if (g_strcmp0(name, indicator_order[i]) == 0) {
192 return i;
193 }
194 }
195
196 return -1;
197}
198
199typedef struct _incoming_position_t incoming_position_t;
200struct _incoming_position_t {
201 gint objposition;
202 gint entryposition;
203 gint menupos;
204 gboolean found;
205};
206
207/* This function helps by determining where in the menu list
208 this new entry should be placed. It compares the objects
209 that they're on, and then the individual entries. Each
210 is progressively more expensive. */
211static void
212place_in_menu (GtkWidget * widget, gpointer user_data)
213{
214 incoming_position_t * position = (incoming_position_t *)user_data;
215 if (position->found) {
216 /* We've already been placed, just finish the foreach */
217 return;
218 }
219
220 IndicatorObject * io = INDICATOR_OBJECT(g_object_get_data(G_OBJECT(widget), MENU_DATA_INDICATOR_OBJECT))((((IndicatorObject*) g_type_check_instance_cast ((GTypeInstance
*) ((g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((widget)), (((GType) ((20) << (2)))
))))), "indicator-object"))), ((indicator_object_get_type ())
)))))
;
221 g_assert(io != NULL)do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_
; if (io != ((void*)0)) _g_boolean_var_ = 1; else _g_boolean_var_
= 0; _g_boolean_var_; }), 1)) ; else g_assertion_message_expr
("Indicator-Applet", "applet-main.c", 221, ((const char*) (__func__
)), "io != NULL"); } while (0)
;
222
223 gint objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER))((gint) (glong) (g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
), "indicator-order-number")))
;
224 /* We've already passed it, well, then this is where
225 we should be be. Stop! */
226 if (objposition > position->objposition) {
227 position->found = TRUE(!(0));
228 return;
229 }
230
231 /* The objects don't match yet, keep looking */
232 if (objposition < position->objposition) {
233 position->menupos++;
234 return;
235 }
236
237 /* The objects are the same, let's start looking at entries. */
238 IndicatorObjectEntry * entry = (IndicatorObjectEntry *)g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
239 gint entryposition = indicator_object_get_location(io, entry);
240
241 if (entryposition > position->entryposition) {
242 position->found = TRUE(!(0));
243 return;
244 }
245
246 if (entryposition < position->entryposition) {
247 position->menupos++;
248 return;
249 }
250
251 /* We've got the same object and the same entry. Well,
252 let's just put it right here then. */
253 position->found = TRUE(!(0));
254 return;
255}
256
257static void
258something_shown (GtkWidget * widget, gpointer user_data)
259{
260 GtkWidget * menuitem = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
261 gtk_widget_show(menuitem);
262}
263
264static void
265something_hidden (GtkWidget * widget, gpointer user_data)
266{
267 GtkWidget * menuitem = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
268 gtk_widget_hide(menuitem);
269}
270
271static void
272sensitive_cb (GObject * obj, GParamSpec * pspec, gpointer user_data)
273{
274 g_return_if_fail(GTK_IS_WIDGET(obj))do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((obj)); GType __t = ((gtk_widget_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet", ((const
char*) (__func__)), "GTK_IS_WIDGET(obj)"); return; } } while
(0)
;
275 g_return_if_fail(GTK_IS_WIDGET(user_data))do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((gtk_widget_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet", ((const
char*) (__func__)), "GTK_IS_WIDGET(user_data)"); return; } }
while (0)
;
276
277 gtk_widget_set_sensitive(GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
, gtk_widget_get_sensitive(GTK_WIDGET(obj)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(obj)), ((gtk_widget_get_type ()))))))
));
278 return;
279}
280
281static void
282entry_activated (GtkWidget * widget, gpointer user_data)
283{
284 g_return_if_fail(GTK_IS_WIDGET(widget))do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((gtk_widget_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet", ((const
char*) (__func__)), "GTK_IS_WIDGET(widget)"); return; } } while
(0)
;
285 gpointer pio = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, "indicator");
286 g_return_if_fail(INDICATOR_IS_OBJECT(pio))do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((pio)); GType __t = ((indicator_object_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet", ((const
char*) (__func__)), "INDICATOR_IS_OBJECT(pio)"); return; } }
while (0)
;
287 IndicatorObject * io = INDICATOR_OBJECT(pio)((((IndicatorObject*) g_type_check_instance_cast ((GTypeInstance
*) ((pio)), ((indicator_object_get_type ()))))))
;
288
289 return indicator_object_entry_activate(io, (IndicatorObjectEntry *)user_data, gtk_get_current_event_time());
290}
291
292static gboolean
293entry_scrolled (GtkWidget *menuitem, GdkEventScroll *event, gpointer data)
294{
295 IndicatorObject *io = g_object_get_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_OBJECT"indicator-object");
296 IndicatorObjectEntry *entry = g_object_get_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
297
298 g_return_val_if_fail(INDICATOR_IS_OBJECT(io), FALSE)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((io)); GType __t = ((indicator_object_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet", ((const
char*) (__func__)), "INDICATOR_IS_OBJECT(io)"); return ((0))
; } } while (0)
;
299
300 g_signal_emit_by_name (io, "scroll", 1, event->direction);
301 g_signal_emit_by_name (io, "scroll-entry", entry, 1, event->direction);
302 g_signal_emit_by_name (io, INDICATOR_OBJECT_SIGNAL_ENTRY_SCROLLED"entry-scrolled", entry, 1, event->direction);
303
304 return FALSE(0);
305}
306
307static void
308accessible_desc_update_cb (GtkWidget * widget, gpointer userdata)
309{
310 gpointer data = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
311
312 if (data != userdata) {
313 return;
314 }
315
316 IndicatorObjectEntry * entry = (IndicatorObjectEntry *)data;
317 update_accessible_desc(entry, widget);
318}
319
320static void
321accessible_desc_update (IndicatorObject * io, IndicatorObjectEntry * entry, GtkWidget * menubar)
322{
323 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, accessible_desc_update_cb, entry);
324 return;
325}
326
327#define PANEL_PADDING8 8
328static gboolean
329entry_resized (GtkWidget *applet, guint newsize, gpointer data)
330{
331 IndicatorObject *io = (IndicatorObject *)data;
332
333 size = newsize;
334
335 /* Work on the entries */
336 GList * entries = indicator_object_get_entries(io);
337 GList * entry = NULL((void*)0);
338
339 for (entry = entries; entry != NULL((void*)0); entry = g_list_next(entry)((entry) ? (((GList *)(entry))->next) : ((void*)0))) {
340 IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)entry->data;
341 if (entrydata->image != NULL((void*)0)) {
342 /* Resize to fit panel */
343 gtk_image_set_pixel_size (entrydata->image, size - PANEL_PADDING8);
344 }
345 }
346
347 return FALSE(0);
348}
349
350static void
351entry_added (IndicatorObject * io, IndicatorObjectEntry * entry, GtkWidget * menubar)
352{
353 g_debug("Signal: Entry Added");
354 gboolean something_visible = FALSE(0);
355 gboolean something_sensitive = FALSE(0);
356
357 GtkWidget * menuitem = gtk_menu_item_new();
358 GtkWidget * box = (packdirection == GTK_PACK_DIRECTION_LTR) ?
359 gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3) : gtk_box_new(GTK_ORIENTATION_VERTICAL, 3);
360
361 /* Allows indicators to receive mouse scroll event */
362 gtk_widget_add_events(GTK_WIDGET(menuitem)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(menuitem)), ((gtk_widget_get_type ()))))))
, GDK_SCROLL_MASK);
363
364 g_object_set_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "indicator", io);
365 g_object_set_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "box", box);
366
367 g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(entry_activated), entry)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((menuitem)), (((GType) ((20) << (2)
)))))))), ("activate"), (((GCallback) (entry_activated))), (entry
), ((void*)0), (GConnectFlags) 0)
;
368 g_signal_connect(G_OBJECT(menuitem), "scroll-event", G_CALLBACK(entry_scrolled), entry)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((menuitem)), (((GType) ((20) << (2)
)))))))), ("scroll-event"), (((GCallback) (entry_scrolled))),
(entry), ((void*)0), (GConnectFlags) 0)
;
369
370 if (entry->image != NULL((void*)0)) {
371 /* Resize to fit panel */
372 gtk_image_set_pixel_size (entry->image, size - PANEL_PADDING8);
373 gtk_box_pack_start(GTK_BOX(box)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((box
)), ((gtk_box_get_type ()))))))
, GTK_WIDGET(entry->image)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->image)), ((gtk_widget_get_type ()))))))
, FALSE(0), FALSE(0), 1);
374 if (gtk_widget_get_visible(GTK_WIDGET(entry->image)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->image)), ((gtk_widget_get_type ()))))))
)) {
375 something_visible = TRUE(!(0));
376 }
377
378 if (gtk_widget_get_sensitive(GTK_WIDGET(entry->image)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->image)), ((gtk_widget_get_type ()))))))
)) {
379 something_sensitive = TRUE(!(0));
380 }
381
382 g_signal_connect(G_OBJECT(entry->image), "show", G_CALLBACK(something_shown), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), ("show"), (((GCallback) (something_shown))), (menuitem
), ((void*)0), (GConnectFlags) 0)
;
383 g_signal_connect(G_OBJECT(entry->image), "hide", G_CALLBACK(something_hidden), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), ("hide"), (((GCallback) (something_hidden))), (
menuitem), ((void*)0), (GConnectFlags) 0)
;
384
385 g_signal_connect(G_OBJECT(entry->image), "notify::sensitive", G_CALLBACK(sensitive_cb), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), ("notify::sensitive"), (((GCallback) (sensitive_cb
))), (menuitem), ((void*)0), (GConnectFlags) 0)
;
386 }
387 if (entry->label != NULL((void*)0)) {
388 switch(packdirection) {
389 case GTK_PACK_DIRECTION_LTR:
390 gtk_label_set_angle(GTK_LABEL(entry->label)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_label_get_type ()))))))
, 0.0);
391 break;
392 case GTK_PACK_DIRECTION_TTB:
393 gtk_label_set_angle(GTK_LABEL(entry->label)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_label_get_type ()))))))
,
394 (orient == MATE_PANEL_APPLET_ORIENT_LEFT) ?
395 270.0 : 90.0);
396 break;
397 default:
398 break;
399 }
400 gtk_box_pack_start(GTK_BOX(box)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((box
)), ((gtk_box_get_type ()))))))
, GTK_WIDGET(entry->label)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_widget_get_type ()))))))
, FALSE(0), FALSE(0), 1);
401
402 if (gtk_widget_get_visible(GTK_WIDGET(entry->label)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_widget_get_type ()))))))
)) {
403 something_visible = TRUE(!(0));
404 }
405
406 if (gtk_widget_get_sensitive(GTK_WIDGET(entry->label)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_widget_get_type ()))))))
)) {
407 something_sensitive = TRUE(!(0));
408 }
409
410 g_signal_connect(G_OBJECT(entry->label), "show", G_CALLBACK(something_shown), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), ("show"), (((GCallback) (something_shown))), (menuitem
), ((void*)0), (GConnectFlags) 0)
;
411 g_signal_connect(G_OBJECT(entry->label), "hide", G_CALLBACK(something_hidden), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), ("hide"), (((GCallback) (something_hidden))), (
menuitem), ((void*)0), (GConnectFlags) 0)
;
412
413 g_signal_connect(G_OBJECT(entry->label), "notify::sensitive", G_CALLBACK(sensitive_cb), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), ("notify::sensitive"), (((GCallback) (sensitive_cb
))), (menuitem), ((void*)0), (GConnectFlags) 0)
;
414 }
415 gtk_container_add(GTK_CONTAINER(menuitem)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menuitem)), ((gtk_container_get_type ()))))))
, box);
416 gtk_widget_show(box);
417
418 if (entry->menu != NULL((void*)0)) {
419 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem)((((GtkMenuItem*) g_type_check_instance_cast ((GTypeInstance*
) ((menuitem)), ((gtk_menu_item_get_type ()))))))
, GTK_WIDGET(entry->menu)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->menu)), ((gtk_widget_get_type ()))))))
);
420 }
421
422 incoming_position_t position;
423 position.objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER))((gint) (glong) (g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
), "indicator-order-number")))
;
424 position.entryposition = indicator_object_get_location(io, entry);
425 position.menupos = 0;
426 position.found = FALSE(0);
427
428 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, place_in_menu, &position);
429
430 gtk_menu_shell_insert(GTK_MENU_SHELL(menubar)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_menu_shell_get_type ()))))))
, menuitem, position.menupos);
431
432 if (something_visible) {
433 if (entry->accessible_desc != NULL((void*)0)) {
434 update_accessible_desc(entry, menuitem);
435 }
436 gtk_widget_show(menuitem);
437 }
438 gtk_widget_set_sensitive(menuitem, something_sensitive);
439
440 g_object_set_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry", entry);
441 g_object_set_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_OBJECT"indicator-object", io);
442
443 return;
444}
445
446static void
447entry_removed_cb (GtkWidget * widget, gpointer userdata)
448{
449 gpointer data = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
450
451 if (data != userdata) {
452 return;
453 }
454
455 IndicatorObjectEntry * entry = (IndicatorObjectEntry *)data;
456 if (entry->label != NULL((void*)0)) {
457 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(something_shown), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_shown))), (widget
))
;
458 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(something_hidden), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_hidden))), (widget
))
;
459 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(sensitive_cb), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (sensitive_cb))), (widget)
)
;
460 }
461 if (entry->image != NULL((void*)0)) {
462 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(something_shown), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_shown))), (widget
))
;
463 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(something_hidden), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_hidden))), (widget
))
;
464 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(sensitive_cb), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (sensitive_cb))), (widget)
)
;
465 }
466
467 gtk_widget_destroy(widget);
468 return;
469}
470
471static void
472entry_removed (IndicatorObject * io G_GNUC_UNUSED__attribute__((__unused__)), IndicatorObjectEntry * entry,
473 gpointer user_data)
474{
475 g_debug("Signal: Entry Removed");
476
477 gtk_container_foreach(GTK_CONTAINER(user_data)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((gtk_container_get_type ()))))))
, entry_removed_cb, entry);
478
479 return;
480}
481
482static void
483entry_moved_find_cb (GtkWidget * widget, gpointer userdata)
484{
485 gpointer * array = (gpointer *)userdata;
486 if (array[1] != NULL((void*)0)) {
487 return;
488 }
489
490 gpointer data = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
491
492 if (data != array[0]) {
493 return;
494 }
495
496 array[1] = widget;
497 return;
498}
499
500/* Gets called when an entry for an object was moved. */
501static void
502entry_moved (IndicatorObject * io, IndicatorObjectEntry * entry,
503 gint old G_GNUC_UNUSED__attribute__((__unused__)), gint new G_GNUC_UNUSED__attribute__((__unused__)), gpointer user_data)
504{
505 GtkWidget * menubar = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
506
507 gpointer array[2];
508 array[0] = entry;
509 array[1] = NULL((void*)0);
510
511 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, entry_moved_find_cb, array);
512 if (array[1] == NULL((void*)0)) {
513 g_warning("Moving an entry that isn't in our menus.");
514 return;
515 }
516
517 GtkWidget * mi = GTK_WIDGET(array[1])((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(array[1])), ((gtk_widget_get_type ()))))))
;
518 g_object_ref(G_OBJECT(mi)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
mi)), (((GType) ((20) << (2))))))))
);
519 gtk_container_remove(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, mi);
520
521 incoming_position_t position;
522 position.objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER))((gint) (glong) (g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
), "indicator-order-number")))
;
523 position.entryposition = indicator_object_get_location(io, entry);
524 position.menupos = 0;
525 position.found = FALSE(0);
526
527 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, place_in_menu, &position);
528
529 gtk_menu_shell_insert(GTK_MENU_SHELL(menubar)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_menu_shell_get_type ()))))))
, mi, position.menupos);
530 g_object_unref(G_OBJECT(mi)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
mi)), (((GType) ((20) << (2))))))))
);
531
532 return;
533}
534
535static void
536menu_show (IndicatorObject * io, IndicatorObjectEntry * entry,
537 guint32 timestamp, gpointer user_data)
538{
539 GtkWidget * menubar = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
540
541 if (entry == NULL((void*)0)) {
542 /* Close any open menus instead of opening one */
543 GList * entries = indicator_object_get_entries(io);
544 GList * entry = NULL((void*)0);
545 for (entry = entries; entry != NULL((void*)0); entry = g_list_next(entry)((entry) ? (((GList *)(entry))->next) : ((void*)0))) {
546 IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)entry->data;
547 gtk_menu_popdown(entrydata->menu);
548 }
549 g_list_free(entries);
550
551 /* And tell the menubar to exit activation mode too */
552 gtk_menu_shell_cancel(GTK_MENU_SHELL(menubar)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_menu_shell_get_type ()))))))
);
553 return;
554 }
555
556 // TODO: do something sensible here
557}
558
559static void
560update_accessible_desc(IndicatorObjectEntry * entry, GtkWidget * menuitem)
561{
562 /* FIXME: We need to deal with the use case where the contents of the
563 label overrides what is found in the atk object's name, or at least
564 orca speaks the label instead of the atk object name.
565 */
566 AtkObject * menuitem_obj = gtk_widget_get_accessible(menuitem);
567 if (menuitem_obj == NULL((void*)0)) {
568 /* Should there be an error printed here? */
569 return;
570 }
571
572 if (entry->accessible_desc != NULL((void*)0)) {
573 atk_object_set_name(menuitem_obj, entry->accessible_desc);
574 } else {
575 atk_object_set_name(menuitem_obj, "");
576 }
577 return;
578}
579
580static void
581load_indicator (MatePanelApplet *applet, GtkWidget * menubar, IndicatorObject *io, const gchar *name)
582{
583 /* Set the environment it's in */
584 indicator_object_set_environment(io, (const GStrv)indicator_env);
585
586 /* Attach the 'name' to the object */
587#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
588 int pos = 5000 - indicator_object_get_position(io);
589 if (pos > 5000) {
590 pos = name2order(name);
591 }
592#else
593 int pos = name2order(name);
594#endif
595
596 g_object_set_data(G_OBJECT(io)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
io)), (((GType) ((20) << (2))))))))
, IO_DATA_ORDER_NUMBER"indicator-order-number", GINT_TO_POINTER(pos)((gpointer) (glong) (pos)));
597
598 /* Connect to its signals */
599 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED, G_CALLBACK(entry_added), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("entry-added"), (((GCallback) (entry_added))), (menubar)
, ((void*)0), (GConnectFlags) 0)
;
600 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED, G_CALLBACK(entry_removed), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("entry-removed"), (((GCallback) (entry_removed))), (menubar
), ((void*)0), (GConnectFlags) 0)
;
601 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_MOVED, G_CALLBACK(entry_moved), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("entry-moved"), (((GCallback) (entry_moved))), (menubar)
, ((void*)0), (GConnectFlags) 0)
;
602 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_MENU_SHOW, G_CALLBACK(menu_show), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("menu-show"), (((GCallback) (menu_show))), (menubar), ((
void*)0), (GConnectFlags) 0)
;
603 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ACCESSIBLE_DESC_UPDATE, G_CALLBACK(accessible_desc_update), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("accessible-desc-update"), (((GCallback) (accessible_desc_update
))), (menubar), ((void*)0), (GConnectFlags) 0)
;
604
605 /* Track panel resize */
606 g_signal_connect_object(G_OBJECT(applet)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
applet)), (((GType) ((20) << (2))))))))
, "change-size", G_CALLBACK(entry_resized)((GCallback) (entry_resized)), G_OBJECT(io)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
io)), (((GType) ((20) << (2))))))))
, 0);
607
608 /* Work on the entries */
609 GList * entries = indicator_object_get_entries(io);
610 GList * entry = NULL((void*)0);
611
612 for (entry = entries; entry != NULL((void*)0); entry = g_list_next(entry)((entry) ? (((GList *)(entry))->next) : ((void*)0))) {
613 IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)entry->data;
614 entry_added(io, entrydata, menubar);
615 }
616
617 g_list_free(entries);
618}
619
620static gboolean
621load_module (const gchar * name, MatePanelApplet *applet, GtkWidget * menubar)
622{
623 g_debug("Looking at Module: %s", name);
624 g_return_val_if_fail(name != NULL, FALSE)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if (name != ((void*)0)) _g_boolean_var_ = 1; else _g_boolean_var_
= 0; _g_boolean_var_; }), 1))) { } else { g_return_if_fail_warning
("Indicator-Applet", ((const char*) (__func__)), "name != NULL"
); return ((0)); } } while (0)
;
625
626 if (!g_str_has_suffix(name, G_MODULE_SUFFIX"so")) {
627 return FALSE(0);
628 }
629
630 g_debug("Loading Module: %s", name);
631
632 /* Build the object for the module */
633 gchar * fullpath = g_build_filename(INDICATOR_DIR"/usr/lib64/indicators3/7/", name, NULL((void*)0));
634 IndicatorObject * io = indicator_object_new_from_file(fullpath);
635 g_free(fullpath);
636
637 load_indicator(applet, menubar, io, name);
638
639 return TRUE(!(0));
640}
641
642static void
643load_modules (MatePanelApplet *applet, GtkWidget *menubar, gint *indicators_loaded)
644{
645 if (g_file_test(INDICATOR_DIR"/usr/lib64/indicators3/7/", (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))) {
646 GDir * dir = g_dir_open(INDICATOR_DIR"/usr/lib64/indicators3/7/", 0, NULL((void*)0));
647
648 const gchar * name;
649 gint count = 0;
650 while ((name = g_dir_read_name(dir)) != NULL((void*)0)) {
651#ifdef INDICATOR_APPLET_APPMENU
652 if (g_strcmp0(name, INDICATOR_SERVICE_APPMENU"libappmenu.so")) {
653 continue;
654 }
655#else
656 if (!g_strcmp0(name, INDICATOR_SERVICE_APPMENU"libappmenu.so")) {
657 continue;
658 }
659#endif
660#ifdef INDICATOR_APPLET1
661 if (!g_strcmp0(name, INDICATOR_SERVICE_ME"libme.so")) {
662 continue;
663 }
664 if (!g_strcmp0(name, INDICATOR_SERVICE_DATETIME"libdatetime.so")) {
665 continue;
666 }
667#endif
668 if (load_module(name, applet, menubar)) {
669 count++;
670 }
671 }
672
673 *indicators_loaded += count;
674
675 g_dir_close (dir);
676 }
677}
678
679#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
680
681static void
682load_indicators_from_indicator_files (MatePanelApplet *applet, GtkWidget *menubar, gint *indicators_loaded)
683{
684 GDir *dir;
685 const gchar *name;
686 GError *error = NULL((void*)0);
687
688 dir = g_dir_open (INDICATOR_SERVICE_DIR, 0, &error);
689
690 if (!dir) {
691 g_warning ("unable to open indicator service file directory: %s", error->message);
692 g_error_free (error);
693
694 return;
695 }
696
697 gint count = 0;
698 while ((name = g_dir_read_name (dir))) {
699 gchar *filename;
700 IndicatorNg *indicator;
701
702 filename = g_build_filename (INDICATOR_SERVICE_DIR, name, NULL((void*)0));
703 indicator = indicator_ng_new_for_profile (filename, "desktop", &error);
704 g_free (filename);
705
706#ifdef INDICATOR_APPLET_APPMENU
707 if (g_strcmp0(name, INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu")) {
708 continue;
709 }
710#else
711 if (!g_strcmp0(name, INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu")) {
712 continue;
713 }
714#endif
715#ifdef INDICATOR_APPLET1
716 if (!g_strcmp0(name, INDICATOR_SERVICE_ME_NG"com.canonical.indicator.me")) {
717 continue;
718 }
719 if (!g_strcmp0(name, INDICATOR_SERVICE_DATETIME_NG"com.canonical.indicator.datetime")) {
720 continue;
721 }
722#endif
723
724 if (indicator) {
725 load_indicator(applet, menubar, INDICATOR_OBJECT (indicator)((((IndicatorObject*) g_type_check_instance_cast ((GTypeInstance
*) ((indicator)), ((indicator_object_get_type ()))))))
, name);
726 count++;
727 }else{
728 g_warning ("unable to load '%s': %s", name, error->message);
729 g_clear_error (&error);
730 }
731 }
732
733 *indicators_loaded += count;
734
735 g_dir_close (dir);
736}
737#endif /* HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG */
738
739static void
740hotkey_filter (char * keystring G_GNUC_UNUSED__attribute__((__unused__)), gpointer data)
741{
742 g_return_if_fail(GTK_IS_MENU_SHELL(data))do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((data)); GType __t = ((gtk_menu_shell_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet", ((const
char*) (__func__)), "GTK_IS_MENU_SHELL(data)"); return; } } while
(0)
;
743
744 /* Oh, wow, it's us! */
745 GList * children = gtk_container_get_children(GTK_CONTAINER(data)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((gtk_container_get_type ()))))))
);
746 if (children == NULL((void*)0)) {
747 g_debug("Menubar has no children");
748 return;
749 }
750
751 gtk_menu_shell_select_item(GTK_MENU_SHELL(data)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((gtk_menu_shell_get_type ()))))))
, GTK_WIDGET(g_list_last(children)->data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(g_list_last(children)->data)), ((gtk_widget_get_type ()))
))))
);
752 g_list_free(children);
753 return;
754}
755
756static gboolean
757menubar_press (GtkWidget * widget,
758 GdkEventButton *event,
759 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
760{
761 if (event->button != 1) {
762 g_signal_stop_emission_by_name(widget, "button-press-event");
763 }
764
765 return FALSE(0);
766}
767
768static gboolean
769menubar_on_draw (GtkWidget * widget,
770 cairo_t * cr,
771 GtkWidget * menubar)
772{
773 /* FIXME: either port to gtk_render_focus or remove this function */
774 if (gtk_widget_has_focus(menubar))
775 gtk_paint_focus(gtk_widget_get_style(widget),
776 cr,
777 gtk_widget_get_state(menubar),
778 widget, "menubar-applet", 0, 0, -1, -1);
779
780 return FALSE(0);
781}
782
783static void
784about_cb (GtkAction *action G_GNUC_UNUSED__attribute__((__unused__)),
785 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
786{
787 static const gchar *authors[] = {
788 "Ted Gould <ted@canonical.com>",
789 NULL((void*)0)
790 };
791
792 static gchar *license[] = {
793 N_("This program is free software: you can redistribute it and/or modify it ""This program is free software: you can redistribute it and/or modify it "
"under the terms of the GNU General Public License version 3, as published "
"by the Free Software Foundation."
794 "under the terms of the GNU General Public License version 3, as published ""This program is free software: you can redistribute it and/or modify it "
"under the terms of the GNU General Public License version 3, as published "
"by the Free Software Foundation."
795 "by the Free Software Foundation.")"This program is free software: you can redistribute it and/or modify it "
"under the terms of the GNU General Public License version 3, as published "
"by the Free Software Foundation."
,
796 N_("This program is distributed in the hope that it will be useful, but ""This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
797 "WITHOUT ANY WARRANTY; without even the implied warranties of ""This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
798 "MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR ""This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
799 "PURPOSE. See the GNU General Public License for more details.")"This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
,
800 N_("You should have received a copy of the GNU General Public License along ""You should have received a copy of the GNU General Public License along "
"with this program. If not, see <http://www.gnu.org/licenses/>."
801 "with this program. If not, see <http://www.gnu.org/licenses/>.")"You should have received a copy of the GNU General Public License along "
"with this program. If not, see <http://www.gnu.org/licenses/>."
,
802 NULL((void*)0)
803 };
804 gchar *license_i18n;
805
806 license_i18n = g_strconcat (_(license[0])dcgettext (((void*)0), license[0], 5), "\n\n", _(license[1])dcgettext (((void*)0), license[1], 5), "\n\n", _(license[2])dcgettext (((void*)0), license[2], 5), NULL((void*)0));
807
808 gtk_show_about_dialog(NULL((void*)0),
809 "version", VERSION"1.24.0",
810 "copyright", _("Copyright \xc2\xa9 2009-2010 Canonical, Ltd.\n"dcgettext (((void*)0), "Copyright \xc2\xa9 2009-2010 Canonical, Ltd.\n"
"Copyright \xc2\xa9 2011-2020 MATE developers", 5)
811 "Copyright \xc2\xa9 2011-2020 MATE developers")dcgettext (((void*)0), "Copyright \xc2\xa9 2009-2010 Canonical, Ltd.\n"
"Copyright \xc2\xa9 2011-2020 MATE developers", 5)
,
812#ifdef INDICATOR_APPLET_APPMENU
813 "comments", _("An applet to hold your application menus.")dcgettext (((void*)0), "An applet to hold your application menus."
, 5)
,
814#endif
815 "comments", _("An applet to hold all of the system indicators.")dcgettext (((void*)0), "An applet to hold all of the system indicators."
, 5)
,
816 "authors", authors,
817 "license", license_i18n,
818 "wrap-license", TRUE(!(0)),
819 "translator-credits", _("translator-credits")dcgettext (((void*)0), "translator-credits", 5),
820 "logo-icon-name", "mate-indicator-applet",
821 "icon-name", "mate-indicator-applet",
822 "website", "https://mate-desktop.org",
823 "website-label", _("MATE Website")dcgettext (((void*)0), "MATE Website", 5),
824 NULL((void*)0)
825 );
826
827 g_free (license_i18n);
828
829 return;
830}
831
832static gboolean
833swap_orient_cb (GtkWidget *item, gpointer data)
834{
835 GtkWidget *from = (GtkWidget *) data;
836 GtkWidget *to = (GtkWidget *) g_object_get_data(G_OBJECT(from)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
from)), (((GType) ((20) << (2))))))))
, "to");
837 g_object_ref(G_OBJECT(item)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
item)), (((GType) ((20) << (2))))))))
);
838 gtk_container_remove(GTK_CONTAINER(from)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((from)), ((gtk_container_get_type ()))))))
, item);
839 if (GTK_IS_LABEL(item)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(item)); GType __t = ((gtk_label_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; }))))
) {
840 switch(packdirection) {
841 case GTK_PACK_DIRECTION_LTR:
842 gtk_label_set_angle(GTK_LABEL(item)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(item)), ((gtk_label_get_type ()))))))
, 0.0);
843 break;
844 case GTK_PACK_DIRECTION_TTB:
845 gtk_label_set_angle(GTK_LABEL(item)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(item)), ((gtk_label_get_type ()))))))
,
846 (orient == MATE_PANEL_APPLET_ORIENT_LEFT) ?
847 270.0 : 90.0);
848 break;
849 default:
850 break;
851 }
852 }
853 gtk_box_pack_start(GTK_BOX(to)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((to
)), ((gtk_box_get_type ()))))))
, item, FALSE(0), FALSE(0), 0);
854 return TRUE(!(0));
855}
856
857static gboolean
858reorient_box_cb (GtkWidget *menuitem, gpointer data)
859{
860 GtkWidget *from = g_object_get_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "box");
861 GtkWidget *to = (packdirection == GTK_PACK_DIRECTION_LTR) ?
862 gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0) : gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
863 g_object_set_data(G_OBJECT(from)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
from)), (((GType) ((20) << (2))))))))
, "to", to);
864 gtk_container_foreach(GTK_CONTAINER(from)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((from)), ((gtk_container_get_type ()))))))
, (GtkCallback)swap_orient_cb,
865 from);
866 gtk_container_remove(GTK_CONTAINER(menuitem)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menuitem)), ((gtk_container_get_type ()))))))
, from);
867 gtk_container_add(GTK_CONTAINER(menuitem)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menuitem)), ((gtk_container_get_type ()))))))
, to);
868 g_object_set_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "box", to);
869 gtk_widget_show_all(menuitem);
870 return TRUE(!(0));
871}
872
873static gboolean
874matepanelapplet_reorient_cb (GtkWidget *applet, MatePanelAppletOrient neworient,
875 gpointer data)
876{
877 GtkWidget *menubar = (GtkWidget *)data;
878 if ((((neworient == MATE_PANEL_APPLET_ORIENT_UP) ||
879 (neworient == MATE_PANEL_APPLET_ORIENT_DOWN)) &&
880 ((orient == MATE_PANEL_APPLET_ORIENT_LEFT) ||
881 (orient == MATE_PANEL_APPLET_ORIENT_RIGHT))) ||
882 (((neworient == MATE_PANEL_APPLET_ORIENT_LEFT) ||
883 (neworient == MATE_PANEL_APPLET_ORIENT_RIGHT)) &&
884 ((orient == MATE_PANEL_APPLET_ORIENT_UP) ||
885 (orient == MATE_PANEL_APPLET_ORIENT_DOWN)))) {
886 packdirection = (packdirection == GTK_PACK_DIRECTION_LTR) ?
887 GTK_PACK_DIRECTION_TTB : GTK_PACK_DIRECTION_LTR;
888 gtk_menu_bar_set_pack_direction(GTK_MENU_BAR(menubar)((((GtkMenuBar*) g_type_check_instance_cast ((GTypeInstance*)
((menubar)), ((gtk_menu_bar_get_type ()))))))
,
889 packdirection);
890 orient = neworient;
891 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
,
892 (GtkCallback)reorient_box_cb, NULL((void*)0));
893 }
894 orient = neworient;
895 return FALSE(0);
896}
897
898#ifdef N_
899#undef N_
900#endif
901#define N_(x)x x
902
903static void
904log_to_file_cb (GObject * source_obj G_GNUC_UNUSED__attribute__((__unused__)),
905 GAsyncResult * result G_GNUC_UNUSED__attribute__((__unused__)), gpointer user_data)
906{
907 g_free(user_data);
908 return;
909}
910
911static void
912log_to_file (const gchar * domain G_GNUC_UNUSED__attribute__((__unused__)),
913 GLogLevelFlags level G_GNUC_UNUSED__attribute__((__unused__)),
914 const gchar * message,
915 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
916{
917 if (log_file == NULL((void*)0)) {
918 GError * error = NULL((void*)0);
919 gchar * filename = g_build_filename(g_get_user_cache_dir(), LOG_FILE_NAME"indicator-applet.log", NULL((void*)0));
920 GFile * file = g_file_new_for_path(filename);
921 g_free(filename);
922
923 if (!g_file_test(g_get_user_cache_dir(), G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) {
924 GFile * cachedir = g_file_new_for_path(g_get_user_cache_dir());
925 g_file_make_directory_with_parents(cachedir, NULL((void*)0), &error);
926
927 if (error != NULL((void*)0)) {
928 g_error("Unable to make directory '%s' for log file: %s", g_get_user_cache_dir(), error->message);
929 return;
930 }
931 }
932
933 g_file_delete(file, NULL((void*)0), NULL((void*)0));
934
935 GFileIOStream * io = g_file_create_readwrite(file,
936 G_FILE_CREATE_REPLACE_DESTINATION, /* flags */
937 NULL((void*)0), /* cancelable */
938 &error); /* error */
939 if (error != NULL((void*)0)) {
940 g_error("Unable to replace file: %s", error->message);
941 return;
This statement is never executed
942 }
943
944 log_file = g_io_stream_get_output_stream(G_IO_STREAM(io)((((GIOStream*) g_type_check_instance_cast ((GTypeInstance*) (
(io)), ((g_io_stream_get_type ()))))))
);
945 }
946
947 gchar * outputstring = g_strdup_printf("%s\n", message);
948 g_output_stream_write_async(log_file,
949 outputstring, /* data */
950 strlen(outputstring), /* length */
951 G_PRIORITY_LOW300, /* priority */
952 NULL((void*)0), /* cancelable */
953 log_to_file_cb, /* callback */
954 outputstring); /* data */
955
956 return;
957}
958
959static gboolean
960applet_fill_cb (MatePanelApplet * applet, const gchar * iid G_GNUC_UNUSED__attribute__((__unused__)),
961 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
962{
963#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
964 ido_init();
965#endif
966
967 static const GtkActionEntry menu_actions[] = {
968 {"About", GTK_STOCK_ABOUT((GtkStock)"gtk-about"), N_("_About")"_About", NULL((void*)0), NULL((void*)0), G_CALLBACK(about_cb)((GCallback) (about_cb))}
969 };
970 static const gchar *menu_xml = "<menuitem name=\"About\" action=\"About\"/>";
971
972 static gboolean first_time = FALSE(0);
973 GtkWidget *menubar;
974 gint indicators_loaded = 0;
975 GtkActionGroup *action_group;
976
977 if (!first_time)
978 {
979 first_time = TRUE(!(0));
980#ifdef INDICATOR_APPLET1
981 g_set_application_name(_("Indicator Applet")dcgettext (((void*)0), "Indicator Applet", 5));
982#endif
983#ifdef INDICATOR_APPLET_COMPLETE
984 g_set_application_name(_("Indicator Applet Complete")dcgettext (((void*)0), "Indicator Applet Complete", 5));
985#endif
986#ifdef INDICATOR_APPLET_APPMENU
987 g_set_application_name(_("Indicator Applet Application Menu")dcgettext (((void*)0), "Indicator Applet Application Menu", 5
)
);
988#endif
989
990 g_log_set_default_handler(log_to_file, NULL((void*)0));
991
992 tomboy_keybinder_init();
993 }
994
995 /* Set panel options */
996 gtk_container_set_border_width(GTK_CONTAINER (applet)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_container_get_type ()))))))
, 0);
997 mate_panel_applet_set_flags(applet, MATE_PANEL_APPLET_EXPAND_MINOR);
998 menubar = gtk_menu_bar_new();
999 action_group = gtk_action_group_new ("Indicator Applet Actions");
1000 gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE"mate-indicator-applet");
1001 gtk_action_group_add_actions (action_group, menu_actions,
1002 G_N_ELEMENTS (menu_actions)(sizeof (menu_actions) / sizeof ((menu_actions)[0])),
1003 menubar);
1004 mate_panel_applet_setup_menu(applet, menu_xml, action_group);
1005 g_object_unref(action_group);
1006#ifdef INDICATOR_APPLET1
1007 atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
),
1008 "indicator-applet");
1009#endif
1010#ifdef INDICATOR_APPLET_COMPLETE
1011 atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
),
1012 "indicator-applet-complete");
1013#endif
1014#ifdef INDICATOR_APPLET_APPMENU
1015 atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
),
1016 "indicator-applet-appmenu");
1017#endif
1018
1019 /* Init some theme/icon stuff */
1020 gtk_icon_theme_append_search_path(gtk_icon_theme_get_default(),
1021 INDICATOR_ICONS_DIR"/usr/share/libindicator/icons/");
1022 /* g_debug("Icons directory: %s", INDICATOR_ICONS_DIR); */
1023 gtk_widget_set_name(GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
, "fast-user-switch-applet");
1024
1025 /* Build menubar */
1026 size = (mate_panel_applet_get_size (applet));
1027 orient = (mate_panel_applet_get_orient(applet));
1028 packdirection = ((orient == MATE_PANEL_APPLET_ORIENT_UP) ||
1029 (orient == MATE_PANEL_APPLET_ORIENT_DOWN)) ?
1030 GTK_PACK_DIRECTION_LTR : GTK_PACK_DIRECTION_TTB;
1031 gtk_menu_bar_set_pack_direction(GTK_MENU_BAR(menubar)((((GtkMenuBar*) g_type_check_instance_cast ((GTypeInstance*)
((menubar)), ((gtk_menu_bar_get_type ()))))))
,
1032 packdirection);
1033 gtk_widget_set_can_focus (menubar, TRUE(!(0)));
1034 gtk_widget_set_name(GTK_WIDGET (menubar)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(menubar)), ((gtk_widget_get_type ()))))))
, "fast-user-switch-menubar");
1035 g_signal_connect(menubar, "button-press-event", G_CALLBACK(menubar_press), NULL)g_signal_connect_data ((menubar), ("button-press-event"), (((
GCallback) (menubar_press))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
;
1036 g_signal_connect_after(menubar, "draw", G_CALLBACK(menubar_on_draw), menubar)g_signal_connect_data ((menubar), ("draw"), (((GCallback) (menubar_on_draw
))), (menubar), ((void*)0), G_CONNECT_AFTER)
;
1037 g_signal_connect(applet, "change-orient",g_signal_connect_data ((applet), ("change-orient"), (((GCallback
) (matepanelapplet_reorient_cb))), (menubar), ((void*)0), (GConnectFlags
) 0)
1038 G_CALLBACK(matepanelapplet_reorient_cb), menubar)g_signal_connect_data ((applet), ("change-orient"), (((GCallback
) (matepanelapplet_reorient_cb))), (menubar), ((void*)0), (GConnectFlags
) 0)
;
1039 gtk_container_set_border_width(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, 0);
1040
1041 /* Add in filter func */
1042 tomboy_keybinder_bind(hotkey_keycode, hotkey_filter, menubar);
1043
1044 load_modules(applet, menubar, &indicators_loaded);
1045#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
1046 load_indicators_from_indicator_files(applet, menubar, &indicators_loaded);
1047#endif
1048
1049 if (indicators_loaded == 0) {
1050 /* A label to allow for click through */
1051 GtkWidget * item = gtk_label_new(_("No Indicators")dcgettext (((void*)0), "No Indicators", 5));
1052 mate_panel_applet_set_background_widget(applet, item);
1053 gtk_container_add(GTK_CONTAINER(applet)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_container_get_type ()))))))
, item);
1054 gtk_widget_show(item);
1055 } else {
1056 gtk_container_add(GTK_CONTAINER(applet)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_container_get_type ()))))))
, menubar);
1057 mate_panel_applet_set_background_widget(applet, menubar);
1058 gtk_widget_show(menubar);
1059 }
1060
1061 gtk_widget_show(GTK_WIDGET(applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
);
1062
1063 return TRUE(!(0));
1064
1065}
diff --git a/2020-04-09-123617-6853-1@4b55003793c9_master/report-9fcfe1.html b/2020-04-09-123617-6853-1@4b55003793c9_master/report-9fcfe1.html new file mode 100644 index 0000000..b8c0b0c --- /dev/null +++ b/2020-04-09-123617-6853-1@4b55003793c9_master/report-9fcfe1.html @@ -0,0 +1,1412 @@ + + + +applet-main.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:applet-main.c
Warning:line 929, column 5
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name applet-main.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -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 -mrelocation-model static -mthread-model posix -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -momit-leaf-frame-pointer -resource-dir /usr/lib64/clang/9.0.1 -D HAVE_CONFIG_H -I . -I .. -D G_LOG_DOMAIN="Indicator-Applet-Complete" -D DATADIR="/usr/local/share" -D INDICATOR_DIR="/usr/lib64/indicators3/7/" -D INDICATOR_ICONS_DIR="/usr/share/libindicator/icons/" -D INDICATOR_APPLET_COMPLETE -I ./.. -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/fribidi -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gio-unix-2.0 -I /usr/include/libdrm -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-panel-4.0/libmate-panel-applet -I /usr/include/libindicator3-0.4 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/fribidi -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gio-unix-2.0 -I /usr/include/libdrm -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/9.0.1/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wno-unused-parameter -Wno-sign-compare -fdebug-compilation-dir /rootdir/src -ferror-limit 19 -fmessage-length 0 -fobjc-runtime=gcc -fdiagnostics-show-option -vectorize-loops -vectorize-slp -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 -o /rootdir/html-report/2020-04-09-123617-6853-1 -x c applet-main.c +
+ + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2A small wrapper utility to load indicators and put them as menu items
3into the mate-panel using it's applet interface.
4
5Copyright 2009-2010 Canonical Ltd.
6
7Authors:
8 Ted Gould <ted@canonical.com>
9
10This program is free software: you can redistribute it and/or modify it
11under the terms of the GNU General Public License version 3, as published
12by the Free Software Foundation.
13
14This program is distributed in the hope that it will be useful, but
15WITHOUT ANY WARRANTY; without even the implied warranties of
16MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
17PURPOSE. See the GNU General Public License for more details.
18
19You should have received a copy of the GNU General Public License along
20with this program. If not, see <http://www.gnu.org/licenses/>.
21*/
22
23#include <stdlib.h>
24#include <string.h>
25#include <config.h>
26#include <glib/gi18n.h>
27#include <mate-panel-applet.h>
28#include <gdk/gdkkeysyms.h>
29#include <gtk/gtk.h>
30
31#if HAVE_UBUNTU_INDICATOR1
32
33#define INDICATOR_SERVICE_APPMENU"libappmenu.so" "libappmenu.so"
34#define INDICATOR_SERVICE_ME"libme.so" "libme.so"
35#define INDICATOR_SERVICE_DATETIME"libdatetime.so" "libdatetime.so"
36
37#define INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu" "com.canonical.indicator.appmenu"
38#define INDICATOR_SERVICE_ME_NG"com.canonical.indicator.me" "com.canonical.indicator.me"
39#define INDICATOR_SERVICE_DATETIME_NG"com.canonical.indicator.datetime" "com.canonical.indicator.datetime"
40
41#include <libindicator/indicator-object.h>
42#endif
43
44#if HAVE_AYATANA_INDICATOR
45
46#define INDICATOR_SERVICE_APPMENU"libappmenu.so" "libayatana-appmenu.so"
47#define INDICATOR_SERVICE_ME"libme.so" "libayatana-me.so"
48#define INDICATOR_SERVICE_DATETIME"libdatetime.so" "libayatana-datetime.so"
49
50#define INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu" "org.ayatana.indicator.appmenu"
51#define INDICATOR_SERVICE_ME_NG"com.canonical.indicator.me" "org.ayatana.indicator.me"
52#define INDICATOR_SERVICE_DATETIME_NG"com.canonical.indicator.datetime" "org.ayatana.indicator.datetime"
53
54#include <libayatana-indicator/indicator-object.h>
55#endif
56
57/* For new style indicators */
58
59#if HAVE_UBUNTU_INDICATOR1 && HAVE_UBUNTU_INDICATOR_NG
60
61#include <libido/libido.h>
62#include <libindicator/indicator-ng.h>
63
64#define INDICATOR_SERVICE_DIR "/usr/share/unity/indicators"
65
66#endif
67
68#if HAVE_AYATANA_INDICATOR && HAVE_AYATANA_INDICATOR_NG
69
70#include <libayatana-ido/libayatana-ido.h>
71#include <libayatana-indicator/indicator-ng.h>
72
73#define INDICATOR_SERVICE_DIR "/usr/share/ayatana/indicators"
74
75#endif
76
77#include "tomboykeybinder.h"
78
79static gchar * indicator_order[] = {
80#if HAVE_UBUNTU_INDICATOR1
81 "libapplication.so",
82 "libmessaging.so",
83 "libsoundmenu.so",
84 "libdatetime.so",
85 "libsession.so",
86#endif
87#if HAVE_AYATANA_INDICATOR
88 "libayatana-application.so",
89 "libayatana-messaging.so",
90 "libayatana-soundmenu.so",
91 "libayatana-datetime.so",
92 "libayatana-session.so",
93#endif
94 NULL((void*)0)
95};
96
97static GtkPackDirection packdirection;
98static MatePanelAppletOrient orient;
99static guint size;
100
101#define MENU_DATA_INDICATOR_OBJECT"indicator-object" "indicator-object"
102#define MENU_DATA_INDICATOR_ENTRY"indicator-entry" "indicator-entry"
103
104#define IO_DATA_ORDER_NUMBER"indicator-order-number" "indicator-order-number"
105
106static gboolean applet_fill_cb (MatePanelApplet * applet, const gchar * iid, gpointer data);
107
108static void update_accessible_desc (IndicatorObjectEntry * entry, GtkWidget * menuitem);
109
110/*************
111 * main
112 * ***********/
113
114#ifdef INDICATOR_APPLET
115MATE_PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletFactory",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
116 PANEL_TYPE_APPLET,int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
117 "indicator-applet",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
118 applet_fill_cb, NULL)int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
;
119#endif
120#ifdef INDICATOR_APPLET_COMPLETE1
121MATE_PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletCompleteFactory",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
122 PANEL_TYPE_APPLET,int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
123 "indicator-applet-complete",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
124 applet_fill_cb, NULL)int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
;
125#endif
126#ifdef INDICATOR_APPLET_APPMENU
127MATE_PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletAppmenuFactory",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
128 PANEL_TYPE_APPLET,int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
129 "indicator-applet-appmenu",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
130 applet_fill_cb, NULL)int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
;
131#endif
132
133/*************
134 * log files
135 * ***********/
136#ifdef INDICATOR_APPLET
137#define LOG_FILE_NAME"indicator-applet-complete.log" "indicator-applet.log"
138#endif
139#ifdef INDICATOR_APPLET_COMPLETE1
140#define LOG_FILE_NAME"indicator-applet-complete.log" "indicator-applet-complete.log"
141#endif
142#ifdef INDICATOR_APPLET_APPMENU
143#define LOG_FILE_NAME"indicator-applet-complete.log" "indicator-applet-appmenu.log"
144#endif
145GOutputStream * log_file = NULL((void*)0);
146
147/*****************
148 * Hotkey support
149 * **************/
150#ifdef INDICATOR_APPLET
151gchar * hotkey_keycode = "<Super>M";
152#endif
153#ifdef INDICATOR_APPLET_SESSION
154gchar * hotkey_keycode = "<Super>S";
155#endif
156#ifdef INDICATOR_APPLET_COMPLETE1
157gchar * hotkey_keycode = "<Super>S";
158#endif
159#ifdef INDICATOR_APPLET_APPMENU
160gchar * hotkey_keycode = "<Super>F1";
161#endif
162
163/********************
164 * Environment Names
165 * *******************/
166#ifdef INDICATOR_APPLET
167#define INDICATOR_SPECIFIC_ENV"indicator-applet-complete" "indicator-applet-original"
168#endif
169#ifdef INDICATOR_APPLET_COMPLETE1
170#define INDICATOR_SPECIFIC_ENV"indicator-applet-complete" "indicator-applet-complete"
171#endif
172#ifdef INDICATOR_APPLET_APPMENU
173#define INDICATOR_SPECIFIC_ENV"indicator-applet-complete" "indicator-applet-appmenu"
174#endif
175
176static const gchar * indicator_env[] = {
177 "indicator-applet",
178 INDICATOR_SPECIFIC_ENV"indicator-applet-complete",
179 NULL((void*)0)
180};
181
182/*************
183 * init function
184 * ***********/
185
186static gint
187name2order (const gchar * name) {
188 int i;
189
190 for (i = 0; indicator_order[i] != NULL((void*)0); i++) {
191 if (g_strcmp0(name, indicator_order[i]) == 0) {
192 return i;
193 }
194 }
195
196 return -1;
197}
198
199typedef struct _incoming_position_t incoming_position_t;
200struct _incoming_position_t {
201 gint objposition;
202 gint entryposition;
203 gint menupos;
204 gboolean found;
205};
206
207/* This function helps by determining where in the menu list
208 this new entry should be placed. It compares the objects
209 that they're on, and then the individual entries. Each
210 is progressively more expensive. */
211static void
212place_in_menu (GtkWidget * widget, gpointer user_data)
213{
214 incoming_position_t * position = (incoming_position_t *)user_data;
215 if (position->found) {
216 /* We've already been placed, just finish the foreach */
217 return;
218 }
219
220 IndicatorObject * io = INDICATOR_OBJECT(g_object_get_data(G_OBJECT(widget), MENU_DATA_INDICATOR_OBJECT))((((IndicatorObject*) g_type_check_instance_cast ((GTypeInstance
*) ((g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((widget)), (((GType) ((20) << (2)))
))))), "indicator-object"))), ((indicator_object_get_type ())
)))))
;
221 g_assert(io != NULL)do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_
; if (io != ((void*)0)) _g_boolean_var_ = 1; else _g_boolean_var_
= 0; _g_boolean_var_; }), 1)) ; else g_assertion_message_expr
("Indicator-Applet-Complete", "applet-main.c", 221, ((const char
*) (__func__)), "io != NULL"); } while (0)
;
222
223 gint objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER))((gint) (glong) (g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
), "indicator-order-number")))
;
224 /* We've already passed it, well, then this is where
225 we should be be. Stop! */
226 if (objposition > position->objposition) {
227 position->found = TRUE(!(0));
228 return;
229 }
230
231 /* The objects don't match yet, keep looking */
232 if (objposition < position->objposition) {
233 position->menupos++;
234 return;
235 }
236
237 /* The objects are the same, let's start looking at entries. */
238 IndicatorObjectEntry * entry = (IndicatorObjectEntry *)g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
239 gint entryposition = indicator_object_get_location(io, entry);
240
241 if (entryposition > position->entryposition) {
242 position->found = TRUE(!(0));
243 return;
244 }
245
246 if (entryposition < position->entryposition) {
247 position->menupos++;
248 return;
249 }
250
251 /* We've got the same object and the same entry. Well,
252 let's just put it right here then. */
253 position->found = TRUE(!(0));
254 return;
255}
256
257static void
258something_shown (GtkWidget * widget, gpointer user_data)
259{
260 GtkWidget * menuitem = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
261 gtk_widget_show(menuitem);
262}
263
264static void
265something_hidden (GtkWidget * widget, gpointer user_data)
266{
267 GtkWidget * menuitem = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
268 gtk_widget_hide(menuitem);
269}
270
271static void
272sensitive_cb (GObject * obj, GParamSpec * pspec, gpointer user_data)
273{
274 g_return_if_fail(GTK_IS_WIDGET(obj))do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((obj)); GType __t = ((gtk_widget_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet-Complete"
, ((const char*) (__func__)), "GTK_IS_WIDGET(obj)"); return; }
} while (0)
;
275 g_return_if_fail(GTK_IS_WIDGET(user_data))do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((gtk_widget_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet-Complete"
, ((const char*) (__func__)), "GTK_IS_WIDGET(user_data)"); return
; } } while (0)
;
276
277 gtk_widget_set_sensitive(GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
, gtk_widget_get_sensitive(GTK_WIDGET(obj)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(obj)), ((gtk_widget_get_type ()))))))
));
278 return;
279}
280
281static void
282entry_activated (GtkWidget * widget, gpointer user_data)
283{
284 g_return_if_fail(GTK_IS_WIDGET(widget))do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((gtk_widget_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet-Complete"
, ((const char*) (__func__)), "GTK_IS_WIDGET(widget)"); return
; } } while (0)
;
285 gpointer pio = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, "indicator");
286 g_return_if_fail(INDICATOR_IS_OBJECT(pio))do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((pio)); GType __t = ((indicator_object_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet-Complete"
, ((const char*) (__func__)), "INDICATOR_IS_OBJECT(pio)"); return
; } } while (0)
;
287 IndicatorObject * io = INDICATOR_OBJECT(pio)((((IndicatorObject*) g_type_check_instance_cast ((GTypeInstance
*) ((pio)), ((indicator_object_get_type ()))))))
;
288
289 return indicator_object_entry_activate(io, (IndicatorObjectEntry *)user_data, gtk_get_current_event_time());
290}
291
292static gboolean
293entry_scrolled (GtkWidget *menuitem, GdkEventScroll *event, gpointer data)
294{
295 IndicatorObject *io = g_object_get_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_OBJECT"indicator-object");
296 IndicatorObjectEntry *entry = g_object_get_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
297
298 g_return_val_if_fail(INDICATOR_IS_OBJECT(io), FALSE)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((io)); GType __t = ((indicator_object_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet-Complete"
, ((const char*) (__func__)), "INDICATOR_IS_OBJECT(io)"); return
((0)); } } while (0)
;
299
300 g_signal_emit_by_name (io, "scroll", 1, event->direction);
301 g_signal_emit_by_name (io, "scroll-entry", entry, 1, event->direction);
302 g_signal_emit_by_name (io, INDICATOR_OBJECT_SIGNAL_ENTRY_SCROLLED"entry-scrolled", entry, 1, event->direction);
303
304 return FALSE(0);
305}
306
307static void
308accessible_desc_update_cb (GtkWidget * widget, gpointer userdata)
309{
310 gpointer data = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
311
312 if (data != userdata) {
313 return;
314 }
315
316 IndicatorObjectEntry * entry = (IndicatorObjectEntry *)data;
317 update_accessible_desc(entry, widget);
318}
319
320static void
321accessible_desc_update (IndicatorObject * io, IndicatorObjectEntry * entry, GtkWidget * menubar)
322{
323 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, accessible_desc_update_cb, entry);
324 return;
325}
326
327#define PANEL_PADDING8 8
328static gboolean
329entry_resized (GtkWidget *applet, guint newsize, gpointer data)
330{
331 IndicatorObject *io = (IndicatorObject *)data;
332
333 size = newsize;
334
335 /* Work on the entries */
336 GList * entries = indicator_object_get_entries(io);
337 GList * entry = NULL((void*)0);
338
339 for (entry = entries; entry != NULL((void*)0); entry = g_list_next(entry)((entry) ? (((GList *)(entry))->next) : ((void*)0))) {
340 IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)entry->data;
341 if (entrydata->image != NULL((void*)0)) {
342 /* Resize to fit panel */
343 gtk_image_set_pixel_size (entrydata->image, size - PANEL_PADDING8);
344 }
345 }
346
347 return FALSE(0);
348}
349
350static void
351entry_added (IndicatorObject * io, IndicatorObjectEntry * entry, GtkWidget * menubar)
352{
353 g_debug("Signal: Entry Added");
354 gboolean something_visible = FALSE(0);
355 gboolean something_sensitive = FALSE(0);
356
357 GtkWidget * menuitem = gtk_menu_item_new();
358 GtkWidget * box = (packdirection == GTK_PACK_DIRECTION_LTR) ?
359 gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3) : gtk_box_new(GTK_ORIENTATION_VERTICAL, 3);
360
361 /* Allows indicators to receive mouse scroll event */
362 gtk_widget_add_events(GTK_WIDGET(menuitem)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(menuitem)), ((gtk_widget_get_type ()))))))
, GDK_SCROLL_MASK);
363
364 g_object_set_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "indicator", io);
365 g_object_set_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "box", box);
366
367 g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(entry_activated), entry)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((menuitem)), (((GType) ((20) << (2)
)))))))), ("activate"), (((GCallback) (entry_activated))), (entry
), ((void*)0), (GConnectFlags) 0)
;
368 g_signal_connect(G_OBJECT(menuitem), "scroll-event", G_CALLBACK(entry_scrolled), entry)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((menuitem)), (((GType) ((20) << (2)
)))))))), ("scroll-event"), (((GCallback) (entry_scrolled))),
(entry), ((void*)0), (GConnectFlags) 0)
;
369
370 if (entry->image != NULL((void*)0)) {
371 /* Resize to fit panel */
372 gtk_image_set_pixel_size (entry->image, size - PANEL_PADDING8);
373 gtk_box_pack_start(GTK_BOX(box)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((box
)), ((gtk_box_get_type ()))))))
, GTK_WIDGET(entry->image)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->image)), ((gtk_widget_get_type ()))))))
, FALSE(0), FALSE(0), 1);
374 if (gtk_widget_get_visible(GTK_WIDGET(entry->image)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->image)), ((gtk_widget_get_type ()))))))
)) {
375 something_visible = TRUE(!(0));
376 }
377
378 if (gtk_widget_get_sensitive(GTK_WIDGET(entry->image)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->image)), ((gtk_widget_get_type ()))))))
)) {
379 something_sensitive = TRUE(!(0));
380 }
381
382 g_signal_connect(G_OBJECT(entry->image), "show", G_CALLBACK(something_shown), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), ("show"), (((GCallback) (something_shown))), (menuitem
), ((void*)0), (GConnectFlags) 0)
;
383 g_signal_connect(G_OBJECT(entry->image), "hide", G_CALLBACK(something_hidden), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), ("hide"), (((GCallback) (something_hidden))), (
menuitem), ((void*)0), (GConnectFlags) 0)
;
384
385 g_signal_connect(G_OBJECT(entry->image), "notify::sensitive", G_CALLBACK(sensitive_cb), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), ("notify::sensitive"), (((GCallback) (sensitive_cb
))), (menuitem), ((void*)0), (GConnectFlags) 0)
;
386 }
387 if (entry->label != NULL((void*)0)) {
388 switch(packdirection) {
389 case GTK_PACK_DIRECTION_LTR:
390 gtk_label_set_angle(GTK_LABEL(entry->label)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_label_get_type ()))))))
, 0.0);
391 break;
392 case GTK_PACK_DIRECTION_TTB:
393 gtk_label_set_angle(GTK_LABEL(entry->label)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_label_get_type ()))))))
,
394 (orient == MATE_PANEL_APPLET_ORIENT_LEFT) ?
395 270.0 : 90.0);
396 break;
397 default:
398 break;
399 }
400 gtk_box_pack_start(GTK_BOX(box)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((box
)), ((gtk_box_get_type ()))))))
, GTK_WIDGET(entry->label)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_widget_get_type ()))))))
, FALSE(0), FALSE(0), 1);
401
402 if (gtk_widget_get_visible(GTK_WIDGET(entry->label)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_widget_get_type ()))))))
)) {
403 something_visible = TRUE(!(0));
404 }
405
406 if (gtk_widget_get_sensitive(GTK_WIDGET(entry->label)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_widget_get_type ()))))))
)) {
407 something_sensitive = TRUE(!(0));
408 }
409
410 g_signal_connect(G_OBJECT(entry->label), "show", G_CALLBACK(something_shown), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), ("show"), (((GCallback) (something_shown))), (menuitem
), ((void*)0), (GConnectFlags) 0)
;
411 g_signal_connect(G_OBJECT(entry->label), "hide", G_CALLBACK(something_hidden), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), ("hide"), (((GCallback) (something_hidden))), (
menuitem), ((void*)0), (GConnectFlags) 0)
;
412
413 g_signal_connect(G_OBJECT(entry->label), "notify::sensitive", G_CALLBACK(sensitive_cb), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), ("notify::sensitive"), (((GCallback) (sensitive_cb
))), (menuitem), ((void*)0), (GConnectFlags) 0)
;
414 }
415 gtk_container_add(GTK_CONTAINER(menuitem)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menuitem)), ((gtk_container_get_type ()))))))
, box);
416 gtk_widget_show(box);
417
418 if (entry->menu != NULL((void*)0)) {
419 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem)((((GtkMenuItem*) g_type_check_instance_cast ((GTypeInstance*
) ((menuitem)), ((gtk_menu_item_get_type ()))))))
, GTK_WIDGET(entry->menu)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->menu)), ((gtk_widget_get_type ()))))))
);
420 }
421
422 incoming_position_t position;
423 position.objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER))((gint) (glong) (g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
), "indicator-order-number")))
;
424 position.entryposition = indicator_object_get_location(io, entry);
425 position.menupos = 0;
426 position.found = FALSE(0);
427
428 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, place_in_menu, &position);
429
430 gtk_menu_shell_insert(GTK_MENU_SHELL(menubar)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_menu_shell_get_type ()))))))
, menuitem, position.menupos);
431
432 if (something_visible) {
433 if (entry->accessible_desc != NULL((void*)0)) {
434 update_accessible_desc(entry, menuitem);
435 }
436 gtk_widget_show(menuitem);
437 }
438 gtk_widget_set_sensitive(menuitem, something_sensitive);
439
440 g_object_set_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry", entry);
441 g_object_set_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_OBJECT"indicator-object", io);
442
443 return;
444}
445
446static void
447entry_removed_cb (GtkWidget * widget, gpointer userdata)
448{
449 gpointer data = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
450
451 if (data != userdata) {
452 return;
453 }
454
455 IndicatorObjectEntry * entry = (IndicatorObjectEntry *)data;
456 if (entry->label != NULL((void*)0)) {
457 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(something_shown), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_shown))), (widget
))
;
458 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(something_hidden), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_hidden))), (widget
))
;
459 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(sensitive_cb), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (sensitive_cb))), (widget)
)
;
460 }
461 if (entry->image != NULL((void*)0)) {
462 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(something_shown), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_shown))), (widget
))
;
463 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(something_hidden), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_hidden))), (widget
))
;
464 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(sensitive_cb), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (sensitive_cb))), (widget)
)
;
465 }
466
467 gtk_widget_destroy(widget);
468 return;
469}
470
471static void
472entry_removed (IndicatorObject * io G_GNUC_UNUSED__attribute__((__unused__)), IndicatorObjectEntry * entry,
473 gpointer user_data)
474{
475 g_debug("Signal: Entry Removed");
476
477 gtk_container_foreach(GTK_CONTAINER(user_data)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((gtk_container_get_type ()))))))
, entry_removed_cb, entry);
478
479 return;
480}
481
482static void
483entry_moved_find_cb (GtkWidget * widget, gpointer userdata)
484{
485 gpointer * array = (gpointer *)userdata;
486 if (array[1] != NULL((void*)0)) {
487 return;
488 }
489
490 gpointer data = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
491
492 if (data != array[0]) {
493 return;
494 }
495
496 array[1] = widget;
497 return;
498}
499
500/* Gets called when an entry for an object was moved. */
501static void
502entry_moved (IndicatorObject * io, IndicatorObjectEntry * entry,
503 gint old G_GNUC_UNUSED__attribute__((__unused__)), gint new G_GNUC_UNUSED__attribute__((__unused__)), gpointer user_data)
504{
505 GtkWidget * menubar = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
506
507 gpointer array[2];
508 array[0] = entry;
509 array[1] = NULL((void*)0);
510
511 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, entry_moved_find_cb, array);
512 if (array[1] == NULL((void*)0)) {
513 g_warning("Moving an entry that isn't in our menus.");
514 return;
515 }
516
517 GtkWidget * mi = GTK_WIDGET(array[1])((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(array[1])), ((gtk_widget_get_type ()))))))
;
518 g_object_ref(G_OBJECT(mi)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
mi)), (((GType) ((20) << (2))))))))
);
519 gtk_container_remove(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, mi);
520
521 incoming_position_t position;
522 position.objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER))((gint) (glong) (g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
), "indicator-order-number")))
;
523 position.entryposition = indicator_object_get_location(io, entry);
524 position.menupos = 0;
525 position.found = FALSE(0);
526
527 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, place_in_menu, &position);
528
529 gtk_menu_shell_insert(GTK_MENU_SHELL(menubar)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_menu_shell_get_type ()))))))
, mi, position.menupos);
530 g_object_unref(G_OBJECT(mi)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
mi)), (((GType) ((20) << (2))))))))
);
531
532 return;
533}
534
535static void
536menu_show (IndicatorObject * io, IndicatorObjectEntry * entry,
537 guint32 timestamp, gpointer user_data)
538{
539 GtkWidget * menubar = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
540
541 if (entry == NULL((void*)0)) {
542 /* Close any open menus instead of opening one */
543 GList * entries = indicator_object_get_entries(io);
544 GList * entry = NULL((void*)0);
545 for (entry = entries; entry != NULL((void*)0); entry = g_list_next(entry)((entry) ? (((GList *)(entry))->next) : ((void*)0))) {
546 IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)entry->data;
547 gtk_menu_popdown(entrydata->menu);
548 }
549 g_list_free(entries);
550
551 /* And tell the menubar to exit activation mode too */
552 gtk_menu_shell_cancel(GTK_MENU_SHELL(menubar)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_menu_shell_get_type ()))))))
);
553 return;
554 }
555
556 // TODO: do something sensible here
557}
558
559static void
560update_accessible_desc(IndicatorObjectEntry * entry, GtkWidget * menuitem)
561{
562 /* FIXME: We need to deal with the use case where the contents of the
563 label overrides what is found in the atk object's name, or at least
564 orca speaks the label instead of the atk object name.
565 */
566 AtkObject * menuitem_obj = gtk_widget_get_accessible(menuitem);
567 if (menuitem_obj == NULL((void*)0)) {
568 /* Should there be an error printed here? */
569 return;
570 }
571
572 if (entry->accessible_desc != NULL((void*)0)) {
573 atk_object_set_name(menuitem_obj, entry->accessible_desc);
574 } else {
575 atk_object_set_name(menuitem_obj, "");
576 }
577 return;
578}
579
580static void
581load_indicator (MatePanelApplet *applet, GtkWidget * menubar, IndicatorObject *io, const gchar *name)
582{
583 /* Set the environment it's in */
584 indicator_object_set_environment(io, (const GStrv)indicator_env);
585
586 /* Attach the 'name' to the object */
587#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
588 int pos = 5000 - indicator_object_get_position(io);
589 if (pos > 5000) {
590 pos = name2order(name);
591 }
592#else
593 int pos = name2order(name);
594#endif
595
596 g_object_set_data(G_OBJECT(io)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
io)), (((GType) ((20) << (2))))))))
, IO_DATA_ORDER_NUMBER"indicator-order-number", GINT_TO_POINTER(pos)((gpointer) (glong) (pos)));
597
598 /* Connect to its signals */
599 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED, G_CALLBACK(entry_added), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("entry-added"), (((GCallback) (entry_added))), (menubar)
, ((void*)0), (GConnectFlags) 0)
;
600 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED, G_CALLBACK(entry_removed), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("entry-removed"), (((GCallback) (entry_removed))), (menubar
), ((void*)0), (GConnectFlags) 0)
;
601 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_MOVED, G_CALLBACK(entry_moved), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("entry-moved"), (((GCallback) (entry_moved))), (menubar)
, ((void*)0), (GConnectFlags) 0)
;
602 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_MENU_SHOW, G_CALLBACK(menu_show), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("menu-show"), (((GCallback) (menu_show))), (menubar), ((
void*)0), (GConnectFlags) 0)
;
603 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ACCESSIBLE_DESC_UPDATE, G_CALLBACK(accessible_desc_update), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("accessible-desc-update"), (((GCallback) (accessible_desc_update
))), (menubar), ((void*)0), (GConnectFlags) 0)
;
604
605 /* Track panel resize */
606 g_signal_connect_object(G_OBJECT(applet)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
applet)), (((GType) ((20) << (2))))))))
, "change-size", G_CALLBACK(entry_resized)((GCallback) (entry_resized)), G_OBJECT(io)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
io)), (((GType) ((20) << (2))))))))
, 0);
607
608 /* Work on the entries */
609 GList * entries = indicator_object_get_entries(io);
610 GList * entry = NULL((void*)0);
611
612 for (entry = entries; entry != NULL((void*)0); entry = g_list_next(entry)((entry) ? (((GList *)(entry))->next) : ((void*)0))) {
613 IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)entry->data;
614 entry_added(io, entrydata, menubar);
615 }
616
617 g_list_free(entries);
618}
619
620static gboolean
621load_module (const gchar * name, MatePanelApplet *applet, GtkWidget * menubar)
622{
623 g_debug("Looking at Module: %s", name);
624 g_return_val_if_fail(name != NULL, FALSE)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if (name != ((void*)0)) _g_boolean_var_ = 1; else _g_boolean_var_
= 0; _g_boolean_var_; }), 1))) { } else { g_return_if_fail_warning
("Indicator-Applet-Complete", ((const char*) (__func__)), "name != NULL"
); return ((0)); } } while (0)
;
625
626 if (!g_str_has_suffix(name, G_MODULE_SUFFIX"so")) {
627 return FALSE(0);
628 }
629
630 g_debug("Loading Module: %s", name);
631
632 /* Build the object for the module */
633 gchar * fullpath = g_build_filename(INDICATOR_DIR"/usr/lib64/indicators3/7/", name, NULL((void*)0));
634 IndicatorObject * io = indicator_object_new_from_file(fullpath);
635 g_free(fullpath);
636
637 load_indicator(applet, menubar, io, name);
638
639 return TRUE(!(0));
640}
641
642static void
643load_modules (MatePanelApplet *applet, GtkWidget *menubar, gint *indicators_loaded)
644{
645 if (g_file_test(INDICATOR_DIR"/usr/lib64/indicators3/7/", (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))) {
646 GDir * dir = g_dir_open(INDICATOR_DIR"/usr/lib64/indicators3/7/", 0, NULL((void*)0));
647
648 const gchar * name;
649 gint count = 0;
650 while ((name = g_dir_read_name(dir)) != NULL((void*)0)) {
651#ifdef INDICATOR_APPLET_APPMENU
652 if (g_strcmp0(name, INDICATOR_SERVICE_APPMENU"libappmenu.so")) {
653 continue;
654 }
655#else
656 if (!g_strcmp0(name, INDICATOR_SERVICE_APPMENU"libappmenu.so")) {
657 continue;
658 }
659#endif
660#ifdef INDICATOR_APPLET
661 if (!g_strcmp0(name, INDICATOR_SERVICE_ME"libme.so")) {
662 continue;
663 }
664 if (!g_strcmp0(name, INDICATOR_SERVICE_DATETIME"libdatetime.so")) {
665 continue;
666 }
667#endif
668 if (load_module(name, applet, menubar)) {
669 count++;
670 }
671 }
672
673 *indicators_loaded += count;
674
675 g_dir_close (dir);
676 }
677}
678
679#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
680
681static void
682load_indicators_from_indicator_files (MatePanelApplet *applet, GtkWidget *menubar, gint *indicators_loaded)
683{
684 GDir *dir;
685 const gchar *name;
686 GError *error = NULL((void*)0);
687
688 dir = g_dir_open (INDICATOR_SERVICE_DIR, 0, &error);
689
690 if (!dir) {
691 g_warning ("unable to open indicator service file directory: %s", error->message);
692 g_error_free (error);
693
694 return;
695 }
696
697 gint count = 0;
698 while ((name = g_dir_read_name (dir))) {
699 gchar *filename;
700 IndicatorNg *indicator;
701
702 filename = g_build_filename (INDICATOR_SERVICE_DIR, name, NULL((void*)0));
703 indicator = indicator_ng_new_for_profile (filename, "desktop", &error);
704 g_free (filename);
705
706#ifdef INDICATOR_APPLET_APPMENU
707 if (g_strcmp0(name, INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu")) {
708 continue;
709 }
710#else
711 if (!g_strcmp0(name, INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu")) {
712 continue;
713 }
714#endif
715#ifdef INDICATOR_APPLET
716 if (!g_strcmp0(name, INDICATOR_SERVICE_ME_NG"com.canonical.indicator.me")) {
717 continue;
718 }
719 if (!g_strcmp0(name, INDICATOR_SERVICE_DATETIME_NG"com.canonical.indicator.datetime")) {
720 continue;
721 }
722#endif
723
724 if (indicator) {
725 load_indicator(applet, menubar, INDICATOR_OBJECT (indicator)((((IndicatorObject*) g_type_check_instance_cast ((GTypeInstance
*) ((indicator)), ((indicator_object_get_type ()))))))
, name);
726 count++;
727 }else{
728 g_warning ("unable to load '%s': %s", name, error->message);
729 g_clear_error (&error);
730 }
731 }
732
733 *indicators_loaded += count;
734
735 g_dir_close (dir);
736}
737#endif /* HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG */
738
739static void
740hotkey_filter (char * keystring G_GNUC_UNUSED__attribute__((__unused__)), gpointer data)
741{
742 g_return_if_fail(GTK_IS_MENU_SHELL(data))do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((data)); GType __t = ((gtk_menu_shell_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet-Complete"
, ((const char*) (__func__)), "GTK_IS_MENU_SHELL(data)"); return
; } } while (0)
;
743
744 /* Oh, wow, it's us! */
745 GList * children = gtk_container_get_children(GTK_CONTAINER(data)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((gtk_container_get_type ()))))))
);
746 if (children == NULL((void*)0)) {
747 g_debug("Menubar has no children");
748 return;
749 }
750
751 gtk_menu_shell_select_item(GTK_MENU_SHELL(data)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((gtk_menu_shell_get_type ()))))))
, GTK_WIDGET(g_list_last(children)->data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(g_list_last(children)->data)), ((gtk_widget_get_type ()))
))))
);
752 g_list_free(children);
753 return;
754}
755
756static gboolean
757menubar_press (GtkWidget * widget,
758 GdkEventButton *event,
759 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
760{
761 if (event->button != 1) {
762 g_signal_stop_emission_by_name(widget, "button-press-event");
763 }
764
765 return FALSE(0);
766}
767
768static gboolean
769menubar_on_draw (GtkWidget * widget,
770 cairo_t * cr,
771 GtkWidget * menubar)
772{
773 /* FIXME: either port to gtk_render_focus or remove this function */
774 if (gtk_widget_has_focus(menubar))
775 gtk_paint_focus(gtk_widget_get_style(widget),
776 cr,
777 gtk_widget_get_state(menubar),
778 widget, "menubar-applet", 0, 0, -1, -1);
779
780 return FALSE(0);
781}
782
783static void
784about_cb (GtkAction *action G_GNUC_UNUSED__attribute__((__unused__)),
785 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
786{
787 static const gchar *authors[] = {
788 "Ted Gould <ted@canonical.com>",
789 NULL((void*)0)
790 };
791
792 static gchar *license[] = {
793 N_("This program is free software: you can redistribute it and/or modify it ""This program is free software: you can redistribute it and/or modify it "
"under the terms of the GNU General Public License version 3, as published "
"by the Free Software Foundation."
794 "under the terms of the GNU General Public License version 3, as published ""This program is free software: you can redistribute it and/or modify it "
"under the terms of the GNU General Public License version 3, as published "
"by the Free Software Foundation."
795 "by the Free Software Foundation.")"This program is free software: you can redistribute it and/or modify it "
"under the terms of the GNU General Public License version 3, as published "
"by the Free Software Foundation."
,
796 N_("This program is distributed in the hope that it will be useful, but ""This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
797 "WITHOUT ANY WARRANTY; without even the implied warranties of ""This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
798 "MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR ""This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
799 "PURPOSE. See the GNU General Public License for more details.")"This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
,
800 N_("You should have received a copy of the GNU General Public License along ""You should have received a copy of the GNU General Public License along "
"with this program. If not, see <http://www.gnu.org/licenses/>."
801 "with this program. If not, see <http://www.gnu.org/licenses/>.")"You should have received a copy of the GNU General Public License along "
"with this program. If not, see <http://www.gnu.org/licenses/>."
,
802 NULL((void*)0)
803 };
804 gchar *license_i18n;
805
806 license_i18n = g_strconcat (_(license[0])dcgettext (((void*)0), license[0], 5), "\n\n", _(license[1])dcgettext (((void*)0), license[1], 5), "\n\n", _(license[2])dcgettext (((void*)0), license[2], 5), NULL((void*)0));
807
808 gtk_show_about_dialog(NULL((void*)0),
809 "version", VERSION"1.24.0",
810 "copyright", _("Copyright \xc2\xa9 2009-2010 Canonical, Ltd.\n"dcgettext (((void*)0), "Copyright \xc2\xa9 2009-2010 Canonical, Ltd.\n"
"Copyright \xc2\xa9 2011-2020 MATE developers", 5)
811 "Copyright \xc2\xa9 2011-2020 MATE developers")dcgettext (((void*)0), "Copyright \xc2\xa9 2009-2010 Canonical, Ltd.\n"
"Copyright \xc2\xa9 2011-2020 MATE developers", 5)
,
812#ifdef INDICATOR_APPLET_APPMENU
813 "comments", _("An applet to hold your application menus.")dcgettext (((void*)0), "An applet to hold your application menus."
, 5)
,
814#endif
815 "comments", _("An applet to hold all of the system indicators.")dcgettext (((void*)0), "An applet to hold all of the system indicators."
, 5)
,
816 "authors", authors,
817 "license", license_i18n,
818 "wrap-license", TRUE(!(0)),
819 "translator-credits", _("translator-credits")dcgettext (((void*)0), "translator-credits", 5),
820 "logo-icon-name", "mate-indicator-applet",
821 "icon-name", "mate-indicator-applet",
822 "website", "https://mate-desktop.org",
823 "website-label", _("MATE Website")dcgettext (((void*)0), "MATE Website", 5),
824 NULL((void*)0)
825 );
826
827 g_free (license_i18n);
828
829 return;
830}
831
832static gboolean
833swap_orient_cb (GtkWidget *item, gpointer data)
834{
835 GtkWidget *from = (GtkWidget *) data;
836 GtkWidget *to = (GtkWidget *) g_object_get_data(G_OBJECT(from)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
from)), (((GType) ((20) << (2))))))))
, "to");
837 g_object_ref(G_OBJECT(item)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
item)), (((GType) ((20) << (2))))))))
);
838 gtk_container_remove(GTK_CONTAINER(from)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((from)), ((gtk_container_get_type ()))))))
, item);
839 if (GTK_IS_LABEL(item)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(item)); GType __t = ((gtk_label_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; }))))
) {
840 switch(packdirection) {
841 case GTK_PACK_DIRECTION_LTR:
842 gtk_label_set_angle(GTK_LABEL(item)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(item)), ((gtk_label_get_type ()))))))
, 0.0);
843 break;
844 case GTK_PACK_DIRECTION_TTB:
845 gtk_label_set_angle(GTK_LABEL(item)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(item)), ((gtk_label_get_type ()))))))
,
846 (orient == MATE_PANEL_APPLET_ORIENT_LEFT) ?
847 270.0 : 90.0);
848 break;
849 default:
850 break;
851 }
852 }
853 gtk_box_pack_start(GTK_BOX(to)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((to
)), ((gtk_box_get_type ()))))))
, item, FALSE(0), FALSE(0), 0);
854 return TRUE(!(0));
855}
856
857static gboolean
858reorient_box_cb (GtkWidget *menuitem, gpointer data)
859{
860 GtkWidget *from = g_object_get_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "box");
861 GtkWidget *to = (packdirection == GTK_PACK_DIRECTION_LTR) ?
862 gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0) : gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
863 g_object_set_data(G_OBJECT(from)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
from)), (((GType) ((20) << (2))))))))
, "to", to);
864 gtk_container_foreach(GTK_CONTAINER(from)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((from)), ((gtk_container_get_type ()))))))
, (GtkCallback)swap_orient_cb,
865 from);
866 gtk_container_remove(GTK_CONTAINER(menuitem)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menuitem)), ((gtk_container_get_type ()))))))
, from);
867 gtk_container_add(GTK_CONTAINER(menuitem)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menuitem)), ((gtk_container_get_type ()))))))
, to);
868 g_object_set_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "box", to);
869 gtk_widget_show_all(menuitem);
870 return TRUE(!(0));
871}
872
873static gboolean
874matepanelapplet_reorient_cb (GtkWidget *applet, MatePanelAppletOrient neworient,
875 gpointer data)
876{
877 GtkWidget *menubar = (GtkWidget *)data;
878 if ((((neworient == MATE_PANEL_APPLET_ORIENT_UP) ||
879 (neworient == MATE_PANEL_APPLET_ORIENT_DOWN)) &&
880 ((orient == MATE_PANEL_APPLET_ORIENT_LEFT) ||
881 (orient == MATE_PANEL_APPLET_ORIENT_RIGHT))) ||
882 (((neworient == MATE_PANEL_APPLET_ORIENT_LEFT) ||
883 (neworient == MATE_PANEL_APPLET_ORIENT_RIGHT)) &&
884 ((orient == MATE_PANEL_APPLET_ORIENT_UP) ||
885 (orient == MATE_PANEL_APPLET_ORIENT_DOWN)))) {
886 packdirection = (packdirection == GTK_PACK_DIRECTION_LTR) ?
887 GTK_PACK_DIRECTION_TTB : GTK_PACK_DIRECTION_LTR;
888 gtk_menu_bar_set_pack_direction(GTK_MENU_BAR(menubar)((((GtkMenuBar*) g_type_check_instance_cast ((GTypeInstance*)
((menubar)), ((gtk_menu_bar_get_type ()))))))
,
889 packdirection);
890 orient = neworient;
891 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
,
892 (GtkCallback)reorient_box_cb, NULL((void*)0));
893 }
894 orient = neworient;
895 return FALSE(0);
896}
897
898#ifdef N_
899#undef N_
900#endif
901#define N_(x)x x
902
903static void
904log_to_file_cb (GObject * source_obj G_GNUC_UNUSED__attribute__((__unused__)),
905 GAsyncResult * result G_GNUC_UNUSED__attribute__((__unused__)), gpointer user_data)
906{
907 g_free(user_data);
908 return;
909}
910
911static void
912log_to_file (const gchar * domain G_GNUC_UNUSED__attribute__((__unused__)),
913 GLogLevelFlags level G_GNUC_UNUSED__attribute__((__unused__)),
914 const gchar * message,
915 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
916{
917 if (log_file == NULL((void*)0)) {
918 GError * error = NULL((void*)0);
919 gchar * filename = g_build_filename(g_get_user_cache_dir(), LOG_FILE_NAME"indicator-applet-complete.log", NULL((void*)0));
920 GFile * file = g_file_new_for_path(filename);
921 g_free(filename);
922
923 if (!g_file_test(g_get_user_cache_dir(), G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) {
924 GFile * cachedir = g_file_new_for_path(g_get_user_cache_dir());
925 g_file_make_directory_with_parents(cachedir, NULL((void*)0), &error);
926
927 if (error != NULL((void*)0)) {
928 g_error("Unable to make directory '%s' for log file: %s", g_get_user_cache_dir(), error->message);
929 return;
This statement is never executed
930 }
931 }
932
933 g_file_delete(file, NULL((void*)0), NULL((void*)0));
934
935 GFileIOStream * io = g_file_create_readwrite(file,
936 G_FILE_CREATE_REPLACE_DESTINATION, /* flags */
937 NULL((void*)0), /* cancelable */
938 &error); /* error */
939 if (error != NULL((void*)0)) {
940 g_error("Unable to replace file: %s", error->message);
941 return;
942 }
943
944 log_file = g_io_stream_get_output_stream(G_IO_STREAM(io)((((GIOStream*) g_type_check_instance_cast ((GTypeInstance*) (
(io)), ((g_io_stream_get_type ()))))))
);
945 }
946
947 gchar * outputstring = g_strdup_printf("%s\n", message);
948 g_output_stream_write_async(log_file,
949 outputstring, /* data */
950 strlen(outputstring), /* length */
951 G_PRIORITY_LOW300, /* priority */
952 NULL((void*)0), /* cancelable */
953 log_to_file_cb, /* callback */
954 outputstring); /* data */
955
956 return;
957}
958
959static gboolean
960applet_fill_cb (MatePanelApplet * applet, const gchar * iid G_GNUC_UNUSED__attribute__((__unused__)),
961 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
962{
963#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
964 ido_init();
965#endif
966
967 static const GtkActionEntry menu_actions[] = {
968 {"About", GTK_STOCK_ABOUT((GtkStock)"gtk-about"), N_("_About")"_About", NULL((void*)0), NULL((void*)0), G_CALLBACK(about_cb)((GCallback) (about_cb))}
969 };
970 static const gchar *menu_xml = "<menuitem name=\"About\" action=\"About\"/>";
971
972 static gboolean first_time = FALSE(0);
973 GtkWidget *menubar;
974 gint indicators_loaded = 0;
975 GtkActionGroup *action_group;
976
977 if (!first_time)
978 {
979 first_time = TRUE(!(0));
980#ifdef INDICATOR_APPLET
981 g_set_application_name(_("Indicator Applet")dcgettext (((void*)0), "Indicator Applet", 5));
982#endif
983#ifdef INDICATOR_APPLET_COMPLETE1
984 g_set_application_name(_("Indicator Applet Complete")dcgettext (((void*)0), "Indicator Applet Complete", 5));
985#endif
986#ifdef INDICATOR_APPLET_APPMENU
987 g_set_application_name(_("Indicator Applet Application Menu")dcgettext (((void*)0), "Indicator Applet Application Menu", 5
)
);
988#endif
989
990 g_log_set_default_handler(log_to_file, NULL((void*)0));
991
992 tomboy_keybinder_init();
993 }
994
995 /* Set panel options */
996 gtk_container_set_border_width(GTK_CONTAINER (applet)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_container_get_type ()))))))
, 0);
997 mate_panel_applet_set_flags(applet, MATE_PANEL_APPLET_EXPAND_MINOR);
998 menubar = gtk_menu_bar_new();
999 action_group = gtk_action_group_new ("Indicator Applet Actions");
1000 gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE"mate-indicator-applet");
1001 gtk_action_group_add_actions (action_group, menu_actions,
1002 G_N_ELEMENTS (menu_actions)(sizeof (menu_actions) / sizeof ((menu_actions)[0])),
1003 menubar);
1004 mate_panel_applet_setup_menu(applet, menu_xml, action_group);
1005 g_object_unref(action_group);
1006#ifdef INDICATOR_APPLET
1007 atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
),
1008 "indicator-applet");
1009#endif
1010#ifdef INDICATOR_APPLET_COMPLETE1
1011 atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
),
1012 "indicator-applet-complete");
1013#endif
1014#ifdef INDICATOR_APPLET_APPMENU
1015 atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
),
1016 "indicator-applet-appmenu");
1017#endif
1018
1019 /* Init some theme/icon stuff */
1020 gtk_icon_theme_append_search_path(gtk_icon_theme_get_default(),
1021 INDICATOR_ICONS_DIR"/usr/share/libindicator/icons/");
1022 /* g_debug("Icons directory: %s", INDICATOR_ICONS_DIR); */
1023 gtk_widget_set_name(GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
, "fast-user-switch-applet");
1024
1025 /* Build menubar */
1026 size = (mate_panel_applet_get_size (applet));
1027 orient = (mate_panel_applet_get_orient(applet));
1028 packdirection = ((orient == MATE_PANEL_APPLET_ORIENT_UP) ||
1029 (orient == MATE_PANEL_APPLET_ORIENT_DOWN)) ?
1030 GTK_PACK_DIRECTION_LTR : GTK_PACK_DIRECTION_TTB;
1031 gtk_menu_bar_set_pack_direction(GTK_MENU_BAR(menubar)((((GtkMenuBar*) g_type_check_instance_cast ((GTypeInstance*)
((menubar)), ((gtk_menu_bar_get_type ()))))))
,
1032 packdirection);
1033 gtk_widget_set_can_focus (menubar, TRUE(!(0)));
1034 gtk_widget_set_name(GTK_WIDGET (menubar)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(menubar)), ((gtk_widget_get_type ()))))))
, "fast-user-switch-menubar");
1035 g_signal_connect(menubar, "button-press-event", G_CALLBACK(menubar_press), NULL)g_signal_connect_data ((menubar), ("button-press-event"), (((
GCallback) (menubar_press))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
;
1036 g_signal_connect_after(menubar, "draw", G_CALLBACK(menubar_on_draw), menubar)g_signal_connect_data ((menubar), ("draw"), (((GCallback) (menubar_on_draw
))), (menubar), ((void*)0), G_CONNECT_AFTER)
;
1037 g_signal_connect(applet, "change-orient",g_signal_connect_data ((applet), ("change-orient"), (((GCallback
) (matepanelapplet_reorient_cb))), (menubar), ((void*)0), (GConnectFlags
) 0)
1038 G_CALLBACK(matepanelapplet_reorient_cb), menubar)g_signal_connect_data ((applet), ("change-orient"), (((GCallback
) (matepanelapplet_reorient_cb))), (menubar), ((void*)0), (GConnectFlags
) 0)
;
1039 gtk_container_set_border_width(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, 0);
1040
1041 /* Add in filter func */
1042 tomboy_keybinder_bind(hotkey_keycode, hotkey_filter, menubar);
1043
1044 load_modules(applet, menubar, &indicators_loaded);
1045#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
1046 load_indicators_from_indicator_files(applet, menubar, &indicators_loaded);
1047#endif
1048
1049 if (indicators_loaded == 0) {
1050 /* A label to allow for click through */
1051 GtkWidget * item = gtk_label_new(_("No Indicators")dcgettext (((void*)0), "No Indicators", 5));
1052 mate_panel_applet_set_background_widget(applet, item);
1053 gtk_container_add(GTK_CONTAINER(applet)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_container_get_type ()))))))
, item);
1054 gtk_widget_show(item);
1055 } else {
1056 gtk_container_add(GTK_CONTAINER(applet)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_container_get_type ()))))))
, menubar);
1057 mate_panel_applet_set_background_widget(applet, menubar);
1058 gtk_widget_show(menubar);
1059 }
1060
1061 gtk_widget_show(GTK_WIDGET(applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
);
1062
1063 return TRUE(!(0));
1064
1065}
diff --git a/2020-04-09-123617-6853-1@4b55003793c9_master/report-a3a98b.html b/2020-04-09-123617-6853-1@4b55003793c9_master/report-a3a98b.html new file mode 100644 index 0000000..677ca22 --- /dev/null +++ b/2020-04-09-123617-6853-1@4b55003793c9_master/report-a3a98b.html @@ -0,0 +1,1412 @@ + + + +applet-main.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:applet-main.c
Warning:line 941, column 4
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name applet-main.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -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 -mrelocation-model static -mthread-model posix -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -momit-leaf-frame-pointer -resource-dir /usr/lib64/clang/9.0.1 -D HAVE_CONFIG_H -I . -I .. -D G_LOG_DOMAIN="Indicator-Applet-Appmenu" -D DATADIR="/usr/local/share" -D INDICATOR_DIR="/usr/lib64/indicators3/7/" -D INDICATOR_ICONS_DIR="/usr/share/libindicator/icons/" -D INDICATOR_APPLET_APPMENU -I ./.. -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/fribidi -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gio-unix-2.0 -I /usr/include/libdrm -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-panel-4.0/libmate-panel-applet -I /usr/include/libindicator3-0.4 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/fribidi -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gio-unix-2.0 -I /usr/include/libdrm -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/9.0.1/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wno-unused-parameter -Wno-sign-compare -fdebug-compilation-dir /rootdir/src -ferror-limit 19 -fmessage-length 0 -fobjc-runtime=gcc -fdiagnostics-show-option -vectorize-loops -vectorize-slp -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 -o /rootdir/html-report/2020-04-09-123617-6853-1 -x c applet-main.c +
+ + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2A small wrapper utility to load indicators and put them as menu items
3into the mate-panel using it's applet interface.
4
5Copyright 2009-2010 Canonical Ltd.
6
7Authors:
8 Ted Gould <ted@canonical.com>
9
10This program is free software: you can redistribute it and/or modify it
11under the terms of the GNU General Public License version 3, as published
12by the Free Software Foundation.
13
14This program is distributed in the hope that it will be useful, but
15WITHOUT ANY WARRANTY; without even the implied warranties of
16MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
17PURPOSE. See the GNU General Public License for more details.
18
19You should have received a copy of the GNU General Public License along
20with this program. If not, see <http://www.gnu.org/licenses/>.
21*/
22
23#include <stdlib.h>
24#include <string.h>
25#include <config.h>
26#include <glib/gi18n.h>
27#include <mate-panel-applet.h>
28#include <gdk/gdkkeysyms.h>
29#include <gtk/gtk.h>
30
31#if HAVE_UBUNTU_INDICATOR1
32
33#define INDICATOR_SERVICE_APPMENU"libappmenu.so" "libappmenu.so"
34#define INDICATOR_SERVICE_ME"libme.so" "libme.so"
35#define INDICATOR_SERVICE_DATETIME"libdatetime.so" "libdatetime.so"
36
37#define INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu" "com.canonical.indicator.appmenu"
38#define INDICATOR_SERVICE_ME_NG"com.canonical.indicator.me" "com.canonical.indicator.me"
39#define INDICATOR_SERVICE_DATETIME_NG"com.canonical.indicator.datetime" "com.canonical.indicator.datetime"
40
41#include <libindicator/indicator-object.h>
42#endif
43
44#if HAVE_AYATANA_INDICATOR
45
46#define INDICATOR_SERVICE_APPMENU"libappmenu.so" "libayatana-appmenu.so"
47#define INDICATOR_SERVICE_ME"libme.so" "libayatana-me.so"
48#define INDICATOR_SERVICE_DATETIME"libdatetime.so" "libayatana-datetime.so"
49
50#define INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu" "org.ayatana.indicator.appmenu"
51#define INDICATOR_SERVICE_ME_NG"com.canonical.indicator.me" "org.ayatana.indicator.me"
52#define INDICATOR_SERVICE_DATETIME_NG"com.canonical.indicator.datetime" "org.ayatana.indicator.datetime"
53
54#include <libayatana-indicator/indicator-object.h>
55#endif
56
57/* For new style indicators */
58
59#if HAVE_UBUNTU_INDICATOR1 && HAVE_UBUNTU_INDICATOR_NG
60
61#include <libido/libido.h>
62#include <libindicator/indicator-ng.h>
63
64#define INDICATOR_SERVICE_DIR "/usr/share/unity/indicators"
65
66#endif
67
68#if HAVE_AYATANA_INDICATOR && HAVE_AYATANA_INDICATOR_NG
69
70#include <libayatana-ido/libayatana-ido.h>
71#include <libayatana-indicator/indicator-ng.h>
72
73#define INDICATOR_SERVICE_DIR "/usr/share/ayatana/indicators"
74
75#endif
76
77#include "tomboykeybinder.h"
78
79static gchar * indicator_order[] = {
80#if HAVE_UBUNTU_INDICATOR1
81 "libapplication.so",
82 "libmessaging.so",
83 "libsoundmenu.so",
84 "libdatetime.so",
85 "libsession.so",
86#endif
87#if HAVE_AYATANA_INDICATOR
88 "libayatana-application.so",
89 "libayatana-messaging.so",
90 "libayatana-soundmenu.so",
91 "libayatana-datetime.so",
92 "libayatana-session.so",
93#endif
94 NULL((void*)0)
95};
96
97static GtkPackDirection packdirection;
98static MatePanelAppletOrient orient;
99static guint size;
100
101#define MENU_DATA_INDICATOR_OBJECT"indicator-object" "indicator-object"
102#define MENU_DATA_INDICATOR_ENTRY"indicator-entry" "indicator-entry"
103
104#define IO_DATA_ORDER_NUMBER"indicator-order-number" "indicator-order-number"
105
106static gboolean applet_fill_cb (MatePanelApplet * applet, const gchar * iid, gpointer data);
107
108static void update_accessible_desc (IndicatorObjectEntry * entry, GtkWidget * menuitem);
109
110/*************
111 * main
112 * ***********/
113
114#ifdef INDICATOR_APPLET
115MATE_PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletFactory",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
116 PANEL_TYPE_APPLET,int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
117 "indicator-applet",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
118 applet_fill_cb, NULL)int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
;
119#endif
120#ifdef INDICATOR_APPLET_COMPLETE
121MATE_PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletCompleteFactory",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
122 PANEL_TYPE_APPLET,int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
123 "indicator-applet-complete",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
124 applet_fill_cb, NULL)int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
;
125#endif
126#ifdef INDICATOR_APPLET_APPMENU1
127MATE_PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletAppmenuFactory",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
128 PANEL_TYPE_APPLET,int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
129 "indicator-applet-appmenu",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
130 applet_fill_cb, NULL)int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
;
131#endif
132
133/*************
134 * log files
135 * ***********/
136#ifdef INDICATOR_APPLET
137#define LOG_FILE_NAME"indicator-applet-appmenu.log" "indicator-applet.log"
138#endif
139#ifdef INDICATOR_APPLET_COMPLETE
140#define LOG_FILE_NAME"indicator-applet-appmenu.log" "indicator-applet-complete.log"
141#endif
142#ifdef INDICATOR_APPLET_APPMENU1
143#define LOG_FILE_NAME"indicator-applet-appmenu.log" "indicator-applet-appmenu.log"
144#endif
145GOutputStream * log_file = NULL((void*)0);
146
147/*****************
148 * Hotkey support
149 * **************/
150#ifdef INDICATOR_APPLET
151gchar * hotkey_keycode = "<Super>M";
152#endif
153#ifdef INDICATOR_APPLET_SESSION
154gchar * hotkey_keycode = "<Super>S";
155#endif
156#ifdef INDICATOR_APPLET_COMPLETE
157gchar * hotkey_keycode = "<Super>S";
158#endif
159#ifdef INDICATOR_APPLET_APPMENU1
160gchar * hotkey_keycode = "<Super>F1";
161#endif
162
163/********************
164 * Environment Names
165 * *******************/
166#ifdef INDICATOR_APPLET
167#define INDICATOR_SPECIFIC_ENV"indicator-applet-appmenu" "indicator-applet-original"
168#endif
169#ifdef INDICATOR_APPLET_COMPLETE
170#define INDICATOR_SPECIFIC_ENV"indicator-applet-appmenu" "indicator-applet-complete"
171#endif
172#ifdef INDICATOR_APPLET_APPMENU1
173#define INDICATOR_SPECIFIC_ENV"indicator-applet-appmenu" "indicator-applet-appmenu"
174#endif
175
176static const gchar * indicator_env[] = {
177 "indicator-applet",
178 INDICATOR_SPECIFIC_ENV"indicator-applet-appmenu",
179 NULL((void*)0)
180};
181
182/*************
183 * init function
184 * ***********/
185
186static gint
187name2order (const gchar * name) {
188 int i;
189
190 for (i = 0; indicator_order[i] != NULL((void*)0); i++) {
191 if (g_strcmp0(name, indicator_order[i]) == 0) {
192 return i;
193 }
194 }
195
196 return -1;
197}
198
199typedef struct _incoming_position_t incoming_position_t;
200struct _incoming_position_t {
201 gint objposition;
202 gint entryposition;
203 gint menupos;
204 gboolean found;
205};
206
207/* This function helps by determining where in the menu list
208 this new entry should be placed. It compares the objects
209 that they're on, and then the individual entries. Each
210 is progressively more expensive. */
211static void
212place_in_menu (GtkWidget * widget, gpointer user_data)
213{
214 incoming_position_t * position = (incoming_position_t *)user_data;
215 if (position->found) {
216 /* We've already been placed, just finish the foreach */
217 return;
218 }
219
220 IndicatorObject * io = INDICATOR_OBJECT(g_object_get_data(G_OBJECT(widget), MENU_DATA_INDICATOR_OBJECT))((((IndicatorObject*) g_type_check_instance_cast ((GTypeInstance
*) ((g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((widget)), (((GType) ((20) << (2)))
))))), "indicator-object"))), ((indicator_object_get_type ())
)))))
;
221 g_assert(io != NULL)do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_
; if (io != ((void*)0)) _g_boolean_var_ = 1; else _g_boolean_var_
= 0; _g_boolean_var_; }), 1)) ; else g_assertion_message_expr
("Indicator-Applet-Appmenu", "applet-main.c", 221, ((const char
*) (__func__)), "io != NULL"); } while (0)
;
222
223 gint objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER))((gint) (glong) (g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
), "indicator-order-number")))
;
224 /* We've already passed it, well, then this is where
225 we should be be. Stop! */
226 if (objposition > position->objposition) {
227 position->found = TRUE(!(0));
228 return;
229 }
230
231 /* The objects don't match yet, keep looking */
232 if (objposition < position->objposition) {
233 position->menupos++;
234 return;
235 }
236
237 /* The objects are the same, let's start looking at entries. */
238 IndicatorObjectEntry * entry = (IndicatorObjectEntry *)g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
239 gint entryposition = indicator_object_get_location(io, entry);
240
241 if (entryposition > position->entryposition) {
242 position->found = TRUE(!(0));
243 return;
244 }
245
246 if (entryposition < position->entryposition) {
247 position->menupos++;
248 return;
249 }
250
251 /* We've got the same object and the same entry. Well,
252 let's just put it right here then. */
253 position->found = TRUE(!(0));
254 return;
255}
256
257static void
258something_shown (GtkWidget * widget, gpointer user_data)
259{
260 GtkWidget * menuitem = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
261 gtk_widget_show(menuitem);
262}
263
264static void
265something_hidden (GtkWidget * widget, gpointer user_data)
266{
267 GtkWidget * menuitem = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
268 gtk_widget_hide(menuitem);
269}
270
271static void
272sensitive_cb (GObject * obj, GParamSpec * pspec, gpointer user_data)
273{
274 g_return_if_fail(GTK_IS_WIDGET(obj))do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((obj)); GType __t = ((gtk_widget_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet-Appmenu",
((const char*) (__func__)), "GTK_IS_WIDGET(obj)"); return; }
} while (0)
;
275 g_return_if_fail(GTK_IS_WIDGET(user_data))do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((gtk_widget_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet-Appmenu",
((const char*) (__func__)), "GTK_IS_WIDGET(user_data)"); return
; } } while (0)
;
276
277 gtk_widget_set_sensitive(GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
, gtk_widget_get_sensitive(GTK_WIDGET(obj)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(obj)), ((gtk_widget_get_type ()))))))
));
278 return;
279}
280
281static void
282entry_activated (GtkWidget * widget, gpointer user_data)
283{
284 g_return_if_fail(GTK_IS_WIDGET(widget))do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((gtk_widget_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet-Appmenu",
((const char*) (__func__)), "GTK_IS_WIDGET(widget)"); return
; } } while (0)
;
285 gpointer pio = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, "indicator");
286 g_return_if_fail(INDICATOR_IS_OBJECT(pio))do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((pio)); GType __t = ((indicator_object_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet-Appmenu",
((const char*) (__func__)), "INDICATOR_IS_OBJECT(pio)"); return
; } } while (0)
;
287 IndicatorObject * io = INDICATOR_OBJECT(pio)((((IndicatorObject*) g_type_check_instance_cast ((GTypeInstance
*) ((pio)), ((indicator_object_get_type ()))))))
;
288
289 return indicator_object_entry_activate(io, (IndicatorObjectEntry *)user_data, gtk_get_current_event_time());
290}
291
292static gboolean
293entry_scrolled (GtkWidget *menuitem, GdkEventScroll *event, gpointer data)
294{
295 IndicatorObject *io = g_object_get_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_OBJECT"indicator-object");
296 IndicatorObjectEntry *entry = g_object_get_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
297
298 g_return_val_if_fail(INDICATOR_IS_OBJECT(io), FALSE)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((io)); GType __t = ((indicator_object_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet-Appmenu",
((const char*) (__func__)), "INDICATOR_IS_OBJECT(io)"); return
((0)); } } while (0)
;
299
300 g_signal_emit_by_name (io, "scroll", 1, event->direction);
301 g_signal_emit_by_name (io, "scroll-entry", entry, 1, event->direction);
302 g_signal_emit_by_name (io, INDICATOR_OBJECT_SIGNAL_ENTRY_SCROLLED"entry-scrolled", entry, 1, event->direction);
303
304 return FALSE(0);
305}
306
307static void
308accessible_desc_update_cb (GtkWidget * widget, gpointer userdata)
309{
310 gpointer data = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
311
312 if (data != userdata) {
313 return;
314 }
315
316 IndicatorObjectEntry * entry = (IndicatorObjectEntry *)data;
317 update_accessible_desc(entry, widget);
318}
319
320static void
321accessible_desc_update (IndicatorObject * io, IndicatorObjectEntry * entry, GtkWidget * menubar)
322{
323 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, accessible_desc_update_cb, entry);
324 return;
325}
326
327#define PANEL_PADDING8 8
328static gboolean
329entry_resized (GtkWidget *applet, guint newsize, gpointer data)
330{
331 IndicatorObject *io = (IndicatorObject *)data;
332
333 size = newsize;
334
335 /* Work on the entries */
336 GList * entries = indicator_object_get_entries(io);
337 GList * entry = NULL((void*)0);
338
339 for (entry = entries; entry != NULL((void*)0); entry = g_list_next(entry)((entry) ? (((GList *)(entry))->next) : ((void*)0))) {
340 IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)entry->data;
341 if (entrydata->image != NULL((void*)0)) {
342 /* Resize to fit panel */
343 gtk_image_set_pixel_size (entrydata->image, size - PANEL_PADDING8);
344 }
345 }
346
347 return FALSE(0);
348}
349
350static void
351entry_added (IndicatorObject * io, IndicatorObjectEntry * entry, GtkWidget * menubar)
352{
353 g_debug("Signal: Entry Added");
354 gboolean something_visible = FALSE(0);
355 gboolean something_sensitive = FALSE(0);
356
357 GtkWidget * menuitem = gtk_menu_item_new();
358 GtkWidget * box = (packdirection == GTK_PACK_DIRECTION_LTR) ?
359 gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3) : gtk_box_new(GTK_ORIENTATION_VERTICAL, 3);
360
361 /* Allows indicators to receive mouse scroll event */
362 gtk_widget_add_events(GTK_WIDGET(menuitem)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(menuitem)), ((gtk_widget_get_type ()))))))
, GDK_SCROLL_MASK);
363
364 g_object_set_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "indicator", io);
365 g_object_set_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "box", box);
366
367 g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(entry_activated), entry)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((menuitem)), (((GType) ((20) << (2)
)))))))), ("activate"), (((GCallback) (entry_activated))), (entry
), ((void*)0), (GConnectFlags) 0)
;
368 g_signal_connect(G_OBJECT(menuitem), "scroll-event", G_CALLBACK(entry_scrolled), entry)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((menuitem)), (((GType) ((20) << (2)
)))))))), ("scroll-event"), (((GCallback) (entry_scrolled))),
(entry), ((void*)0), (GConnectFlags) 0)
;
369
370 if (entry->image != NULL((void*)0)) {
371 /* Resize to fit panel */
372 gtk_image_set_pixel_size (entry->image, size - PANEL_PADDING8);
373 gtk_box_pack_start(GTK_BOX(box)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((box
)), ((gtk_box_get_type ()))))))
, GTK_WIDGET(entry->image)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->image)), ((gtk_widget_get_type ()))))))
, FALSE(0), FALSE(0), 1);
374 if (gtk_widget_get_visible(GTK_WIDGET(entry->image)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->image)), ((gtk_widget_get_type ()))))))
)) {
375 something_visible = TRUE(!(0));
376 }
377
378 if (gtk_widget_get_sensitive(GTK_WIDGET(entry->image)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->image)), ((gtk_widget_get_type ()))))))
)) {
379 something_sensitive = TRUE(!(0));
380 }
381
382 g_signal_connect(G_OBJECT(entry->image), "show", G_CALLBACK(something_shown), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), ("show"), (((GCallback) (something_shown))), (menuitem
), ((void*)0), (GConnectFlags) 0)
;
383 g_signal_connect(G_OBJECT(entry->image), "hide", G_CALLBACK(something_hidden), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), ("hide"), (((GCallback) (something_hidden))), (
menuitem), ((void*)0), (GConnectFlags) 0)
;
384
385 g_signal_connect(G_OBJECT(entry->image), "notify::sensitive", G_CALLBACK(sensitive_cb), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), ("notify::sensitive"), (((GCallback) (sensitive_cb
))), (menuitem), ((void*)0), (GConnectFlags) 0)
;
386 }
387 if (entry->label != NULL((void*)0)) {
388 switch(packdirection) {
389 case GTK_PACK_DIRECTION_LTR:
390 gtk_label_set_angle(GTK_LABEL(entry->label)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_label_get_type ()))))))
, 0.0);
391 break;
392 case GTK_PACK_DIRECTION_TTB:
393 gtk_label_set_angle(GTK_LABEL(entry->label)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_label_get_type ()))))))
,
394 (orient == MATE_PANEL_APPLET_ORIENT_LEFT) ?
395 270.0 : 90.0);
396 break;
397 default:
398 break;
399 }
400 gtk_box_pack_start(GTK_BOX(box)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((box
)), ((gtk_box_get_type ()))))))
, GTK_WIDGET(entry->label)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_widget_get_type ()))))))
, FALSE(0), FALSE(0), 1);
401
402 if (gtk_widget_get_visible(GTK_WIDGET(entry->label)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_widget_get_type ()))))))
)) {
403 something_visible = TRUE(!(0));
404 }
405
406 if (gtk_widget_get_sensitive(GTK_WIDGET(entry->label)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_widget_get_type ()))))))
)) {
407 something_sensitive = TRUE(!(0));
408 }
409
410 g_signal_connect(G_OBJECT(entry->label), "show", G_CALLBACK(something_shown), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), ("show"), (((GCallback) (something_shown))), (menuitem
), ((void*)0), (GConnectFlags) 0)
;
411 g_signal_connect(G_OBJECT(entry->label), "hide", G_CALLBACK(something_hidden), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), ("hide"), (((GCallback) (something_hidden))), (
menuitem), ((void*)0), (GConnectFlags) 0)
;
412
413 g_signal_connect(G_OBJECT(entry->label), "notify::sensitive", G_CALLBACK(sensitive_cb), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), ("notify::sensitive"), (((GCallback) (sensitive_cb
))), (menuitem), ((void*)0), (GConnectFlags) 0)
;
414 }
415 gtk_container_add(GTK_CONTAINER(menuitem)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menuitem)), ((gtk_container_get_type ()))))))
, box);
416 gtk_widget_show(box);
417
418 if (entry->menu != NULL((void*)0)) {
419 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem)((((GtkMenuItem*) g_type_check_instance_cast ((GTypeInstance*
) ((menuitem)), ((gtk_menu_item_get_type ()))))))
, GTK_WIDGET(entry->menu)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->menu)), ((gtk_widget_get_type ()))))))
);
420 }
421
422 incoming_position_t position;
423 position.objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER))((gint) (glong) (g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
), "indicator-order-number")))
;
424 position.entryposition = indicator_object_get_location(io, entry);
425 position.menupos = 0;
426 position.found = FALSE(0);
427
428 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, place_in_menu, &position);
429
430 gtk_menu_shell_insert(GTK_MENU_SHELL(menubar)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_menu_shell_get_type ()))))))
, menuitem, position.menupos);
431
432 if (something_visible) {
433 if (entry->accessible_desc != NULL((void*)0)) {
434 update_accessible_desc(entry, menuitem);
435 }
436 gtk_widget_show(menuitem);
437 }
438 gtk_widget_set_sensitive(menuitem, something_sensitive);
439
440 g_object_set_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry", entry);
441 g_object_set_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_OBJECT"indicator-object", io);
442
443 return;
444}
445
446static void
447entry_removed_cb (GtkWidget * widget, gpointer userdata)
448{
449 gpointer data = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
450
451 if (data != userdata) {
452 return;
453 }
454
455 IndicatorObjectEntry * entry = (IndicatorObjectEntry *)data;
456 if (entry->label != NULL((void*)0)) {
457 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(something_shown), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_shown))), (widget
))
;
458 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(something_hidden), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_hidden))), (widget
))
;
459 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(sensitive_cb), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (sensitive_cb))), (widget)
)
;
460 }
461 if (entry->image != NULL((void*)0)) {
462 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(something_shown), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_shown))), (widget
))
;
463 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(something_hidden), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_hidden))), (widget
))
;
464 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(sensitive_cb), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (sensitive_cb))), (widget)
)
;
465 }
466
467 gtk_widget_destroy(widget);
468 return;
469}
470
471static void
472entry_removed (IndicatorObject * io G_GNUC_UNUSED__attribute__((__unused__)), IndicatorObjectEntry * entry,
473 gpointer user_data)
474{
475 g_debug("Signal: Entry Removed");
476
477 gtk_container_foreach(GTK_CONTAINER(user_data)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((gtk_container_get_type ()))))))
, entry_removed_cb, entry);
478
479 return;
480}
481
482static void
483entry_moved_find_cb (GtkWidget * widget, gpointer userdata)
484{
485 gpointer * array = (gpointer *)userdata;
486 if (array[1] != NULL((void*)0)) {
487 return;
488 }
489
490 gpointer data = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
491
492 if (data != array[0]) {
493 return;
494 }
495
496 array[1] = widget;
497 return;
498}
499
500/* Gets called when an entry for an object was moved. */
501static void
502entry_moved (IndicatorObject * io, IndicatorObjectEntry * entry,
503 gint old G_GNUC_UNUSED__attribute__((__unused__)), gint new G_GNUC_UNUSED__attribute__((__unused__)), gpointer user_data)
504{
505 GtkWidget * menubar = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
506
507 gpointer array[2];
508 array[0] = entry;
509 array[1] = NULL((void*)0);
510
511 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, entry_moved_find_cb, array);
512 if (array[1] == NULL((void*)0)) {
513 g_warning("Moving an entry that isn't in our menus.");
514 return;
515 }
516
517 GtkWidget * mi = GTK_WIDGET(array[1])((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(array[1])), ((gtk_widget_get_type ()))))))
;
518 g_object_ref(G_OBJECT(mi)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
mi)), (((GType) ((20) << (2))))))))
);
519 gtk_container_remove(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, mi);
520
521 incoming_position_t position;
522 position.objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER))((gint) (glong) (g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
), "indicator-order-number")))
;
523 position.entryposition = indicator_object_get_location(io, entry);
524 position.menupos = 0;
525 position.found = FALSE(0);
526
527 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, place_in_menu, &position);
528
529 gtk_menu_shell_insert(GTK_MENU_SHELL(menubar)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_menu_shell_get_type ()))))))
, mi, position.menupos);
530 g_object_unref(G_OBJECT(mi)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
mi)), (((GType) ((20) << (2))))))))
);
531
532 return;
533}
534
535static void
536menu_show (IndicatorObject * io, IndicatorObjectEntry * entry,
537 guint32 timestamp, gpointer user_data)
538{
539 GtkWidget * menubar = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
540
541 if (entry == NULL((void*)0)) {
542 /* Close any open menus instead of opening one */
543 GList * entries = indicator_object_get_entries(io);
544 GList * entry = NULL((void*)0);
545 for (entry = entries; entry != NULL((void*)0); entry = g_list_next(entry)((entry) ? (((GList *)(entry))->next) : ((void*)0))) {
546 IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)entry->data;
547 gtk_menu_popdown(entrydata->menu);
548 }
549 g_list_free(entries);
550
551 /* And tell the menubar to exit activation mode too */
552 gtk_menu_shell_cancel(GTK_MENU_SHELL(menubar)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_menu_shell_get_type ()))))))
);
553 return;
554 }
555
556 // TODO: do something sensible here
557}
558
559static void
560update_accessible_desc(IndicatorObjectEntry * entry, GtkWidget * menuitem)
561{
562 /* FIXME: We need to deal with the use case where the contents of the
563 label overrides what is found in the atk object's name, or at least
564 orca speaks the label instead of the atk object name.
565 */
566 AtkObject * menuitem_obj = gtk_widget_get_accessible(menuitem);
567 if (menuitem_obj == NULL((void*)0)) {
568 /* Should there be an error printed here? */
569 return;
570 }
571
572 if (entry->accessible_desc != NULL((void*)0)) {
573 atk_object_set_name(menuitem_obj, entry->accessible_desc);
574 } else {
575 atk_object_set_name(menuitem_obj, "");
576 }
577 return;
578}
579
580static void
581load_indicator (MatePanelApplet *applet, GtkWidget * menubar, IndicatorObject *io, const gchar *name)
582{
583 /* Set the environment it's in */
584 indicator_object_set_environment(io, (const GStrv)indicator_env);
585
586 /* Attach the 'name' to the object */
587#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
588 int pos = 5000 - indicator_object_get_position(io);
589 if (pos > 5000) {
590 pos = name2order(name);
591 }
592#else
593 int pos = name2order(name);
594#endif
595
596 g_object_set_data(G_OBJECT(io)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
io)), (((GType) ((20) << (2))))))))
, IO_DATA_ORDER_NUMBER"indicator-order-number", GINT_TO_POINTER(pos)((gpointer) (glong) (pos)));
597
598 /* Connect to its signals */
599 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED, G_CALLBACK(entry_added), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("entry-added"), (((GCallback) (entry_added))), (menubar)
, ((void*)0), (GConnectFlags) 0)
;
600 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED, G_CALLBACK(entry_removed), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("entry-removed"), (((GCallback) (entry_removed))), (menubar
), ((void*)0), (GConnectFlags) 0)
;
601 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_MOVED, G_CALLBACK(entry_moved), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("entry-moved"), (((GCallback) (entry_moved))), (menubar)
, ((void*)0), (GConnectFlags) 0)
;
602 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_MENU_SHOW, G_CALLBACK(menu_show), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("menu-show"), (((GCallback) (menu_show))), (menubar), ((
void*)0), (GConnectFlags) 0)
;
603 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ACCESSIBLE_DESC_UPDATE, G_CALLBACK(accessible_desc_update), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("accessible-desc-update"), (((GCallback) (accessible_desc_update
))), (menubar), ((void*)0), (GConnectFlags) 0)
;
604
605 /* Track panel resize */
606 g_signal_connect_object(G_OBJECT(applet)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
applet)), (((GType) ((20) << (2))))))))
, "change-size", G_CALLBACK(entry_resized)((GCallback) (entry_resized)), G_OBJECT(io)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
io)), (((GType) ((20) << (2))))))))
, 0);
607
608 /* Work on the entries */
609 GList * entries = indicator_object_get_entries(io);
610 GList * entry = NULL((void*)0);
611
612 for (entry = entries; entry != NULL((void*)0); entry = g_list_next(entry)((entry) ? (((GList *)(entry))->next) : ((void*)0))) {
613 IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)entry->data;
614 entry_added(io, entrydata, menubar);
615 }
616
617 g_list_free(entries);
618}
619
620static gboolean
621load_module (const gchar * name, MatePanelApplet *applet, GtkWidget * menubar)
622{
623 g_debug("Looking at Module: %s", name);
624 g_return_val_if_fail(name != NULL, FALSE)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if (name != ((void*)0)) _g_boolean_var_ = 1; else _g_boolean_var_
= 0; _g_boolean_var_; }), 1))) { } else { g_return_if_fail_warning
("Indicator-Applet-Appmenu", ((const char*) (__func__)), "name != NULL"
); return ((0)); } } while (0)
;
625
626 if (!g_str_has_suffix(name, G_MODULE_SUFFIX"so")) {
627 return FALSE(0);
628 }
629
630 g_debug("Loading Module: %s", name);
631
632 /* Build the object for the module */
633 gchar * fullpath = g_build_filename(INDICATOR_DIR"/usr/lib64/indicators3/7/", name, NULL((void*)0));
634 IndicatorObject * io = indicator_object_new_from_file(fullpath);
635 g_free(fullpath);
636
637 load_indicator(applet, menubar, io, name);
638
639 return TRUE(!(0));
640}
641
642static void
643load_modules (MatePanelApplet *applet, GtkWidget *menubar, gint *indicators_loaded)
644{
645 if (g_file_test(INDICATOR_DIR"/usr/lib64/indicators3/7/", (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))) {
646 GDir * dir = g_dir_open(INDICATOR_DIR"/usr/lib64/indicators3/7/", 0, NULL((void*)0));
647
648 const gchar * name;
649 gint count = 0;
650 while ((name = g_dir_read_name(dir)) != NULL((void*)0)) {
651#ifdef INDICATOR_APPLET_APPMENU1
652 if (g_strcmp0(name, INDICATOR_SERVICE_APPMENU"libappmenu.so")) {
653 continue;
654 }
655#else
656 if (!g_strcmp0(name, INDICATOR_SERVICE_APPMENU"libappmenu.so")) {
657 continue;
658 }
659#endif
660#ifdef INDICATOR_APPLET
661 if (!g_strcmp0(name, INDICATOR_SERVICE_ME"libme.so")) {
662 continue;
663 }
664 if (!g_strcmp0(name, INDICATOR_SERVICE_DATETIME"libdatetime.so")) {
665 continue;
666 }
667#endif
668 if (load_module(name, applet, menubar)) {
669 count++;
670 }
671 }
672
673 *indicators_loaded += count;
674
675 g_dir_close (dir);
676 }
677}
678
679#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
680
681static void
682load_indicators_from_indicator_files (MatePanelApplet *applet, GtkWidget *menubar, gint *indicators_loaded)
683{
684 GDir *dir;
685 const gchar *name;
686 GError *error = NULL((void*)0);
687
688 dir = g_dir_open (INDICATOR_SERVICE_DIR, 0, &error);
689
690 if (!dir) {
691 g_warning ("unable to open indicator service file directory: %s", error->message);
692 g_error_free (error);
693
694 return;
695 }
696
697 gint count = 0;
698 while ((name = g_dir_read_name (dir))) {
699 gchar *filename;
700 IndicatorNg *indicator;
701
702 filename = g_build_filename (INDICATOR_SERVICE_DIR, name, NULL((void*)0));
703 indicator = indicator_ng_new_for_profile (filename, "desktop", &error);
704 g_free (filename);
705
706#ifdef INDICATOR_APPLET_APPMENU1
707 if (g_strcmp0(name, INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu")) {
708 continue;
709 }
710#else
711 if (!g_strcmp0(name, INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu")) {
712 continue;
713 }
714#endif
715#ifdef INDICATOR_APPLET
716 if (!g_strcmp0(name, INDICATOR_SERVICE_ME_NG"com.canonical.indicator.me")) {
717 continue;
718 }
719 if (!g_strcmp0(name, INDICATOR_SERVICE_DATETIME_NG"com.canonical.indicator.datetime")) {
720 continue;
721 }
722#endif
723
724 if (indicator) {
725 load_indicator(applet, menubar, INDICATOR_OBJECT (indicator)((((IndicatorObject*) g_type_check_instance_cast ((GTypeInstance
*) ((indicator)), ((indicator_object_get_type ()))))))
, name);
726 count++;
727 }else{
728 g_warning ("unable to load '%s': %s", name, error->message);
729 g_clear_error (&error);
730 }
731 }
732
733 *indicators_loaded += count;
734
735 g_dir_close (dir);
736}
737#endif /* HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG */
738
739static void
740hotkey_filter (char * keystring G_GNUC_UNUSED__attribute__((__unused__)), gpointer data)
741{
742 g_return_if_fail(GTK_IS_MENU_SHELL(data))do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((data)); GType __t = ((gtk_menu_shell_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet-Appmenu",
((const char*) (__func__)), "GTK_IS_MENU_SHELL(data)"); return
; } } while (0)
;
743
744 /* Oh, wow, it's us! */
745 GList * children = gtk_container_get_children(GTK_CONTAINER(data)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((gtk_container_get_type ()))))))
);
746 if (children == NULL((void*)0)) {
747 g_debug("Menubar has no children");
748 return;
749 }
750
751 gtk_menu_shell_select_item(GTK_MENU_SHELL(data)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((gtk_menu_shell_get_type ()))))))
, GTK_WIDGET(g_list_last(children)->data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(g_list_last(children)->data)), ((gtk_widget_get_type ()))
))))
);
752 g_list_free(children);
753 return;
754}
755
756static gboolean
757menubar_press (GtkWidget * widget,
758 GdkEventButton *event,
759 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
760{
761 if (event->button != 1) {
762 g_signal_stop_emission_by_name(widget, "button-press-event");
763 }
764
765 return FALSE(0);
766}
767
768static gboolean
769menubar_on_draw (GtkWidget * widget,
770 cairo_t * cr,
771 GtkWidget * menubar)
772{
773 /* FIXME: either port to gtk_render_focus or remove this function */
774 if (gtk_widget_has_focus(menubar))
775 gtk_paint_focus(gtk_widget_get_style(widget),
776 cr,
777 gtk_widget_get_state(menubar),
778 widget, "menubar-applet", 0, 0, -1, -1);
779
780 return FALSE(0);
781}
782
783static void
784about_cb (GtkAction *action G_GNUC_UNUSED__attribute__((__unused__)),
785 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
786{
787 static const gchar *authors[] = {
788 "Ted Gould <ted@canonical.com>",
789 NULL((void*)0)
790 };
791
792 static gchar *license[] = {
793 N_("This program is free software: you can redistribute it and/or modify it ""This program is free software: you can redistribute it and/or modify it "
"under the terms of the GNU General Public License version 3, as published "
"by the Free Software Foundation."
794 "under the terms of the GNU General Public License version 3, as published ""This program is free software: you can redistribute it and/or modify it "
"under the terms of the GNU General Public License version 3, as published "
"by the Free Software Foundation."
795 "by the Free Software Foundation.")"This program is free software: you can redistribute it and/or modify it "
"under the terms of the GNU General Public License version 3, as published "
"by the Free Software Foundation."
,
796 N_("This program is distributed in the hope that it will be useful, but ""This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
797 "WITHOUT ANY WARRANTY; without even the implied warranties of ""This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
798 "MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR ""This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
799 "PURPOSE. See the GNU General Public License for more details.")"This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
,
800 N_("You should have received a copy of the GNU General Public License along ""You should have received a copy of the GNU General Public License along "
"with this program. If not, see <http://www.gnu.org/licenses/>."
801 "with this program. If not, see <http://www.gnu.org/licenses/>.")"You should have received a copy of the GNU General Public License along "
"with this program. If not, see <http://www.gnu.org/licenses/>."
,
802 NULL((void*)0)
803 };
804 gchar *license_i18n;
805
806 license_i18n = g_strconcat (_(license[0])dcgettext (((void*)0), license[0], 5), "\n\n", _(license[1])dcgettext (((void*)0), license[1], 5), "\n\n", _(license[2])dcgettext (((void*)0), license[2], 5), NULL((void*)0));
807
808 gtk_show_about_dialog(NULL((void*)0),
809 "version", VERSION"1.24.0",
810 "copyright", _("Copyright \xc2\xa9 2009-2010 Canonical, Ltd.\n"dcgettext (((void*)0), "Copyright \xc2\xa9 2009-2010 Canonical, Ltd.\n"
"Copyright \xc2\xa9 2011-2020 MATE developers", 5)
811 "Copyright \xc2\xa9 2011-2020 MATE developers")dcgettext (((void*)0), "Copyright \xc2\xa9 2009-2010 Canonical, Ltd.\n"
"Copyright \xc2\xa9 2011-2020 MATE developers", 5)
,
812#ifdef INDICATOR_APPLET_APPMENU1
813 "comments", _("An applet to hold your application menus.")dcgettext (((void*)0), "An applet to hold your application menus."
, 5)
,
814#endif
815 "comments", _("An applet to hold all of the system indicators.")dcgettext (((void*)0), "An applet to hold all of the system indicators."
, 5)
,
816 "authors", authors,
817 "license", license_i18n,
818 "wrap-license", TRUE(!(0)),
819 "translator-credits", _("translator-credits")dcgettext (((void*)0), "translator-credits", 5),
820 "logo-icon-name", "mate-indicator-applet",
821 "icon-name", "mate-indicator-applet",
822 "website", "https://mate-desktop.org",
823 "website-label", _("MATE Website")dcgettext (((void*)0), "MATE Website", 5),
824 NULL((void*)0)
825 );
826
827 g_free (license_i18n);
828
829 return;
830}
831
832static gboolean
833swap_orient_cb (GtkWidget *item, gpointer data)
834{
835 GtkWidget *from = (GtkWidget *) data;
836 GtkWidget *to = (GtkWidget *) g_object_get_data(G_OBJECT(from)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
from)), (((GType) ((20) << (2))))))))
, "to");
837 g_object_ref(G_OBJECT(item)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
item)), (((GType) ((20) << (2))))))))
);
838 gtk_container_remove(GTK_CONTAINER(from)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((from)), ((gtk_container_get_type ()))))))
, item);
839 if (GTK_IS_LABEL(item)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(item)); GType __t = ((gtk_label_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; }))))
) {
840 switch(packdirection) {
841 case GTK_PACK_DIRECTION_LTR:
842 gtk_label_set_angle(GTK_LABEL(item)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(item)), ((gtk_label_get_type ()))))))
, 0.0);
843 break;
844 case GTK_PACK_DIRECTION_TTB:
845 gtk_label_set_angle(GTK_LABEL(item)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(item)), ((gtk_label_get_type ()))))))
,
846 (orient == MATE_PANEL_APPLET_ORIENT_LEFT) ?
847 270.0 : 90.0);
848 break;
849 default:
850 break;
851 }
852 }
853 gtk_box_pack_start(GTK_BOX(to)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((to
)), ((gtk_box_get_type ()))))))
, item, FALSE(0), FALSE(0), 0);
854 return TRUE(!(0));
855}
856
857static gboolean
858reorient_box_cb (GtkWidget *menuitem, gpointer data)
859{
860 GtkWidget *from = g_object_get_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "box");
861 GtkWidget *to = (packdirection == GTK_PACK_DIRECTION_LTR) ?
862 gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0) : gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
863 g_object_set_data(G_OBJECT(from)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
from)), (((GType) ((20) << (2))))))))
, "to", to);
864 gtk_container_foreach(GTK_CONTAINER(from)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((from)), ((gtk_container_get_type ()))))))
, (GtkCallback)swap_orient_cb,
865 from);
866 gtk_container_remove(GTK_CONTAINER(menuitem)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menuitem)), ((gtk_container_get_type ()))))))
, from);
867 gtk_container_add(GTK_CONTAINER(menuitem)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menuitem)), ((gtk_container_get_type ()))))))
, to);
868 g_object_set_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "box", to);
869 gtk_widget_show_all(menuitem);
870 return TRUE(!(0));
871}
872
873static gboolean
874matepanelapplet_reorient_cb (GtkWidget *applet, MatePanelAppletOrient neworient,
875 gpointer data)
876{
877 GtkWidget *menubar = (GtkWidget *)data;
878 if ((((neworient == MATE_PANEL_APPLET_ORIENT_UP) ||
879 (neworient == MATE_PANEL_APPLET_ORIENT_DOWN)) &&
880 ((orient == MATE_PANEL_APPLET_ORIENT_LEFT) ||
881 (orient == MATE_PANEL_APPLET_ORIENT_RIGHT))) ||
882 (((neworient == MATE_PANEL_APPLET_ORIENT_LEFT) ||
883 (neworient == MATE_PANEL_APPLET_ORIENT_RIGHT)) &&
884 ((orient == MATE_PANEL_APPLET_ORIENT_UP) ||
885 (orient == MATE_PANEL_APPLET_ORIENT_DOWN)))) {
886 packdirection = (packdirection == GTK_PACK_DIRECTION_LTR) ?
887 GTK_PACK_DIRECTION_TTB : GTK_PACK_DIRECTION_LTR;
888 gtk_menu_bar_set_pack_direction(GTK_MENU_BAR(menubar)((((GtkMenuBar*) g_type_check_instance_cast ((GTypeInstance*)
((menubar)), ((gtk_menu_bar_get_type ()))))))
,
889 packdirection);
890 orient = neworient;
891 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
,
892 (GtkCallback)reorient_box_cb, NULL((void*)0));
893 }
894 orient = neworient;
895 return FALSE(0);
896}
897
898#ifdef N_
899#undef N_
900#endif
901#define N_(x)x x
902
903static void
904log_to_file_cb (GObject * source_obj G_GNUC_UNUSED__attribute__((__unused__)),
905 GAsyncResult * result G_GNUC_UNUSED__attribute__((__unused__)), gpointer user_data)
906{
907 g_free(user_data);
908 return;
909}
910
911static void
912log_to_file (const gchar * domain G_GNUC_UNUSED__attribute__((__unused__)),
913 GLogLevelFlags level G_GNUC_UNUSED__attribute__((__unused__)),
914 const gchar * message,
915 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
916{
917 if (log_file == NULL((void*)0)) {
918 GError * error = NULL((void*)0);
919 gchar * filename = g_build_filename(g_get_user_cache_dir(), LOG_FILE_NAME"indicator-applet-appmenu.log", NULL((void*)0));
920 GFile * file = g_file_new_for_path(filename);
921 g_free(filename);
922
923 if (!g_file_test(g_get_user_cache_dir(), G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) {
924 GFile * cachedir = g_file_new_for_path(g_get_user_cache_dir());
925 g_file_make_directory_with_parents(cachedir, NULL((void*)0), &error);
926
927 if (error != NULL((void*)0)) {
928 g_error("Unable to make directory '%s' for log file: %s", g_get_user_cache_dir(), error->message);
929 return;
930 }
931 }
932
933 g_file_delete(file, NULL((void*)0), NULL((void*)0));
934
935 GFileIOStream * io = g_file_create_readwrite(file,
936 G_FILE_CREATE_REPLACE_DESTINATION, /* flags */
937 NULL((void*)0), /* cancelable */
938 &error); /* error */
939 if (error != NULL((void*)0)) {
940 g_error("Unable to replace file: %s", error->message);
941 return;
This statement is never executed
942 }
943
944 log_file = g_io_stream_get_output_stream(G_IO_STREAM(io)((((GIOStream*) g_type_check_instance_cast ((GTypeInstance*) (
(io)), ((g_io_stream_get_type ()))))))
);
945 }
946
947 gchar * outputstring = g_strdup_printf("%s\n", message);
948 g_output_stream_write_async(log_file,
949 outputstring, /* data */
950 strlen(outputstring), /* length */
951 G_PRIORITY_LOW300, /* priority */
952 NULL((void*)0), /* cancelable */
953 log_to_file_cb, /* callback */
954 outputstring); /* data */
955
956 return;
957}
958
959static gboolean
960applet_fill_cb (MatePanelApplet * applet, const gchar * iid G_GNUC_UNUSED__attribute__((__unused__)),
961 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
962{
963#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
964 ido_init();
965#endif
966
967 static const GtkActionEntry menu_actions[] = {
968 {"About", GTK_STOCK_ABOUT((GtkStock)"gtk-about"), N_("_About")"_About", NULL((void*)0), NULL((void*)0), G_CALLBACK(about_cb)((GCallback) (about_cb))}
969 };
970 static const gchar *menu_xml = "<menuitem name=\"About\" action=\"About\"/>";
971
972 static gboolean first_time = FALSE(0);
973 GtkWidget *menubar;
974 gint indicators_loaded = 0;
975 GtkActionGroup *action_group;
976
977 if (!first_time)
978 {
979 first_time = TRUE(!(0));
980#ifdef INDICATOR_APPLET
981 g_set_application_name(_("Indicator Applet")dcgettext (((void*)0), "Indicator Applet", 5));
982#endif
983#ifdef INDICATOR_APPLET_COMPLETE
984 g_set_application_name(_("Indicator Applet Complete")dcgettext (((void*)0), "Indicator Applet Complete", 5));
985#endif
986#ifdef INDICATOR_APPLET_APPMENU1
987 g_set_application_name(_("Indicator Applet Application Menu")dcgettext (((void*)0), "Indicator Applet Application Menu", 5
)
);
988#endif
989
990 g_log_set_default_handler(log_to_file, NULL((void*)0));
991
992 tomboy_keybinder_init();
993 }
994
995 /* Set panel options */
996 gtk_container_set_border_width(GTK_CONTAINER (applet)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_container_get_type ()))))))
, 0);
997 mate_panel_applet_set_flags(applet, MATE_PANEL_APPLET_EXPAND_MINOR);
998 menubar = gtk_menu_bar_new();
999 action_group = gtk_action_group_new ("Indicator Applet Actions");
1000 gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE"mate-indicator-applet");
1001 gtk_action_group_add_actions (action_group, menu_actions,
1002 G_N_ELEMENTS (menu_actions)(sizeof (menu_actions) / sizeof ((menu_actions)[0])),
1003 menubar);
1004 mate_panel_applet_setup_menu(applet, menu_xml, action_group);
1005 g_object_unref(action_group);
1006#ifdef INDICATOR_APPLET
1007 atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
),
1008 "indicator-applet");
1009#endif
1010#ifdef INDICATOR_APPLET_COMPLETE
1011 atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
),
1012 "indicator-applet-complete");
1013#endif
1014#ifdef INDICATOR_APPLET_APPMENU1
1015 atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
),
1016 "indicator-applet-appmenu");
1017#endif
1018
1019 /* Init some theme/icon stuff */
1020 gtk_icon_theme_append_search_path(gtk_icon_theme_get_default(),
1021 INDICATOR_ICONS_DIR"/usr/share/libindicator/icons/");
1022 /* g_debug("Icons directory: %s", INDICATOR_ICONS_DIR); */
1023 gtk_widget_set_name(GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
, "fast-user-switch-applet");
1024
1025 /* Build menubar */
1026 size = (mate_panel_applet_get_size (applet));
1027 orient = (mate_panel_applet_get_orient(applet));
1028 packdirection = ((orient == MATE_PANEL_APPLET_ORIENT_UP) ||
1029 (orient == MATE_PANEL_APPLET_ORIENT_DOWN)) ?
1030 GTK_PACK_DIRECTION_LTR : GTK_PACK_DIRECTION_TTB;
1031 gtk_menu_bar_set_pack_direction(GTK_MENU_BAR(menubar)((((GtkMenuBar*) g_type_check_instance_cast ((GTypeInstance*)
((menubar)), ((gtk_menu_bar_get_type ()))))))
,
1032 packdirection);
1033 gtk_widget_set_can_focus (menubar, TRUE(!(0)));
1034 gtk_widget_set_name(GTK_WIDGET (menubar)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(menubar)), ((gtk_widget_get_type ()))))))
, "fast-user-switch-menubar");
1035 g_signal_connect(menubar, "button-press-event", G_CALLBACK(menubar_press), NULL)g_signal_connect_data ((menubar), ("button-press-event"), (((
GCallback) (menubar_press))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
;
1036 g_signal_connect_after(menubar, "draw", G_CALLBACK(menubar_on_draw), menubar)g_signal_connect_data ((menubar), ("draw"), (((GCallback) (menubar_on_draw
))), (menubar), ((void*)0), G_CONNECT_AFTER)
;
1037 g_signal_connect(applet, "change-orient",g_signal_connect_data ((applet), ("change-orient"), (((GCallback
) (matepanelapplet_reorient_cb))), (menubar), ((void*)0), (GConnectFlags
) 0)
1038 G_CALLBACK(matepanelapplet_reorient_cb), menubar)g_signal_connect_data ((applet), ("change-orient"), (((GCallback
) (matepanelapplet_reorient_cb))), (menubar), ((void*)0), (GConnectFlags
) 0)
;
1039 gtk_container_set_border_width(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, 0);
1040
1041 /* Add in filter func */
1042 tomboy_keybinder_bind(hotkey_keycode, hotkey_filter, menubar);
1043
1044 load_modules(applet, menubar, &indicators_loaded);
1045#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
1046 load_indicators_from_indicator_files(applet, menubar, &indicators_loaded);
1047#endif
1048
1049 if (indicators_loaded == 0) {
1050 /* A label to allow for click through */
1051 GtkWidget * item = gtk_label_new(_("No Indicators")dcgettext (((void*)0), "No Indicators", 5));
1052 mate_panel_applet_set_background_widget(applet, item);
1053 gtk_container_add(GTK_CONTAINER(applet)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_container_get_type ()))))))
, item);
1054 gtk_widget_show(item);
1055 } else {
1056 gtk_container_add(GTK_CONTAINER(applet)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_container_get_type ()))))))
, menubar);
1057 mate_panel_applet_set_background_widget(applet, menubar);
1058 gtk_widget_show(menubar);
1059 }
1060
1061 gtk_widget_show(GTK_WIDGET(applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
);
1062
1063 return TRUE(!(0));
1064
1065}
diff --git a/2020-04-09-123617-6853-1@4b55003793c9_master/report-b4f74e.html b/2020-04-09-123617-6853-1@4b55003793c9_master/report-b4f74e.html new file mode 100644 index 0000000..ddd339c --- /dev/null +++ b/2020-04-09-123617-6853-1@4b55003793c9_master/report-b4f74e.html @@ -0,0 +1,1412 @@ + + + +applet-main.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:applet-main.c
Warning:line 929, column 5
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name applet-main.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -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 -mrelocation-model static -mthread-model posix -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -momit-leaf-frame-pointer -resource-dir /usr/lib64/clang/9.0.1 -D HAVE_CONFIG_H -I . -I .. -D G_LOG_DOMAIN="Indicator-Applet-Appmenu" -D DATADIR="/usr/local/share" -D INDICATOR_DIR="/usr/lib64/indicators3/7/" -D INDICATOR_ICONS_DIR="/usr/share/libindicator/icons/" -D INDICATOR_APPLET_APPMENU -I ./.. -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/fribidi -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gio-unix-2.0 -I /usr/include/libdrm -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-panel-4.0/libmate-panel-applet -I /usr/include/libindicator3-0.4 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/fribidi -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gio-unix-2.0 -I /usr/include/libdrm -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/9.0.1/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wno-unused-parameter -Wno-sign-compare -fdebug-compilation-dir /rootdir/src -ferror-limit 19 -fmessage-length 0 -fobjc-runtime=gcc -fdiagnostics-show-option -vectorize-loops -vectorize-slp -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 -o /rootdir/html-report/2020-04-09-123617-6853-1 -x c applet-main.c +
+ + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2A small wrapper utility to load indicators and put them as menu items
3into the mate-panel using it's applet interface.
4
5Copyright 2009-2010 Canonical Ltd.
6
7Authors:
8 Ted Gould <ted@canonical.com>
9
10This program is free software: you can redistribute it and/or modify it
11under the terms of the GNU General Public License version 3, as published
12by the Free Software Foundation.
13
14This program is distributed in the hope that it will be useful, but
15WITHOUT ANY WARRANTY; without even the implied warranties of
16MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
17PURPOSE. See the GNU General Public License for more details.
18
19You should have received a copy of the GNU General Public License along
20with this program. If not, see <http://www.gnu.org/licenses/>.
21*/
22
23#include <stdlib.h>
24#include <string.h>
25#include <config.h>
26#include <glib/gi18n.h>
27#include <mate-panel-applet.h>
28#include <gdk/gdkkeysyms.h>
29#include <gtk/gtk.h>
30
31#if HAVE_UBUNTU_INDICATOR1
32
33#define INDICATOR_SERVICE_APPMENU"libappmenu.so" "libappmenu.so"
34#define INDICATOR_SERVICE_ME"libme.so" "libme.so"
35#define INDICATOR_SERVICE_DATETIME"libdatetime.so" "libdatetime.so"
36
37#define INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu" "com.canonical.indicator.appmenu"
38#define INDICATOR_SERVICE_ME_NG"com.canonical.indicator.me" "com.canonical.indicator.me"
39#define INDICATOR_SERVICE_DATETIME_NG"com.canonical.indicator.datetime" "com.canonical.indicator.datetime"
40
41#include <libindicator/indicator-object.h>
42#endif
43
44#if HAVE_AYATANA_INDICATOR
45
46#define INDICATOR_SERVICE_APPMENU"libappmenu.so" "libayatana-appmenu.so"
47#define INDICATOR_SERVICE_ME"libme.so" "libayatana-me.so"
48#define INDICATOR_SERVICE_DATETIME"libdatetime.so" "libayatana-datetime.so"
49
50#define INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu" "org.ayatana.indicator.appmenu"
51#define INDICATOR_SERVICE_ME_NG"com.canonical.indicator.me" "org.ayatana.indicator.me"
52#define INDICATOR_SERVICE_DATETIME_NG"com.canonical.indicator.datetime" "org.ayatana.indicator.datetime"
53
54#include <libayatana-indicator/indicator-object.h>
55#endif
56
57/* For new style indicators */
58
59#if HAVE_UBUNTU_INDICATOR1 && HAVE_UBUNTU_INDICATOR_NG
60
61#include <libido/libido.h>
62#include <libindicator/indicator-ng.h>
63
64#define INDICATOR_SERVICE_DIR "/usr/share/unity/indicators"
65
66#endif
67
68#if HAVE_AYATANA_INDICATOR && HAVE_AYATANA_INDICATOR_NG
69
70#include <libayatana-ido/libayatana-ido.h>
71#include <libayatana-indicator/indicator-ng.h>
72
73#define INDICATOR_SERVICE_DIR "/usr/share/ayatana/indicators"
74
75#endif
76
77#include "tomboykeybinder.h"
78
79static gchar * indicator_order[] = {
80#if HAVE_UBUNTU_INDICATOR1
81 "libapplication.so",
82 "libmessaging.so",
83 "libsoundmenu.so",
84 "libdatetime.so",
85 "libsession.so",
86#endif
87#if HAVE_AYATANA_INDICATOR
88 "libayatana-application.so",
89 "libayatana-messaging.so",
90 "libayatana-soundmenu.so",
91 "libayatana-datetime.so",
92 "libayatana-session.so",
93#endif
94 NULL((void*)0)
95};
96
97static GtkPackDirection packdirection;
98static MatePanelAppletOrient orient;
99static guint size;
100
101#define MENU_DATA_INDICATOR_OBJECT"indicator-object" "indicator-object"
102#define MENU_DATA_INDICATOR_ENTRY"indicator-entry" "indicator-entry"
103
104#define IO_DATA_ORDER_NUMBER"indicator-order-number" "indicator-order-number"
105
106static gboolean applet_fill_cb (MatePanelApplet * applet, const gchar * iid, gpointer data);
107
108static void update_accessible_desc (IndicatorObjectEntry * entry, GtkWidget * menuitem);
109
110/*************
111 * main
112 * ***********/
113
114#ifdef INDICATOR_APPLET
115MATE_PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletFactory",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
116 PANEL_TYPE_APPLET,int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
117 "indicator-applet",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
118 applet_fill_cb, NULL)int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
;
119#endif
120#ifdef INDICATOR_APPLET_COMPLETE
121MATE_PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletCompleteFactory",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
122 PANEL_TYPE_APPLET,int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
123 "indicator-applet-complete",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
124 applet_fill_cb, NULL)int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
;
125#endif
126#ifdef INDICATOR_APPLET_APPMENU1
127MATE_PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletAppmenuFactory",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
128 PANEL_TYPE_APPLET,int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
129 "indicator-applet-appmenu",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
130 applet_fill_cb, NULL)int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
;
131#endif
132
133/*************
134 * log files
135 * ***********/
136#ifdef INDICATOR_APPLET
137#define LOG_FILE_NAME"indicator-applet-appmenu.log" "indicator-applet.log"
138#endif
139#ifdef INDICATOR_APPLET_COMPLETE
140#define LOG_FILE_NAME"indicator-applet-appmenu.log" "indicator-applet-complete.log"
141#endif
142#ifdef INDICATOR_APPLET_APPMENU1
143#define LOG_FILE_NAME"indicator-applet-appmenu.log" "indicator-applet-appmenu.log"
144#endif
145GOutputStream * log_file = NULL((void*)0);
146
147/*****************
148 * Hotkey support
149 * **************/
150#ifdef INDICATOR_APPLET
151gchar * hotkey_keycode = "<Super>M";
152#endif
153#ifdef INDICATOR_APPLET_SESSION
154gchar * hotkey_keycode = "<Super>S";
155#endif
156#ifdef INDICATOR_APPLET_COMPLETE
157gchar * hotkey_keycode = "<Super>S";
158#endif
159#ifdef INDICATOR_APPLET_APPMENU1
160gchar * hotkey_keycode = "<Super>F1";
161#endif
162
163/********************
164 * Environment Names
165 * *******************/
166#ifdef INDICATOR_APPLET
167#define INDICATOR_SPECIFIC_ENV"indicator-applet-appmenu" "indicator-applet-original"
168#endif
169#ifdef INDICATOR_APPLET_COMPLETE
170#define INDICATOR_SPECIFIC_ENV"indicator-applet-appmenu" "indicator-applet-complete"
171#endif
172#ifdef INDICATOR_APPLET_APPMENU1
173#define INDICATOR_SPECIFIC_ENV"indicator-applet-appmenu" "indicator-applet-appmenu"
174#endif
175
176static const gchar * indicator_env[] = {
177 "indicator-applet",
178 INDICATOR_SPECIFIC_ENV"indicator-applet-appmenu",
179 NULL((void*)0)
180};
181
182/*************
183 * init function
184 * ***********/
185
186static gint
187name2order (const gchar * name) {
188 int i;
189
190 for (i = 0; indicator_order[i] != NULL((void*)0); i++) {
191 if (g_strcmp0(name, indicator_order[i]) == 0) {
192 return i;
193 }
194 }
195
196 return -1;
197}
198
199typedef struct _incoming_position_t incoming_position_t;
200struct _incoming_position_t {
201 gint objposition;
202 gint entryposition;
203 gint menupos;
204 gboolean found;
205};
206
207/* This function helps by determining where in the menu list
208 this new entry should be placed. It compares the objects
209 that they're on, and then the individual entries. Each
210 is progressively more expensive. */
211static void
212place_in_menu (GtkWidget * widget, gpointer user_data)
213{
214 incoming_position_t * position = (incoming_position_t *)user_data;
215 if (position->found) {
216 /* We've already been placed, just finish the foreach */
217 return;
218 }
219
220 IndicatorObject * io = INDICATOR_OBJECT(g_object_get_data(G_OBJECT(widget), MENU_DATA_INDICATOR_OBJECT))((((IndicatorObject*) g_type_check_instance_cast ((GTypeInstance
*) ((g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((widget)), (((GType) ((20) << (2)))
))))), "indicator-object"))), ((indicator_object_get_type ())
)))))
;
221 g_assert(io != NULL)do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_
; if (io != ((void*)0)) _g_boolean_var_ = 1; else _g_boolean_var_
= 0; _g_boolean_var_; }), 1)) ; else g_assertion_message_expr
("Indicator-Applet-Appmenu", "applet-main.c", 221, ((const char
*) (__func__)), "io != NULL"); } while (0)
;
222
223 gint objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER))((gint) (glong) (g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
), "indicator-order-number")))
;
224 /* We've already passed it, well, then this is where
225 we should be be. Stop! */
226 if (objposition > position->objposition) {
227 position->found = TRUE(!(0));
228 return;
229 }
230
231 /* The objects don't match yet, keep looking */
232 if (objposition < position->objposition) {
233 position->menupos++;
234 return;
235 }
236
237 /* The objects are the same, let's start looking at entries. */
238 IndicatorObjectEntry * entry = (IndicatorObjectEntry *)g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
239 gint entryposition = indicator_object_get_location(io, entry);
240
241 if (entryposition > position->entryposition) {
242 position->found = TRUE(!(0));
243 return;
244 }
245
246 if (entryposition < position->entryposition) {
247 position->menupos++;
248 return;
249 }
250
251 /* We've got the same object and the same entry. Well,
252 let's just put it right here then. */
253 position->found = TRUE(!(0));
254 return;
255}
256
257static void
258something_shown (GtkWidget * widget, gpointer user_data)
259{
260 GtkWidget * menuitem = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
261 gtk_widget_show(menuitem);
262}
263
264static void
265something_hidden (GtkWidget * widget, gpointer user_data)
266{
267 GtkWidget * menuitem = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
268 gtk_widget_hide(menuitem);
269}
270
271static void
272sensitive_cb (GObject * obj, GParamSpec * pspec, gpointer user_data)
273{
274 g_return_if_fail(GTK_IS_WIDGET(obj))do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((obj)); GType __t = ((gtk_widget_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet-Appmenu",
((const char*) (__func__)), "GTK_IS_WIDGET(obj)"); return; }
} while (0)
;
275 g_return_if_fail(GTK_IS_WIDGET(user_data))do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((gtk_widget_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet-Appmenu",
((const char*) (__func__)), "GTK_IS_WIDGET(user_data)"); return
; } } while (0)
;
276
277 gtk_widget_set_sensitive(GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
, gtk_widget_get_sensitive(GTK_WIDGET(obj)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(obj)), ((gtk_widget_get_type ()))))))
));
278 return;
279}
280
281static void
282entry_activated (GtkWidget * widget, gpointer user_data)
283{
284 g_return_if_fail(GTK_IS_WIDGET(widget))do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((gtk_widget_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet-Appmenu",
((const char*) (__func__)), "GTK_IS_WIDGET(widget)"); return
; } } while (0)
;
285 gpointer pio = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, "indicator");
286 g_return_if_fail(INDICATOR_IS_OBJECT(pio))do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((pio)); GType __t = ((indicator_object_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet-Appmenu",
((const char*) (__func__)), "INDICATOR_IS_OBJECT(pio)"); return
; } } while (0)
;
287 IndicatorObject * io = INDICATOR_OBJECT(pio)((((IndicatorObject*) g_type_check_instance_cast ((GTypeInstance
*) ((pio)), ((indicator_object_get_type ()))))))
;
288
289 return indicator_object_entry_activate(io, (IndicatorObjectEntry *)user_data, gtk_get_current_event_time());
290}
291
292static gboolean
293entry_scrolled (GtkWidget *menuitem, GdkEventScroll *event, gpointer data)
294{
295 IndicatorObject *io = g_object_get_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_OBJECT"indicator-object");
296 IndicatorObjectEntry *entry = g_object_get_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
297
298 g_return_val_if_fail(INDICATOR_IS_OBJECT(io), FALSE)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((io)); GType __t = ((indicator_object_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet-Appmenu",
((const char*) (__func__)), "INDICATOR_IS_OBJECT(io)"); return
((0)); } } while (0)
;
299
300 g_signal_emit_by_name (io, "scroll", 1, event->direction);
301 g_signal_emit_by_name (io, "scroll-entry", entry, 1, event->direction);
302 g_signal_emit_by_name (io, INDICATOR_OBJECT_SIGNAL_ENTRY_SCROLLED"entry-scrolled", entry, 1, event->direction);
303
304 return FALSE(0);
305}
306
307static void
308accessible_desc_update_cb (GtkWidget * widget, gpointer userdata)
309{
310 gpointer data = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
311
312 if (data != userdata) {
313 return;
314 }
315
316 IndicatorObjectEntry * entry = (IndicatorObjectEntry *)data;
317 update_accessible_desc(entry, widget);
318}
319
320static void
321accessible_desc_update (IndicatorObject * io, IndicatorObjectEntry * entry, GtkWidget * menubar)
322{
323 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, accessible_desc_update_cb, entry);
324 return;
325}
326
327#define PANEL_PADDING8 8
328static gboolean
329entry_resized (GtkWidget *applet, guint newsize, gpointer data)
330{
331 IndicatorObject *io = (IndicatorObject *)data;
332
333 size = newsize;
334
335 /* Work on the entries */
336 GList * entries = indicator_object_get_entries(io);
337 GList * entry = NULL((void*)0);
338
339 for (entry = entries; entry != NULL((void*)0); entry = g_list_next(entry)((entry) ? (((GList *)(entry))->next) : ((void*)0))) {
340 IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)entry->data;
341 if (entrydata->image != NULL((void*)0)) {
342 /* Resize to fit panel */
343 gtk_image_set_pixel_size (entrydata->image, size - PANEL_PADDING8);
344 }
345 }
346
347 return FALSE(0);
348}
349
350static void
351entry_added (IndicatorObject * io, IndicatorObjectEntry * entry, GtkWidget * menubar)
352{
353 g_debug("Signal: Entry Added");
354 gboolean something_visible = FALSE(0);
355 gboolean something_sensitive = FALSE(0);
356
357 GtkWidget * menuitem = gtk_menu_item_new();
358 GtkWidget * box = (packdirection == GTK_PACK_DIRECTION_LTR) ?
359 gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3) : gtk_box_new(GTK_ORIENTATION_VERTICAL, 3);
360
361 /* Allows indicators to receive mouse scroll event */
362 gtk_widget_add_events(GTK_WIDGET(menuitem)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(menuitem)), ((gtk_widget_get_type ()))))))
, GDK_SCROLL_MASK);
363
364 g_object_set_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "indicator", io);
365 g_object_set_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "box", box);
366
367 g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(entry_activated), entry)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((menuitem)), (((GType) ((20) << (2)
)))))))), ("activate"), (((GCallback) (entry_activated))), (entry
), ((void*)0), (GConnectFlags) 0)
;
368 g_signal_connect(G_OBJECT(menuitem), "scroll-event", G_CALLBACK(entry_scrolled), entry)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((menuitem)), (((GType) ((20) << (2)
)))))))), ("scroll-event"), (((GCallback) (entry_scrolled))),
(entry), ((void*)0), (GConnectFlags) 0)
;
369
370 if (entry->image != NULL((void*)0)) {
371 /* Resize to fit panel */
372 gtk_image_set_pixel_size (entry->image, size - PANEL_PADDING8);
373 gtk_box_pack_start(GTK_BOX(box)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((box
)), ((gtk_box_get_type ()))))))
, GTK_WIDGET(entry->image)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->image)), ((gtk_widget_get_type ()))))))
, FALSE(0), FALSE(0), 1);
374 if (gtk_widget_get_visible(GTK_WIDGET(entry->image)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->image)), ((gtk_widget_get_type ()))))))
)) {
375 something_visible = TRUE(!(0));
376 }
377
378 if (gtk_widget_get_sensitive(GTK_WIDGET(entry->image)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->image)), ((gtk_widget_get_type ()))))))
)) {
379 something_sensitive = TRUE(!(0));
380 }
381
382 g_signal_connect(G_OBJECT(entry->image), "show", G_CALLBACK(something_shown), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), ("show"), (((GCallback) (something_shown))), (menuitem
), ((void*)0), (GConnectFlags) 0)
;
383 g_signal_connect(G_OBJECT(entry->image), "hide", G_CALLBACK(something_hidden), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), ("hide"), (((GCallback) (something_hidden))), (
menuitem), ((void*)0), (GConnectFlags) 0)
;
384
385 g_signal_connect(G_OBJECT(entry->image), "notify::sensitive", G_CALLBACK(sensitive_cb), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), ("notify::sensitive"), (((GCallback) (sensitive_cb
))), (menuitem), ((void*)0), (GConnectFlags) 0)
;
386 }
387 if (entry->label != NULL((void*)0)) {
388 switch(packdirection) {
389 case GTK_PACK_DIRECTION_LTR:
390 gtk_label_set_angle(GTK_LABEL(entry->label)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_label_get_type ()))))))
, 0.0);
391 break;
392 case GTK_PACK_DIRECTION_TTB:
393 gtk_label_set_angle(GTK_LABEL(entry->label)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_label_get_type ()))))))
,
394 (orient == MATE_PANEL_APPLET_ORIENT_LEFT) ?
395 270.0 : 90.0);
396 break;
397 default:
398 break;
399 }
400 gtk_box_pack_start(GTK_BOX(box)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((box
)), ((gtk_box_get_type ()))))))
, GTK_WIDGET(entry->label)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_widget_get_type ()))))))
, FALSE(0), FALSE(0), 1);
401
402 if (gtk_widget_get_visible(GTK_WIDGET(entry->label)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_widget_get_type ()))))))
)) {
403 something_visible = TRUE(!(0));
404 }
405
406 if (gtk_widget_get_sensitive(GTK_WIDGET(entry->label)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_widget_get_type ()))))))
)) {
407 something_sensitive = TRUE(!(0));
408 }
409
410 g_signal_connect(G_OBJECT(entry->label), "show", G_CALLBACK(something_shown), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), ("show"), (((GCallback) (something_shown))), (menuitem
), ((void*)0), (GConnectFlags) 0)
;
411 g_signal_connect(G_OBJECT(entry->label), "hide", G_CALLBACK(something_hidden), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), ("hide"), (((GCallback) (something_hidden))), (
menuitem), ((void*)0), (GConnectFlags) 0)
;
412
413 g_signal_connect(G_OBJECT(entry->label), "notify::sensitive", G_CALLBACK(sensitive_cb), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), ("notify::sensitive"), (((GCallback) (sensitive_cb
))), (menuitem), ((void*)0), (GConnectFlags) 0)
;
414 }
415 gtk_container_add(GTK_CONTAINER(menuitem)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menuitem)), ((gtk_container_get_type ()))))))
, box);
416 gtk_widget_show(box);
417
418 if (entry->menu != NULL((void*)0)) {
419 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem)((((GtkMenuItem*) g_type_check_instance_cast ((GTypeInstance*
) ((menuitem)), ((gtk_menu_item_get_type ()))))))
, GTK_WIDGET(entry->menu)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->menu)), ((gtk_widget_get_type ()))))))
);
420 }
421
422 incoming_position_t position;
423 position.objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER))((gint) (glong) (g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
), "indicator-order-number")))
;
424 position.entryposition = indicator_object_get_location(io, entry);
425 position.menupos = 0;
426 position.found = FALSE(0);
427
428 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, place_in_menu, &position);
429
430 gtk_menu_shell_insert(GTK_MENU_SHELL(menubar)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_menu_shell_get_type ()))))))
, menuitem, position.menupos);
431
432 if (something_visible) {
433 if (entry->accessible_desc != NULL((void*)0)) {
434 update_accessible_desc(entry, menuitem);
435 }
436 gtk_widget_show(menuitem);
437 }
438 gtk_widget_set_sensitive(menuitem, something_sensitive);
439
440 g_object_set_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry", entry);
441 g_object_set_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_OBJECT"indicator-object", io);
442
443 return;
444}
445
446static void
447entry_removed_cb (GtkWidget * widget, gpointer userdata)
448{
449 gpointer data = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
450
451 if (data != userdata) {
452 return;
453 }
454
455 IndicatorObjectEntry * entry = (IndicatorObjectEntry *)data;
456 if (entry->label != NULL((void*)0)) {
457 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(something_shown), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_shown))), (widget
))
;
458 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(something_hidden), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_hidden))), (widget
))
;
459 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(sensitive_cb), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (sensitive_cb))), (widget)
)
;
460 }
461 if (entry->image != NULL((void*)0)) {
462 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(something_shown), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_shown))), (widget
))
;
463 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(something_hidden), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_hidden))), (widget
))
;
464 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(sensitive_cb), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (sensitive_cb))), (widget)
)
;
465 }
466
467 gtk_widget_destroy(widget);
468 return;
469}
470
471static void
472entry_removed (IndicatorObject * io G_GNUC_UNUSED__attribute__((__unused__)), IndicatorObjectEntry * entry,
473 gpointer user_data)
474{
475 g_debug("Signal: Entry Removed");
476
477 gtk_container_foreach(GTK_CONTAINER(user_data)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((gtk_container_get_type ()))))))
, entry_removed_cb, entry);
478
479 return;
480}
481
482static void
483entry_moved_find_cb (GtkWidget * widget, gpointer userdata)
484{
485 gpointer * array = (gpointer *)userdata;
486 if (array[1] != NULL((void*)0)) {
487 return;
488 }
489
490 gpointer data = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
491
492 if (data != array[0]) {
493 return;
494 }
495
496 array[1] = widget;
497 return;
498}
499
500/* Gets called when an entry for an object was moved. */
501static void
502entry_moved (IndicatorObject * io, IndicatorObjectEntry * entry,
503 gint old G_GNUC_UNUSED__attribute__((__unused__)), gint new G_GNUC_UNUSED__attribute__((__unused__)), gpointer user_data)
504{
505 GtkWidget * menubar = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
506
507 gpointer array[2];
508 array[0] = entry;
509 array[1] = NULL((void*)0);
510
511 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, entry_moved_find_cb, array);
512 if (array[1] == NULL((void*)0)) {
513 g_warning("Moving an entry that isn't in our menus.");
514 return;
515 }
516
517 GtkWidget * mi = GTK_WIDGET(array[1])((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(array[1])), ((gtk_widget_get_type ()))))))
;
518 g_object_ref(G_OBJECT(mi)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
mi)), (((GType) ((20) << (2))))))))
);
519 gtk_container_remove(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, mi);
520
521 incoming_position_t position;
522 position.objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER))((gint) (glong) (g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
), "indicator-order-number")))
;
523 position.entryposition = indicator_object_get_location(io, entry);
524 position.menupos = 0;
525 position.found = FALSE(0);
526
527 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, place_in_menu, &position);
528
529 gtk_menu_shell_insert(GTK_MENU_SHELL(menubar)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_menu_shell_get_type ()))))))
, mi, position.menupos);
530 g_object_unref(G_OBJECT(mi)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
mi)), (((GType) ((20) << (2))))))))
);
531
532 return;
533}
534
535static void
536menu_show (IndicatorObject * io, IndicatorObjectEntry * entry,
537 guint32 timestamp, gpointer user_data)
538{
539 GtkWidget * menubar = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
540
541 if (entry == NULL((void*)0)) {
542 /* Close any open menus instead of opening one */
543 GList * entries = indicator_object_get_entries(io);
544 GList * entry = NULL((void*)0);
545 for (entry = entries; entry != NULL((void*)0); entry = g_list_next(entry)((entry) ? (((GList *)(entry))->next) : ((void*)0))) {
546 IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)entry->data;
547 gtk_menu_popdown(entrydata->menu);
548 }
549 g_list_free(entries);
550
551 /* And tell the menubar to exit activation mode too */
552 gtk_menu_shell_cancel(GTK_MENU_SHELL(menubar)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_menu_shell_get_type ()))))))
);
553 return;
554 }
555
556 // TODO: do something sensible here
557}
558
559static void
560update_accessible_desc(IndicatorObjectEntry * entry, GtkWidget * menuitem)
561{
562 /* FIXME: We need to deal with the use case where the contents of the
563 label overrides what is found in the atk object's name, or at least
564 orca speaks the label instead of the atk object name.
565 */
566 AtkObject * menuitem_obj = gtk_widget_get_accessible(menuitem);
567 if (menuitem_obj == NULL((void*)0)) {
568 /* Should there be an error printed here? */
569 return;
570 }
571
572 if (entry->accessible_desc != NULL((void*)0)) {
573 atk_object_set_name(menuitem_obj, entry->accessible_desc);
574 } else {
575 atk_object_set_name(menuitem_obj, "");
576 }
577 return;
578}
579
580static void
581load_indicator (MatePanelApplet *applet, GtkWidget * menubar, IndicatorObject *io, const gchar *name)
582{
583 /* Set the environment it's in */
584 indicator_object_set_environment(io, (const GStrv)indicator_env);
585
586 /* Attach the 'name' to the object */
587#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
588 int pos = 5000 - indicator_object_get_position(io);
589 if (pos > 5000) {
590 pos = name2order(name);
591 }
592#else
593 int pos = name2order(name);
594#endif
595
596 g_object_set_data(G_OBJECT(io)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
io)), (((GType) ((20) << (2))))))))
, IO_DATA_ORDER_NUMBER"indicator-order-number", GINT_TO_POINTER(pos)((gpointer) (glong) (pos)));
597
598 /* Connect to its signals */
599 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED, G_CALLBACK(entry_added), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("entry-added"), (((GCallback) (entry_added))), (menubar)
, ((void*)0), (GConnectFlags) 0)
;
600 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED, G_CALLBACK(entry_removed), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("entry-removed"), (((GCallback) (entry_removed))), (menubar
), ((void*)0), (GConnectFlags) 0)
;
601 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_MOVED, G_CALLBACK(entry_moved), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("entry-moved"), (((GCallback) (entry_moved))), (menubar)
, ((void*)0), (GConnectFlags) 0)
;
602 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_MENU_SHOW, G_CALLBACK(menu_show), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("menu-show"), (((GCallback) (menu_show))), (menubar), ((
void*)0), (GConnectFlags) 0)
;
603 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ACCESSIBLE_DESC_UPDATE, G_CALLBACK(accessible_desc_update), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("accessible-desc-update"), (((GCallback) (accessible_desc_update
))), (menubar), ((void*)0), (GConnectFlags) 0)
;
604
605 /* Track panel resize */
606 g_signal_connect_object(G_OBJECT(applet)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
applet)), (((GType) ((20) << (2))))))))
, "change-size", G_CALLBACK(entry_resized)((GCallback) (entry_resized)), G_OBJECT(io)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
io)), (((GType) ((20) << (2))))))))
, 0);
607
608 /* Work on the entries */
609 GList * entries = indicator_object_get_entries(io);
610 GList * entry = NULL((void*)0);
611
612 for (entry = entries; entry != NULL((void*)0); entry = g_list_next(entry)((entry) ? (((GList *)(entry))->next) : ((void*)0))) {
613 IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)entry->data;
614 entry_added(io, entrydata, menubar);
615 }
616
617 g_list_free(entries);
618}
619
620static gboolean
621load_module (const gchar * name, MatePanelApplet *applet, GtkWidget * menubar)
622{
623 g_debug("Looking at Module: %s", name);
624 g_return_val_if_fail(name != NULL, FALSE)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if (name != ((void*)0)) _g_boolean_var_ = 1; else _g_boolean_var_
= 0; _g_boolean_var_; }), 1))) { } else { g_return_if_fail_warning
("Indicator-Applet-Appmenu", ((const char*) (__func__)), "name != NULL"
); return ((0)); } } while (0)
;
625
626 if (!g_str_has_suffix(name, G_MODULE_SUFFIX"so")) {
627 return FALSE(0);
628 }
629
630 g_debug("Loading Module: %s", name);
631
632 /* Build the object for the module */
633 gchar * fullpath = g_build_filename(INDICATOR_DIR"/usr/lib64/indicators3/7/", name, NULL((void*)0));
634 IndicatorObject * io = indicator_object_new_from_file(fullpath);
635 g_free(fullpath);
636
637 load_indicator(applet, menubar, io, name);
638
639 return TRUE(!(0));
640}
641
642static void
643load_modules (MatePanelApplet *applet, GtkWidget *menubar, gint *indicators_loaded)
644{
645 if (g_file_test(INDICATOR_DIR"/usr/lib64/indicators3/7/", (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))) {
646 GDir * dir = g_dir_open(INDICATOR_DIR"/usr/lib64/indicators3/7/", 0, NULL((void*)0));
647
648 const gchar * name;
649 gint count = 0;
650 while ((name = g_dir_read_name(dir)) != NULL((void*)0)) {
651#ifdef INDICATOR_APPLET_APPMENU1
652 if (g_strcmp0(name, INDICATOR_SERVICE_APPMENU"libappmenu.so")) {
653 continue;
654 }
655#else
656 if (!g_strcmp0(name, INDICATOR_SERVICE_APPMENU"libappmenu.so")) {
657 continue;
658 }
659#endif
660#ifdef INDICATOR_APPLET
661 if (!g_strcmp0(name, INDICATOR_SERVICE_ME"libme.so")) {
662 continue;
663 }
664 if (!g_strcmp0(name, INDICATOR_SERVICE_DATETIME"libdatetime.so")) {
665 continue;
666 }
667#endif
668 if (load_module(name, applet, menubar)) {
669 count++;
670 }
671 }
672
673 *indicators_loaded += count;
674
675 g_dir_close (dir);
676 }
677}
678
679#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
680
681static void
682load_indicators_from_indicator_files (MatePanelApplet *applet, GtkWidget *menubar, gint *indicators_loaded)
683{
684 GDir *dir;
685 const gchar *name;
686 GError *error = NULL((void*)0);
687
688 dir = g_dir_open (INDICATOR_SERVICE_DIR, 0, &error);
689
690 if (!dir) {
691 g_warning ("unable to open indicator service file directory: %s", error->message);
692 g_error_free (error);
693
694 return;
695 }
696
697 gint count = 0;
698 while ((name = g_dir_read_name (dir))) {
699 gchar *filename;
700 IndicatorNg *indicator;
701
702 filename = g_build_filename (INDICATOR_SERVICE_DIR, name, NULL((void*)0));
703 indicator = indicator_ng_new_for_profile (filename, "desktop", &error);
704 g_free (filename);
705
706#ifdef INDICATOR_APPLET_APPMENU1
707 if (g_strcmp0(name, INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu")) {
708 continue;
709 }
710#else
711 if (!g_strcmp0(name, INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu")) {
712 continue;
713 }
714#endif
715#ifdef INDICATOR_APPLET
716 if (!g_strcmp0(name, INDICATOR_SERVICE_ME_NG"com.canonical.indicator.me")) {
717 continue;
718 }
719 if (!g_strcmp0(name, INDICATOR_SERVICE_DATETIME_NG"com.canonical.indicator.datetime")) {
720 continue;
721 }
722#endif
723
724 if (indicator) {
725 load_indicator(applet, menubar, INDICATOR_OBJECT (indicator)((((IndicatorObject*) g_type_check_instance_cast ((GTypeInstance
*) ((indicator)), ((indicator_object_get_type ()))))))
, name);
726 count++;
727 }else{
728 g_warning ("unable to load '%s': %s", name, error->message);
729 g_clear_error (&error);
730 }
731 }
732
733 *indicators_loaded += count;
734
735 g_dir_close (dir);
736}
737#endif /* HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG */
738
739static void
740hotkey_filter (char * keystring G_GNUC_UNUSED__attribute__((__unused__)), gpointer data)
741{
742 g_return_if_fail(GTK_IS_MENU_SHELL(data))do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((data)); GType __t = ((gtk_menu_shell_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet-Appmenu",
((const char*) (__func__)), "GTK_IS_MENU_SHELL(data)"); return
; } } while (0)
;
743
744 /* Oh, wow, it's us! */
745 GList * children = gtk_container_get_children(GTK_CONTAINER(data)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((gtk_container_get_type ()))))))
);
746 if (children == NULL((void*)0)) {
747 g_debug("Menubar has no children");
748 return;
749 }
750
751 gtk_menu_shell_select_item(GTK_MENU_SHELL(data)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((gtk_menu_shell_get_type ()))))))
, GTK_WIDGET(g_list_last(children)->data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(g_list_last(children)->data)), ((gtk_widget_get_type ()))
))))
);
752 g_list_free(children);
753 return;
754}
755
756static gboolean
757menubar_press (GtkWidget * widget,
758 GdkEventButton *event,
759 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
760{
761 if (event->button != 1) {
762 g_signal_stop_emission_by_name(widget, "button-press-event");
763 }
764
765 return FALSE(0);
766}
767
768static gboolean
769menubar_on_draw (GtkWidget * widget,
770 cairo_t * cr,
771 GtkWidget * menubar)
772{
773 /* FIXME: either port to gtk_render_focus or remove this function */
774 if (gtk_widget_has_focus(menubar))
775 gtk_paint_focus(gtk_widget_get_style(widget),
776 cr,
777 gtk_widget_get_state(menubar),
778 widget, "menubar-applet", 0, 0, -1, -1);
779
780 return FALSE(0);
781}
782
783static void
784about_cb (GtkAction *action G_GNUC_UNUSED__attribute__((__unused__)),
785 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
786{
787 static const gchar *authors[] = {
788 "Ted Gould <ted@canonical.com>",
789 NULL((void*)0)
790 };
791
792 static gchar *license[] = {
793 N_("This program is free software: you can redistribute it and/or modify it ""This program is free software: you can redistribute it and/or modify it "
"under the terms of the GNU General Public License version 3, as published "
"by the Free Software Foundation."
794 "under the terms of the GNU General Public License version 3, as published ""This program is free software: you can redistribute it and/or modify it "
"under the terms of the GNU General Public License version 3, as published "
"by the Free Software Foundation."
795 "by the Free Software Foundation.")"This program is free software: you can redistribute it and/or modify it "
"under the terms of the GNU General Public License version 3, as published "
"by the Free Software Foundation."
,
796 N_("This program is distributed in the hope that it will be useful, but ""This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
797 "WITHOUT ANY WARRANTY; without even the implied warranties of ""This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
798 "MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR ""This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
799 "PURPOSE. See the GNU General Public License for more details.")"This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
,
800 N_("You should have received a copy of the GNU General Public License along ""You should have received a copy of the GNU General Public License along "
"with this program. If not, see <http://www.gnu.org/licenses/>."
801 "with this program. If not, see <http://www.gnu.org/licenses/>.")"You should have received a copy of the GNU General Public License along "
"with this program. If not, see <http://www.gnu.org/licenses/>."
,
802 NULL((void*)0)
803 };
804 gchar *license_i18n;
805
806 license_i18n = g_strconcat (_(license[0])dcgettext (((void*)0), license[0], 5), "\n\n", _(license[1])dcgettext (((void*)0), license[1], 5), "\n\n", _(license[2])dcgettext (((void*)0), license[2], 5), NULL((void*)0));
807
808 gtk_show_about_dialog(NULL((void*)0),
809 "version", VERSION"1.24.0",
810 "copyright", _("Copyright \xc2\xa9 2009-2010 Canonical, Ltd.\n"dcgettext (((void*)0), "Copyright \xc2\xa9 2009-2010 Canonical, Ltd.\n"
"Copyright \xc2\xa9 2011-2020 MATE developers", 5)
811 "Copyright \xc2\xa9 2011-2020 MATE developers")dcgettext (((void*)0), "Copyright \xc2\xa9 2009-2010 Canonical, Ltd.\n"
"Copyright \xc2\xa9 2011-2020 MATE developers", 5)
,
812#ifdef INDICATOR_APPLET_APPMENU1
813 "comments", _("An applet to hold your application menus.")dcgettext (((void*)0), "An applet to hold your application menus."
, 5)
,
814#endif
815 "comments", _("An applet to hold all of the system indicators.")dcgettext (((void*)0), "An applet to hold all of the system indicators."
, 5)
,
816 "authors", authors,
817 "license", license_i18n,
818 "wrap-license", TRUE(!(0)),
819 "translator-credits", _("translator-credits")dcgettext (((void*)0), "translator-credits", 5),
820 "logo-icon-name", "mate-indicator-applet",
821 "icon-name", "mate-indicator-applet",
822 "website", "https://mate-desktop.org",
823 "website-label", _("MATE Website")dcgettext (((void*)0), "MATE Website", 5),
824 NULL((void*)0)
825 );
826
827 g_free (license_i18n);
828
829 return;
830}
831
832static gboolean
833swap_orient_cb (GtkWidget *item, gpointer data)
834{
835 GtkWidget *from = (GtkWidget *) data;
836 GtkWidget *to = (GtkWidget *) g_object_get_data(G_OBJECT(from)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
from)), (((GType) ((20) << (2))))))))
, "to");
837 g_object_ref(G_OBJECT(item)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
item)), (((GType) ((20) << (2))))))))
);
838 gtk_container_remove(GTK_CONTAINER(from)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((from)), ((gtk_container_get_type ()))))))
, item);
839 if (GTK_IS_LABEL(item)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(item)); GType __t = ((gtk_label_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; }))))
) {
840 switch(packdirection) {
841 case GTK_PACK_DIRECTION_LTR:
842 gtk_label_set_angle(GTK_LABEL(item)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(item)), ((gtk_label_get_type ()))))))
, 0.0);
843 break;
844 case GTK_PACK_DIRECTION_TTB:
845 gtk_label_set_angle(GTK_LABEL(item)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(item)), ((gtk_label_get_type ()))))))
,
846 (orient == MATE_PANEL_APPLET_ORIENT_LEFT) ?
847 270.0 : 90.0);
848 break;
849 default:
850 break;
851 }
852 }
853 gtk_box_pack_start(GTK_BOX(to)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((to
)), ((gtk_box_get_type ()))))))
, item, FALSE(0), FALSE(0), 0);
854 return TRUE(!(0));
855}
856
857static gboolean
858reorient_box_cb (GtkWidget *menuitem, gpointer data)
859{
860 GtkWidget *from = g_object_get_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "box");
861 GtkWidget *to = (packdirection == GTK_PACK_DIRECTION_LTR) ?
862 gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0) : gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
863 g_object_set_data(G_OBJECT(from)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
from)), (((GType) ((20) << (2))))))))
, "to", to);
864 gtk_container_foreach(GTK_CONTAINER(from)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((from)), ((gtk_container_get_type ()))))))
, (GtkCallback)swap_orient_cb,
865 from);
866 gtk_container_remove(GTK_CONTAINER(menuitem)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menuitem)), ((gtk_container_get_type ()))))))
, from);
867 gtk_container_add(GTK_CONTAINER(menuitem)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menuitem)), ((gtk_container_get_type ()))))))
, to);
868 g_object_set_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "box", to);
869 gtk_widget_show_all(menuitem);
870 return TRUE(!(0));
871}
872
873static gboolean
874matepanelapplet_reorient_cb (GtkWidget *applet, MatePanelAppletOrient neworient,
875 gpointer data)
876{
877 GtkWidget *menubar = (GtkWidget *)data;
878 if ((((neworient == MATE_PANEL_APPLET_ORIENT_UP) ||
879 (neworient == MATE_PANEL_APPLET_ORIENT_DOWN)) &&
880 ((orient == MATE_PANEL_APPLET_ORIENT_LEFT) ||
881 (orient == MATE_PANEL_APPLET_ORIENT_RIGHT))) ||
882 (((neworient == MATE_PANEL_APPLET_ORIENT_LEFT) ||
883 (neworient == MATE_PANEL_APPLET_ORIENT_RIGHT)) &&
884 ((orient == MATE_PANEL_APPLET_ORIENT_UP) ||
885 (orient == MATE_PANEL_APPLET_ORIENT_DOWN)))) {
886 packdirection = (packdirection == GTK_PACK_DIRECTION_LTR) ?
887 GTK_PACK_DIRECTION_TTB : GTK_PACK_DIRECTION_LTR;
888 gtk_menu_bar_set_pack_direction(GTK_MENU_BAR(menubar)((((GtkMenuBar*) g_type_check_instance_cast ((GTypeInstance*)
((menubar)), ((gtk_menu_bar_get_type ()))))))
,
889 packdirection);
890 orient = neworient;
891 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
,
892 (GtkCallback)reorient_box_cb, NULL((void*)0));
893 }
894 orient = neworient;
895 return FALSE(0);
896}
897
898#ifdef N_
899#undef N_
900#endif
901#define N_(x)x x
902
903static void
904log_to_file_cb (GObject * source_obj G_GNUC_UNUSED__attribute__((__unused__)),
905 GAsyncResult * result G_GNUC_UNUSED__attribute__((__unused__)), gpointer user_data)
906{
907 g_free(user_data);
908 return;
909}
910
911static void
912log_to_file (const gchar * domain G_GNUC_UNUSED__attribute__((__unused__)),
913 GLogLevelFlags level G_GNUC_UNUSED__attribute__((__unused__)),
914 const gchar * message,
915 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
916{
917 if (log_file == NULL((void*)0)) {
918 GError * error = NULL((void*)0);
919 gchar * filename = g_build_filename(g_get_user_cache_dir(), LOG_FILE_NAME"indicator-applet-appmenu.log", NULL((void*)0));
920 GFile * file = g_file_new_for_path(filename);
921 g_free(filename);
922
923 if (!g_file_test(g_get_user_cache_dir(), G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) {
924 GFile * cachedir = g_file_new_for_path(g_get_user_cache_dir());
925 g_file_make_directory_with_parents(cachedir, NULL((void*)0), &error);
926
927 if (error != NULL((void*)0)) {
928 g_error("Unable to make directory '%s' for log file: %s", g_get_user_cache_dir(), error->message);
929 return;
This statement is never executed
930 }
931 }
932
933 g_file_delete(file, NULL((void*)0), NULL((void*)0));
934
935 GFileIOStream * io = g_file_create_readwrite(file,
936 G_FILE_CREATE_REPLACE_DESTINATION, /* flags */
937 NULL((void*)0), /* cancelable */
938 &error); /* error */
939 if (error != NULL((void*)0)) {
940 g_error("Unable to replace file: %s", error->message);
941 return;
942 }
943
944 log_file = g_io_stream_get_output_stream(G_IO_STREAM(io)((((GIOStream*) g_type_check_instance_cast ((GTypeInstance*) (
(io)), ((g_io_stream_get_type ()))))))
);
945 }
946
947 gchar * outputstring = g_strdup_printf("%s\n", message);
948 g_output_stream_write_async(log_file,
949 outputstring, /* data */
950 strlen(outputstring), /* length */
951 G_PRIORITY_LOW300, /* priority */
952 NULL((void*)0), /* cancelable */
953 log_to_file_cb, /* callback */
954 outputstring); /* data */
955
956 return;
957}
958
959static gboolean
960applet_fill_cb (MatePanelApplet * applet, const gchar * iid G_GNUC_UNUSED__attribute__((__unused__)),
961 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
962{
963#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
964 ido_init();
965#endif
966
967 static const GtkActionEntry menu_actions[] = {
968 {"About", GTK_STOCK_ABOUT((GtkStock)"gtk-about"), N_("_About")"_About", NULL((void*)0), NULL((void*)0), G_CALLBACK(about_cb)((GCallback) (about_cb))}
969 };
970 static const gchar *menu_xml = "<menuitem name=\"About\" action=\"About\"/>";
971
972 static gboolean first_time = FALSE(0);
973 GtkWidget *menubar;
974 gint indicators_loaded = 0;
975 GtkActionGroup *action_group;
976
977 if (!first_time)
978 {
979 first_time = TRUE(!(0));
980#ifdef INDICATOR_APPLET
981 g_set_application_name(_("Indicator Applet")dcgettext (((void*)0), "Indicator Applet", 5));
982#endif
983#ifdef INDICATOR_APPLET_COMPLETE
984 g_set_application_name(_("Indicator Applet Complete")dcgettext (((void*)0), "Indicator Applet Complete", 5));
985#endif
986#ifdef INDICATOR_APPLET_APPMENU1
987 g_set_application_name(_("Indicator Applet Application Menu")dcgettext (((void*)0), "Indicator Applet Application Menu", 5
)
);
988#endif
989
990 g_log_set_default_handler(log_to_file, NULL((void*)0));
991
992 tomboy_keybinder_init();
993 }
994
995 /* Set panel options */
996 gtk_container_set_border_width(GTK_CONTAINER (applet)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_container_get_type ()))))))
, 0);
997 mate_panel_applet_set_flags(applet, MATE_PANEL_APPLET_EXPAND_MINOR);
998 menubar = gtk_menu_bar_new();
999 action_group = gtk_action_group_new ("Indicator Applet Actions");
1000 gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE"mate-indicator-applet");
1001 gtk_action_group_add_actions (action_group, menu_actions,
1002 G_N_ELEMENTS (menu_actions)(sizeof (menu_actions) / sizeof ((menu_actions)[0])),
1003 menubar);
1004 mate_panel_applet_setup_menu(applet, menu_xml, action_group);
1005 g_object_unref(action_group);
1006#ifdef INDICATOR_APPLET
1007 atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
),
1008 "indicator-applet");
1009#endif
1010#ifdef INDICATOR_APPLET_COMPLETE
1011 atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
),
1012 "indicator-applet-complete");
1013#endif
1014#ifdef INDICATOR_APPLET_APPMENU1
1015 atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
),
1016 "indicator-applet-appmenu");
1017#endif
1018
1019 /* Init some theme/icon stuff */
1020 gtk_icon_theme_append_search_path(gtk_icon_theme_get_default(),
1021 INDICATOR_ICONS_DIR"/usr/share/libindicator/icons/");
1022 /* g_debug("Icons directory: %s", INDICATOR_ICONS_DIR); */
1023 gtk_widget_set_name(GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
, "fast-user-switch-applet");
1024
1025 /* Build menubar */
1026 size = (mate_panel_applet_get_size (applet));
1027 orient = (mate_panel_applet_get_orient(applet));
1028 packdirection = ((orient == MATE_PANEL_APPLET_ORIENT_UP) ||
1029 (orient == MATE_PANEL_APPLET_ORIENT_DOWN)) ?
1030 GTK_PACK_DIRECTION_LTR : GTK_PACK_DIRECTION_TTB;
1031 gtk_menu_bar_set_pack_direction(GTK_MENU_BAR(menubar)((((GtkMenuBar*) g_type_check_instance_cast ((GTypeInstance*)
((menubar)), ((gtk_menu_bar_get_type ()))))))
,
1032 packdirection);
1033 gtk_widget_set_can_focus (menubar, TRUE(!(0)));
1034 gtk_widget_set_name(GTK_WIDGET (menubar)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(menubar)), ((gtk_widget_get_type ()))))))
, "fast-user-switch-menubar");
1035 g_signal_connect(menubar, "button-press-event", G_CALLBACK(menubar_press), NULL)g_signal_connect_data ((menubar), ("button-press-event"), (((
GCallback) (menubar_press))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
;
1036 g_signal_connect_after(menubar, "draw", G_CALLBACK(menubar_on_draw), menubar)g_signal_connect_data ((menubar), ("draw"), (((GCallback) (menubar_on_draw
))), (menubar), ((void*)0), G_CONNECT_AFTER)
;
1037 g_signal_connect(applet, "change-orient",g_signal_connect_data ((applet), ("change-orient"), (((GCallback
) (matepanelapplet_reorient_cb))), (menubar), ((void*)0), (GConnectFlags
) 0)
1038 G_CALLBACK(matepanelapplet_reorient_cb), menubar)g_signal_connect_data ((applet), ("change-orient"), (((GCallback
) (matepanelapplet_reorient_cb))), (menubar), ((void*)0), (GConnectFlags
) 0)
;
1039 gtk_container_set_border_width(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, 0);
1040
1041 /* Add in filter func */
1042 tomboy_keybinder_bind(hotkey_keycode, hotkey_filter, menubar);
1043
1044 load_modules(applet, menubar, &indicators_loaded);
1045#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
1046 load_indicators_from_indicator_files(applet, menubar, &indicators_loaded);
1047#endif
1048
1049 if (indicators_loaded == 0) {
1050 /* A label to allow for click through */
1051 GtkWidget * item = gtk_label_new(_("No Indicators")dcgettext (((void*)0), "No Indicators", 5));
1052 mate_panel_applet_set_background_widget(applet, item);
1053 gtk_container_add(GTK_CONTAINER(applet)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_container_get_type ()))))))
, item);
1054 gtk_widget_show(item);
1055 } else {
1056 gtk_container_add(GTK_CONTAINER(applet)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_container_get_type ()))))))
, menubar);
1057 mate_panel_applet_set_background_widget(applet, menubar);
1058 gtk_widget_show(menubar);
1059 }
1060
1061 gtk_widget_show(GTK_WIDGET(applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
);
1062
1063 return TRUE(!(0));
1064
1065}
diff --git a/2020-04-09-123617-6853-1@4b55003793c9_master/scanview.css b/2020-04-09-123617-6853-1@4b55003793c9_master/scanview.css new file mode 100644 index 0000000..cf8a5a6 --- /dev/null +++ b/2020-04-09-123617-6853-1@4b55003793c9_master/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/2020-04-09-123617-6853-1@4b55003793c9_master/sorttable.js b/2020-04-09-123617-6853-1@4b55003793c9_master/sorttable.js new file mode 100644 index 0000000..32faa07 --- /dev/null +++ b/2020-04-09-123617-6853-1@4b55003793c9_master/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(" + + + + +
+
   1
+   2
+   3
+   4
+   5
+   6
+   7
+   8
+   9
+  10
+  11
+  12
+  13
+  14
+  15
+  16
+  17
+  18
+  19
+  20
+  21
+  22
+  23
+  24
+  25
+  26
+  27
+  28
+  29
+  30
+  31
+  32
+  33
+  34
+  35
+  36
+  37
+  38
+  39
+  40
+  41
+  42
+  43
+  44
+  45
+  46
+  47
+  48
+  49
+  50
+  51
+  52
+  53
+  54
+  55
+  56
+  57
+  58
+  59
+  60
+  61
+  62
+  63
+  64
+  65
+  66
+  67
+  68
+  69
+  70
+  71
+  72
+  73
+  74
+  75
+  76
+  77
+  78
+  79
+  80
+  81
+  82
+  83
+  84
+  85
+  86
+  87
+  88
+  89
+  90
+  91
+  92
+  93
+  94
+  95
+  96
+  97
+  98
+  99
+ 100
+ 101
+ 102
+ 103
+ 104
+ 105
+ 106
+ 107
+ 108
+ 109
+ 110
+ 111
+ 112
+ 113
+ 114
+ 115
+ 116
+ 117
+ 118
+ 119
+ 120
+ 121
+ 122
+ 123
+ 124
+ 125
+ 126
+ 127
+ 128
+ 129
+ 130
+ 131
+ 132
+ 133
+ 134
+ 135
+ 136
+ 137
+ 138
+ 139
+ 140
+ 141
+ 142
+ 143
+ 144
+ 145
+ 146
+ 147
+ 148
+ 149
+ 150
+ 151
+ 152
+ 153
+ 154
+ 155
+ 156
+ 157
+ 158
+ 159
+ 160
+ 161
+ 162
+ 163
+ 164
+ 165
+ 166
+ 167
+ 168
+ 169
+ 170
+ 171
+ 172
+ 173
+ 174
+ 175
+ 176
+ 177
+ 178
+ 179
+ 180
+ 181
+ 182
+ 183
+ 184
+ 185
+ 186
+ 187
+ 188
+ 189
+ 190
+ 191
+ 192
+ 193
+ 194
+ 195
+ 196
+ 197
+ 198
+ 199
+ 200
+ 201
+ 202
+ 203
+ 204
+ 205
+ 206
+ 207
+ 208
+ 209
+ 210
+ 211
+ 212
+ 213
+ 214
+ 215
+ 216
+ 217
+ 218
+ 219
+ 220
+ 221
+ 222
+ 223
+ 224
+ 225
+ 226
+ 227
+ 228
+ 229
+ 230
+ 231
+ 232
+ 233
+ 234
+ 235
+ 236
+ 237
+ 238
+ 239
+ 240
+ 241
+ 242
+ 243
+ 244
+ 245
+ 246
+ 247
+ 248
+ 249
+ 250
+ 251
+ 252
+ 253
+ 254
+ 255
+ 256
+ 257
+ 258
+ 259
+ 260
+ 261
+ 262
+ 263
+ 264
+ 265
+ 266
+ 267
+ 268
+ 269
+ 270
+ 271
+ 272
+ 273
+ 274
+ 275
+ 276
+ 277
+ 278
+ 279
+ 280
+ 281
+ 282
+ 283
+ 284
+ 285
+ 286
+ 287
+ 288
+ 289
+ 290
+ 291
+ 292
+ 293
+ 294
+ 295
+ 296
+ 297
+ 298
+ 299
+ 300
+ 301
+ 302
+ 303
+ 304
+ 305
+ 306
+ 307
+ 308
+ 309
+ 310
+ 311
+ 312
+ 313
+ 314
+ 315
+ 316
+ 317
+ 318
+ 319
+ 320
+ 321
+ 322
+ 323
+ 324
+ 325
+ 326
+ 327
+ 328
+ 329
+ 330
+ 331
+ 332
+ 333
+ 334
+ 335
+ 336
+ 337
+ 338
+ 339
+ 340
+ 341
+ 342
+ 343
+ 344
+ 345
+ 346
+ 347
+ 348
+ 349
+ 350
+ 351
+ 352
+ 353
+ 354
+ 355
+ 356
+ 357
+ 358
+ 359
+ 360
+ 361
+ 362
+ 363
+ 364
+ 365
+ 366
+ 367
+ 368
+ 369
+ 370
+ 371
+ 372
+ 373
+ 374
+ 375
+ 376
+ 377
+ 378
+ 379
+ 380
+ 381
+ 382
+ 383
+ 384
+ 385
+ 386
+ 387
+ 388
+ 389
+ 390
+ 391
+ 392
+ 393
+ 394
+ 395
+ 396
+ 397
+ 398
+ 399
+ 400
+ 401
+ 402
+ 403
+ 404
+ 405
+ 406
+ 407
+ 408
+ 409
+ 410
+ 411
+ 412
+ 413
+ 414
+ 415
+ 416
+ 417
+ 418
+ 419
+ 420
+ 421
+ 422
+ 423
+ 424
+ 425
+ 426
+ 427
+ 428
+ 429
+ 430
+ 431
+ 432
+ 433
+ 434
+ 435
+ 436
+ 437
+ 438
+ 439
+ 440
+ 441
+ 442
+ 443
+ 444
+ 445
+ 446
+ 447
+ 448
+ 449
+ 450
+ 451
+ 452
+ 453
+ 454
+ 455
+ 456
+ 457
+ 458
+ 459
+ 460
+ 461
+ 462
+ 463
+ 464
+ 465
+ 466
+ 467
+ 468
+ 469
+ 470
+ 471
+ 472
+ 473
+ 474
+ 475
+ 476
+ 477
+ 478
+ 479
+ 480
+ 481
+ 482
+ 483
+ 484
+ 485
+ 486
+ 487
+ 488
+ 489
+ 490
+ 491
+ 492
+ 493
+ 494
+ 495
+ 496
+ 497
+ 498
+ 499
+ 500
+ 501
+ 502
+ 503
+ 504
+ 505
+ 506
+ 507
+ 508
+ 509
+ 510
+ 511
+ 512
+ 513
+ 514
+ 515
+ 516
+ 517
+ 518
+ 519
+ 520
+ 521
+ 522
+ 523
+ 524
+ 525
+ 526
+ 527
+ 528
+ 529
+ 530
+ 531
+ 532
+ 533
+ 534
+ 535
+ 536
+ 537
+ 538
+ 539
+ 540
+ 541
+ 542
+ 543
+ 544
+ 545
+ 546
+ 547
+ 548
+ 549
+ 550
+ 551
+ 552
+ 553
+ 554
+ 555
+ 556
+ 557
+ 558
+ 559
+ 560
+ 561
+ 562
+ 563
+ 564
+ 565
+ 566
+ 567
+ 568
+ 569
+ 570
+ 571
+ 572
+ 573
+ 574
+ 575
+ 576
+ 577
+ 578
+ 579
+ 580
+ 581
+ 582
+ 583
+ 584
+ 585
+ 586
+ 587
+ 588
+ 589
+ 590
+ 591
+ 592
+ 593
+ 594
+ 595
+ 596
+ 597
+ 598
+ 599
+ 600
+ 601
+ 602
+ 603
+ 604
+ 605
+ 606
+ 607
+ 608
+ 609
+ 610
+ 611
+ 612
+ 613
+ 614
+ 615
+ 616
+ 617
+ 618
+ 619
+ 620
+ 621
+ 622
+ 623
+ 624
+ 625
+ 626
+ 627
+ 628
+ 629
+ 630
+ 631
+ 632
+ 633
+ 634
+ 635
+ 636
+ 637
+ 638
+ 639
+ 640
+ 641
+ 642
+ 643
+ 644
+ 645
+ 646
+ 647
+ 648
+ 649
+ 650
+ 651
+ 652
+ 653
+ 654
+ 655
+ 656
+ 657
+ 658
+ 659
+ 660
+ 661
+ 662
+ 663
+ 664
+ 665
+ 666
+ 667
+ 668
+ 669
+ 670
+ 671
+ 672
+ 673
+ 674
+ 675
+ 676
+ 677
+ 678
+ 679
+ 680
+ 681
+ 682
+ 683
+ 684
+ 685
+ 686
+ 687
+ 688
+ 689
+ 690
+ 691
+ 692
+ 693
+ 694
+ 695
+ 696
+ 697
+ 698
+ 699
+ 700
+ 701
+ 702
+ 703
+ 704
+ 705
+ 706
+ 707
+ 708
+ 709
+ 710
+ 711
+ 712
+ 713
+ 714
+ 715
+ 716
+ 717
+ 718
+ 719
+ 720
+ 721
+ 722
+ 723
+ 724
+ 725
+ 726
+ 727
+ 728
+ 729
+ 730
+ 731
+ 732
+ 733
+ 734
+ 735
+ 736
+ 737
+ 738
+ 739
+ 740
+ 741
+ 742
+ 743
+ 744
+ 745
+ 746
+ 747
+ 748
+ 749
+ 750
+ 751
+ 752
+ 753
+ 754
+ 755
+ 756
+ 757
+ 758
+ 759
+ 760
+ 761
+ 762
+ 763
+ 764
+ 765
+ 766
+ 767
+ 768
+ 769
+ 770
+ 771
+ 772
+ 773
+ 774
+ 775
+ 776
+ 777
+ 778
+ 779
+ 780
+ 781
+ 782
+ 783
+ 784
+ 785
+ 786
+ 787
+ 788
+ 789
+ 790
+ 791
+ 792
+ 793
+ 794
+ 795
+ 796
+ 797
+ 798
+ 799
+ 800
+ 801
+ 802
+ 803
+ 804
+ 805
+ 806
+ 807
+ 808
+ 809
+ 810
+ 811
+ 812
+ 813
+ 814
+ 815
+ 816
+ 817
+ 818
+ 819
+ 820
+ 821
+ 822
+ 823
+ 824
+ 825
+ 826
+ 827
+ 828
+ 829
+ 830
+ 831
+ 832
+ 833
+ 834
+ 835
+ 836
+ 837
+ 838
+ 839
+ 840
+ 841
+ 842
+ 843
+ 844
+ 845
+ 846
+ 847
+ 848
+ 849
+ 850
+ 851
+ 852
+ 853
+ 854
+ 855
+ 856
+ 857
+ 858
+ 859
+ 860
+ 861
+ 862
+ 863
+ 864
+ 865
+ 866
+ 867
+ 868
+ 869
+ 870
+ 871
+ 872
+ 873
+ 874
+ 875
+ 876
+ 877
+ 878
+ 879
+ 880
+ 881
+ 882
+ 883
+ 884
+ 885
+ 886
+ 887
+ 888
+ 889
+ 890
+ 891
+ 892
+ 893
+ 894
+ 895
+ 896
+ 897
+ 898
+ 899
+ 900
+ 901
+ 902
+ 903
+ 904
+ 905
+ 906
+ 907
+ 908
+ 909
+ 910
+ 911
+ 912
+ 913
+ 914
+ 915
+ 916
+ 917
+ 918
+ 919
+ 920
+ 921
+ 922
+ 923
+ 924
+ 925
+ 926
+ 927
+ 928
+ 929
+ 930
+ 931
+ 932
+ 933
+ 934
+ 935
+ 936
+ 937
+ 938
+ 939
+ 940
+ 941
+ 942
+ 943
+ 944
+ 945
+ 946
+ 947
+ 948
+ 949
+ 950
+ 951
+ 952
+ 953
+ 954
+ 955
+ 956
+ 957
+ 958
+ 959
+ 960
+ 961
+ 962
+ 963
+ 964
+ 965
+ 966
+ 967
+ 968
+ 969
+ 970
+ 971
+ 972
+ 973
+ 974
+ 975
+ 976
+ 977
+ 978
+ 979
+ 980
+ 981
+ 982
+ 983
+ 984
+ 985
+ 986
+ 987
+ 988
+ 989
+ 990
+ 991
+ 992
+ 993
+ 994
+ 995
+ 996
+ 997
+ 998
+ 999
+1000
+1001
+1002
+1003
+1004
+1005
+1006
+1007
+1008
+1009
+1010
+1011
+1012
+1013
+1014
+1015
+1016
+1017
+1018
+1019
+1020
+1021
+1022
+1023
+1024
+1025
+1026
+1027
+1028
+1029
+1030
+1031
+1032
+1033
+1034
+1035
+1036
+1037
+1038
+1039
+1040
+1041
+1042
+1043
+1044
+1045
+1046
+1047
+1048
+1049
+1050
+1051
+1052
+1053
+1054
+1055
+1056
+1057
+1058
+1059
+1060
+1061
+1062
+1063
+1064
+1065
/*
+A small wrapper utility to load indicators and put them as menu items
+into the mate-panel using it's applet interface.
+
+Copyright 2009-2010 Canonical Ltd.
+
+Authors:
+    Ted Gould <ted@canonical.com>
+
+This program is free software: you can redistribute it and/or modify it
+under the terms of the GNU General Public License version 3, as published
+by the Free Software Foundation.
+
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranties of
+MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
+PURPOSE.  See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along
+with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include <stdlib.h>
+#include <string.h>
+#include <config.h>
+#include <glib/gi18n.h>
+#include <mate-panel-applet.h>
+#include <gdk/gdkkeysyms.h>
+#include <gtk/gtk.h>
+
+#if HAVE_UBUNTU_INDICATOR
+
+#define INDICATOR_SERVICE_APPMENU	"libappmenu.so"
+#define INDICATOR_SERVICE_ME		"libme.so"
+#define INDICATOR_SERVICE_DATETIME	"libdatetime.so"
+
+#define INDICATOR_SERVICE_APPMENU_NG	"com.canonical.indicator.appmenu"
+#define INDICATOR_SERVICE_ME_NG		"com.canonical.indicator.me"
+#define INDICATOR_SERVICE_DATETIME_NG	"com.canonical.indicator.datetime"
+
+#include <libindicator/indicator-object.h>
+#endif
+
+#if HAVE_AYATANA_INDICATOR
+
+#define INDICATOR_SERVICE_APPMENU	"libayatana-appmenu.so"
+#define INDICATOR_SERVICE_ME		"libayatana-me.so"
+#define INDICATOR_SERVICE_DATETIME	"libayatana-datetime.so"
+
+#define INDICATOR_SERVICE_APPMENU_NG	"org.ayatana.indicator.appmenu"
+#define INDICATOR_SERVICE_ME_NG		"org.ayatana.indicator.me"
+#define INDICATOR_SERVICE_DATETIME_NG	"org.ayatana.indicator.datetime"
+
+#include <libayatana-indicator/indicator-object.h>
+#endif
+
+/* For new style indicators */
+
+#if HAVE_UBUNTU_INDICATOR && HAVE_UBUNTU_INDICATOR_NG
+
+#include <libido/libido.h>
+#include <libindicator/indicator-ng.h>
+
+#define INDICATOR_SERVICE_DIR "/usr/share/unity/indicators"
+
+#endif
+
+#if HAVE_AYATANA_INDICATOR && HAVE_AYATANA_INDICATOR_NG
+
+#include <libayatana-ido/libayatana-ido.h>
+#include <libayatana-indicator/indicator-ng.h>
+
+#define INDICATOR_SERVICE_DIR "/usr/share/ayatana/indicators"
+
+#endif
+
+#include "tomboykeybinder.h"
+
+static gchar * indicator_order[] = {
+#if HAVE_UBUNTU_INDICATOR
+	"libapplication.so",
+	"libmessaging.so",
+	"libsoundmenu.so",
+	"libdatetime.so",
+	"libsession.so",
+#endif
+#if HAVE_AYATANA_INDICATOR
+	"libayatana-application.so",
+	"libayatana-messaging.so",
+	"libayatana-soundmenu.so",
+	"libayatana-datetime.so",
+	"libayatana-session.so",
+#endif
+	NULL
+};
+
+static GtkPackDirection packdirection;
+static MatePanelAppletOrient orient;
+static guint size;
+
+#define  MENU_DATA_INDICATOR_OBJECT  "indicator-object"
+#define  MENU_DATA_INDICATOR_ENTRY   "indicator-entry"
+
+#define  IO_DATA_ORDER_NUMBER        "indicator-order-number"
+
+static gboolean     applet_fill_cb (MatePanelApplet * applet, const gchar * iid, gpointer data);
+
+static void update_accessible_desc (IndicatorObjectEntry * entry, GtkWidget * menuitem);
+
+/*************
+ * main
+ * ***********/
+
+#ifdef INDICATOR_APPLET
+MATE_PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletFactory",
+               PANEL_TYPE_APPLET,
+               "indicator-applet",
+               applet_fill_cb, NULL);
+#endif
+#ifdef INDICATOR_APPLET_COMPLETE
+MATE_PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletCompleteFactory",
+               PANEL_TYPE_APPLET,
+               "indicator-applet-complete",
+               applet_fill_cb, NULL);
+#endif
+#ifdef INDICATOR_APPLET_APPMENU
+MATE_PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletAppmenuFactory",
+               PANEL_TYPE_APPLET,
+               "indicator-applet-appmenu",
+               applet_fill_cb, NULL);
+#endif
+
+/*************
+ * log files
+ * ***********/
+#ifdef INDICATOR_APPLET
+#define LOG_FILE_NAME  "indicator-applet.log"
+#endif
+#ifdef INDICATOR_APPLET_COMPLETE
+#define LOG_FILE_NAME  "indicator-applet-complete.log"
+#endif
+#ifdef INDICATOR_APPLET_APPMENU
+#define LOG_FILE_NAME  "indicator-applet-appmenu.log"
+#endif
+GOutputStream * log_file = NULL;
+
+/*****************
+ * Hotkey support
+ * **************/
+#ifdef INDICATOR_APPLET
+gchar * hotkey_keycode = "<Super>M";
+#endif
+#ifdef INDICATOR_APPLET_SESSION
+gchar * hotkey_keycode = "<Super>S";
+#endif
+#ifdef INDICATOR_APPLET_COMPLETE
+gchar * hotkey_keycode = "<Super>S";
+#endif
+#ifdef INDICATOR_APPLET_APPMENU
+gchar * hotkey_keycode = "<Super>F1";
+#endif
+
+/********************
+ * Environment Names
+ * *******************/
+#ifdef INDICATOR_APPLET
+#define INDICATOR_SPECIFIC_ENV  "indicator-applet-original"
+#endif
+#ifdef INDICATOR_APPLET_COMPLETE
+#define INDICATOR_SPECIFIC_ENV  "indicator-applet-complete"
+#endif
+#ifdef INDICATOR_APPLET_APPMENU
+#define INDICATOR_SPECIFIC_ENV  "indicator-applet-appmenu"
+#endif
+
+static const gchar * indicator_env[] = {
+	"indicator-applet",
+	INDICATOR_SPECIFIC_ENV,
+	NULL
+};
+
+/*************
+ * init function
+ * ***********/
+
+static gint
+name2order (const gchar * name) {
+	int i;
+
+	for (i = 0; indicator_order[i] != NULL; i++) {
+		if (g_strcmp0(name, indicator_order[i]) == 0) {
+			return i;
+		}
+	}
+
+	return -1;
+}
+
+typedef struct _incoming_position_t incoming_position_t;
+struct _incoming_position_t {
+	gint objposition;
+	gint entryposition;
+	gint menupos;
+	gboolean found;
+};
+
+/* This function helps by determining where in the menu list
+   this new entry should be placed.  It compares the objects
+   that they're on, and then the individual entries.  Each
+   is progressively more expensive. */
+static void
+place_in_menu (GtkWidget * widget, gpointer user_data)
+{
+	incoming_position_t * position = (incoming_position_t *)user_data;
+	if (position->found) {
+		/* We've already been placed, just finish the foreach */
+		return;
+	}
+
+	IndicatorObject * io = INDICATOR_OBJECT(g_object_get_data(G_OBJECT(widget), MENU_DATA_INDICATOR_OBJECT));
+	g_assert(io != NULL);
+
+	gint objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER));
+	/* We've already passed it, well, then this is where
+	   we should be be.  Stop! */
+	if (objposition > position->objposition) {
+		position->found = TRUE;
+		return;
+	}
+
+	/* The objects don't match yet, keep looking */
+	if (objposition < position->objposition) {
+		position->menupos++;
+		return;
+	}
+
+	/* The objects are the same, let's start looking at entries. */
+	IndicatorObjectEntry * entry = (IndicatorObjectEntry *)g_object_get_data(G_OBJECT(widget), MENU_DATA_INDICATOR_ENTRY);
+	gint entryposition = indicator_object_get_location(io, entry);
+
+	if (entryposition > position->entryposition) {
+		position->found = TRUE;
+		return;
+	}
+
+	if (entryposition < position->entryposition) {
+		position->menupos++;
+		return;
+	}
+
+	/* We've got the same object and the same entry.  Well,
+	   let's just put it right here then. */
+	position->found = TRUE;
+	return;
+}
+
+static void
+something_shown (GtkWidget * widget, gpointer user_data)
+{
+	GtkWidget * menuitem = GTK_WIDGET(user_data);
+	gtk_widget_show(menuitem);
+}
+
+static void
+something_hidden (GtkWidget * widget, gpointer user_data)
+{
+	GtkWidget * menuitem = GTK_WIDGET(user_data);
+	gtk_widget_hide(menuitem);
+}
+
+static void
+sensitive_cb (GObject * obj, GParamSpec * pspec, gpointer user_data)
+{
+	g_return_if_fail(GTK_IS_WIDGET(obj));
+	g_return_if_fail(GTK_IS_WIDGET(user_data));
+
+	gtk_widget_set_sensitive(GTK_WIDGET(user_data), gtk_widget_get_sensitive(GTK_WIDGET(obj)));
+	return;
+}
+
+static void
+entry_activated (GtkWidget * widget, gpointer user_data)
+{
+	g_return_if_fail(GTK_IS_WIDGET(widget));
+	gpointer pio = g_object_get_data(G_OBJECT(widget), "indicator");
+	g_return_if_fail(INDICATOR_IS_OBJECT(pio));
+	IndicatorObject * io = INDICATOR_OBJECT(pio);
+
+	return indicator_object_entry_activate(io, (IndicatorObjectEntry *)user_data, gtk_get_current_event_time());
+}
+
+static gboolean
+entry_scrolled (GtkWidget *menuitem, GdkEventScroll *event, gpointer data)
+{
+	IndicatorObject *io = g_object_get_data (G_OBJECT (menuitem), MENU_DATA_INDICATOR_OBJECT);
+	IndicatorObjectEntry *entry = g_object_get_data (G_OBJECT (menuitem), MENU_DATA_INDICATOR_ENTRY);
+
+	g_return_val_if_fail(INDICATOR_IS_OBJECT(io), FALSE);
+
+	g_signal_emit_by_name (io, "scroll", 1, event->direction);
+	g_signal_emit_by_name (io, "scroll-entry", entry, 1, event->direction);
+	g_signal_emit_by_name (io, INDICATOR_OBJECT_SIGNAL_ENTRY_SCROLLED, entry, 1, event->direction);
+
+	return FALSE;
+}
+
+static void
+accessible_desc_update_cb (GtkWidget * widget, gpointer userdata)
+{
+	gpointer data = g_object_get_data(G_OBJECT(widget), MENU_DATA_INDICATOR_ENTRY);
+
+	if (data != userdata) {
+		return;
+	}
+
+	IndicatorObjectEntry * entry = (IndicatorObjectEntry *)data;
+	update_accessible_desc(entry, widget);
+}
+
+static void
+accessible_desc_update (IndicatorObject * io, IndicatorObjectEntry * entry, GtkWidget * menubar)
+{
+	gtk_container_foreach(GTK_CONTAINER(menubar), accessible_desc_update_cb, entry);
+	return;
+}
+
+#define PANEL_PADDING 8
+static gboolean
+entry_resized (GtkWidget *applet, guint newsize, gpointer data)
+{
+	IndicatorObject *io = (IndicatorObject *)data;
+
+	size = newsize;
+
+	/* Work on the entries */
+	GList * entries = indicator_object_get_entries(io);
+	GList * entry = NULL;
+
+	for (entry = entries; entry != NULL; entry = g_list_next(entry)) {
+		IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)entry->data;
+		if (entrydata->image != NULL) {
+			/* Resize to fit panel */
+			gtk_image_set_pixel_size (entrydata->image, size - PANEL_PADDING);
+		}
+	}
+
+	return FALSE;
+}
+
+static void
+entry_added (IndicatorObject * io, IndicatorObjectEntry * entry, GtkWidget * menubar)
+{
+	g_debug("Signal: Entry Added");
+	gboolean something_visible = FALSE;
+	gboolean something_sensitive = FALSE;
+
+	GtkWidget * menuitem = gtk_menu_item_new();
+	GtkWidget * box = (packdirection == GTK_PACK_DIRECTION_LTR) ?
+		gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3) : gtk_box_new(GTK_ORIENTATION_VERTICAL, 3);
+
+	/* Allows indicators to receive mouse scroll event */
+	gtk_widget_add_events(GTK_WIDGET(menuitem), GDK_SCROLL_MASK);
+
+	g_object_set_data (G_OBJECT (menuitem), "indicator", io);
+	g_object_set_data (G_OBJECT (menuitem), "box", box);
+
+	g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(entry_activated), entry);
+	g_signal_connect(G_OBJECT(menuitem), "scroll-event", G_CALLBACK(entry_scrolled), entry);
+
+	if (entry->image != NULL) {
+		/* Resize to fit panel */
+		gtk_image_set_pixel_size (entry->image, size - PANEL_PADDING);
+		gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(entry->image), FALSE, FALSE, 1);
+		if (gtk_widget_get_visible(GTK_WIDGET(entry->image))) {
+			something_visible = TRUE;
+		}
+
+		if (gtk_widget_get_sensitive(GTK_WIDGET(entry->image))) {
+			something_sensitive = TRUE;
+		}
+
+		g_signal_connect(G_OBJECT(entry->image), "show", G_CALLBACK(something_shown), menuitem);
+		g_signal_connect(G_OBJECT(entry->image), "hide", G_CALLBACK(something_hidden), menuitem);
+
+		g_signal_connect(G_OBJECT(entry->image), "notify::sensitive", G_CALLBACK(sensitive_cb), menuitem);
+	}
+	if (entry->label != NULL) {
+		switch(packdirection) {
+			case GTK_PACK_DIRECTION_LTR:
+				gtk_label_set_angle(GTK_LABEL(entry->label), 0.0);
+				break;
+			case GTK_PACK_DIRECTION_TTB:
+				gtk_label_set_angle(GTK_LABEL(entry->label),
+						(orient == MATE_PANEL_APPLET_ORIENT_LEFT) ?
+						270.0 : 90.0);
+				break;
+			default:
+				break;
+		}
+		gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(entry->label), FALSE, FALSE, 1);
+
+		if (gtk_widget_get_visible(GTK_WIDGET(entry->label))) {
+			something_visible = TRUE;
+		}
+
+		if (gtk_widget_get_sensitive(GTK_WIDGET(entry->label))) {
+			something_sensitive = TRUE;
+		}
+
+		g_signal_connect(G_OBJECT(entry->label), "show", G_CALLBACK(something_shown), menuitem);
+		g_signal_connect(G_OBJECT(entry->label), "hide", G_CALLBACK(something_hidden), menuitem);
+
+		g_signal_connect(G_OBJECT(entry->label), "notify::sensitive", G_CALLBACK(sensitive_cb), menuitem);
+	}
+	gtk_container_add(GTK_CONTAINER(menuitem), box);
+	gtk_widget_show(box);
+
+	if (entry->menu != NULL) {
+		gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), GTK_WIDGET(entry->menu));
+	}
+
+	incoming_position_t position;
+	position.objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER));
+	position.entryposition = indicator_object_get_location(io, entry);
+	position.menupos = 0;
+	position.found = FALSE;
+
+	gtk_container_foreach(GTK_CONTAINER(menubar), place_in_menu, &position);
+
+	gtk_menu_shell_insert(GTK_MENU_SHELL(menubar), menuitem, position.menupos);
+
+	if (something_visible) {
+		if (entry->accessible_desc != NULL) {
+			update_accessible_desc(entry, menuitem);
+		}
+		gtk_widget_show(menuitem);
+	}
+	gtk_widget_set_sensitive(menuitem, something_sensitive);
+
+	g_object_set_data(G_OBJECT(menuitem), MENU_DATA_INDICATOR_ENTRY,  entry);
+	g_object_set_data(G_OBJECT(menuitem), MENU_DATA_INDICATOR_OBJECT, io);
+
+	return;
+}
+
+static void
+entry_removed_cb (GtkWidget * widget, gpointer userdata)
+{
+	gpointer data = g_object_get_data(G_OBJECT(widget), MENU_DATA_INDICATOR_ENTRY);
+
+	if (data != userdata) {
+		return;
+	}
+
+	IndicatorObjectEntry * entry = (IndicatorObjectEntry *)data;
+	if (entry->label != NULL) {
+		g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(something_shown), widget);
+		g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(something_hidden), widget);
+		g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(sensitive_cb), widget);
+	}
+	if (entry->image != NULL) {
+		g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(something_shown), widget);
+		g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(something_hidden), widget);
+		g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(sensitive_cb), widget);
+	}
+
+	gtk_widget_destroy(widget);
+	return;
+}
+
+static void
+entry_removed (IndicatorObject * io G_GNUC_UNUSED, IndicatorObjectEntry * entry,
+               gpointer user_data)
+{
+	g_debug("Signal: Entry Removed");
+
+	gtk_container_foreach(GTK_CONTAINER(user_data), entry_removed_cb, entry);
+
+	return;
+}
+
+static void
+entry_moved_find_cb (GtkWidget * widget, gpointer userdata)
+{
+	gpointer * array = (gpointer *)userdata;
+	if (array[1] != NULL) {
+		return;
+	}
+
+	gpointer data = g_object_get_data(G_OBJECT(widget), MENU_DATA_INDICATOR_ENTRY);
+
+	if (data != array[0]) {
+		return;
+	}
+
+	array[1] = widget;
+	return;
+}
+
+/* Gets called when an entry for an object was moved. */
+static void
+entry_moved (IndicatorObject * io, IndicatorObjectEntry * entry,
+             gint old G_GNUC_UNUSED, gint new G_GNUC_UNUSED, gpointer user_data)
+{
+	GtkWidget * menubar = GTK_WIDGET(user_data);
+
+	gpointer array[2];
+	array[0] = entry;
+	array[1] = NULL;
+
+	gtk_container_foreach(GTK_CONTAINER(menubar), entry_moved_find_cb, array);
+	if (array[1] == NULL) {
+		g_warning("Moving an entry that isn't in our menus.");
+		return;
+	}
+
+	GtkWidget * mi = GTK_WIDGET(array[1]);
+	g_object_ref(G_OBJECT(mi));
+	gtk_container_remove(GTK_CONTAINER(menubar), mi);
+
+	incoming_position_t position;
+	position.objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER));
+	position.entryposition = indicator_object_get_location(io, entry);
+	position.menupos = 0;
+	position.found = FALSE;
+
+	gtk_container_foreach(GTK_CONTAINER(menubar), place_in_menu, &position);
+
+	gtk_menu_shell_insert(GTK_MENU_SHELL(menubar), mi, position.menupos);
+	g_object_unref(G_OBJECT(mi));
+
+	return;
+}
+
+static void
+menu_show (IndicatorObject * io, IndicatorObjectEntry * entry,<--- Shadowed declaration
+           guint32 timestamp, gpointer user_data)
+{
+	GtkWidget * menubar = GTK_WIDGET(user_data);
+
+	if (entry == NULL) {
+		/* Close any open menus instead of opening one */
+		GList * entries = indicator_object_get_entries(io);
+		GList * entry = NULL;<--- Shadow variable
+		for (entry = entries; entry != NULL; entry = g_list_next(entry)) {
+			IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)entry->data;
+			gtk_menu_popdown(entrydata->menu);
+		}
+		g_list_free(entries);
+
+		/* And tell the menubar to exit activation mode too */
+		gtk_menu_shell_cancel(GTK_MENU_SHELL(menubar));
+		return;
+	}
+
+	// TODO: do something sensible here
+}
+
+static void
+update_accessible_desc(IndicatorObjectEntry * entry, GtkWidget * menuitem)
+{
+	/* FIXME: We need to deal with the use case where the contents of the
+	   label overrides what is found in the atk object's name, or at least
+	   orca speaks the label instead of the atk object name.
+	 */
+	AtkObject * menuitem_obj = gtk_widget_get_accessible(menuitem);
+	if (menuitem_obj == NULL) {
+		/* Should there be an error printed here? */
+		return;
+	}
+
+	if (entry->accessible_desc != NULL) {
+		atk_object_set_name(menuitem_obj, entry->accessible_desc);
+	} else {
+		atk_object_set_name(menuitem_obj, "");
+	}
+	return;
+}
+
+static void
+load_indicator (MatePanelApplet *applet, GtkWidget * menubar, IndicatorObject *io, const gchar *name)
+{
+	/* Set the environment it's in */
+	indicator_object_set_environment(io, (const GStrv)indicator_env);
+
+	/* Attach the 'name' to the object */
+#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
+	int pos = 5000 - indicator_object_get_position(io);
+	if (pos > 5000) {
+		pos = name2order(name);
+	}
+#else
+	int pos = name2order(name);
+#endif
+
+	g_object_set_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER, GINT_TO_POINTER(pos));
+
+	/* Connect to its signals */
+	g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED,   G_CALLBACK(entry_added),    menubar);
+	g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED, G_CALLBACK(entry_removed),  menubar);
+	g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_MOVED,   G_CALLBACK(entry_moved),    menubar);
+	g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_MENU_SHOW,     G_CALLBACK(menu_show),      menubar);
+	g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ACCESSIBLE_DESC_UPDATE, G_CALLBACK(accessible_desc_update), menubar);
+
+	/* Track panel resize */
+	g_signal_connect_object(G_OBJECT(applet), "change-size", G_CALLBACK(entry_resized), G_OBJECT(io), 0);
+
+	/* Work on the entries */
+	GList * entries = indicator_object_get_entries(io);
+	GList * entry = NULL;
+
+	for (entry = entries; entry != NULL; entry = g_list_next(entry)) {
+		IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)entry->data;
+		entry_added(io, entrydata, menubar);
+	}
+
+	g_list_free(entries);
+}
+
+static gboolean
+load_module (const gchar * name, MatePanelApplet *applet, GtkWidget * menubar)
+{
+	g_debug("Looking at Module: %s", name);
+	g_return_val_if_fail(name != NULL, FALSE);
+
+	if (!g_str_has_suffix(name, G_MODULE_SUFFIX)) {
+		return FALSE;
+	}
+
+	g_debug("Loading Module: %s", name);
+
+	/* Build the object for the module */
+	gchar * fullpath = g_build_filename(INDICATOR_DIR, name, NULL);
+	IndicatorObject * io = indicator_object_new_from_file(fullpath);
+	g_free(fullpath);
+
+	load_indicator(applet, menubar, io, name);
+
+	return TRUE;
+}
+
+static void
+load_modules (MatePanelApplet *applet, GtkWidget *menubar, gint *indicators_loaded)
+{
+	if (g_file_test(INDICATOR_DIR, (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))) {
+		GDir * dir = g_dir_open(INDICATOR_DIR, 0, NULL);
+
+		const gchar * name;
+		gint count = 0;
+		while ((name = g_dir_read_name(dir)) != NULL) {
+#ifdef INDICATOR_APPLET_APPMENU
+			if (g_strcmp0(name, INDICATOR_SERVICE_APPMENU)) {
+				continue;
+			}
+#else
+			if (!g_strcmp0(name, INDICATOR_SERVICE_APPMENU)) {
+				continue;
+			}
+#endif
+#ifdef INDICATOR_APPLET
+			if (!g_strcmp0(name, INDICATOR_SERVICE_ME)) {
+				continue;
+			}
+			if (!g_strcmp0(name, INDICATOR_SERVICE_DATETIME)) {
+				continue;
+			}
+#endif
+			if (load_module(name, applet, menubar)) {
+				count++;
+			}
+		}
+
+		*indicators_loaded += count;
+
+		g_dir_close (dir);
+	}
+}
+
+#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
+
+static void
+load_indicators_from_indicator_files (MatePanelApplet *applet, GtkWidget *menubar, gint *indicators_loaded)
+{
+	GDir *dir;
+	const gchar *name;
+	GError *error = NULL;
+
+	dir = g_dir_open (INDICATOR_SERVICE_DIR, 0, &error);
+
+	if (!dir) {
+		g_warning ("unable to open indicator service file directory: %s", error->message);
+		g_error_free (error);
+
+		return;
+	}
+
+	gint count = 0;
+	while ((name = g_dir_read_name (dir))) {
+		gchar *filename;
+		IndicatorNg *indicator;
+
+		filename = g_build_filename (INDICATOR_SERVICE_DIR, name, NULL);
+		indicator = indicator_ng_new_for_profile (filename, "desktop", &error);
+		g_free (filename);
+
+#ifdef INDICATOR_APPLET_APPMENU
+		if (g_strcmp0(name, INDICATOR_SERVICE_APPMENU_NG)) {
+			continue;
+		}
+#else
+		if (!g_strcmp0(name, INDICATOR_SERVICE_APPMENU_NG)) {
+			continue;
+		}
+#endif
+#ifdef INDICATOR_APPLET
+		if (!g_strcmp0(name, INDICATOR_SERVICE_ME_NG)) {
+			continue;
+		}
+		if (!g_strcmp0(name, INDICATOR_SERVICE_DATETIME_NG)) {
+			continue;
+		}
+#endif
+
+		if (indicator) {
+			load_indicator(applet, menubar, INDICATOR_OBJECT (indicator), name);
+			count++;
+		}else{
+			g_warning ("unable to load '%s': %s", name, error->message);
+			g_clear_error (&error);
+		}
+	}
+
+	*indicators_loaded += count;
+
+	g_dir_close (dir);
+}
+#endif  /* HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG */
+
+static void
+hotkey_filter (char * keystring G_GNUC_UNUSED, gpointer data)
+{
+	g_return_if_fail(GTK_IS_MENU_SHELL(data));
+
+	/* Oh, wow, it's us! */
+	GList * children = gtk_container_get_children(GTK_CONTAINER(data));
+	if (children == NULL) {
+		g_debug("Menubar has no children");
+		return;
+	}
+
+	gtk_menu_shell_select_item(GTK_MENU_SHELL(data), GTK_WIDGET(g_list_last(children)->data));
+	g_list_free(children);
+	return;
+}
+
+static gboolean
+menubar_press (GtkWidget * widget,
+                    GdkEventButton *event,
+                    gpointer data G_GNUC_UNUSED)
+{
+	if (event->button != 1) {
+		g_signal_stop_emission_by_name(widget, "button-press-event");
+	}
+
+	return FALSE;
+}
+
+static gboolean
+menubar_on_draw (GtkWidget * widget,
+                 cairo_t * cr,
+                 GtkWidget * menubar)
+{
+	/* FIXME: either port to gtk_render_focus or remove this function */
+	if (gtk_widget_has_focus(menubar))
+		gtk_paint_focus(gtk_widget_get_style(widget),
+		                cr,
+		                gtk_widget_get_state(menubar),
+		                widget, "menubar-applet", 0, 0, -1, -1);
+
+	return FALSE;
+}
+
+static void
+about_cb (GtkAction *action G_GNUC_UNUSED,
+          gpointer   data G_GNUC_UNUSED)
+{
+	static const gchar *authors[] = {
+		"Ted Gould <ted@canonical.com>",
+		NULL
+	};
+
+	static gchar *license[] = {
+        N_("This program is free software: you can redistribute it and/or modify it "
+           "under the terms of the GNU General Public License version 3, as published "
+           "by the Free Software Foundation."),
+        N_("This program is distributed in the hope that it will be useful, but "
+           "WITHOUT ANY WARRANTY; without even the implied warranties of "
+           "MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
+           "PURPOSE.  See the GNU General Public License for more details."),
+        N_("You should have received a copy of the GNU General Public License along "
+           "with this program.  If not, see <http://www.gnu.org/licenses/>."),
+		NULL
+	};
+	gchar *license_i18n;
+
+	license_i18n = g_strconcat (_(license[0]), "\n\n", _(license[1]), "\n\n", _(license[2]), NULL);
+
+	gtk_show_about_dialog(NULL,
+		"version", VERSION,
+		"copyright", _("Copyright \xc2\xa9 2009-2010 Canonical, Ltd.\n"
+		               "Copyright \xc2\xa9 2011-2020 MATE developers"),
+#ifdef INDICATOR_APPLET_APPMENU
+		"comments", _("An applet to hold your application menus."),
+#endif
+		"comments", _("An applet to hold all of the system indicators."),
+		"authors", authors,
+		"license", license_i18n,
+		"wrap-license", TRUE,
+		"translator-credits", _("translator-credits"),
+		"logo-icon-name", "mate-indicator-applet",
+		"icon-name", "mate-indicator-applet",
+		"website", "https://mate-desktop.org",
+		"website-label", _("MATE Website"),
+		NULL
+	);
+
+	g_free (license_i18n);
+
+	return;
+}
+
+static gboolean
+swap_orient_cb (GtkWidget *item, gpointer data)
+{
+	GtkWidget *from = (GtkWidget *) data;
+	GtkWidget *to = (GtkWidget *) g_object_get_data(G_OBJECT(from), "to");
+	g_object_ref(G_OBJECT(item));
+	gtk_container_remove(GTK_CONTAINER(from), item);
+	if (GTK_IS_LABEL(item)) {
+			switch(packdirection) {
+			case GTK_PACK_DIRECTION_LTR:
+				gtk_label_set_angle(GTK_LABEL(item), 0.0);
+				break;
+			case GTK_PACK_DIRECTION_TTB:
+				gtk_label_set_angle(GTK_LABEL(item),
+						(orient == MATE_PANEL_APPLET_ORIENT_LEFT) ?
+						270.0 : 90.0);
+				break;
+			default:
+				break;
+		}
+	}
+	gtk_box_pack_start(GTK_BOX(to), item, FALSE, FALSE, 0);
+	return TRUE;
+}
+
+static gboolean
+reorient_box_cb (GtkWidget *menuitem, gpointer data)
+{
+	GtkWidget *from = g_object_get_data(G_OBJECT(menuitem), "box");
+	GtkWidget *to = (packdirection == GTK_PACK_DIRECTION_LTR) ?
+		gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0) : gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
+	g_object_set_data(G_OBJECT(from), "to", to);
+	gtk_container_foreach(GTK_CONTAINER(from), (GtkCallback)swap_orient_cb,
+			from);
+	gtk_container_remove(GTK_CONTAINER(menuitem), from);
+	gtk_container_add(GTK_CONTAINER(menuitem), to);
+	g_object_set_data(G_OBJECT(menuitem), "box", to);
+	gtk_widget_show_all(menuitem);
+	return TRUE;
+}
+
+static gboolean
+matepanelapplet_reorient_cb (GtkWidget *applet, MatePanelAppletOrient neworient,
+		gpointer data)
+{
+	GtkWidget *menubar = (GtkWidget *)data;
+	if ((((neworient == MATE_PANEL_APPLET_ORIENT_UP) ||
+			(neworient == MATE_PANEL_APPLET_ORIENT_DOWN)) &&
+			((orient == MATE_PANEL_APPLET_ORIENT_LEFT) ||
+			(orient == MATE_PANEL_APPLET_ORIENT_RIGHT))) ||
+			(((neworient == MATE_PANEL_APPLET_ORIENT_LEFT) ||
+			(neworient == MATE_PANEL_APPLET_ORIENT_RIGHT)) &&
+			((orient == MATE_PANEL_APPLET_ORIENT_UP) ||
+			(orient == MATE_PANEL_APPLET_ORIENT_DOWN)))) {
+		packdirection = (packdirection == GTK_PACK_DIRECTION_LTR) ?
+				GTK_PACK_DIRECTION_TTB : GTK_PACK_DIRECTION_LTR;
+		gtk_menu_bar_set_pack_direction(GTK_MENU_BAR(menubar),
+				packdirection);
+		orient = neworient;
+		gtk_container_foreach(GTK_CONTAINER(menubar),
+				(GtkCallback)reorient_box_cb, NULL);
+	}
+	orient = neworient;
+	return FALSE;
+}
+
+#ifdef N_
+#undef N_
+#endif
+#define N_(x) x
+
+static void
+log_to_file_cb (GObject * source_obj G_GNUC_UNUSED,
+                GAsyncResult * result G_GNUC_UNUSED, gpointer user_data)
+{
+	g_free(user_data);
+	return;
+}
+
+static void
+log_to_file (const gchar * domain G_GNUC_UNUSED,
+             GLogLevelFlags level G_GNUC_UNUSED,
+             const gchar * message,
+             gpointer data G_GNUC_UNUSED)
+{
+	if (log_file == NULL) {
+		GError * error = NULL;
+		gchar * filename = g_build_filename(g_get_user_cache_dir(), LOG_FILE_NAME, NULL);
+		GFile * file = g_file_new_for_path(filename);
+		g_free(filename);
+
+		if (!g_file_test(g_get_user_cache_dir(), G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) {
+			GFile * cachedir = g_file_new_for_path(g_get_user_cache_dir());
+			g_file_make_directory_with_parents(cachedir, NULL, &error);
+
+			if (error != NULL) {
+				g_error("Unable to make directory '%s' for log file: %s", g_get_user_cache_dir(), error->message);
+				return;
+			}
+		}
+
+		g_file_delete(file, NULL, NULL);
+
+		GFileIOStream * io = g_file_create_readwrite(file,
+		                          G_FILE_CREATE_REPLACE_DESTINATION, /* flags */
+		                          NULL, /* cancelable */
+		                          &error); /* error */
+		if (error != NULL) {
+			g_error("Unable to replace file: %s", error->message);
+			return;
+		}
+
+		log_file = g_io_stream_get_output_stream(G_IO_STREAM(io));
+	}
+
+	gchar * outputstring = g_strdup_printf("%s\n", message);
+	g_output_stream_write_async(log_file,
+	                            outputstring, /* data */
+	                            strlen(outputstring), /* length */
+	                            G_PRIORITY_LOW, /* priority */
+	                            NULL, /* cancelable */
+	                            log_to_file_cb, /* callback */
+	                            outputstring); /* data */
+
+	return;
+}
+
+static gboolean
+applet_fill_cb (MatePanelApplet * applet, const gchar * iid G_GNUC_UNUSED,
+                gpointer data G_GNUC_UNUSED)
+{
+#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
+	ido_init();
+#endif
+
+	static const GtkActionEntry menu_actions[] = {
+		{"About", GTK_STOCK_ABOUT, N_("_About"), NULL, NULL, G_CALLBACK(about_cb)}
+	};
+	static const gchar *menu_xml = "<menuitem name=\"About\" action=\"About\"/>";
+
+	static gboolean first_time = FALSE;
+	GtkWidget *menubar;
+	gint indicators_loaded = 0;
+	GtkActionGroup *action_group;
+
+	if (!first_time)
+	{
+		first_time = TRUE;
+#ifdef INDICATOR_APPLET
+		g_set_application_name(_("Indicator Applet"));
+#endif
+#ifdef INDICATOR_APPLET_COMPLETE
+		g_set_application_name(_("Indicator Applet Complete"));
+#endif
+#ifdef INDICATOR_APPLET_APPMENU
+		g_set_application_name(_("Indicator Applet Application Menu"));
+#endif
+
+		g_log_set_default_handler(log_to_file, NULL);
+
+		tomboy_keybinder_init();
+	}
+
+	/* Set panel options */
+	gtk_container_set_border_width(GTK_CONTAINER (applet), 0);
+	mate_panel_applet_set_flags(applet, MATE_PANEL_APPLET_EXPAND_MINOR);
+	menubar = gtk_menu_bar_new();
+	action_group = gtk_action_group_new ("Indicator Applet Actions");
+	gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
+	gtk_action_group_add_actions (action_group, menu_actions,
+	                              G_N_ELEMENTS (menu_actions),
+	                              menubar);
+	mate_panel_applet_setup_menu(applet, menu_xml, action_group);
+	g_object_unref(action_group);
+#ifdef INDICATOR_APPLET
+	atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)),
+	                     "indicator-applet");
+#endif
+#ifdef INDICATOR_APPLET_COMPLETE
+	atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)),
+	                     "indicator-applet-complete");
+#endif
+#ifdef INDICATOR_APPLET_APPMENU
+	atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)),
+	                     "indicator-applet-appmenu");
+#endif
+
+	/* Init some theme/icon stuff */
+	gtk_icon_theme_append_search_path(gtk_icon_theme_get_default(),
+	                                  INDICATOR_ICONS_DIR);
+	/* g_debug("Icons directory: %s", INDICATOR_ICONS_DIR); */
+	gtk_widget_set_name(GTK_WIDGET (applet), "fast-user-switch-applet");
+
+	/* Build menubar */
+	size = (mate_panel_applet_get_size (applet));
+	orient = (mate_panel_applet_get_orient(applet));
+	packdirection = ((orient == MATE_PANEL_APPLET_ORIENT_UP) ||
+			(orient == MATE_PANEL_APPLET_ORIENT_DOWN)) ?
+			GTK_PACK_DIRECTION_LTR : GTK_PACK_DIRECTION_TTB;
+	gtk_menu_bar_set_pack_direction(GTK_MENU_BAR(menubar),
+			packdirection);
+	gtk_widget_set_can_focus (menubar, TRUE);
+	gtk_widget_set_name(GTK_WIDGET (menubar), "fast-user-switch-menubar");
+	g_signal_connect(menubar, "button-press-event", G_CALLBACK(menubar_press), NULL);
+	g_signal_connect_after(menubar, "draw", G_CALLBACK(menubar_on_draw), menubar);
+	g_signal_connect(applet, "change-orient",
+			G_CALLBACK(matepanelapplet_reorient_cb), menubar);
+	gtk_container_set_border_width(GTK_CONTAINER(menubar), 0);
+
+	/* Add in filter func */
+	tomboy_keybinder_bind(hotkey_keycode, hotkey_filter, menubar);
+
+	load_modules(applet, menubar, &indicators_loaded);
+#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
+	load_indicators_from_indicator_files(applet, menubar, &indicators_loaded);
+#endif
+
+	if (indicators_loaded == 0) {
+		/* A label to allow for click through */
+		GtkWidget * item = gtk_label_new(_("No Indicators"));
+		mate_panel_applet_set_background_widget(applet, item);
+		gtk_container_add(GTK_CONTAINER(applet), item);
+		gtk_widget_show(item);
+	} else {
+		gtk_container_add(GTK_CONTAINER(applet), menubar);
+		mate_panel_applet_set_background_widget(applet, menubar);
+		gtk_widget_show(menubar);
+	}
+
+	gtk_widget_show(GTK_WIDGET(applet));
+
+	return TRUE;
+
+}
+
+
+
+ + + diff --git a/2020-04-09-123647-2786-cppcheck@4b55003793c9_master/1.html b/2020-04-09-123647-2786-cppcheck@4b55003793c9_master/1.html new file mode 100644 index 0000000..6bc0c8a --- /dev/null +++ b/2020-04-09-123647-2786-cppcheck@4b55003793c9_master/1.html @@ -0,0 +1,1208 @@ + + + + + + Cppcheck - HTML report - mate-indicator-applet + + + + + + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
/* eggaccelerators.c
+ * Copyright (C) 2002  Red Hat, Inc.; Copyright 1998, 2001 Tim Janik
+ * Developed by Havoc Pennington, Tim Janik
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
+ */
+
+#include "eggaccelerators.h"
+
+#include <string.h>
+#include <gdk/gdkx.h>
+#include <gdk/gdkkeysyms.h>
+
+enum
+{
+  EGG_MODMAP_ENTRY_SHIFT   = 0,
+  EGG_MODMAP_ENTRY_LOCK    = 1,
+  EGG_MODMAP_ENTRY_CONTROL = 2,
+  EGG_MODMAP_ENTRY_MOD1    = 3,
+  EGG_MODMAP_ENTRY_MOD2    = 4,
+  EGG_MODMAP_ENTRY_MOD3    = 5,
+  EGG_MODMAP_ENTRY_MOD4    = 6,
+  EGG_MODMAP_ENTRY_MOD5    = 7,
+  EGG_MODMAP_ENTRY_LAST    = 8
+};
+
+#define MODMAP_ENTRY_TO_MODIFIER(x) (1 << (x))
+
+typedef struct
+{
+  EggVirtualModifierType mapping[EGG_MODMAP_ENTRY_LAST];
+
+} EggModmap;
+
+const EggModmap* egg_keymap_get_modmap (GdkKeymap *keymap);
+
+static inline gboolean
+is_alt (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'a' || string[1] == 'A') &&
+	  (string[2] == 'l' || string[2] == 'L') &&
+	  (string[3] == 't' || string[3] == 'T') &&
+	  (string[4] == '>'));
+}
+
+static inline gboolean
+is_ctl (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'c' || string[1] == 'C') &&
+	  (string[2] == 't' || string[2] == 'T') &&
+	  (string[3] == 'l' || string[3] == 'L') &&
+	  (string[4] == '>'));
+}
+
+static inline gboolean
+is_modx (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'm' || string[1] == 'M') &&
+	  (string[2] == 'o' || string[2] == 'O') &&
+	  (string[3] == 'd' || string[3] == 'D') &&
+	  (string[4] >= '1' && string[4] <= '5') &&
+	  (string[5] == '>'));
+}
+
+static inline gboolean
+is_ctrl (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'c' || string[1] == 'C') &&
+	  (string[2] == 't' || string[2] == 'T') &&
+	  (string[3] == 'r' || string[3] == 'R') &&
+	  (string[4] == 'l' || string[4] == 'L') &&
+	  (string[5] == '>'));
+}
+
+static inline gboolean
+is_shft (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 's' || string[1] == 'S') &&
+	  (string[2] == 'h' || string[2] == 'H') &&
+	  (string[3] == 'f' || string[3] == 'F') &&
+	  (string[4] == 't' || string[4] == 'T') &&
+	  (string[5] == '>'));
+}
+
+static inline gboolean
+is_shift (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 's' || string[1] == 'S') &&
+	  (string[2] == 'h' || string[2] == 'H') &&
+	  (string[3] == 'i' || string[3] == 'I') &&
+	  (string[4] == 'f' || string[4] == 'F') &&
+	  (string[5] == 't' || string[5] == 'T') &&
+	  (string[6] == '>'));
+}
+
+static inline gboolean
+is_control (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'c' || string[1] == 'C') &&
+	  (string[2] == 'o' || string[2] == 'O') &&
+	  (string[3] == 'n' || string[3] == 'N') &&
+	  (string[4] == 't' || string[4] == 'T') &&
+	  (string[5] == 'r' || string[5] == 'R') &&
+	  (string[6] == 'o' || string[6] == 'O') &&
+	  (string[7] == 'l' || string[7] == 'L') &&
+	  (string[8] == '>'));
+}
+
+static inline gboolean
+is_release (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'r' || string[1] == 'R') &&
+	  (string[2] == 'e' || string[2] == 'E') &&
+	  (string[3] == 'l' || string[3] == 'L') &&
+	  (string[4] == 'e' || string[4] == 'E') &&
+	  (string[5] == 'a' || string[5] == 'A') &&
+	  (string[6] == 's' || string[6] == 'S') &&
+	  (string[7] == 'e' || string[7] == 'E') &&
+	  (string[8] == '>'));
+}
+
+static inline gboolean
+is_meta (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'm' || string[1] == 'M') &&
+	  (string[2] == 'e' || string[2] == 'E') &&
+	  (string[3] == 't' || string[3] == 'T') &&
+	  (string[4] == 'a' || string[4] == 'A') &&
+	  (string[5] == '>'));
+}
+
+static inline gboolean
+is_super (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 's' || string[1] == 'S') &&
+	  (string[2] == 'u' || string[2] == 'U') &&
+	  (string[3] == 'p' || string[3] == 'P') &&
+	  (string[4] == 'e' || string[4] == 'E') &&
+	  (string[5] == 'r' || string[5] == 'R') &&
+	  (string[6] == '>'));
+}
+
+static inline gboolean
+is_hyper (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'h' || string[1] == 'H') &&
+	  (string[2] == 'y' || string[2] == 'Y') &&
+	  (string[3] == 'p' || string[3] == 'P') &&
+	  (string[4] == 'e' || string[4] == 'E') &&
+	  (string[5] == 'r' || string[5] == 'R') &&
+	  (string[6] == '>'));
+}
+
+/**
+ * egg_accelerator_parse_virtual:
+ * @accelerator:      string representing an accelerator
+ * @accelerator_key:  return location for accelerator keyval
+ * @accelerator_mods: return location for accelerator modifier mask
+ *
+ * Parses a string representing a virtual accelerator. The format
+ * looks like "&lt;Control&gt;a" or "&lt;Shift&gt;&lt;Alt&gt;F1" or
+ * "&lt;Release&gt;z" (the last one is for key release).  The parser
+ * is fairly liberal and allows lower or upper case, and also
+ * abbreviations such as "&lt;Ctl&gt;" and "&lt;Ctrl&gt;".
+ *
+ * If the parse fails, @accelerator_key and @accelerator_mods will
+ * be set to 0 (zero) and %FALSE will be returned. If the string contains
+ * only modifiers, @accelerator_key will be set to 0 but %TRUE will be
+ * returned.
+ *
+ * The virtual vs. concrete accelerator distinction is a relic of
+ * how the X Window System works; there are modifiers Mod2-Mod5 that
+ * can represent various keyboard keys (numlock, meta, hyper, etc.),
+ * the virtual modifier represents the keyboard key, the concrete
+ * modifier the actual Mod2-Mod5 bits in the key press event.
+ *
+ * Returns: %TRUE on success.
+ */
+gboolean
+egg_accelerator_parse_virtual (const gchar            *accelerator,
+                               guint                  *accelerator_key,
+                               EggVirtualModifierType *accelerator_mods)
+{
+  guint keyval;
+  GdkModifierType mods;
+  gint len;
+  gboolean bad_keyval;
+
+  if (accelerator_key)
+    *accelerator_key = 0;
+  if (accelerator_mods)
+    *accelerator_mods = 0;
+
+  g_return_val_if_fail (accelerator != NULL, FALSE);
+
+  bad_keyval = FALSE;
+
+  keyval = 0;
+  mods = 0;
+  len = strlen (accelerator);
+  while (len)
+    {
+      if (*accelerator == '<')
+	{
+	  if (len >= 9 && is_release (accelerator))
+	    {
+	      accelerator += 9;
+	      len -= 9;
+	      mods |= EGG_VIRTUAL_RELEASE_MASK;
+	    }
+	  else if (len >= 9 && is_control (accelerator))
+	    {
+	      accelerator += 9;
+	      len -= 9;
+	      mods |= EGG_VIRTUAL_CONTROL_MASK;
+	    }
+	  else if (len >= 7 && is_shift (accelerator))
+	    {
+	      accelerator += 7;
+	      len -= 7;
+	      mods |= EGG_VIRTUAL_SHIFT_MASK;
+	    }
+	  else if (len >= 6 && is_shft (accelerator))
+	    {
+	      accelerator += 6;
+	      len -= 6;
+	      mods |= EGG_VIRTUAL_SHIFT_MASK;
+	    }
+	  else if (len >= 6 && is_ctrl (accelerator))
+	    {
+	      accelerator += 6;
+	      len -= 6;
+	      mods |= EGG_VIRTUAL_CONTROL_MASK;
+	    }
+	  else if (len >= 6 && is_modx (accelerator))
+	    {
+	      static const guint mod_vals[] = {
+		EGG_VIRTUAL_ALT_MASK, EGG_VIRTUAL_MOD2_MASK, EGG_VIRTUAL_MOD3_MASK,
+		EGG_VIRTUAL_MOD4_MASK, EGG_VIRTUAL_MOD5_MASK
+	      };
+
+	      len -= 6;
+	      accelerator += 4;
+	      mods |= mod_vals[*accelerator - '1'];
+	      accelerator += 2;
+	    }
+	  else if (len >= 5 && is_ctl (accelerator))
+	    {
+	      accelerator += 5;
+	      len -= 5;
+	      mods |= EGG_VIRTUAL_CONTROL_MASK;
+	    }
+	  else if (len >= 5 && is_alt (accelerator))
+	    {
+	      accelerator += 5;
+	      len -= 5;
+	      mods |= EGG_VIRTUAL_ALT_MASK;
+	    }
+          else if (len >= 6 && is_meta (accelerator))
+	    {
+	      accelerator += 6;
+	      len -= 6;
+	      mods |= EGG_VIRTUAL_META_MASK;
+	    }
+          else if (len >= 7 && is_hyper (accelerator))
+	    {
+	      accelerator += 7;
+	      len -= 7;
+	      mods |= EGG_VIRTUAL_HYPER_MASK;
+	    }
+          else if (len >= 7 && is_super (accelerator))
+	    {
+	      accelerator += 7;
+	      len -= 7;
+	      mods |= EGG_VIRTUAL_SUPER_MASK;
+	    }
+	  else
+	    {
+	      gchar last_ch;
+
+	      last_ch = *accelerator;
+	      while (last_ch && last_ch != '>')
+		{
+		  last_ch = *accelerator;
+		  accelerator += 1;
+		  len -= 1;
+		}
+	    }
+	}
+      else
+	{
+          keyval = gdk_keyval_from_name (accelerator);
+
+          if (keyval == 0)
+            bad_keyval = TRUE;
+
+          accelerator += len;
+          len -= len;
+	}
+    }
+
+  if (accelerator_key)
+    *accelerator_key = gdk_keyval_to_lower (keyval);
+  if (accelerator_mods)
+    *accelerator_mods = mods;
+
+  return !bad_keyval;
+}
+
+void
+egg_keymap_resolve_virtual_modifiers (GdkKeymap              *keymap,
+                                      EggVirtualModifierType  virtual_mods,
+                                      GdkModifierType        *concrete_mods)
+{
+  GdkModifierType concrete;
+  int i;
+  const EggModmap *modmap;
+
+  g_return_if_fail (GDK_IS_KEYMAP (keymap));
+  g_return_if_fail (concrete_mods != NULL);
+
+  modmap = egg_keymap_get_modmap (keymap);
+
+  /* Not so sure about this algorithm. */
+
+  concrete = 0;
+  i = 0;
+  while (i < EGG_MODMAP_ENTRY_LAST)
+    {
+      if (modmap->mapping[i] & virtual_mods)
+        concrete |= (1 << i);
+
+      ++i;
+    }
+
+  *concrete_mods = concrete;
+}
+
+void
+egg_keymap_virtualize_modifiers (GdkKeymap              *keymap,
+                                 GdkModifierType         concrete_mods,
+                                 EggVirtualModifierType *virtual_mods)
+{
+  GdkModifierType virtual;
+  int i;
+  const EggModmap *modmap;
+
+  g_return_if_fail (GDK_IS_KEYMAP (keymap));
+  g_return_if_fail (virtual_mods != NULL);
+
+  modmap = egg_keymap_get_modmap (keymap);
+
+  /* Not so sure about this algorithm. */
+
+  virtual = 0;
+  i = 0;
+  while (i < EGG_MODMAP_ENTRY_LAST)
+    {
+      if ((1 << i) & concrete_mods)
+        {
+          EggVirtualModifierType cleaned;
+
+          cleaned = modmap->mapping[i] & ~(EGG_VIRTUAL_MOD2_MASK |
+                                           EGG_VIRTUAL_MOD3_MASK |
+                                           EGG_VIRTUAL_MOD4_MASK |
+                                           EGG_VIRTUAL_MOD5_MASK);
+
+          if (cleaned != 0)
+            {
+              virtual |= cleaned;
+            }
+          else
+            {
+              /* Rather than dropping mod2->mod5 if not bound,
+               * go ahead and use the concrete names
+               */
+              virtual |= modmap->mapping[i];
+            }
+        }
+
+      ++i;
+    }
+
+  *virtual_mods = virtual;
+}
+
+static void
+reload_modmap (GdkKeymap *keymap,
+               EggModmap *modmap)
+{
+  XModifierKeymap *xmodmap;
+  int map_size;
+  int i;
+
+  /* FIXME multihead */
+  xmodmap = XGetModifierMapping (gdk_x11_get_default_xdisplay ());
+
+  memset (modmap->mapping, 0, sizeof (modmap->mapping));
+
+  /* there are 8 modifiers, and the first 3 are shift, shift lock,
+   * and control
+   */
+  map_size = 8 * xmodmap->max_keypermod;
+  i = 3 * xmodmap->max_keypermod;
+  while (i < map_size)
+    {
+      /* get the key code at this point in the map,
+       * see if its keysym is one we're interested in
+       */
+      int keycode = xmodmap->modifiermap[i];
+      GdkKeymapKey *keys;
+      guint *keyvals;
+      int n_entries;
+      int j;
+      EggVirtualModifierType mask;
+
+      keys = NULL;
+      keyvals = NULL;
+      n_entries = 0;
+
+      gdk_keymap_get_entries_for_keycode (keymap,
+                                          keycode,
+                                          &keys, &keyvals, &n_entries);
+
+      mask = 0;
+      j = 0;
+      while (j < n_entries)
+        {
+          if (keyvals[j] == GDK_KEY_Num_Lock)
+            mask |= EGG_VIRTUAL_NUM_LOCK_MASK;
+          else if (keyvals[j] == GDK_KEY_Scroll_Lock)
+            mask |= EGG_VIRTUAL_SCROLL_LOCK_MASK;
+          else if (keyvals[j] == GDK_KEY_Meta_L ||
+                   keyvals[j] == GDK_KEY_Meta_R)
+            mask |= EGG_VIRTUAL_META_MASK;
+          else if (keyvals[j] == GDK_KEY_Hyper_L ||
+                   keyvals[j] == GDK_KEY_Hyper_R)
+            mask |= EGG_VIRTUAL_HYPER_MASK;
+          else if (keyvals[j] == GDK_KEY_Super_L ||
+                   keyvals[j] == GDK_KEY_Super_R)
+            mask |= EGG_VIRTUAL_SUPER_MASK;
+          else if (keyvals[j] == GDK_KEY_Mode_switch)
+            mask |= EGG_VIRTUAL_MODE_SWITCH_MASK;
+
+          ++j;
+        }
+
+      /* Mod1Mask is 1 << 3 for example, i.e. the
+       * fourth modifier, i / keyspermod is the modifier
+       * index
+       */
+      modmap->mapping[i/xmodmap->max_keypermod] |= mask;
+
+      g_free (keyvals);
+      g_free (keys);
+
+      ++i;
+    }
+
+  /* Add in the not-really-virtual fixed entries */
+  modmap->mapping[EGG_MODMAP_ENTRY_SHIFT] |= EGG_VIRTUAL_SHIFT_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_CONTROL] |= EGG_VIRTUAL_CONTROL_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_LOCK] |= EGG_VIRTUAL_LOCK_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD1] |= EGG_VIRTUAL_ALT_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD2] |= EGG_VIRTUAL_MOD2_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD3] |= EGG_VIRTUAL_MOD3_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD4] |= EGG_VIRTUAL_MOD4_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD5] |= EGG_VIRTUAL_MOD5_MASK;
+
+  XFreeModifiermap (xmodmap);
+}
+
+const EggModmap*
+egg_keymap_get_modmap (GdkKeymap *keymap)
+{
+  EggModmap *modmap;
+
+  /* This is all a hack, much simpler when we can just
+   * modify GDK directly.
+   */
+
+  modmap = g_object_get_data (G_OBJECT (keymap),
+                              "egg-modmap");
+
+  if (modmap == NULL)
+    {
+      modmap = g_new0 (EggModmap, 1);
+
+      /* FIXME modify keymap change events with an event filter
+       * and force a reload if we get one
+       */
+
+      reload_modmap (keymap, modmap);
+
+      g_object_set_data_full (G_OBJECT (keymap),
+                              "egg-modmap",
+                              modmap,
+                              g_free);
+    }
+
+  g_assert (modmap != NULL);
+
+  return modmap;
+}
+
+
+
+ + + diff --git a/2020-04-09-123647-2786-cppcheck@4b55003793c9_master/index.html b/2020-04-09-123647-2786-cppcheck@4b55003793c9_master/index.html new file mode 100644 index 0000000..390cedb --- /dev/null +++ b/2020-04-09-123647-2786-cppcheck@4b55003793c9_master/index.html @@ -0,0 +1,104 @@ + + + + + + Cppcheck - HTML report - mate-indicator-applet + + + + + + + +
+ + + + + + + + + +
LineIdCWESeverityMessage
0missingIncludeSysteminformationCppcheck cannot find all the include files (use --check-config for details)
src/applet-main.c
544shadowArgument398styleLocal variable 'entry' shadows outer argument
src/eggaccelerators.c
321duplicateExpression398styleSame expression on both sides of '-='.
+
+ + + diff --git a/2020-04-09-123647-2786-cppcheck@4b55003793c9_master/stats.html b/2020-04-09-123647-2786-cppcheck@4b55003793c9_master/stats.html new file mode 100644 index 0000000..490b8a8 --- /dev/null +++ b/2020-04-09-123647-2786-cppcheck@4b55003793c9_master/stats.html @@ -0,0 +1,90 @@ + + + + + + Cppcheck - HTML report - mate-indicator-applet + + + + + + + +
+

Top 10 files for style severity, total findings: 2
+   1  src/eggaccelerators.c
+   1  src/applet-main.c
+

+ +
+ + + diff --git a/2020-04-09-123647-2786-cppcheck@4b55003793c9_master/style.css b/2020-04-09-123647-2786-cppcheck@4b55003793c9_master/style.css new file mode 100644 index 0000000..c39571c --- /dev/null +++ b/2020-04-09-123647-2786-cppcheck@4b55003793c9_master/style.css @@ -0,0 +1,149 @@ + +body { + font: 13px Arial, Verdana, Sans-Serif; + margin: 0; + width: auto; +} + +h1 { + margin: 10px; +} + +#footer > p { + margin: 4px; +} + +.error { + background-color: #ffb7b7; +} + +.error2 { + background-color: #faa; + border: 1px dotted black; + display: inline-block; + margin-left: 4px; +} + +.inconclusive { + background-color: #B6B6B4; +} + +.inconclusive2 { + background-color: #B6B6B4; + border: 1px dotted black; + display: inline-block; + margin-left: 4px; +} + +div.verbose { + display: inline-block; + vertical-align: top; + cursor: help; +} + +div.verbose div.content { + display: none; + position: absolute; + padding: 10px; + margin: 4px; + max-width: 40%; + white-space: pre-wrap; + border: 1px solid black; + background-color: #FFFFCC; + cursor: auto; +} + +.highlight .hll { + padding: 1px; +} + +#header { + border-bottom: thin solid #aaa; +} + +#menu { + float: left; + margin-top: 5px; + text-align: left; + width: 150px; + /*height: 75%;*/ + position: fixed; + overflow: auto; + z-index: 1; +} + +#menu_index { + float: left; + margin-top: 5px; + padding-left: 5px; + text-align: left; + width: 300px; + /*height: 75%;*/ + position: fixed; + overflow: auto; + z-index: 1; +} + +#menu > a { + display: block; + margin-left: 10px; + font: 12px; + z-index: 1; +} + +#filename { + margin-left: 10px; + font: 12px; + z-index: 1; +} + +.highlighttable { + background-color:white; + z-index: 10; + position: relative; + margin: -10 px; +} + +#content { + background-color: white; + -webkit-box-sizing: content-box; + -moz-box-sizing: content-box; + box-sizing: content-box; + float: left; + margin: 5px; + margin-left: 10px; + padding: 0 10px 10px 10px; + width: 80%; + padding-left: 150px; +} + +#content_index { + background-color: white; + -webkit-box-sizing: content-box; + -moz-box-sizing: content-box; + box-sizing: content-box; + float: left; + margin: 5px; + margin-left: 10px; + padding: 0 10px 10px 10px; + width: 80%; + padding-left: 300px; +} + +.linenos { + border-right: thin solid #aaa; + color: lightgray; + padding-right: 6px; +} + +#footer { + border-top: thin solid #aaa; + clear: both; + font-size: 90%; + margin-top: 5px; +} + +#footer ul { + list-style-type: none; + padding-left: 0; +} diff --git a/2020-04-09-124840-6850-1@e69dd120803f_shadow/index.html b/2020-04-09-124840-6850-1@e69dd120803f_shadow/index.html new file mode 100644 index 0000000..1ae5f35 --- /dev/null +++ b/2020-04-09-124840-6850-1@e69dd120803f_shadow/index.html @@ -0,0 +1,109 @@ + + +rootdir - scan-build results + + + + + + +

rootdir - scan-build results

+ + + + + + + +
User:root@9c2eb7d78bb8
Working Directory:/rootdir
Command Line:make -j 2
Clang Version:clang version 9.0.1 (Fedora 9.0.1-2.fc31) +
Date:Thu Apr 9 12:48:40 2020
+

Bug Summary

+ + + + +
Bug TypeQuantityDisplay?
All Bugs6
Dead code
Unreachable code6
+

Reports

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Bug GroupBug Type ▾FileFunction/MethodLinePath Length
Dead codeUnreachable codeapplet-main.clog_to_file9411View Report
Dead codeUnreachable codeapplet-main.clog_to_file9411View Report
Dead codeUnreachable codeapplet-main.clog_to_file9291View Report
Dead codeUnreachable codeapplet-main.clog_to_file9411View Report
Dead codeUnreachable codeapplet-main.clog_to_file9291View Report
Dead codeUnreachable codeapplet-main.clog_to_file9291View Report
+ + diff --git a/2020-04-09-124840-6850-1@e69dd120803f_shadow/report-21a122.html b/2020-04-09-124840-6850-1@e69dd120803f_shadow/report-21a122.html new file mode 100644 index 0000000..699a7ac --- /dev/null +++ b/2020-04-09-124840-6850-1@e69dd120803f_shadow/report-21a122.html @@ -0,0 +1,1412 @@ + + + +applet-main.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:applet-main.c
Warning:line 929, column 5
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name applet-main.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -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 -mrelocation-model static -mthread-model posix -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -momit-leaf-frame-pointer -resource-dir /usr/lib64/clang/9.0.1 -D HAVE_CONFIG_H -I . -I .. -D G_LOG_DOMAIN="Indicator-Applet-Complete" -D DATADIR="/usr/local/share" -D INDICATOR_DIR="/usr/lib64/indicators3/7/" -D INDICATOR_ICONS_DIR="/usr/share/libindicator/icons/" -D INDICATOR_APPLET_COMPLETE -I ./.. -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/fribidi -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gio-unix-2.0 -I /usr/include/libdrm -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-panel-4.0/libmate-panel-applet -I /usr/include/libindicator3-0.4 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/fribidi -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gio-unix-2.0 -I /usr/include/libdrm -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/9.0.1/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wno-unused-parameter -Wno-sign-compare -fdebug-compilation-dir /rootdir/src -ferror-limit 19 -fmessage-length 0 -fobjc-runtime=gcc -fdiagnostics-show-option -vectorize-loops -vectorize-slp -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 -o /rootdir/html-report/2020-04-09-124840-6850-1 -x c applet-main.c +
+ + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2A small wrapper utility to load indicators and put them as menu items
3into the mate-panel using it's applet interface.
4
5Copyright 2009-2010 Canonical Ltd.
6
7Authors:
8 Ted Gould <ted@canonical.com>
9
10This program is free software: you can redistribute it and/or modify it
11under the terms of the GNU General Public License version 3, as published
12by the Free Software Foundation.
13
14This program is distributed in the hope that it will be useful, but
15WITHOUT ANY WARRANTY; without even the implied warranties of
16MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
17PURPOSE. See the GNU General Public License for more details.
18
19You should have received a copy of the GNU General Public License along
20with this program. If not, see <http://www.gnu.org/licenses/>.
21*/
22
23#include <stdlib.h>
24#include <string.h>
25#include <config.h>
26#include <glib/gi18n.h>
27#include <mate-panel-applet.h>
28#include <gdk/gdkkeysyms.h>
29#include <gtk/gtk.h>
30
31#if HAVE_UBUNTU_INDICATOR1
32
33#define INDICATOR_SERVICE_APPMENU"libappmenu.so" "libappmenu.so"
34#define INDICATOR_SERVICE_ME"libme.so" "libme.so"
35#define INDICATOR_SERVICE_DATETIME"libdatetime.so" "libdatetime.so"
36
37#define INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu" "com.canonical.indicator.appmenu"
38#define INDICATOR_SERVICE_ME_NG"com.canonical.indicator.me" "com.canonical.indicator.me"
39#define INDICATOR_SERVICE_DATETIME_NG"com.canonical.indicator.datetime" "com.canonical.indicator.datetime"
40
41#include <libindicator/indicator-object.h>
42#endif
43
44#if HAVE_AYATANA_INDICATOR
45
46#define INDICATOR_SERVICE_APPMENU"libappmenu.so" "libayatana-appmenu.so"
47#define INDICATOR_SERVICE_ME"libme.so" "libayatana-me.so"
48#define INDICATOR_SERVICE_DATETIME"libdatetime.so" "libayatana-datetime.so"
49
50#define INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu" "org.ayatana.indicator.appmenu"
51#define INDICATOR_SERVICE_ME_NG"com.canonical.indicator.me" "org.ayatana.indicator.me"
52#define INDICATOR_SERVICE_DATETIME_NG"com.canonical.indicator.datetime" "org.ayatana.indicator.datetime"
53
54#include <libayatana-indicator/indicator-object.h>
55#endif
56
57/* For new style indicators */
58
59#if HAVE_UBUNTU_INDICATOR1 && HAVE_UBUNTU_INDICATOR_NG
60
61#include <libido/libido.h>
62#include <libindicator/indicator-ng.h>
63
64#define INDICATOR_SERVICE_DIR "/usr/share/unity/indicators"
65
66#endif
67
68#if HAVE_AYATANA_INDICATOR && HAVE_AYATANA_INDICATOR_NG
69
70#include <libayatana-ido/libayatana-ido.h>
71#include <libayatana-indicator/indicator-ng.h>
72
73#define INDICATOR_SERVICE_DIR "/usr/share/ayatana/indicators"
74
75#endif
76
77#include "tomboykeybinder.h"
78
79static gchar * indicator_order[] = {
80#if HAVE_UBUNTU_INDICATOR1
81 "libapplication.so",
82 "libmessaging.so",
83 "libsoundmenu.so",
84 "libdatetime.so",
85 "libsession.so",
86#endif
87#if HAVE_AYATANA_INDICATOR
88 "libayatana-application.so",
89 "libayatana-messaging.so",
90 "libayatana-soundmenu.so",
91 "libayatana-datetime.so",
92 "libayatana-session.so",
93#endif
94 NULL((void*)0)
95};
96
97static GtkPackDirection packdirection;
98static MatePanelAppletOrient orient;
99static guint size;
100
101#define MENU_DATA_INDICATOR_OBJECT"indicator-object" "indicator-object"
102#define MENU_DATA_INDICATOR_ENTRY"indicator-entry" "indicator-entry"
103
104#define IO_DATA_ORDER_NUMBER"indicator-order-number" "indicator-order-number"
105
106static gboolean applet_fill_cb (MatePanelApplet * applet, const gchar * iid, gpointer data);
107
108static void update_accessible_desc (IndicatorObjectEntry * entry, GtkWidget * menuitem);
109
110/*************
111 * main
112 * ***********/
113
114#ifdef INDICATOR_APPLET
115MATE_PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletFactory",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
116 PANEL_TYPE_APPLET,int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
117 "indicator-applet",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
118 applet_fill_cb, NULL)int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
;
119#endif
120#ifdef INDICATOR_APPLET_COMPLETE1
121MATE_PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletCompleteFactory",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
122 PANEL_TYPE_APPLET,int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
123 "indicator-applet-complete",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
124 applet_fill_cb, NULL)int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
;
125#endif
126#ifdef INDICATOR_APPLET_APPMENU
127MATE_PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletAppmenuFactory",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
128 PANEL_TYPE_APPLET,int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
129 "indicator-applet-appmenu",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
130 applet_fill_cb, NULL)int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
;
131#endif
132
133/*************
134 * log files
135 * ***********/
136#ifdef INDICATOR_APPLET
137#define LOG_FILE_NAME"indicator-applet-complete.log" "indicator-applet.log"
138#endif
139#ifdef INDICATOR_APPLET_COMPLETE1
140#define LOG_FILE_NAME"indicator-applet-complete.log" "indicator-applet-complete.log"
141#endif
142#ifdef INDICATOR_APPLET_APPMENU
143#define LOG_FILE_NAME"indicator-applet-complete.log" "indicator-applet-appmenu.log"
144#endif
145GOutputStream * log_file = NULL((void*)0);
146
147/*****************
148 * Hotkey support
149 * **************/
150#ifdef INDICATOR_APPLET
151gchar * hotkey_keycode = "<Super>M";
152#endif
153#ifdef INDICATOR_APPLET_SESSION
154gchar * hotkey_keycode = "<Super>S";
155#endif
156#ifdef INDICATOR_APPLET_COMPLETE1
157gchar * hotkey_keycode = "<Super>S";
158#endif
159#ifdef INDICATOR_APPLET_APPMENU
160gchar * hotkey_keycode = "<Super>F1";
161#endif
162
163/********************
164 * Environment Names
165 * *******************/
166#ifdef INDICATOR_APPLET
167#define INDICATOR_SPECIFIC_ENV"indicator-applet-complete" "indicator-applet-original"
168#endif
169#ifdef INDICATOR_APPLET_COMPLETE1
170#define INDICATOR_SPECIFIC_ENV"indicator-applet-complete" "indicator-applet-complete"
171#endif
172#ifdef INDICATOR_APPLET_APPMENU
173#define INDICATOR_SPECIFIC_ENV"indicator-applet-complete" "indicator-applet-appmenu"
174#endif
175
176static const gchar * indicator_env[] = {
177 "indicator-applet",
178 INDICATOR_SPECIFIC_ENV"indicator-applet-complete",
179 NULL((void*)0)
180};
181
182/*************
183 * init function
184 * ***********/
185
186static gint
187name2order (const gchar * name) {
188 int i;
189
190 for (i = 0; indicator_order[i] != NULL((void*)0); i++) {
191 if (g_strcmp0(name, indicator_order[i]) == 0) {
192 return i;
193 }
194 }
195
196 return -1;
197}
198
199typedef struct _incoming_position_t incoming_position_t;
200struct _incoming_position_t {
201 gint objposition;
202 gint entryposition;
203 gint menupos;
204 gboolean found;
205};
206
207/* This function helps by determining where in the menu list
208 this new entry should be placed. It compares the objects
209 that they're on, and then the individual entries. Each
210 is progressively more expensive. */
211static void
212place_in_menu (GtkWidget * widget, gpointer user_data)
213{
214 incoming_position_t * position = (incoming_position_t *)user_data;
215 if (position->found) {
216 /* We've already been placed, just finish the foreach */
217 return;
218 }
219
220 IndicatorObject * io = INDICATOR_OBJECT(g_object_get_data(G_OBJECT(widget), MENU_DATA_INDICATOR_OBJECT))((((IndicatorObject*) g_type_check_instance_cast ((GTypeInstance
*) ((g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((widget)), (((GType) ((20) << (2)))
))))), "indicator-object"))), ((indicator_object_get_type ())
)))))
;
221 g_assert(io != NULL)do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_
; if (io != ((void*)0)) _g_boolean_var_ = 1; else _g_boolean_var_
= 0; _g_boolean_var_; }), 1)) ; else g_assertion_message_expr
("Indicator-Applet-Complete", "applet-main.c", 221, ((const char
*) (__func__)), "io != NULL"); } while (0)
;
222
223 gint objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER))((gint) (glong) (g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
), "indicator-order-number")))
;
224 /* We've already passed it, well, then this is where
225 we should be be. Stop! */
226 if (objposition > position->objposition) {
227 position->found = TRUE(!(0));
228 return;
229 }
230
231 /* The objects don't match yet, keep looking */
232 if (objposition < position->objposition) {
233 position->menupos++;
234 return;
235 }
236
237 /* The objects are the same, let's start looking at entries. */
238 IndicatorObjectEntry * entry = (IndicatorObjectEntry *)g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
239 gint entryposition = indicator_object_get_location(io, entry);
240
241 if (entryposition > position->entryposition) {
242 position->found = TRUE(!(0));
243 return;
244 }
245
246 if (entryposition < position->entryposition) {
247 position->menupos++;
248 return;
249 }
250
251 /* We've got the same object and the same entry. Well,
252 let's just put it right here then. */
253 position->found = TRUE(!(0));
254 return;
255}
256
257static void
258something_shown (GtkWidget * widget, gpointer user_data)
259{
260 GtkWidget * menuitem = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
261 gtk_widget_show(menuitem);
262}
263
264static void
265something_hidden (GtkWidget * widget, gpointer user_data)
266{
267 GtkWidget * menuitem = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
268 gtk_widget_hide(menuitem);
269}
270
271static void
272sensitive_cb (GObject * obj, GParamSpec * pspec, gpointer user_data)
273{
274 g_return_if_fail(GTK_IS_WIDGET(obj))do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((obj)); GType __t = ((gtk_widget_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet-Complete"
, ((const char*) (__func__)), "GTK_IS_WIDGET(obj)"); return; }
} while (0)
;
275 g_return_if_fail(GTK_IS_WIDGET(user_data))do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((gtk_widget_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet-Complete"
, ((const char*) (__func__)), "GTK_IS_WIDGET(user_data)"); return
; } } while (0)
;
276
277 gtk_widget_set_sensitive(GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
, gtk_widget_get_sensitive(GTK_WIDGET(obj)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(obj)), ((gtk_widget_get_type ()))))))
));
278 return;
279}
280
281static void
282entry_activated (GtkWidget * widget, gpointer user_data)
283{
284 g_return_if_fail(GTK_IS_WIDGET(widget))do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((gtk_widget_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet-Complete"
, ((const char*) (__func__)), "GTK_IS_WIDGET(widget)"); return
; } } while (0)
;
285 gpointer pio = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, "indicator");
286 g_return_if_fail(INDICATOR_IS_OBJECT(pio))do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((pio)); GType __t = ((indicator_object_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet-Complete"
, ((const char*) (__func__)), "INDICATOR_IS_OBJECT(pio)"); return
; } } while (0)
;
287 IndicatorObject * io = INDICATOR_OBJECT(pio)((((IndicatorObject*) g_type_check_instance_cast ((GTypeInstance
*) ((pio)), ((indicator_object_get_type ()))))))
;
288
289 return indicator_object_entry_activate(io, (IndicatorObjectEntry *)user_data, gtk_get_current_event_time());
290}
291
292static gboolean
293entry_scrolled (GtkWidget *menuitem, GdkEventScroll *event, gpointer data)
294{
295 IndicatorObject *io = g_object_get_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_OBJECT"indicator-object");
296 IndicatorObjectEntry *entry = g_object_get_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
297
298 g_return_val_if_fail(INDICATOR_IS_OBJECT(io), FALSE)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((io)); GType __t = ((indicator_object_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet-Complete"
, ((const char*) (__func__)), "INDICATOR_IS_OBJECT(io)"); return
((0)); } } while (0)
;
299
300 g_signal_emit_by_name (io, "scroll", 1, event->direction);
301 g_signal_emit_by_name (io, "scroll-entry", entry, 1, event->direction);
302 g_signal_emit_by_name (io, INDICATOR_OBJECT_SIGNAL_ENTRY_SCROLLED"entry-scrolled", entry, 1, event->direction);
303
304 return FALSE(0);
305}
306
307static void
308accessible_desc_update_cb (GtkWidget * widget, gpointer userdata)
309{
310 gpointer data = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
311
312 if (data != userdata) {
313 return;
314 }
315
316 IndicatorObjectEntry * entry = (IndicatorObjectEntry *)data;
317 update_accessible_desc(entry, widget);
318}
319
320static void
321accessible_desc_update (IndicatorObject * io, IndicatorObjectEntry * entry, GtkWidget * menubar)
322{
323 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, accessible_desc_update_cb, entry);
324 return;
325}
326
327#define PANEL_PADDING8 8
328static gboolean
329entry_resized (GtkWidget *applet, guint newsize, gpointer data)
330{
331 IndicatorObject *io = (IndicatorObject *)data;
332
333 size = newsize;
334
335 /* Work on the entries */
336 GList * entries = indicator_object_get_entries(io);
337 GList * entry = NULL((void*)0);
338
339 for (entry = entries; entry != NULL((void*)0); entry = g_list_next(entry)((entry) ? (((GList *)(entry))->next) : ((void*)0))) {
340 IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)entry->data;
341 if (entrydata->image != NULL((void*)0)) {
342 /* Resize to fit panel */
343 gtk_image_set_pixel_size (entrydata->image, size - PANEL_PADDING8);
344 }
345 }
346
347 return FALSE(0);
348}
349
350static void
351entry_added (IndicatorObject * io, IndicatorObjectEntry * entry, GtkWidget * menubar)
352{
353 g_debug("Signal: Entry Added");
354 gboolean something_visible = FALSE(0);
355 gboolean something_sensitive = FALSE(0);
356
357 GtkWidget * menuitem = gtk_menu_item_new();
358 GtkWidget * box = (packdirection == GTK_PACK_DIRECTION_LTR) ?
359 gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3) : gtk_box_new(GTK_ORIENTATION_VERTICAL, 3);
360
361 /* Allows indicators to receive mouse scroll event */
362 gtk_widget_add_events(GTK_WIDGET(menuitem)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(menuitem)), ((gtk_widget_get_type ()))))))
, GDK_SCROLL_MASK);
363
364 g_object_set_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "indicator", io);
365 g_object_set_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "box", box);
366
367 g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(entry_activated), entry)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((menuitem)), (((GType) ((20) << (2)
)))))))), ("activate"), (((GCallback) (entry_activated))), (entry
), ((void*)0), (GConnectFlags) 0)
;
368 g_signal_connect(G_OBJECT(menuitem), "scroll-event", G_CALLBACK(entry_scrolled), entry)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((menuitem)), (((GType) ((20) << (2)
)))))))), ("scroll-event"), (((GCallback) (entry_scrolled))),
(entry), ((void*)0), (GConnectFlags) 0)
;
369
370 if (entry->image != NULL((void*)0)) {
371 /* Resize to fit panel */
372 gtk_image_set_pixel_size (entry->image, size - PANEL_PADDING8);
373 gtk_box_pack_start(GTK_BOX(box)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((box
)), ((gtk_box_get_type ()))))))
, GTK_WIDGET(entry->image)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->image)), ((gtk_widget_get_type ()))))))
, FALSE(0), FALSE(0), 1);
374 if (gtk_widget_get_visible(GTK_WIDGET(entry->image)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->image)), ((gtk_widget_get_type ()))))))
)) {
375 something_visible = TRUE(!(0));
376 }
377
378 if (gtk_widget_get_sensitive(GTK_WIDGET(entry->image)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->image)), ((gtk_widget_get_type ()))))))
)) {
379 something_sensitive = TRUE(!(0));
380 }
381
382 g_signal_connect(G_OBJECT(entry->image), "show", G_CALLBACK(something_shown), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), ("show"), (((GCallback) (something_shown))), (menuitem
), ((void*)0), (GConnectFlags) 0)
;
383 g_signal_connect(G_OBJECT(entry->image), "hide", G_CALLBACK(something_hidden), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), ("hide"), (((GCallback) (something_hidden))), (
menuitem), ((void*)0), (GConnectFlags) 0)
;
384
385 g_signal_connect(G_OBJECT(entry->image), "notify::sensitive", G_CALLBACK(sensitive_cb), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), ("notify::sensitive"), (((GCallback) (sensitive_cb
))), (menuitem), ((void*)0), (GConnectFlags) 0)
;
386 }
387 if (entry->label != NULL((void*)0)) {
388 switch(packdirection) {
389 case GTK_PACK_DIRECTION_LTR:
390 gtk_label_set_angle(GTK_LABEL(entry->label)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_label_get_type ()))))))
, 0.0);
391 break;
392 case GTK_PACK_DIRECTION_TTB:
393 gtk_label_set_angle(GTK_LABEL(entry->label)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_label_get_type ()))))))
,
394 (orient == MATE_PANEL_APPLET_ORIENT_LEFT) ?
395 270.0 : 90.0);
396 break;
397 default:
398 break;
399 }
400 gtk_box_pack_start(GTK_BOX(box)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((box
)), ((gtk_box_get_type ()))))))
, GTK_WIDGET(entry->label)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_widget_get_type ()))))))
, FALSE(0), FALSE(0), 1);
401
402 if (gtk_widget_get_visible(GTK_WIDGET(entry->label)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_widget_get_type ()))))))
)) {
403 something_visible = TRUE(!(0));
404 }
405
406 if (gtk_widget_get_sensitive(GTK_WIDGET(entry->label)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_widget_get_type ()))))))
)) {
407 something_sensitive = TRUE(!(0));
408 }
409
410 g_signal_connect(G_OBJECT(entry->label), "show", G_CALLBACK(something_shown), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), ("show"), (((GCallback) (something_shown))), (menuitem
), ((void*)0), (GConnectFlags) 0)
;
411 g_signal_connect(G_OBJECT(entry->label), "hide", G_CALLBACK(something_hidden), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), ("hide"), (((GCallback) (something_hidden))), (
menuitem), ((void*)0), (GConnectFlags) 0)
;
412
413 g_signal_connect(G_OBJECT(entry->label), "notify::sensitive", G_CALLBACK(sensitive_cb), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), ("notify::sensitive"), (((GCallback) (sensitive_cb
))), (menuitem), ((void*)0), (GConnectFlags) 0)
;
414 }
415 gtk_container_add(GTK_CONTAINER(menuitem)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menuitem)), ((gtk_container_get_type ()))))))
, box);
416 gtk_widget_show(box);
417
418 if (entry->menu != NULL((void*)0)) {
419 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem)((((GtkMenuItem*) g_type_check_instance_cast ((GTypeInstance*
) ((menuitem)), ((gtk_menu_item_get_type ()))))))
, GTK_WIDGET(entry->menu)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->menu)), ((gtk_widget_get_type ()))))))
);
420 }
421
422 incoming_position_t position;
423 position.objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER))((gint) (glong) (g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
), "indicator-order-number")))
;
424 position.entryposition = indicator_object_get_location(io, entry);
425 position.menupos = 0;
426 position.found = FALSE(0);
427
428 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, place_in_menu, &position);
429
430 gtk_menu_shell_insert(GTK_MENU_SHELL(menubar)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_menu_shell_get_type ()))))))
, menuitem, position.menupos);
431
432 if (something_visible) {
433 if (entry->accessible_desc != NULL((void*)0)) {
434 update_accessible_desc(entry, menuitem);
435 }
436 gtk_widget_show(menuitem);
437 }
438 gtk_widget_set_sensitive(menuitem, something_sensitive);
439
440 g_object_set_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry", entry);
441 g_object_set_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_OBJECT"indicator-object", io);
442
443 return;
444}
445
446static void
447entry_removed_cb (GtkWidget * widget, gpointer userdata)
448{
449 gpointer data = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
450
451 if (data != userdata) {
452 return;
453 }
454
455 IndicatorObjectEntry * entry = (IndicatorObjectEntry *)data;
456 if (entry->label != NULL((void*)0)) {
457 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(something_shown), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_shown))), (widget
))
;
458 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(something_hidden), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_hidden))), (widget
))
;
459 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(sensitive_cb), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (sensitive_cb))), (widget)
)
;
460 }
461 if (entry->image != NULL((void*)0)) {
462 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(something_shown), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_shown))), (widget
))
;
463 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(something_hidden), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_hidden))), (widget
))
;
464 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(sensitive_cb), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (sensitive_cb))), (widget)
)
;
465 }
466
467 gtk_widget_destroy(widget);
468 return;
469}
470
471static void
472entry_removed (IndicatorObject * io G_GNUC_UNUSED__attribute__((__unused__)), IndicatorObjectEntry * entry,
473 gpointer user_data)
474{
475 g_debug("Signal: Entry Removed");
476
477 gtk_container_foreach(GTK_CONTAINER(user_data)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((gtk_container_get_type ()))))))
, entry_removed_cb, entry);
478
479 return;
480}
481
482static void
483entry_moved_find_cb (GtkWidget * widget, gpointer userdata)
484{
485 gpointer * array = (gpointer *)userdata;
486 if (array[1] != NULL((void*)0)) {
487 return;
488 }
489
490 gpointer data = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
491
492 if (data != array[0]) {
493 return;
494 }
495
496 array[1] = widget;
497 return;
498}
499
500/* Gets called when an entry for an object was moved. */
501static void
502entry_moved (IndicatorObject * io, IndicatorObjectEntry * entry,
503 gint old G_GNUC_UNUSED__attribute__((__unused__)), gint new G_GNUC_UNUSED__attribute__((__unused__)), gpointer user_data)
504{
505 GtkWidget * menubar = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
506
507 gpointer array[2];
508 array[0] = entry;
509 array[1] = NULL((void*)0);
510
511 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, entry_moved_find_cb, array);
512 if (array[1] == NULL((void*)0)) {
513 g_warning("Moving an entry that isn't in our menus.");
514 return;
515 }
516
517 GtkWidget * mi = GTK_WIDGET(array[1])((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(array[1])), ((gtk_widget_get_type ()))))))
;
518 g_object_ref(G_OBJECT(mi)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
mi)), (((GType) ((20) << (2))))))))
);
519 gtk_container_remove(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, mi);
520
521 incoming_position_t position;
522 position.objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER))((gint) (glong) (g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
), "indicator-order-number")))
;
523 position.entryposition = indicator_object_get_location(io, entry);
524 position.menupos = 0;
525 position.found = FALSE(0);
526
527 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, place_in_menu, &position);
528
529 gtk_menu_shell_insert(GTK_MENU_SHELL(menubar)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_menu_shell_get_type ()))))))
, mi, position.menupos);
530 g_object_unref(G_OBJECT(mi)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
mi)), (((GType) ((20) << (2))))))))
);
531
532 return;
533}
534
535static void
536menu_show (IndicatorObject * io, IndicatorObjectEntry * entry,
537 guint32 timestamp, gpointer user_data)
538{
539 GtkWidget * menubar = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
540
541 if (entry == NULL((void*)0)) {
542 /* Close any open menus instead of opening one */
543 GList * entries = indicator_object_get_entries(io);
544 GList * iterator = NULL((void*)0);
545 for (iterator = entries; iterator != NULL((void*)0); iterator = g_list_next(iterator)((iterator) ? (((GList *)(iterator))->next) : ((void*)0))) {
546 IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)iterator->data;
547 gtk_menu_popdown(entrydata->menu);
548 }
549 g_list_free(entries);
550
551 /* And tell the menubar to exit activation mode too */
552 gtk_menu_shell_cancel(GTK_MENU_SHELL(menubar)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_menu_shell_get_type ()))))))
);
553 return;
554 }
555
556 // TODO: do something sensible here
557}
558
559static void
560update_accessible_desc(IndicatorObjectEntry * entry, GtkWidget * menuitem)
561{
562 /* FIXME: We need to deal with the use case where the contents of the
563 label overrides what is found in the atk object's name, or at least
564 orca speaks the label instead of the atk object name.
565 */
566 AtkObject * menuitem_obj = gtk_widget_get_accessible(menuitem);
567 if (menuitem_obj == NULL((void*)0)) {
568 /* Should there be an error printed here? */
569 return;
570 }
571
572 if (entry->accessible_desc != NULL((void*)0)) {
573 atk_object_set_name(menuitem_obj, entry->accessible_desc);
574 } else {
575 atk_object_set_name(menuitem_obj, "");
576 }
577 return;
578}
579
580static void
581load_indicator (MatePanelApplet *applet, GtkWidget * menubar, IndicatorObject *io, const gchar *name)
582{
583 /* Set the environment it's in */
584 indicator_object_set_environment(io, (const GStrv)indicator_env);
585
586 /* Attach the 'name' to the object */
587#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
588 int pos = 5000 - indicator_object_get_position(io);
589 if (pos > 5000) {
590 pos = name2order(name);
591 }
592#else
593 int pos = name2order(name);
594#endif
595
596 g_object_set_data(G_OBJECT(io)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
io)), (((GType) ((20) << (2))))))))
, IO_DATA_ORDER_NUMBER"indicator-order-number", GINT_TO_POINTER(pos)((gpointer) (glong) (pos)));
597
598 /* Connect to its signals */
599 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED, G_CALLBACK(entry_added), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("entry-added"), (((GCallback) (entry_added))), (menubar)
, ((void*)0), (GConnectFlags) 0)
;
600 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED, G_CALLBACK(entry_removed), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("entry-removed"), (((GCallback) (entry_removed))), (menubar
), ((void*)0), (GConnectFlags) 0)
;
601 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_MOVED, G_CALLBACK(entry_moved), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("entry-moved"), (((GCallback) (entry_moved))), (menubar)
, ((void*)0), (GConnectFlags) 0)
;
602 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_MENU_SHOW, G_CALLBACK(menu_show), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("menu-show"), (((GCallback) (menu_show))), (menubar), ((
void*)0), (GConnectFlags) 0)
;
603 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ACCESSIBLE_DESC_UPDATE, G_CALLBACK(accessible_desc_update), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("accessible-desc-update"), (((GCallback) (accessible_desc_update
))), (menubar), ((void*)0), (GConnectFlags) 0)
;
604
605 /* Track panel resize */
606 g_signal_connect_object(G_OBJECT(applet)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
applet)), (((GType) ((20) << (2))))))))
, "change-size", G_CALLBACK(entry_resized)((GCallback) (entry_resized)), G_OBJECT(io)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
io)), (((GType) ((20) << (2))))))))
, 0);
607
608 /* Work on the entries */
609 GList * entries = indicator_object_get_entries(io);
610 GList * entry = NULL((void*)0);
611
612 for (entry = entries; entry != NULL((void*)0); entry = g_list_next(entry)((entry) ? (((GList *)(entry))->next) : ((void*)0))) {
613 IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)entry->data;
614 entry_added(io, entrydata, menubar);
615 }
616
617 g_list_free(entries);
618}
619
620static gboolean
621load_module (const gchar * name, MatePanelApplet *applet, GtkWidget * menubar)
622{
623 g_debug("Looking at Module: %s", name);
624 g_return_val_if_fail(name != NULL, FALSE)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if (name != ((void*)0)) _g_boolean_var_ = 1; else _g_boolean_var_
= 0; _g_boolean_var_; }), 1))) { } else { g_return_if_fail_warning
("Indicator-Applet-Complete", ((const char*) (__func__)), "name != NULL"
); return ((0)); } } while (0)
;
625
626 if (!g_str_has_suffix(name, G_MODULE_SUFFIX"so")) {
627 return FALSE(0);
628 }
629
630 g_debug("Loading Module: %s", name);
631
632 /* Build the object for the module */
633 gchar * fullpath = g_build_filename(INDICATOR_DIR"/usr/lib64/indicators3/7/", name, NULL((void*)0));
634 IndicatorObject * io = indicator_object_new_from_file(fullpath);
635 g_free(fullpath);
636
637 load_indicator(applet, menubar, io, name);
638
639 return TRUE(!(0));
640}
641
642static void
643load_modules (MatePanelApplet *applet, GtkWidget *menubar, gint *indicators_loaded)
644{
645 if (g_file_test(INDICATOR_DIR"/usr/lib64/indicators3/7/", (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))) {
646 GDir * dir = g_dir_open(INDICATOR_DIR"/usr/lib64/indicators3/7/", 0, NULL((void*)0));
647
648 const gchar * name;
649 gint count = 0;
650 while ((name = g_dir_read_name(dir)) != NULL((void*)0)) {
651#ifdef INDICATOR_APPLET_APPMENU
652 if (g_strcmp0(name, INDICATOR_SERVICE_APPMENU"libappmenu.so")) {
653 continue;
654 }
655#else
656 if (!g_strcmp0(name, INDICATOR_SERVICE_APPMENU"libappmenu.so")) {
657 continue;
658 }
659#endif
660#ifdef INDICATOR_APPLET
661 if (!g_strcmp0(name, INDICATOR_SERVICE_ME"libme.so")) {
662 continue;
663 }
664 if (!g_strcmp0(name, INDICATOR_SERVICE_DATETIME"libdatetime.so")) {
665 continue;
666 }
667#endif
668 if (load_module(name, applet, menubar)) {
669 count++;
670 }
671 }
672
673 *indicators_loaded += count;
674
675 g_dir_close (dir);
676 }
677}
678
679#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
680
681static void
682load_indicators_from_indicator_files (MatePanelApplet *applet, GtkWidget *menubar, gint *indicators_loaded)
683{
684 GDir *dir;
685 const gchar *name;
686 GError *error = NULL((void*)0);
687
688 dir = g_dir_open (INDICATOR_SERVICE_DIR, 0, &error);
689
690 if (!dir) {
691 g_warning ("unable to open indicator service file directory: %s", error->message);
692 g_error_free (error);
693
694 return;
695 }
696
697 gint count = 0;
698 while ((name = g_dir_read_name (dir))) {
699 gchar *filename;
700 IndicatorNg *indicator;
701
702 filename = g_build_filename (INDICATOR_SERVICE_DIR, name, NULL((void*)0));
703 indicator = indicator_ng_new_for_profile (filename, "desktop", &error);
704 g_free (filename);
705
706#ifdef INDICATOR_APPLET_APPMENU
707 if (g_strcmp0(name, INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu")) {
708 continue;
709 }
710#else
711 if (!g_strcmp0(name, INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu")) {
712 continue;
713 }
714#endif
715#ifdef INDICATOR_APPLET
716 if (!g_strcmp0(name, INDICATOR_SERVICE_ME_NG"com.canonical.indicator.me")) {
717 continue;
718 }
719 if (!g_strcmp0(name, INDICATOR_SERVICE_DATETIME_NG"com.canonical.indicator.datetime")) {
720 continue;
721 }
722#endif
723
724 if (indicator) {
725 load_indicator(applet, menubar, INDICATOR_OBJECT (indicator)((((IndicatorObject*) g_type_check_instance_cast ((GTypeInstance
*) ((indicator)), ((indicator_object_get_type ()))))))
, name);
726 count++;
727 }else{
728 g_warning ("unable to load '%s': %s", name, error->message);
729 g_clear_error (&error);
730 }
731 }
732
733 *indicators_loaded += count;
734
735 g_dir_close (dir);
736}
737#endif /* HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG */
738
739static void
740hotkey_filter (char * keystring G_GNUC_UNUSED__attribute__((__unused__)), gpointer data)
741{
742 g_return_if_fail(GTK_IS_MENU_SHELL(data))do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((data)); GType __t = ((gtk_menu_shell_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet-Complete"
, ((const char*) (__func__)), "GTK_IS_MENU_SHELL(data)"); return
; } } while (0)
;
743
744 /* Oh, wow, it's us! */
745 GList * children = gtk_container_get_children(GTK_CONTAINER(data)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((gtk_container_get_type ()))))))
);
746 if (children == NULL((void*)0)) {
747 g_debug("Menubar has no children");
748 return;
749 }
750
751 gtk_menu_shell_select_item(GTK_MENU_SHELL(data)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((gtk_menu_shell_get_type ()))))))
, GTK_WIDGET(g_list_last(children)->data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(g_list_last(children)->data)), ((gtk_widget_get_type ()))
))))
);
752 g_list_free(children);
753 return;
754}
755
756static gboolean
757menubar_press (GtkWidget * widget,
758 GdkEventButton *event,
759 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
760{
761 if (event->button != 1) {
762 g_signal_stop_emission_by_name(widget, "button-press-event");
763 }
764
765 return FALSE(0);
766}
767
768static gboolean
769menubar_on_draw (GtkWidget * widget,
770 cairo_t * cr,
771 GtkWidget * menubar)
772{
773 /* FIXME: either port to gtk_render_focus or remove this function */
774 if (gtk_widget_has_focus(menubar))
775 gtk_paint_focus(gtk_widget_get_style(widget),
776 cr,
777 gtk_widget_get_state(menubar),
778 widget, "menubar-applet", 0, 0, -1, -1);
779
780 return FALSE(0);
781}
782
783static void
784about_cb (GtkAction *action G_GNUC_UNUSED__attribute__((__unused__)),
785 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
786{
787 static const gchar *authors[] = {
788 "Ted Gould <ted@canonical.com>",
789 NULL((void*)0)
790 };
791
792 static gchar *license[] = {
793 N_("This program is free software: you can redistribute it and/or modify it ""This program is free software: you can redistribute it and/or modify it "
"under the terms of the GNU General Public License version 3, as published "
"by the Free Software Foundation."
794 "under the terms of the GNU General Public License version 3, as published ""This program is free software: you can redistribute it and/or modify it "
"under the terms of the GNU General Public License version 3, as published "
"by the Free Software Foundation."
795 "by the Free Software Foundation.")"This program is free software: you can redistribute it and/or modify it "
"under the terms of the GNU General Public License version 3, as published "
"by the Free Software Foundation."
,
796 N_("This program is distributed in the hope that it will be useful, but ""This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
797 "WITHOUT ANY WARRANTY; without even the implied warranties of ""This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
798 "MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR ""This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
799 "PURPOSE. See the GNU General Public License for more details.")"This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
,
800 N_("You should have received a copy of the GNU General Public License along ""You should have received a copy of the GNU General Public License along "
"with this program. If not, see <http://www.gnu.org/licenses/>."
801 "with this program. If not, see <http://www.gnu.org/licenses/>.")"You should have received a copy of the GNU General Public License along "
"with this program. If not, see <http://www.gnu.org/licenses/>."
,
802 NULL((void*)0)
803 };
804 gchar *license_i18n;
805
806 license_i18n = g_strconcat (_(license[0])dcgettext (((void*)0), license[0], 5), "\n\n", _(license[1])dcgettext (((void*)0), license[1], 5), "\n\n", _(license[2])dcgettext (((void*)0), license[2], 5), NULL((void*)0));
807
808 gtk_show_about_dialog(NULL((void*)0),
809 "version", VERSION"1.24.0",
810 "copyright", _("Copyright \xc2\xa9 2009-2010 Canonical, Ltd.\n"dcgettext (((void*)0), "Copyright \xc2\xa9 2009-2010 Canonical, Ltd.\n"
"Copyright \xc2\xa9 2011-2020 MATE developers", 5)
811 "Copyright \xc2\xa9 2011-2020 MATE developers")dcgettext (((void*)0), "Copyright \xc2\xa9 2009-2010 Canonical, Ltd.\n"
"Copyright \xc2\xa9 2011-2020 MATE developers", 5)
,
812#ifdef INDICATOR_APPLET_APPMENU
813 "comments", _("An applet to hold your application menus.")dcgettext (((void*)0), "An applet to hold your application menus."
, 5)
,
814#endif
815 "comments", _("An applet to hold all of the system indicators.")dcgettext (((void*)0), "An applet to hold all of the system indicators."
, 5)
,
816 "authors", authors,
817 "license", license_i18n,
818 "wrap-license", TRUE(!(0)),
819 "translator-credits", _("translator-credits")dcgettext (((void*)0), "translator-credits", 5),
820 "logo-icon-name", "mate-indicator-applet",
821 "icon-name", "mate-indicator-applet",
822 "website", "https://mate-desktop.org",
823 "website-label", _("MATE Website")dcgettext (((void*)0), "MATE Website", 5),
824 NULL((void*)0)
825 );
826
827 g_free (license_i18n);
828
829 return;
830}
831
832static gboolean
833swap_orient_cb (GtkWidget *item, gpointer data)
834{
835 GtkWidget *from = (GtkWidget *) data;
836 GtkWidget *to = (GtkWidget *) g_object_get_data(G_OBJECT(from)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
from)), (((GType) ((20) << (2))))))))
, "to");
837 g_object_ref(G_OBJECT(item)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
item)), (((GType) ((20) << (2))))))))
);
838 gtk_container_remove(GTK_CONTAINER(from)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((from)), ((gtk_container_get_type ()))))))
, item);
839 if (GTK_IS_LABEL(item)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(item)); GType __t = ((gtk_label_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; }))))
) {
840 switch(packdirection) {
841 case GTK_PACK_DIRECTION_LTR:
842 gtk_label_set_angle(GTK_LABEL(item)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(item)), ((gtk_label_get_type ()))))))
, 0.0);
843 break;
844 case GTK_PACK_DIRECTION_TTB:
845 gtk_label_set_angle(GTK_LABEL(item)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(item)), ((gtk_label_get_type ()))))))
,
846 (orient == MATE_PANEL_APPLET_ORIENT_LEFT) ?
847 270.0 : 90.0);
848 break;
849 default:
850 break;
851 }
852 }
853 gtk_box_pack_start(GTK_BOX(to)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((to
)), ((gtk_box_get_type ()))))))
, item, FALSE(0), FALSE(0), 0);
854 return TRUE(!(0));
855}
856
857static gboolean
858reorient_box_cb (GtkWidget *menuitem, gpointer data)
859{
860 GtkWidget *from = g_object_get_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "box");
861 GtkWidget *to = (packdirection == GTK_PACK_DIRECTION_LTR) ?
862 gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0) : gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
863 g_object_set_data(G_OBJECT(from)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
from)), (((GType) ((20) << (2))))))))
, "to", to);
864 gtk_container_foreach(GTK_CONTAINER(from)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((from)), ((gtk_container_get_type ()))))))
, (GtkCallback)swap_orient_cb,
865 from);
866 gtk_container_remove(GTK_CONTAINER(menuitem)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menuitem)), ((gtk_container_get_type ()))))))
, from);
867 gtk_container_add(GTK_CONTAINER(menuitem)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menuitem)), ((gtk_container_get_type ()))))))
, to);
868 g_object_set_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "box", to);
869 gtk_widget_show_all(menuitem);
870 return TRUE(!(0));
871}
872
873static gboolean
874matepanelapplet_reorient_cb (GtkWidget *applet, MatePanelAppletOrient neworient,
875 gpointer data)
876{
877 GtkWidget *menubar = (GtkWidget *)data;
878 if ((((neworient == MATE_PANEL_APPLET_ORIENT_UP) ||
879 (neworient == MATE_PANEL_APPLET_ORIENT_DOWN)) &&
880 ((orient == MATE_PANEL_APPLET_ORIENT_LEFT) ||
881 (orient == MATE_PANEL_APPLET_ORIENT_RIGHT))) ||
882 (((neworient == MATE_PANEL_APPLET_ORIENT_LEFT) ||
883 (neworient == MATE_PANEL_APPLET_ORIENT_RIGHT)) &&
884 ((orient == MATE_PANEL_APPLET_ORIENT_UP) ||
885 (orient == MATE_PANEL_APPLET_ORIENT_DOWN)))) {
886 packdirection = (packdirection == GTK_PACK_DIRECTION_LTR) ?
887 GTK_PACK_DIRECTION_TTB : GTK_PACK_DIRECTION_LTR;
888 gtk_menu_bar_set_pack_direction(GTK_MENU_BAR(menubar)((((GtkMenuBar*) g_type_check_instance_cast ((GTypeInstance*)
((menubar)), ((gtk_menu_bar_get_type ()))))))
,
889 packdirection);
890 orient = neworient;
891 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
,
892 (GtkCallback)reorient_box_cb, NULL((void*)0));
893 }
894 orient = neworient;
895 return FALSE(0);
896}
897
898#ifdef N_
899#undef N_
900#endif
901#define N_(x)x x
902
903static void
904log_to_file_cb (GObject * source_obj G_GNUC_UNUSED__attribute__((__unused__)),
905 GAsyncResult * result G_GNUC_UNUSED__attribute__((__unused__)), gpointer user_data)
906{
907 g_free(user_data);
908 return;
909}
910
911static void
912log_to_file (const gchar * domain G_GNUC_UNUSED__attribute__((__unused__)),
913 GLogLevelFlags level G_GNUC_UNUSED__attribute__((__unused__)),
914 const gchar * message,
915 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
916{
917 if (log_file == NULL((void*)0)) {
918 GError * error = NULL((void*)0);
919 gchar * filename = g_build_filename(g_get_user_cache_dir(), LOG_FILE_NAME"indicator-applet-complete.log", NULL((void*)0));
920 GFile * file = g_file_new_for_path(filename);
921 g_free(filename);
922
923 if (!g_file_test(g_get_user_cache_dir(), G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) {
924 GFile * cachedir = g_file_new_for_path(g_get_user_cache_dir());
925 g_file_make_directory_with_parents(cachedir, NULL((void*)0), &error);
926
927 if (error != NULL((void*)0)) {
928 g_error("Unable to make directory '%s' for log file: %s", g_get_user_cache_dir(), error->message);
929 return;
This statement is never executed
930 }
931 }
932
933 g_file_delete(file, NULL((void*)0), NULL((void*)0));
934
935 GFileIOStream * io = g_file_create_readwrite(file,
936 G_FILE_CREATE_REPLACE_DESTINATION, /* flags */
937 NULL((void*)0), /* cancelable */
938 &error); /* error */
939 if (error != NULL((void*)0)) {
940 g_error("Unable to replace file: %s", error->message);
941 return;
942 }
943
944 log_file = g_io_stream_get_output_stream(G_IO_STREAM(io)((((GIOStream*) g_type_check_instance_cast ((GTypeInstance*) (
(io)), ((g_io_stream_get_type ()))))))
);
945 }
946
947 gchar * outputstring = g_strdup_printf("%s\n", message);
948 g_output_stream_write_async(log_file,
949 outputstring, /* data */
950 strlen(outputstring), /* length */
951 G_PRIORITY_LOW300, /* priority */
952 NULL((void*)0), /* cancelable */
953 log_to_file_cb, /* callback */
954 outputstring); /* data */
955
956 return;
957}
958
959static gboolean
960applet_fill_cb (MatePanelApplet * applet, const gchar * iid G_GNUC_UNUSED__attribute__((__unused__)),
961 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
962{
963#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
964 ido_init();
965#endif
966
967 static const GtkActionEntry menu_actions[] = {
968 {"About", GTK_STOCK_ABOUT((GtkStock)"gtk-about"), N_("_About")"_About", NULL((void*)0), NULL((void*)0), G_CALLBACK(about_cb)((GCallback) (about_cb))}
969 };
970 static const gchar *menu_xml = "<menuitem name=\"About\" action=\"About\"/>";
971
972 static gboolean first_time = FALSE(0);
973 GtkWidget *menubar;
974 gint indicators_loaded = 0;
975 GtkActionGroup *action_group;
976
977 if (!first_time)
978 {
979 first_time = TRUE(!(0));
980#ifdef INDICATOR_APPLET
981 g_set_application_name(_("Indicator Applet")dcgettext (((void*)0), "Indicator Applet", 5));
982#endif
983#ifdef INDICATOR_APPLET_COMPLETE1
984 g_set_application_name(_("Indicator Applet Complete")dcgettext (((void*)0), "Indicator Applet Complete", 5));
985#endif
986#ifdef INDICATOR_APPLET_APPMENU
987 g_set_application_name(_("Indicator Applet Application Menu")dcgettext (((void*)0), "Indicator Applet Application Menu", 5
)
);
988#endif
989
990 g_log_set_default_handler(log_to_file, NULL((void*)0));
991
992 tomboy_keybinder_init();
993 }
994
995 /* Set panel options */
996 gtk_container_set_border_width(GTK_CONTAINER (applet)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_container_get_type ()))))))
, 0);
997 mate_panel_applet_set_flags(applet, MATE_PANEL_APPLET_EXPAND_MINOR);
998 menubar = gtk_menu_bar_new();
999 action_group = gtk_action_group_new ("Indicator Applet Actions");
1000 gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE"mate-indicator-applet");
1001 gtk_action_group_add_actions (action_group, menu_actions,
1002 G_N_ELEMENTS (menu_actions)(sizeof (menu_actions) / sizeof ((menu_actions)[0])),
1003 menubar);
1004 mate_panel_applet_setup_menu(applet, menu_xml, action_group);
1005 g_object_unref(action_group);
1006#ifdef INDICATOR_APPLET
1007 atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
),
1008 "indicator-applet");
1009#endif
1010#ifdef INDICATOR_APPLET_COMPLETE1
1011 atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
),
1012 "indicator-applet-complete");
1013#endif
1014#ifdef INDICATOR_APPLET_APPMENU
1015 atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
),
1016 "indicator-applet-appmenu");
1017#endif
1018
1019 /* Init some theme/icon stuff */
1020 gtk_icon_theme_append_search_path(gtk_icon_theme_get_default(),
1021 INDICATOR_ICONS_DIR"/usr/share/libindicator/icons/");
1022 /* g_debug("Icons directory: %s", INDICATOR_ICONS_DIR); */
1023 gtk_widget_set_name(GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
, "fast-user-switch-applet");
1024
1025 /* Build menubar */
1026 size = (mate_panel_applet_get_size (applet));
1027 orient = (mate_panel_applet_get_orient(applet));
1028 packdirection = ((orient == MATE_PANEL_APPLET_ORIENT_UP) ||
1029 (orient == MATE_PANEL_APPLET_ORIENT_DOWN)) ?
1030 GTK_PACK_DIRECTION_LTR : GTK_PACK_DIRECTION_TTB;
1031 gtk_menu_bar_set_pack_direction(GTK_MENU_BAR(menubar)((((GtkMenuBar*) g_type_check_instance_cast ((GTypeInstance*)
((menubar)), ((gtk_menu_bar_get_type ()))))))
,
1032 packdirection);
1033 gtk_widget_set_can_focus (menubar, TRUE(!(0)));
1034 gtk_widget_set_name(GTK_WIDGET (menubar)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(menubar)), ((gtk_widget_get_type ()))))))
, "fast-user-switch-menubar");
1035 g_signal_connect(menubar, "button-press-event", G_CALLBACK(menubar_press), NULL)g_signal_connect_data ((menubar), ("button-press-event"), (((
GCallback) (menubar_press))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
;
1036 g_signal_connect_after(menubar, "draw", G_CALLBACK(menubar_on_draw), menubar)g_signal_connect_data ((menubar), ("draw"), (((GCallback) (menubar_on_draw
))), (menubar), ((void*)0), G_CONNECT_AFTER)
;
1037 g_signal_connect(applet, "change-orient",g_signal_connect_data ((applet), ("change-orient"), (((GCallback
) (matepanelapplet_reorient_cb))), (menubar), ((void*)0), (GConnectFlags
) 0)
1038 G_CALLBACK(matepanelapplet_reorient_cb), menubar)g_signal_connect_data ((applet), ("change-orient"), (((GCallback
) (matepanelapplet_reorient_cb))), (menubar), ((void*)0), (GConnectFlags
) 0)
;
1039 gtk_container_set_border_width(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, 0);
1040
1041 /* Add in filter func */
1042 tomboy_keybinder_bind(hotkey_keycode, hotkey_filter, menubar);
1043
1044 load_modules(applet, menubar, &indicators_loaded);
1045#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
1046 load_indicators_from_indicator_files(applet, menubar, &indicators_loaded);
1047#endif
1048
1049 if (indicators_loaded == 0) {
1050 /* A label to allow for click through */
1051 GtkWidget * item = gtk_label_new(_("No Indicators")dcgettext (((void*)0), "No Indicators", 5));
1052 mate_panel_applet_set_background_widget(applet, item);
1053 gtk_container_add(GTK_CONTAINER(applet)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_container_get_type ()))))))
, item);
1054 gtk_widget_show(item);
1055 } else {
1056 gtk_container_add(GTK_CONTAINER(applet)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_container_get_type ()))))))
, menubar);
1057 mate_panel_applet_set_background_widget(applet, menubar);
1058 gtk_widget_show(menubar);
1059 }
1060
1061 gtk_widget_show(GTK_WIDGET(applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
);
1062
1063 return TRUE(!(0));
1064
1065}
diff --git a/2020-04-09-124840-6850-1@e69dd120803f_shadow/report-29810e.html b/2020-04-09-124840-6850-1@e69dd120803f_shadow/report-29810e.html new file mode 100644 index 0000000..86f7848 --- /dev/null +++ b/2020-04-09-124840-6850-1@e69dd120803f_shadow/report-29810e.html @@ -0,0 +1,1412 @@ + + + +applet-main.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:applet-main.c
Warning:line 929, column 5
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name applet-main.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -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 -mrelocation-model static -mthread-model posix -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -momit-leaf-frame-pointer -resource-dir /usr/lib64/clang/9.0.1 -D HAVE_CONFIG_H -I . -I .. -D G_LOG_DOMAIN="Indicator-Applet" -D DATADIR="/usr/local/share" -D INDICATOR_DIR="/usr/lib64/indicators3/7/" -D INDICATOR_ICONS_DIR="/usr/share/libindicator/icons/" -D INDICATOR_APPLET -I ./.. -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/fribidi -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gio-unix-2.0 -I /usr/include/libdrm -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-panel-4.0/libmate-panel-applet -I /usr/include/libindicator3-0.4 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/fribidi -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gio-unix-2.0 -I /usr/include/libdrm -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/9.0.1/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wno-unused-parameter -Wno-sign-compare -fdebug-compilation-dir /rootdir/src -ferror-limit 19 -fmessage-length 0 -fobjc-runtime=gcc -fdiagnostics-show-option -vectorize-loops -vectorize-slp -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 -o /rootdir/html-report/2020-04-09-124840-6850-1 -x c applet-main.c +
+ + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2A small wrapper utility to load indicators and put them as menu items
3into the mate-panel using it's applet interface.
4
5Copyright 2009-2010 Canonical Ltd.
6
7Authors:
8 Ted Gould <ted@canonical.com>
9
10This program is free software: you can redistribute it and/or modify it
11under the terms of the GNU General Public License version 3, as published
12by the Free Software Foundation.
13
14This program is distributed in the hope that it will be useful, but
15WITHOUT ANY WARRANTY; without even the implied warranties of
16MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
17PURPOSE. See the GNU General Public License for more details.
18
19You should have received a copy of the GNU General Public License along
20with this program. If not, see <http://www.gnu.org/licenses/>.
21*/
22
23#include <stdlib.h>
24#include <string.h>
25#include <config.h>
26#include <glib/gi18n.h>
27#include <mate-panel-applet.h>
28#include <gdk/gdkkeysyms.h>
29#include <gtk/gtk.h>
30
31#if HAVE_UBUNTU_INDICATOR1
32
33#define INDICATOR_SERVICE_APPMENU"libappmenu.so" "libappmenu.so"
34#define INDICATOR_SERVICE_ME"libme.so" "libme.so"
35#define INDICATOR_SERVICE_DATETIME"libdatetime.so" "libdatetime.so"
36
37#define INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu" "com.canonical.indicator.appmenu"
38#define INDICATOR_SERVICE_ME_NG"com.canonical.indicator.me" "com.canonical.indicator.me"
39#define INDICATOR_SERVICE_DATETIME_NG"com.canonical.indicator.datetime" "com.canonical.indicator.datetime"
40
41#include <libindicator/indicator-object.h>
42#endif
43
44#if HAVE_AYATANA_INDICATOR
45
46#define INDICATOR_SERVICE_APPMENU"libappmenu.so" "libayatana-appmenu.so"
47#define INDICATOR_SERVICE_ME"libme.so" "libayatana-me.so"
48#define INDICATOR_SERVICE_DATETIME"libdatetime.so" "libayatana-datetime.so"
49
50#define INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu" "org.ayatana.indicator.appmenu"
51#define INDICATOR_SERVICE_ME_NG"com.canonical.indicator.me" "org.ayatana.indicator.me"
52#define INDICATOR_SERVICE_DATETIME_NG"com.canonical.indicator.datetime" "org.ayatana.indicator.datetime"
53
54#include <libayatana-indicator/indicator-object.h>
55#endif
56
57/* For new style indicators */
58
59#if HAVE_UBUNTU_INDICATOR1 && HAVE_UBUNTU_INDICATOR_NG
60
61#include <libido/libido.h>
62#include <libindicator/indicator-ng.h>
63
64#define INDICATOR_SERVICE_DIR "/usr/share/unity/indicators"
65
66#endif
67
68#if HAVE_AYATANA_INDICATOR && HAVE_AYATANA_INDICATOR_NG
69
70#include <libayatana-ido/libayatana-ido.h>
71#include <libayatana-indicator/indicator-ng.h>
72
73#define INDICATOR_SERVICE_DIR "/usr/share/ayatana/indicators"
74
75#endif
76
77#include "tomboykeybinder.h"
78
79static gchar * indicator_order[] = {
80#if HAVE_UBUNTU_INDICATOR1
81 "libapplication.so",
82 "libmessaging.so",
83 "libsoundmenu.so",
84 "libdatetime.so",
85 "libsession.so",
86#endif
87#if HAVE_AYATANA_INDICATOR
88 "libayatana-application.so",
89 "libayatana-messaging.so",
90 "libayatana-soundmenu.so",
91 "libayatana-datetime.so",
92 "libayatana-session.so",
93#endif
94 NULL((void*)0)
95};
96
97static GtkPackDirection packdirection;
98static MatePanelAppletOrient orient;
99static guint size;
100
101#define MENU_DATA_INDICATOR_OBJECT"indicator-object" "indicator-object"
102#define MENU_DATA_INDICATOR_ENTRY"indicator-entry" "indicator-entry"
103
104#define IO_DATA_ORDER_NUMBER"indicator-order-number" "indicator-order-number"
105
106static gboolean applet_fill_cb (MatePanelApplet * applet, const gchar * iid, gpointer data);
107
108static void update_accessible_desc (IndicatorObjectEntry * entry, GtkWidget * menuitem);
109
110/*************
111 * main
112 * ***********/
113
114#ifdef INDICATOR_APPLET1
115MATE_PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletFactory",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
116 PANEL_TYPE_APPLET,int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
117 "indicator-applet",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
118 applet_fill_cb, NULL)int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
;
119#endif
120#ifdef INDICATOR_APPLET_COMPLETE
121MATE_PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletCompleteFactory",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
122 PANEL_TYPE_APPLET,int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
123 "indicator-applet-complete",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
124 applet_fill_cb, NULL)int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
;
125#endif
126#ifdef INDICATOR_APPLET_APPMENU
127MATE_PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletAppmenuFactory",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
128 PANEL_TYPE_APPLET,int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
129 "indicator-applet-appmenu",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
130 applet_fill_cb, NULL)int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
;
131#endif
132
133/*************
134 * log files
135 * ***********/
136#ifdef INDICATOR_APPLET1
137#define LOG_FILE_NAME"indicator-applet.log" "indicator-applet.log"
138#endif
139#ifdef INDICATOR_APPLET_COMPLETE
140#define LOG_FILE_NAME"indicator-applet.log" "indicator-applet-complete.log"
141#endif
142#ifdef INDICATOR_APPLET_APPMENU
143#define LOG_FILE_NAME"indicator-applet.log" "indicator-applet-appmenu.log"
144#endif
145GOutputStream * log_file = NULL((void*)0);
146
147/*****************
148 * Hotkey support
149 * **************/
150#ifdef INDICATOR_APPLET1
151gchar * hotkey_keycode = "<Super>M";
152#endif
153#ifdef INDICATOR_APPLET_SESSION
154gchar * hotkey_keycode = "<Super>S";
155#endif
156#ifdef INDICATOR_APPLET_COMPLETE
157gchar * hotkey_keycode = "<Super>S";
158#endif
159#ifdef INDICATOR_APPLET_APPMENU
160gchar * hotkey_keycode = "<Super>F1";
161#endif
162
163/********************
164 * Environment Names
165 * *******************/
166#ifdef INDICATOR_APPLET1
167#define INDICATOR_SPECIFIC_ENV"indicator-applet-original" "indicator-applet-original"
168#endif
169#ifdef INDICATOR_APPLET_COMPLETE
170#define INDICATOR_SPECIFIC_ENV"indicator-applet-original" "indicator-applet-complete"
171#endif
172#ifdef INDICATOR_APPLET_APPMENU
173#define INDICATOR_SPECIFIC_ENV"indicator-applet-original" "indicator-applet-appmenu"
174#endif
175
176static const gchar * indicator_env[] = {
177 "indicator-applet",
178 INDICATOR_SPECIFIC_ENV"indicator-applet-original",
179 NULL((void*)0)
180};
181
182/*************
183 * init function
184 * ***********/
185
186static gint
187name2order (const gchar * name) {
188 int i;
189
190 for (i = 0; indicator_order[i] != NULL((void*)0); i++) {
191 if (g_strcmp0(name, indicator_order[i]) == 0) {
192 return i;
193 }
194 }
195
196 return -1;
197}
198
199typedef struct _incoming_position_t incoming_position_t;
200struct _incoming_position_t {
201 gint objposition;
202 gint entryposition;
203 gint menupos;
204 gboolean found;
205};
206
207/* This function helps by determining where in the menu list
208 this new entry should be placed. It compares the objects
209 that they're on, and then the individual entries. Each
210 is progressively more expensive. */
211static void
212place_in_menu (GtkWidget * widget, gpointer user_data)
213{
214 incoming_position_t * position = (incoming_position_t *)user_data;
215 if (position->found) {
216 /* We've already been placed, just finish the foreach */
217 return;
218 }
219
220 IndicatorObject * io = INDICATOR_OBJECT(g_object_get_data(G_OBJECT(widget), MENU_DATA_INDICATOR_OBJECT))((((IndicatorObject*) g_type_check_instance_cast ((GTypeInstance
*) ((g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((widget)), (((GType) ((20) << (2)))
))))), "indicator-object"))), ((indicator_object_get_type ())
)))))
;
221 g_assert(io != NULL)do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_
; if (io != ((void*)0)) _g_boolean_var_ = 1; else _g_boolean_var_
= 0; _g_boolean_var_; }), 1)) ; else g_assertion_message_expr
("Indicator-Applet", "applet-main.c", 221, ((const char*) (__func__
)), "io != NULL"); } while (0)
;
222
223 gint objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER))((gint) (glong) (g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
), "indicator-order-number")))
;
224 /* We've already passed it, well, then this is where
225 we should be be. Stop! */
226 if (objposition > position->objposition) {
227 position->found = TRUE(!(0));
228 return;
229 }
230
231 /* The objects don't match yet, keep looking */
232 if (objposition < position->objposition) {
233 position->menupos++;
234 return;
235 }
236
237 /* The objects are the same, let's start looking at entries. */
238 IndicatorObjectEntry * entry = (IndicatorObjectEntry *)g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
239 gint entryposition = indicator_object_get_location(io, entry);
240
241 if (entryposition > position->entryposition) {
242 position->found = TRUE(!(0));
243 return;
244 }
245
246 if (entryposition < position->entryposition) {
247 position->menupos++;
248 return;
249 }
250
251 /* We've got the same object and the same entry. Well,
252 let's just put it right here then. */
253 position->found = TRUE(!(0));
254 return;
255}
256
257static void
258something_shown (GtkWidget * widget, gpointer user_data)
259{
260 GtkWidget * menuitem = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
261 gtk_widget_show(menuitem);
262}
263
264static void
265something_hidden (GtkWidget * widget, gpointer user_data)
266{
267 GtkWidget * menuitem = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
268 gtk_widget_hide(menuitem);
269}
270
271static void
272sensitive_cb (GObject * obj, GParamSpec * pspec, gpointer user_data)
273{
274 g_return_if_fail(GTK_IS_WIDGET(obj))do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((obj)); GType __t = ((gtk_widget_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet", ((const
char*) (__func__)), "GTK_IS_WIDGET(obj)"); return; } } while
(0)
;
275 g_return_if_fail(GTK_IS_WIDGET(user_data))do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((gtk_widget_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet", ((const
char*) (__func__)), "GTK_IS_WIDGET(user_data)"); return; } }
while (0)
;
276
277 gtk_widget_set_sensitive(GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
, gtk_widget_get_sensitive(GTK_WIDGET(obj)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(obj)), ((gtk_widget_get_type ()))))))
));
278 return;
279}
280
281static void
282entry_activated (GtkWidget * widget, gpointer user_data)
283{
284 g_return_if_fail(GTK_IS_WIDGET(widget))do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((gtk_widget_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet", ((const
char*) (__func__)), "GTK_IS_WIDGET(widget)"); return; } } while
(0)
;
285 gpointer pio = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, "indicator");
286 g_return_if_fail(INDICATOR_IS_OBJECT(pio))do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((pio)); GType __t = ((indicator_object_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet", ((const
char*) (__func__)), "INDICATOR_IS_OBJECT(pio)"); return; } }
while (0)
;
287 IndicatorObject * io = INDICATOR_OBJECT(pio)((((IndicatorObject*) g_type_check_instance_cast ((GTypeInstance
*) ((pio)), ((indicator_object_get_type ()))))))
;
288
289 return indicator_object_entry_activate(io, (IndicatorObjectEntry *)user_data, gtk_get_current_event_time());
290}
291
292static gboolean
293entry_scrolled (GtkWidget *menuitem, GdkEventScroll *event, gpointer data)
294{
295 IndicatorObject *io = g_object_get_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_OBJECT"indicator-object");
296 IndicatorObjectEntry *entry = g_object_get_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
297
298 g_return_val_if_fail(INDICATOR_IS_OBJECT(io), FALSE)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((io)); GType __t = ((indicator_object_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet", ((const
char*) (__func__)), "INDICATOR_IS_OBJECT(io)"); return ((0))
; } } while (0)
;
299
300 g_signal_emit_by_name (io, "scroll", 1, event->direction);
301 g_signal_emit_by_name (io, "scroll-entry", entry, 1, event->direction);
302 g_signal_emit_by_name (io, INDICATOR_OBJECT_SIGNAL_ENTRY_SCROLLED"entry-scrolled", entry, 1, event->direction);
303
304 return FALSE(0);
305}
306
307static void
308accessible_desc_update_cb (GtkWidget * widget, gpointer userdata)
309{
310 gpointer data = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
311
312 if (data != userdata) {
313 return;
314 }
315
316 IndicatorObjectEntry * entry = (IndicatorObjectEntry *)data;
317 update_accessible_desc(entry, widget);
318}
319
320static void
321accessible_desc_update (IndicatorObject * io, IndicatorObjectEntry * entry, GtkWidget * menubar)
322{
323 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, accessible_desc_update_cb, entry);
324 return;
325}
326
327#define PANEL_PADDING8 8
328static gboolean
329entry_resized (GtkWidget *applet, guint newsize, gpointer data)
330{
331 IndicatorObject *io = (IndicatorObject *)data;
332
333 size = newsize;
334
335 /* Work on the entries */
336 GList * entries = indicator_object_get_entries(io);
337 GList * entry = NULL((void*)0);
338
339 for (entry = entries; entry != NULL((void*)0); entry = g_list_next(entry)((entry) ? (((GList *)(entry))->next) : ((void*)0))) {
340 IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)entry->data;
341 if (entrydata->image != NULL((void*)0)) {
342 /* Resize to fit panel */
343 gtk_image_set_pixel_size (entrydata->image, size - PANEL_PADDING8);
344 }
345 }
346
347 return FALSE(0);
348}
349
350static void
351entry_added (IndicatorObject * io, IndicatorObjectEntry * entry, GtkWidget * menubar)
352{
353 g_debug("Signal: Entry Added");
354 gboolean something_visible = FALSE(0);
355 gboolean something_sensitive = FALSE(0);
356
357 GtkWidget * menuitem = gtk_menu_item_new();
358 GtkWidget * box = (packdirection == GTK_PACK_DIRECTION_LTR) ?
359 gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3) : gtk_box_new(GTK_ORIENTATION_VERTICAL, 3);
360
361 /* Allows indicators to receive mouse scroll event */
362 gtk_widget_add_events(GTK_WIDGET(menuitem)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(menuitem)), ((gtk_widget_get_type ()))))))
, GDK_SCROLL_MASK);
363
364 g_object_set_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "indicator", io);
365 g_object_set_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "box", box);
366
367 g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(entry_activated), entry)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((menuitem)), (((GType) ((20) << (2)
)))))))), ("activate"), (((GCallback) (entry_activated))), (entry
), ((void*)0), (GConnectFlags) 0)
;
368 g_signal_connect(G_OBJECT(menuitem), "scroll-event", G_CALLBACK(entry_scrolled), entry)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((menuitem)), (((GType) ((20) << (2)
)))))))), ("scroll-event"), (((GCallback) (entry_scrolled))),
(entry), ((void*)0), (GConnectFlags) 0)
;
369
370 if (entry->image != NULL((void*)0)) {
371 /* Resize to fit panel */
372 gtk_image_set_pixel_size (entry->image, size - PANEL_PADDING8);
373 gtk_box_pack_start(GTK_BOX(box)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((box
)), ((gtk_box_get_type ()))))))
, GTK_WIDGET(entry->image)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->image)), ((gtk_widget_get_type ()))))))
, FALSE(0), FALSE(0), 1);
374 if (gtk_widget_get_visible(GTK_WIDGET(entry->image)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->image)), ((gtk_widget_get_type ()))))))
)) {
375 something_visible = TRUE(!(0));
376 }
377
378 if (gtk_widget_get_sensitive(GTK_WIDGET(entry->image)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->image)), ((gtk_widget_get_type ()))))))
)) {
379 something_sensitive = TRUE(!(0));
380 }
381
382 g_signal_connect(G_OBJECT(entry->image), "show", G_CALLBACK(something_shown), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), ("show"), (((GCallback) (something_shown))), (menuitem
), ((void*)0), (GConnectFlags) 0)
;
383 g_signal_connect(G_OBJECT(entry->image), "hide", G_CALLBACK(something_hidden), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), ("hide"), (((GCallback) (something_hidden))), (
menuitem), ((void*)0), (GConnectFlags) 0)
;
384
385 g_signal_connect(G_OBJECT(entry->image), "notify::sensitive", G_CALLBACK(sensitive_cb), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), ("notify::sensitive"), (((GCallback) (sensitive_cb
))), (menuitem), ((void*)0), (GConnectFlags) 0)
;
386 }
387 if (entry->label != NULL((void*)0)) {
388 switch(packdirection) {
389 case GTK_PACK_DIRECTION_LTR:
390 gtk_label_set_angle(GTK_LABEL(entry->label)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_label_get_type ()))))))
, 0.0);
391 break;
392 case GTK_PACK_DIRECTION_TTB:
393 gtk_label_set_angle(GTK_LABEL(entry->label)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_label_get_type ()))))))
,
394 (orient == MATE_PANEL_APPLET_ORIENT_LEFT) ?
395 270.0 : 90.0);
396 break;
397 default:
398 break;
399 }
400 gtk_box_pack_start(GTK_BOX(box)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((box
)), ((gtk_box_get_type ()))))))
, GTK_WIDGET(entry->label)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_widget_get_type ()))))))
, FALSE(0), FALSE(0), 1);
401
402 if (gtk_widget_get_visible(GTK_WIDGET(entry->label)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_widget_get_type ()))))))
)) {
403 something_visible = TRUE(!(0));
404 }
405
406 if (gtk_widget_get_sensitive(GTK_WIDGET(entry->label)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_widget_get_type ()))))))
)) {
407 something_sensitive = TRUE(!(0));
408 }
409
410 g_signal_connect(G_OBJECT(entry->label), "show", G_CALLBACK(something_shown), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), ("show"), (((GCallback) (something_shown))), (menuitem
), ((void*)0), (GConnectFlags) 0)
;
411 g_signal_connect(G_OBJECT(entry->label), "hide", G_CALLBACK(something_hidden), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), ("hide"), (((GCallback) (something_hidden))), (
menuitem), ((void*)0), (GConnectFlags) 0)
;
412
413 g_signal_connect(G_OBJECT(entry->label), "notify::sensitive", G_CALLBACK(sensitive_cb), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), ("notify::sensitive"), (((GCallback) (sensitive_cb
))), (menuitem), ((void*)0), (GConnectFlags) 0)
;
414 }
415 gtk_container_add(GTK_CONTAINER(menuitem)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menuitem)), ((gtk_container_get_type ()))))))
, box);
416 gtk_widget_show(box);
417
418 if (entry->menu != NULL((void*)0)) {
419 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem)((((GtkMenuItem*) g_type_check_instance_cast ((GTypeInstance*
) ((menuitem)), ((gtk_menu_item_get_type ()))))))
, GTK_WIDGET(entry->menu)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->menu)), ((gtk_widget_get_type ()))))))
);
420 }
421
422 incoming_position_t position;
423 position.objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER))((gint) (glong) (g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
), "indicator-order-number")))
;
424 position.entryposition = indicator_object_get_location(io, entry);
425 position.menupos = 0;
426 position.found = FALSE(0);
427
428 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, place_in_menu, &position);
429
430 gtk_menu_shell_insert(GTK_MENU_SHELL(menubar)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_menu_shell_get_type ()))))))
, menuitem, position.menupos);
431
432 if (something_visible) {
433 if (entry->accessible_desc != NULL((void*)0)) {
434 update_accessible_desc(entry, menuitem);
435 }
436 gtk_widget_show(menuitem);
437 }
438 gtk_widget_set_sensitive(menuitem, something_sensitive);
439
440 g_object_set_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry", entry);
441 g_object_set_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_OBJECT"indicator-object", io);
442
443 return;
444}
445
446static void
447entry_removed_cb (GtkWidget * widget, gpointer userdata)
448{
449 gpointer data = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
450
451 if (data != userdata) {
452 return;
453 }
454
455 IndicatorObjectEntry * entry = (IndicatorObjectEntry *)data;
456 if (entry->label != NULL((void*)0)) {
457 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(something_shown), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_shown))), (widget
))
;
458 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(something_hidden), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_hidden))), (widget
))
;
459 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(sensitive_cb), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (sensitive_cb))), (widget)
)
;
460 }
461 if (entry->image != NULL((void*)0)) {
462 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(something_shown), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_shown))), (widget
))
;
463 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(something_hidden), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_hidden))), (widget
))
;
464 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(sensitive_cb), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (sensitive_cb))), (widget)
)
;
465 }
466
467 gtk_widget_destroy(widget);
468 return;
469}
470
471static void
472entry_removed (IndicatorObject * io G_GNUC_UNUSED__attribute__((__unused__)), IndicatorObjectEntry * entry,
473 gpointer user_data)
474{
475 g_debug("Signal: Entry Removed");
476
477 gtk_container_foreach(GTK_CONTAINER(user_data)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((gtk_container_get_type ()))))))
, entry_removed_cb, entry);
478
479 return;
480}
481
482static void
483entry_moved_find_cb (GtkWidget * widget, gpointer userdata)
484{
485 gpointer * array = (gpointer *)userdata;
486 if (array[1] != NULL((void*)0)) {
487 return;
488 }
489
490 gpointer data = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
491
492 if (data != array[0]) {
493 return;
494 }
495
496 array[1] = widget;
497 return;
498}
499
500/* Gets called when an entry for an object was moved. */
501static void
502entry_moved (IndicatorObject * io, IndicatorObjectEntry * entry,
503 gint old G_GNUC_UNUSED__attribute__((__unused__)), gint new G_GNUC_UNUSED__attribute__((__unused__)), gpointer user_data)
504{
505 GtkWidget * menubar = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
506
507 gpointer array[2];
508 array[0] = entry;
509 array[1] = NULL((void*)0);
510
511 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, entry_moved_find_cb, array);
512 if (array[1] == NULL((void*)0)) {
513 g_warning("Moving an entry that isn't in our menus.");
514 return;
515 }
516
517 GtkWidget * mi = GTK_WIDGET(array[1])((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(array[1])), ((gtk_widget_get_type ()))))))
;
518 g_object_ref(G_OBJECT(mi)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
mi)), (((GType) ((20) << (2))))))))
);
519 gtk_container_remove(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, mi);
520
521 incoming_position_t position;
522 position.objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER))((gint) (glong) (g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
), "indicator-order-number")))
;
523 position.entryposition = indicator_object_get_location(io, entry);
524 position.menupos = 0;
525 position.found = FALSE(0);
526
527 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, place_in_menu, &position);
528
529 gtk_menu_shell_insert(GTK_MENU_SHELL(menubar)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_menu_shell_get_type ()))))))
, mi, position.menupos);
530 g_object_unref(G_OBJECT(mi)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
mi)), (((GType) ((20) << (2))))))))
);
531
532 return;
533}
534
535static void
536menu_show (IndicatorObject * io, IndicatorObjectEntry * entry,
537 guint32 timestamp, gpointer user_data)
538{
539 GtkWidget * menubar = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
540
541 if (entry == NULL((void*)0)) {
542 /* Close any open menus instead of opening one */
543 GList * entries = indicator_object_get_entries(io);
544 GList * iterator = NULL((void*)0);
545 for (iterator = entries; iterator != NULL((void*)0); iterator = g_list_next(iterator)((iterator) ? (((GList *)(iterator))->next) : ((void*)0))) {
546 IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)iterator->data;
547 gtk_menu_popdown(entrydata->menu);
548 }
549 g_list_free(entries);
550
551 /* And tell the menubar to exit activation mode too */
552 gtk_menu_shell_cancel(GTK_MENU_SHELL(menubar)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_menu_shell_get_type ()))))))
);
553 return;
554 }
555
556 // TODO: do something sensible here
557}
558
559static void
560update_accessible_desc(IndicatorObjectEntry * entry, GtkWidget * menuitem)
561{
562 /* FIXME: We need to deal with the use case where the contents of the
563 label overrides what is found in the atk object's name, or at least
564 orca speaks the label instead of the atk object name.
565 */
566 AtkObject * menuitem_obj = gtk_widget_get_accessible(menuitem);
567 if (menuitem_obj == NULL((void*)0)) {
568 /* Should there be an error printed here? */
569 return;
570 }
571
572 if (entry->accessible_desc != NULL((void*)0)) {
573 atk_object_set_name(menuitem_obj, entry->accessible_desc);
574 } else {
575 atk_object_set_name(menuitem_obj, "");
576 }
577 return;
578}
579
580static void
581load_indicator (MatePanelApplet *applet, GtkWidget * menubar, IndicatorObject *io, const gchar *name)
582{
583 /* Set the environment it's in */
584 indicator_object_set_environment(io, (const GStrv)indicator_env);
585
586 /* Attach the 'name' to the object */
587#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
588 int pos = 5000 - indicator_object_get_position(io);
589 if (pos > 5000) {
590 pos = name2order(name);
591 }
592#else
593 int pos = name2order(name);
594#endif
595
596 g_object_set_data(G_OBJECT(io)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
io)), (((GType) ((20) << (2))))))))
, IO_DATA_ORDER_NUMBER"indicator-order-number", GINT_TO_POINTER(pos)((gpointer) (glong) (pos)));
597
598 /* Connect to its signals */
599 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED, G_CALLBACK(entry_added), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("entry-added"), (((GCallback) (entry_added))), (menubar)
, ((void*)0), (GConnectFlags) 0)
;
600 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED, G_CALLBACK(entry_removed), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("entry-removed"), (((GCallback) (entry_removed))), (menubar
), ((void*)0), (GConnectFlags) 0)
;
601 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_MOVED, G_CALLBACK(entry_moved), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("entry-moved"), (((GCallback) (entry_moved))), (menubar)
, ((void*)0), (GConnectFlags) 0)
;
602 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_MENU_SHOW, G_CALLBACK(menu_show), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("menu-show"), (((GCallback) (menu_show))), (menubar), ((
void*)0), (GConnectFlags) 0)
;
603 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ACCESSIBLE_DESC_UPDATE, G_CALLBACK(accessible_desc_update), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("accessible-desc-update"), (((GCallback) (accessible_desc_update
))), (menubar), ((void*)0), (GConnectFlags) 0)
;
604
605 /* Track panel resize */
606 g_signal_connect_object(G_OBJECT(applet)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
applet)), (((GType) ((20) << (2))))))))
, "change-size", G_CALLBACK(entry_resized)((GCallback) (entry_resized)), G_OBJECT(io)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
io)), (((GType) ((20) << (2))))))))
, 0);
607
608 /* Work on the entries */
609 GList * entries = indicator_object_get_entries(io);
610 GList * entry = NULL((void*)0);
611
612 for (entry = entries; entry != NULL((void*)0); entry = g_list_next(entry)((entry) ? (((GList *)(entry))->next) : ((void*)0))) {
613 IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)entry->data;
614 entry_added(io, entrydata, menubar);
615 }
616
617 g_list_free(entries);
618}
619
620static gboolean
621load_module (const gchar * name, MatePanelApplet *applet, GtkWidget * menubar)
622{
623 g_debug("Looking at Module: %s", name);
624 g_return_val_if_fail(name != NULL, FALSE)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if (name != ((void*)0)) _g_boolean_var_ = 1; else _g_boolean_var_
= 0; _g_boolean_var_; }), 1))) { } else { g_return_if_fail_warning
("Indicator-Applet", ((const char*) (__func__)), "name != NULL"
); return ((0)); } } while (0)
;
625
626 if (!g_str_has_suffix(name, G_MODULE_SUFFIX"so")) {
627 return FALSE(0);
628 }
629
630 g_debug("Loading Module: %s", name);
631
632 /* Build the object for the module */
633 gchar * fullpath = g_build_filename(INDICATOR_DIR"/usr/lib64/indicators3/7/", name, NULL((void*)0));
634 IndicatorObject * io = indicator_object_new_from_file(fullpath);
635 g_free(fullpath);
636
637 load_indicator(applet, menubar, io, name);
638
639 return TRUE(!(0));
640}
641
642static void
643load_modules (MatePanelApplet *applet, GtkWidget *menubar, gint *indicators_loaded)
644{
645 if (g_file_test(INDICATOR_DIR"/usr/lib64/indicators3/7/", (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))) {
646 GDir * dir = g_dir_open(INDICATOR_DIR"/usr/lib64/indicators3/7/", 0, NULL((void*)0));
647
648 const gchar * name;
649 gint count = 0;
650 while ((name = g_dir_read_name(dir)) != NULL((void*)0)) {
651#ifdef INDICATOR_APPLET_APPMENU
652 if (g_strcmp0(name, INDICATOR_SERVICE_APPMENU"libappmenu.so")) {
653 continue;
654 }
655#else
656 if (!g_strcmp0(name, INDICATOR_SERVICE_APPMENU"libappmenu.so")) {
657 continue;
658 }
659#endif
660#ifdef INDICATOR_APPLET1
661 if (!g_strcmp0(name, INDICATOR_SERVICE_ME"libme.so")) {
662 continue;
663 }
664 if (!g_strcmp0(name, INDICATOR_SERVICE_DATETIME"libdatetime.so")) {
665 continue;
666 }
667#endif
668 if (load_module(name, applet, menubar)) {
669 count++;
670 }
671 }
672
673 *indicators_loaded += count;
674
675 g_dir_close (dir);
676 }
677}
678
679#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
680
681static void
682load_indicators_from_indicator_files (MatePanelApplet *applet, GtkWidget *menubar, gint *indicators_loaded)
683{
684 GDir *dir;
685 const gchar *name;
686 GError *error = NULL((void*)0);
687
688 dir = g_dir_open (INDICATOR_SERVICE_DIR, 0, &error);
689
690 if (!dir) {
691 g_warning ("unable to open indicator service file directory: %s", error->message);
692 g_error_free (error);
693
694 return;
695 }
696
697 gint count = 0;
698 while ((name = g_dir_read_name (dir))) {
699 gchar *filename;
700 IndicatorNg *indicator;
701
702 filename = g_build_filename (INDICATOR_SERVICE_DIR, name, NULL((void*)0));
703 indicator = indicator_ng_new_for_profile (filename, "desktop", &error);
704 g_free (filename);
705
706#ifdef INDICATOR_APPLET_APPMENU
707 if (g_strcmp0(name, INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu")) {
708 continue;
709 }
710#else
711 if (!g_strcmp0(name, INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu")) {
712 continue;
713 }
714#endif
715#ifdef INDICATOR_APPLET1
716 if (!g_strcmp0(name, INDICATOR_SERVICE_ME_NG"com.canonical.indicator.me")) {
717 continue;
718 }
719 if (!g_strcmp0(name, INDICATOR_SERVICE_DATETIME_NG"com.canonical.indicator.datetime")) {
720 continue;
721 }
722#endif
723
724 if (indicator) {
725 load_indicator(applet, menubar, INDICATOR_OBJECT (indicator)((((IndicatorObject*) g_type_check_instance_cast ((GTypeInstance
*) ((indicator)), ((indicator_object_get_type ()))))))
, name);
726 count++;
727 }else{
728 g_warning ("unable to load '%s': %s", name, error->message);
729 g_clear_error (&error);
730 }
731 }
732
733 *indicators_loaded += count;
734
735 g_dir_close (dir);
736}
737#endif /* HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG */
738
739static void
740hotkey_filter (char * keystring G_GNUC_UNUSED__attribute__((__unused__)), gpointer data)
741{
742 g_return_if_fail(GTK_IS_MENU_SHELL(data))do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((data)); GType __t = ((gtk_menu_shell_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet", ((const
char*) (__func__)), "GTK_IS_MENU_SHELL(data)"); return; } } while
(0)
;
743
744 /* Oh, wow, it's us! */
745 GList * children = gtk_container_get_children(GTK_CONTAINER(data)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((gtk_container_get_type ()))))))
);
746 if (children == NULL((void*)0)) {
747 g_debug("Menubar has no children");
748 return;
749 }
750
751 gtk_menu_shell_select_item(GTK_MENU_SHELL(data)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((gtk_menu_shell_get_type ()))))))
, GTK_WIDGET(g_list_last(children)->data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(g_list_last(children)->data)), ((gtk_widget_get_type ()))
))))
);
752 g_list_free(children);
753 return;
754}
755
756static gboolean
757menubar_press (GtkWidget * widget,
758 GdkEventButton *event,
759 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
760{
761 if (event->button != 1) {
762 g_signal_stop_emission_by_name(widget, "button-press-event");
763 }
764
765 return FALSE(0);
766}
767
768static gboolean
769menubar_on_draw (GtkWidget * widget,
770 cairo_t * cr,
771 GtkWidget * menubar)
772{
773 /* FIXME: either port to gtk_render_focus or remove this function */
774 if (gtk_widget_has_focus(menubar))
775 gtk_paint_focus(gtk_widget_get_style(widget),
776 cr,
777 gtk_widget_get_state(menubar),
778 widget, "menubar-applet", 0, 0, -1, -1);
779
780 return FALSE(0);
781}
782
783static void
784about_cb (GtkAction *action G_GNUC_UNUSED__attribute__((__unused__)),
785 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
786{
787 static const gchar *authors[] = {
788 "Ted Gould <ted@canonical.com>",
789 NULL((void*)0)
790 };
791
792 static gchar *license[] = {
793 N_("This program is free software: you can redistribute it and/or modify it ""This program is free software: you can redistribute it and/or modify it "
"under the terms of the GNU General Public License version 3, as published "
"by the Free Software Foundation."
794 "under the terms of the GNU General Public License version 3, as published ""This program is free software: you can redistribute it and/or modify it "
"under the terms of the GNU General Public License version 3, as published "
"by the Free Software Foundation."
795 "by the Free Software Foundation.")"This program is free software: you can redistribute it and/or modify it "
"under the terms of the GNU General Public License version 3, as published "
"by the Free Software Foundation."
,
796 N_("This program is distributed in the hope that it will be useful, but ""This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
797 "WITHOUT ANY WARRANTY; without even the implied warranties of ""This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
798 "MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR ""This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
799 "PURPOSE. See the GNU General Public License for more details.")"This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
,
800 N_("You should have received a copy of the GNU General Public License along ""You should have received a copy of the GNU General Public License along "
"with this program. If not, see <http://www.gnu.org/licenses/>."
801 "with this program. If not, see <http://www.gnu.org/licenses/>.")"You should have received a copy of the GNU General Public License along "
"with this program. If not, see <http://www.gnu.org/licenses/>."
,
802 NULL((void*)0)
803 };
804 gchar *license_i18n;
805
806 license_i18n = g_strconcat (_(license[0])dcgettext (((void*)0), license[0], 5), "\n\n", _(license[1])dcgettext (((void*)0), license[1], 5), "\n\n", _(license[2])dcgettext (((void*)0), license[2], 5), NULL((void*)0));
807
808 gtk_show_about_dialog(NULL((void*)0),
809 "version", VERSION"1.24.0",
810 "copyright", _("Copyright \xc2\xa9 2009-2010 Canonical, Ltd.\n"dcgettext (((void*)0), "Copyright \xc2\xa9 2009-2010 Canonical, Ltd.\n"
"Copyright \xc2\xa9 2011-2020 MATE developers", 5)
811 "Copyright \xc2\xa9 2011-2020 MATE developers")dcgettext (((void*)0), "Copyright \xc2\xa9 2009-2010 Canonical, Ltd.\n"
"Copyright \xc2\xa9 2011-2020 MATE developers", 5)
,
812#ifdef INDICATOR_APPLET_APPMENU
813 "comments", _("An applet to hold your application menus.")dcgettext (((void*)0), "An applet to hold your application menus."
, 5)
,
814#endif
815 "comments", _("An applet to hold all of the system indicators.")dcgettext (((void*)0), "An applet to hold all of the system indicators."
, 5)
,
816 "authors", authors,
817 "license", license_i18n,
818 "wrap-license", TRUE(!(0)),
819 "translator-credits", _("translator-credits")dcgettext (((void*)0), "translator-credits", 5),
820 "logo-icon-name", "mate-indicator-applet",
821 "icon-name", "mate-indicator-applet",
822 "website", "https://mate-desktop.org",
823 "website-label", _("MATE Website")dcgettext (((void*)0), "MATE Website", 5),
824 NULL((void*)0)
825 );
826
827 g_free (license_i18n);
828
829 return;
830}
831
832static gboolean
833swap_orient_cb (GtkWidget *item, gpointer data)
834{
835 GtkWidget *from = (GtkWidget *) data;
836 GtkWidget *to = (GtkWidget *) g_object_get_data(G_OBJECT(from)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
from)), (((GType) ((20) << (2))))))))
, "to");
837 g_object_ref(G_OBJECT(item)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
item)), (((GType) ((20) << (2))))))))
);
838 gtk_container_remove(GTK_CONTAINER(from)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((from)), ((gtk_container_get_type ()))))))
, item);
839 if (GTK_IS_LABEL(item)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(item)); GType __t = ((gtk_label_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; }))))
) {
840 switch(packdirection) {
841 case GTK_PACK_DIRECTION_LTR:
842 gtk_label_set_angle(GTK_LABEL(item)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(item)), ((gtk_label_get_type ()))))))
, 0.0);
843 break;
844 case GTK_PACK_DIRECTION_TTB:
845 gtk_label_set_angle(GTK_LABEL(item)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(item)), ((gtk_label_get_type ()))))))
,
846 (orient == MATE_PANEL_APPLET_ORIENT_LEFT) ?
847 270.0 : 90.0);
848 break;
849 default:
850 break;
851 }
852 }
853 gtk_box_pack_start(GTK_BOX(to)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((to
)), ((gtk_box_get_type ()))))))
, item, FALSE(0), FALSE(0), 0);
854 return TRUE(!(0));
855}
856
857static gboolean
858reorient_box_cb (GtkWidget *menuitem, gpointer data)
859{
860 GtkWidget *from = g_object_get_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "box");
861 GtkWidget *to = (packdirection == GTK_PACK_DIRECTION_LTR) ?
862 gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0) : gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
863 g_object_set_data(G_OBJECT(from)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
from)), (((GType) ((20) << (2))))))))
, "to", to);
864 gtk_container_foreach(GTK_CONTAINER(from)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((from)), ((gtk_container_get_type ()))))))
, (GtkCallback)swap_orient_cb,
865 from);
866 gtk_container_remove(GTK_CONTAINER(menuitem)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menuitem)), ((gtk_container_get_type ()))))))
, from);
867 gtk_container_add(GTK_CONTAINER(menuitem)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menuitem)), ((gtk_container_get_type ()))))))
, to);
868 g_object_set_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "box", to);
869 gtk_widget_show_all(menuitem);
870 return TRUE(!(0));
871}
872
873static gboolean
874matepanelapplet_reorient_cb (GtkWidget *applet, MatePanelAppletOrient neworient,
875 gpointer data)
876{
877 GtkWidget *menubar = (GtkWidget *)data;
878 if ((((neworient == MATE_PANEL_APPLET_ORIENT_UP) ||
879 (neworient == MATE_PANEL_APPLET_ORIENT_DOWN)) &&
880 ((orient == MATE_PANEL_APPLET_ORIENT_LEFT) ||
881 (orient == MATE_PANEL_APPLET_ORIENT_RIGHT))) ||
882 (((neworient == MATE_PANEL_APPLET_ORIENT_LEFT) ||
883 (neworient == MATE_PANEL_APPLET_ORIENT_RIGHT)) &&
884 ((orient == MATE_PANEL_APPLET_ORIENT_UP) ||
885 (orient == MATE_PANEL_APPLET_ORIENT_DOWN)))) {
886 packdirection = (packdirection == GTK_PACK_DIRECTION_LTR) ?
887 GTK_PACK_DIRECTION_TTB : GTK_PACK_DIRECTION_LTR;
888 gtk_menu_bar_set_pack_direction(GTK_MENU_BAR(menubar)((((GtkMenuBar*) g_type_check_instance_cast ((GTypeInstance*)
((menubar)), ((gtk_menu_bar_get_type ()))))))
,
889 packdirection);
890 orient = neworient;
891 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
,
892 (GtkCallback)reorient_box_cb, NULL((void*)0));
893 }
894 orient = neworient;
895 return FALSE(0);
896}
897
898#ifdef N_
899#undef N_
900#endif
901#define N_(x)x x
902
903static void
904log_to_file_cb (GObject * source_obj G_GNUC_UNUSED__attribute__((__unused__)),
905 GAsyncResult * result G_GNUC_UNUSED__attribute__((__unused__)), gpointer user_data)
906{
907 g_free(user_data);
908 return;
909}
910
911static void
912log_to_file (const gchar * domain G_GNUC_UNUSED__attribute__((__unused__)),
913 GLogLevelFlags level G_GNUC_UNUSED__attribute__((__unused__)),
914 const gchar * message,
915 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
916{
917 if (log_file == NULL((void*)0)) {
918 GError * error = NULL((void*)0);
919 gchar * filename = g_build_filename(g_get_user_cache_dir(), LOG_FILE_NAME"indicator-applet.log", NULL((void*)0));
920 GFile * file = g_file_new_for_path(filename);
921 g_free(filename);
922
923 if (!g_file_test(g_get_user_cache_dir(), G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) {
924 GFile * cachedir = g_file_new_for_path(g_get_user_cache_dir());
925 g_file_make_directory_with_parents(cachedir, NULL((void*)0), &error);
926
927 if (error != NULL((void*)0)) {
928 g_error("Unable to make directory '%s' for log file: %s", g_get_user_cache_dir(), error->message);
929 return;
This statement is never executed
930 }
931 }
932
933 g_file_delete(file, NULL((void*)0), NULL((void*)0));
934
935 GFileIOStream * io = g_file_create_readwrite(file,
936 G_FILE_CREATE_REPLACE_DESTINATION, /* flags */
937 NULL((void*)0), /* cancelable */
938 &error); /* error */
939 if (error != NULL((void*)0)) {
940 g_error("Unable to replace file: %s", error->message);
941 return;
942 }
943
944 log_file = g_io_stream_get_output_stream(G_IO_STREAM(io)((((GIOStream*) g_type_check_instance_cast ((GTypeInstance*) (
(io)), ((g_io_stream_get_type ()))))))
);
945 }
946
947 gchar * outputstring = g_strdup_printf("%s\n", message);
948 g_output_stream_write_async(log_file,
949 outputstring, /* data */
950 strlen(outputstring), /* length */
951 G_PRIORITY_LOW300, /* priority */
952 NULL((void*)0), /* cancelable */
953 log_to_file_cb, /* callback */
954 outputstring); /* data */
955
956 return;
957}
958
959static gboolean
960applet_fill_cb (MatePanelApplet * applet, const gchar * iid G_GNUC_UNUSED__attribute__((__unused__)),
961 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
962{
963#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
964 ido_init();
965#endif
966
967 static const GtkActionEntry menu_actions[] = {
968 {"About", GTK_STOCK_ABOUT((GtkStock)"gtk-about"), N_("_About")"_About", NULL((void*)0), NULL((void*)0), G_CALLBACK(about_cb)((GCallback) (about_cb))}
969 };
970 static const gchar *menu_xml = "<menuitem name=\"About\" action=\"About\"/>";
971
972 static gboolean first_time = FALSE(0);
973 GtkWidget *menubar;
974 gint indicators_loaded = 0;
975 GtkActionGroup *action_group;
976
977 if (!first_time)
978 {
979 first_time = TRUE(!(0));
980#ifdef INDICATOR_APPLET1
981 g_set_application_name(_("Indicator Applet")dcgettext (((void*)0), "Indicator Applet", 5));
982#endif
983#ifdef INDICATOR_APPLET_COMPLETE
984 g_set_application_name(_("Indicator Applet Complete")dcgettext (((void*)0), "Indicator Applet Complete", 5));
985#endif
986#ifdef INDICATOR_APPLET_APPMENU
987 g_set_application_name(_("Indicator Applet Application Menu")dcgettext (((void*)0), "Indicator Applet Application Menu", 5
)
);
988#endif
989
990 g_log_set_default_handler(log_to_file, NULL((void*)0));
991
992 tomboy_keybinder_init();
993 }
994
995 /* Set panel options */
996 gtk_container_set_border_width(GTK_CONTAINER (applet)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_container_get_type ()))))))
, 0);
997 mate_panel_applet_set_flags(applet, MATE_PANEL_APPLET_EXPAND_MINOR);
998 menubar = gtk_menu_bar_new();
999 action_group = gtk_action_group_new ("Indicator Applet Actions");
1000 gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE"mate-indicator-applet");
1001 gtk_action_group_add_actions (action_group, menu_actions,
1002 G_N_ELEMENTS (menu_actions)(sizeof (menu_actions) / sizeof ((menu_actions)[0])),
1003 menubar);
1004 mate_panel_applet_setup_menu(applet, menu_xml, action_group);
1005 g_object_unref(action_group);
1006#ifdef INDICATOR_APPLET1
1007 atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
),
1008 "indicator-applet");
1009#endif
1010#ifdef INDICATOR_APPLET_COMPLETE
1011 atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
),
1012 "indicator-applet-complete");
1013#endif
1014#ifdef INDICATOR_APPLET_APPMENU
1015 atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
),
1016 "indicator-applet-appmenu");
1017#endif
1018
1019 /* Init some theme/icon stuff */
1020 gtk_icon_theme_append_search_path(gtk_icon_theme_get_default(),
1021 INDICATOR_ICONS_DIR"/usr/share/libindicator/icons/");
1022 /* g_debug("Icons directory: %s", INDICATOR_ICONS_DIR); */
1023 gtk_widget_set_name(GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
, "fast-user-switch-applet");
1024
1025 /* Build menubar */
1026 size = (mate_panel_applet_get_size (applet));
1027 orient = (mate_panel_applet_get_orient(applet));
1028 packdirection = ((orient == MATE_PANEL_APPLET_ORIENT_UP) ||
1029 (orient == MATE_PANEL_APPLET_ORIENT_DOWN)) ?
1030 GTK_PACK_DIRECTION_LTR : GTK_PACK_DIRECTION_TTB;
1031 gtk_menu_bar_set_pack_direction(GTK_MENU_BAR(menubar)((((GtkMenuBar*) g_type_check_instance_cast ((GTypeInstance*)
((menubar)), ((gtk_menu_bar_get_type ()))))))
,
1032 packdirection);
1033 gtk_widget_set_can_focus (menubar, TRUE(!(0)));
1034 gtk_widget_set_name(GTK_WIDGET (menubar)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(menubar)), ((gtk_widget_get_type ()))))))
, "fast-user-switch-menubar");
1035 g_signal_connect(menubar, "button-press-event", G_CALLBACK(menubar_press), NULL)g_signal_connect_data ((menubar), ("button-press-event"), (((
GCallback) (menubar_press))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
;
1036 g_signal_connect_after(menubar, "draw", G_CALLBACK(menubar_on_draw), menubar)g_signal_connect_data ((menubar), ("draw"), (((GCallback) (menubar_on_draw
))), (menubar), ((void*)0), G_CONNECT_AFTER)
;
1037 g_signal_connect(applet, "change-orient",g_signal_connect_data ((applet), ("change-orient"), (((GCallback
) (matepanelapplet_reorient_cb))), (menubar), ((void*)0), (GConnectFlags
) 0)
1038 G_CALLBACK(matepanelapplet_reorient_cb), menubar)g_signal_connect_data ((applet), ("change-orient"), (((GCallback
) (matepanelapplet_reorient_cb))), (menubar), ((void*)0), (GConnectFlags
) 0)
;
1039 gtk_container_set_border_width(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, 0);
1040
1041 /* Add in filter func */
1042 tomboy_keybinder_bind(hotkey_keycode, hotkey_filter, menubar);
1043
1044 load_modules(applet, menubar, &indicators_loaded);
1045#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
1046 load_indicators_from_indicator_files(applet, menubar, &indicators_loaded);
1047#endif
1048
1049 if (indicators_loaded == 0) {
1050 /* A label to allow for click through */
1051 GtkWidget * item = gtk_label_new(_("No Indicators")dcgettext (((void*)0), "No Indicators", 5));
1052 mate_panel_applet_set_background_widget(applet, item);
1053 gtk_container_add(GTK_CONTAINER(applet)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_container_get_type ()))))))
, item);
1054 gtk_widget_show(item);
1055 } else {
1056 gtk_container_add(GTK_CONTAINER(applet)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_container_get_type ()))))))
, menubar);
1057 mate_panel_applet_set_background_widget(applet, menubar);
1058 gtk_widget_show(menubar);
1059 }
1060
1061 gtk_widget_show(GTK_WIDGET(applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
);
1062
1063 return TRUE(!(0));
1064
1065}
diff --git a/2020-04-09-124840-6850-1@e69dd120803f_shadow/report-2cd880.html b/2020-04-09-124840-6850-1@e69dd120803f_shadow/report-2cd880.html new file mode 100644 index 0000000..b77287c --- /dev/null +++ b/2020-04-09-124840-6850-1@e69dd120803f_shadow/report-2cd880.html @@ -0,0 +1,1412 @@ + + + +applet-main.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:applet-main.c
Warning:line 941, column 4
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name applet-main.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -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 -mrelocation-model static -mthread-model posix -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -momit-leaf-frame-pointer -resource-dir /usr/lib64/clang/9.0.1 -D HAVE_CONFIG_H -I . -I .. -D G_LOG_DOMAIN="Indicator-Applet-Appmenu" -D DATADIR="/usr/local/share" -D INDICATOR_DIR="/usr/lib64/indicators3/7/" -D INDICATOR_ICONS_DIR="/usr/share/libindicator/icons/" -D INDICATOR_APPLET_APPMENU -I ./.. -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/fribidi -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gio-unix-2.0 -I /usr/include/libdrm -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-panel-4.0/libmate-panel-applet -I /usr/include/libindicator3-0.4 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/fribidi -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gio-unix-2.0 -I /usr/include/libdrm -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/9.0.1/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wno-unused-parameter -Wno-sign-compare -fdebug-compilation-dir /rootdir/src -ferror-limit 19 -fmessage-length 0 -fobjc-runtime=gcc -fdiagnostics-show-option -vectorize-loops -vectorize-slp -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 -o /rootdir/html-report/2020-04-09-124840-6850-1 -x c applet-main.c +
+ + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2A small wrapper utility to load indicators and put them as menu items
3into the mate-panel using it's applet interface.
4
5Copyright 2009-2010 Canonical Ltd.
6
7Authors:
8 Ted Gould <ted@canonical.com>
9
10This program is free software: you can redistribute it and/or modify it
11under the terms of the GNU General Public License version 3, as published
12by the Free Software Foundation.
13
14This program is distributed in the hope that it will be useful, but
15WITHOUT ANY WARRANTY; without even the implied warranties of
16MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
17PURPOSE. See the GNU General Public License for more details.
18
19You should have received a copy of the GNU General Public License along
20with this program. If not, see <http://www.gnu.org/licenses/>.
21*/
22
23#include <stdlib.h>
24#include <string.h>
25#include <config.h>
26#include <glib/gi18n.h>
27#include <mate-panel-applet.h>
28#include <gdk/gdkkeysyms.h>
29#include <gtk/gtk.h>
30
31#if HAVE_UBUNTU_INDICATOR1
32
33#define INDICATOR_SERVICE_APPMENU"libappmenu.so" "libappmenu.so"
34#define INDICATOR_SERVICE_ME"libme.so" "libme.so"
35#define INDICATOR_SERVICE_DATETIME"libdatetime.so" "libdatetime.so"
36
37#define INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu" "com.canonical.indicator.appmenu"
38#define INDICATOR_SERVICE_ME_NG"com.canonical.indicator.me" "com.canonical.indicator.me"
39#define INDICATOR_SERVICE_DATETIME_NG"com.canonical.indicator.datetime" "com.canonical.indicator.datetime"
40
41#include <libindicator/indicator-object.h>
42#endif
43
44#if HAVE_AYATANA_INDICATOR
45
46#define INDICATOR_SERVICE_APPMENU"libappmenu.so" "libayatana-appmenu.so"
47#define INDICATOR_SERVICE_ME"libme.so" "libayatana-me.so"
48#define INDICATOR_SERVICE_DATETIME"libdatetime.so" "libayatana-datetime.so"
49
50#define INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu" "org.ayatana.indicator.appmenu"
51#define INDICATOR_SERVICE_ME_NG"com.canonical.indicator.me" "org.ayatana.indicator.me"
52#define INDICATOR_SERVICE_DATETIME_NG"com.canonical.indicator.datetime" "org.ayatana.indicator.datetime"
53
54#include <libayatana-indicator/indicator-object.h>
55#endif
56
57/* For new style indicators */
58
59#if HAVE_UBUNTU_INDICATOR1 && HAVE_UBUNTU_INDICATOR_NG
60
61#include <libido/libido.h>
62#include <libindicator/indicator-ng.h>
63
64#define INDICATOR_SERVICE_DIR "/usr/share/unity/indicators"
65
66#endif
67
68#if HAVE_AYATANA_INDICATOR && HAVE_AYATANA_INDICATOR_NG
69
70#include <libayatana-ido/libayatana-ido.h>
71#include <libayatana-indicator/indicator-ng.h>
72
73#define INDICATOR_SERVICE_DIR "/usr/share/ayatana/indicators"
74
75#endif
76
77#include "tomboykeybinder.h"
78
79static gchar * indicator_order[] = {
80#if HAVE_UBUNTU_INDICATOR1
81 "libapplication.so",
82 "libmessaging.so",
83 "libsoundmenu.so",
84 "libdatetime.so",
85 "libsession.so",
86#endif
87#if HAVE_AYATANA_INDICATOR
88 "libayatana-application.so",
89 "libayatana-messaging.so",
90 "libayatana-soundmenu.so",
91 "libayatana-datetime.so",
92 "libayatana-session.so",
93#endif
94 NULL((void*)0)
95};
96
97static GtkPackDirection packdirection;
98static MatePanelAppletOrient orient;
99static guint size;
100
101#define MENU_DATA_INDICATOR_OBJECT"indicator-object" "indicator-object"
102#define MENU_DATA_INDICATOR_ENTRY"indicator-entry" "indicator-entry"
103
104#define IO_DATA_ORDER_NUMBER"indicator-order-number" "indicator-order-number"
105
106static gboolean applet_fill_cb (MatePanelApplet * applet, const gchar * iid, gpointer data);
107
108static void update_accessible_desc (IndicatorObjectEntry * entry, GtkWidget * menuitem);
109
110/*************
111 * main
112 * ***********/
113
114#ifdef INDICATOR_APPLET
115MATE_PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletFactory",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
116 PANEL_TYPE_APPLET,int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
117 "indicator-applet",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
118 applet_fill_cb, NULL)int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
;
119#endif
120#ifdef INDICATOR_APPLET_COMPLETE
121MATE_PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletCompleteFactory",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
122 PANEL_TYPE_APPLET,int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
123 "indicator-applet-complete",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
124 applet_fill_cb, NULL)int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
;
125#endif
126#ifdef INDICATOR_APPLET_APPMENU1
127MATE_PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletAppmenuFactory",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
128 PANEL_TYPE_APPLET,int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
129 "indicator-applet-appmenu",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
130 applet_fill_cb, NULL)int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
;
131#endif
132
133/*************
134 * log files
135 * ***********/
136#ifdef INDICATOR_APPLET
137#define LOG_FILE_NAME"indicator-applet-appmenu.log" "indicator-applet.log"
138#endif
139#ifdef INDICATOR_APPLET_COMPLETE
140#define LOG_FILE_NAME"indicator-applet-appmenu.log" "indicator-applet-complete.log"
141#endif
142#ifdef INDICATOR_APPLET_APPMENU1
143#define LOG_FILE_NAME"indicator-applet-appmenu.log" "indicator-applet-appmenu.log"
144#endif
145GOutputStream * log_file = NULL((void*)0);
146
147/*****************
148 * Hotkey support
149 * **************/
150#ifdef INDICATOR_APPLET
151gchar * hotkey_keycode = "<Super>M";
152#endif
153#ifdef INDICATOR_APPLET_SESSION
154gchar * hotkey_keycode = "<Super>S";
155#endif
156#ifdef INDICATOR_APPLET_COMPLETE
157gchar * hotkey_keycode = "<Super>S";
158#endif
159#ifdef INDICATOR_APPLET_APPMENU1
160gchar * hotkey_keycode = "<Super>F1";
161#endif
162
163/********************
164 * Environment Names
165 * *******************/
166#ifdef INDICATOR_APPLET
167#define INDICATOR_SPECIFIC_ENV"indicator-applet-appmenu" "indicator-applet-original"
168#endif
169#ifdef INDICATOR_APPLET_COMPLETE
170#define INDICATOR_SPECIFIC_ENV"indicator-applet-appmenu" "indicator-applet-complete"
171#endif
172#ifdef INDICATOR_APPLET_APPMENU1
173#define INDICATOR_SPECIFIC_ENV"indicator-applet-appmenu" "indicator-applet-appmenu"
174#endif
175
176static const gchar * indicator_env[] = {
177 "indicator-applet",
178 INDICATOR_SPECIFIC_ENV"indicator-applet-appmenu",
179 NULL((void*)0)
180};
181
182/*************
183 * init function
184 * ***********/
185
186static gint
187name2order (const gchar * name) {
188 int i;
189
190 for (i = 0; indicator_order[i] != NULL((void*)0); i++) {
191 if (g_strcmp0(name, indicator_order[i]) == 0) {
192 return i;
193 }
194 }
195
196 return -1;
197}
198
199typedef struct _incoming_position_t incoming_position_t;
200struct _incoming_position_t {
201 gint objposition;
202 gint entryposition;
203 gint menupos;
204 gboolean found;
205};
206
207/* This function helps by determining where in the menu list
208 this new entry should be placed. It compares the objects
209 that they're on, and then the individual entries. Each
210 is progressively more expensive. */
211static void
212place_in_menu (GtkWidget * widget, gpointer user_data)
213{
214 incoming_position_t * position = (incoming_position_t *)user_data;
215 if (position->found) {
216 /* We've already been placed, just finish the foreach */
217 return;
218 }
219
220 IndicatorObject * io = INDICATOR_OBJECT(g_object_get_data(G_OBJECT(widget), MENU_DATA_INDICATOR_OBJECT))((((IndicatorObject*) g_type_check_instance_cast ((GTypeInstance
*) ((g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((widget)), (((GType) ((20) << (2)))
))))), "indicator-object"))), ((indicator_object_get_type ())
)))))
;
221 g_assert(io != NULL)do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_
; if (io != ((void*)0)) _g_boolean_var_ = 1; else _g_boolean_var_
= 0; _g_boolean_var_; }), 1)) ; else g_assertion_message_expr
("Indicator-Applet-Appmenu", "applet-main.c", 221, ((const char
*) (__func__)), "io != NULL"); } while (0)
;
222
223 gint objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER))((gint) (glong) (g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
), "indicator-order-number")))
;
224 /* We've already passed it, well, then this is where
225 we should be be. Stop! */
226 if (objposition > position->objposition) {
227 position->found = TRUE(!(0));
228 return;
229 }
230
231 /* The objects don't match yet, keep looking */
232 if (objposition < position->objposition) {
233 position->menupos++;
234 return;
235 }
236
237 /* The objects are the same, let's start looking at entries. */
238 IndicatorObjectEntry * entry = (IndicatorObjectEntry *)g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
239 gint entryposition = indicator_object_get_location(io, entry);
240
241 if (entryposition > position->entryposition) {
242 position->found = TRUE(!(0));
243 return;
244 }
245
246 if (entryposition < position->entryposition) {
247 position->menupos++;
248 return;
249 }
250
251 /* We've got the same object and the same entry. Well,
252 let's just put it right here then. */
253 position->found = TRUE(!(0));
254 return;
255}
256
257static void
258something_shown (GtkWidget * widget, gpointer user_data)
259{
260 GtkWidget * menuitem = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
261 gtk_widget_show(menuitem);
262}
263
264static void
265something_hidden (GtkWidget * widget, gpointer user_data)
266{
267 GtkWidget * menuitem = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
268 gtk_widget_hide(menuitem);
269}
270
271static void
272sensitive_cb (GObject * obj, GParamSpec * pspec, gpointer user_data)
273{
274 g_return_if_fail(GTK_IS_WIDGET(obj))do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((obj)); GType __t = ((gtk_widget_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet-Appmenu",
((const char*) (__func__)), "GTK_IS_WIDGET(obj)"); return; }
} while (0)
;
275 g_return_if_fail(GTK_IS_WIDGET(user_data))do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((gtk_widget_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet-Appmenu",
((const char*) (__func__)), "GTK_IS_WIDGET(user_data)"); return
; } } while (0)
;
276
277 gtk_widget_set_sensitive(GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
, gtk_widget_get_sensitive(GTK_WIDGET(obj)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(obj)), ((gtk_widget_get_type ()))))))
));
278 return;
279}
280
281static void
282entry_activated (GtkWidget * widget, gpointer user_data)
283{
284 g_return_if_fail(GTK_IS_WIDGET(widget))do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((gtk_widget_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet-Appmenu",
((const char*) (__func__)), "GTK_IS_WIDGET(widget)"); return
; } } while (0)
;
285 gpointer pio = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, "indicator");
286 g_return_if_fail(INDICATOR_IS_OBJECT(pio))do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((pio)); GType __t = ((indicator_object_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet-Appmenu",
((const char*) (__func__)), "INDICATOR_IS_OBJECT(pio)"); return
; } } while (0)
;
287 IndicatorObject * io = INDICATOR_OBJECT(pio)((((IndicatorObject*) g_type_check_instance_cast ((GTypeInstance
*) ((pio)), ((indicator_object_get_type ()))))))
;
288
289 return indicator_object_entry_activate(io, (IndicatorObjectEntry *)user_data, gtk_get_current_event_time());
290}
291
292static gboolean
293entry_scrolled (GtkWidget *menuitem, GdkEventScroll *event, gpointer data)
294{
295 IndicatorObject *io = g_object_get_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_OBJECT"indicator-object");
296 IndicatorObjectEntry *entry = g_object_get_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
297
298 g_return_val_if_fail(INDICATOR_IS_OBJECT(io), FALSE)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((io)); GType __t = ((indicator_object_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet-Appmenu",
((const char*) (__func__)), "INDICATOR_IS_OBJECT(io)"); return
((0)); } } while (0)
;
299
300 g_signal_emit_by_name (io, "scroll", 1, event->direction);
301 g_signal_emit_by_name (io, "scroll-entry", entry, 1, event->direction);
302 g_signal_emit_by_name (io, INDICATOR_OBJECT_SIGNAL_ENTRY_SCROLLED"entry-scrolled", entry, 1, event->direction);
303
304 return FALSE(0);
305}
306
307static void
308accessible_desc_update_cb (GtkWidget * widget, gpointer userdata)
309{
310 gpointer data = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
311
312 if (data != userdata) {
313 return;
314 }
315
316 IndicatorObjectEntry * entry = (IndicatorObjectEntry *)data;
317 update_accessible_desc(entry, widget);
318}
319
320static void
321accessible_desc_update (IndicatorObject * io, IndicatorObjectEntry * entry, GtkWidget * menubar)
322{
323 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, accessible_desc_update_cb, entry);
324 return;
325}
326
327#define PANEL_PADDING8 8
328static gboolean
329entry_resized (GtkWidget *applet, guint newsize, gpointer data)
330{
331 IndicatorObject *io = (IndicatorObject *)data;
332
333 size = newsize;
334
335 /* Work on the entries */
336 GList * entries = indicator_object_get_entries(io);
337 GList * entry = NULL((void*)0);
338
339 for (entry = entries; entry != NULL((void*)0); entry = g_list_next(entry)((entry) ? (((GList *)(entry))->next) : ((void*)0))) {
340 IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)entry->data;
341 if (entrydata->image != NULL((void*)0)) {
342 /* Resize to fit panel */
343 gtk_image_set_pixel_size (entrydata->image, size - PANEL_PADDING8);
344 }
345 }
346
347 return FALSE(0);
348}
349
350static void
351entry_added (IndicatorObject * io, IndicatorObjectEntry * entry, GtkWidget * menubar)
352{
353 g_debug("Signal: Entry Added");
354 gboolean something_visible = FALSE(0);
355 gboolean something_sensitive = FALSE(0);
356
357 GtkWidget * menuitem = gtk_menu_item_new();
358 GtkWidget * box = (packdirection == GTK_PACK_DIRECTION_LTR) ?
359 gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3) : gtk_box_new(GTK_ORIENTATION_VERTICAL, 3);
360
361 /* Allows indicators to receive mouse scroll event */
362 gtk_widget_add_events(GTK_WIDGET(menuitem)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(menuitem)), ((gtk_widget_get_type ()))))))
, GDK_SCROLL_MASK);
363
364 g_object_set_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "indicator", io);
365 g_object_set_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "box", box);
366
367 g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(entry_activated), entry)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((menuitem)), (((GType) ((20) << (2)
)))))))), ("activate"), (((GCallback) (entry_activated))), (entry
), ((void*)0), (GConnectFlags) 0)
;
368 g_signal_connect(G_OBJECT(menuitem), "scroll-event", G_CALLBACK(entry_scrolled), entry)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((menuitem)), (((GType) ((20) << (2)
)))))))), ("scroll-event"), (((GCallback) (entry_scrolled))),
(entry), ((void*)0), (GConnectFlags) 0)
;
369
370 if (entry->image != NULL((void*)0)) {
371 /* Resize to fit panel */
372 gtk_image_set_pixel_size (entry->image, size - PANEL_PADDING8);
373 gtk_box_pack_start(GTK_BOX(box)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((box
)), ((gtk_box_get_type ()))))))
, GTK_WIDGET(entry->image)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->image)), ((gtk_widget_get_type ()))))))
, FALSE(0), FALSE(0), 1);
374 if (gtk_widget_get_visible(GTK_WIDGET(entry->image)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->image)), ((gtk_widget_get_type ()))))))
)) {
375 something_visible = TRUE(!(0));
376 }
377
378 if (gtk_widget_get_sensitive(GTK_WIDGET(entry->image)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->image)), ((gtk_widget_get_type ()))))))
)) {
379 something_sensitive = TRUE(!(0));
380 }
381
382 g_signal_connect(G_OBJECT(entry->image), "show", G_CALLBACK(something_shown), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), ("show"), (((GCallback) (something_shown))), (menuitem
), ((void*)0), (GConnectFlags) 0)
;
383 g_signal_connect(G_OBJECT(entry->image), "hide", G_CALLBACK(something_hidden), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), ("hide"), (((GCallback) (something_hidden))), (
menuitem), ((void*)0), (GConnectFlags) 0)
;
384
385 g_signal_connect(G_OBJECT(entry->image), "notify::sensitive", G_CALLBACK(sensitive_cb), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), ("notify::sensitive"), (((GCallback) (sensitive_cb
))), (menuitem), ((void*)0), (GConnectFlags) 0)
;
386 }
387 if (entry->label != NULL((void*)0)) {
388 switch(packdirection) {
389 case GTK_PACK_DIRECTION_LTR:
390 gtk_label_set_angle(GTK_LABEL(entry->label)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_label_get_type ()))))))
, 0.0);
391 break;
392 case GTK_PACK_DIRECTION_TTB:
393 gtk_label_set_angle(GTK_LABEL(entry->label)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_label_get_type ()))))))
,
394 (orient == MATE_PANEL_APPLET_ORIENT_LEFT) ?
395 270.0 : 90.0);
396 break;
397 default:
398 break;
399 }
400 gtk_box_pack_start(GTK_BOX(box)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((box
)), ((gtk_box_get_type ()))))))
, GTK_WIDGET(entry->label)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_widget_get_type ()))))))
, FALSE(0), FALSE(0), 1);
401
402 if (gtk_widget_get_visible(GTK_WIDGET(entry->label)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_widget_get_type ()))))))
)) {
403 something_visible = TRUE(!(0));
404 }
405
406 if (gtk_widget_get_sensitive(GTK_WIDGET(entry->label)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_widget_get_type ()))))))
)) {
407 something_sensitive = TRUE(!(0));
408 }
409
410 g_signal_connect(G_OBJECT(entry->label), "show", G_CALLBACK(something_shown), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), ("show"), (((GCallback) (something_shown))), (menuitem
), ((void*)0), (GConnectFlags) 0)
;
411 g_signal_connect(G_OBJECT(entry->label), "hide", G_CALLBACK(something_hidden), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), ("hide"), (((GCallback) (something_hidden))), (
menuitem), ((void*)0), (GConnectFlags) 0)
;
412
413 g_signal_connect(G_OBJECT(entry->label), "notify::sensitive", G_CALLBACK(sensitive_cb), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), ("notify::sensitive"), (((GCallback) (sensitive_cb
))), (menuitem), ((void*)0), (GConnectFlags) 0)
;
414 }
415 gtk_container_add(GTK_CONTAINER(menuitem)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menuitem)), ((gtk_container_get_type ()))))))
, box);
416 gtk_widget_show(box);
417
418 if (entry->menu != NULL((void*)0)) {
419 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem)((((GtkMenuItem*) g_type_check_instance_cast ((GTypeInstance*
) ((menuitem)), ((gtk_menu_item_get_type ()))))))
, GTK_WIDGET(entry->menu)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->menu)), ((gtk_widget_get_type ()))))))
);
420 }
421
422 incoming_position_t position;
423 position.objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER))((gint) (glong) (g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
), "indicator-order-number")))
;
424 position.entryposition = indicator_object_get_location(io, entry);
425 position.menupos = 0;
426 position.found = FALSE(0);
427
428 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, place_in_menu, &position);
429
430 gtk_menu_shell_insert(GTK_MENU_SHELL(menubar)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_menu_shell_get_type ()))))))
, menuitem, position.menupos);
431
432 if (something_visible) {
433 if (entry->accessible_desc != NULL((void*)0)) {
434 update_accessible_desc(entry, menuitem);
435 }
436 gtk_widget_show(menuitem);
437 }
438 gtk_widget_set_sensitive(menuitem, something_sensitive);
439
440 g_object_set_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry", entry);
441 g_object_set_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_OBJECT"indicator-object", io);
442
443 return;
444}
445
446static void
447entry_removed_cb (GtkWidget * widget, gpointer userdata)
448{
449 gpointer data = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
450
451 if (data != userdata) {
452 return;
453 }
454
455 IndicatorObjectEntry * entry = (IndicatorObjectEntry *)data;
456 if (entry->label != NULL((void*)0)) {
457 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(something_shown), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_shown))), (widget
))
;
458 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(something_hidden), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_hidden))), (widget
))
;
459 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(sensitive_cb), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (sensitive_cb))), (widget)
)
;
460 }
461 if (entry->image != NULL((void*)0)) {
462 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(something_shown), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_shown))), (widget
))
;
463 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(something_hidden), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_hidden))), (widget
))
;
464 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(sensitive_cb), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (sensitive_cb))), (widget)
)
;
465 }
466
467 gtk_widget_destroy(widget);
468 return;
469}
470
471static void
472entry_removed (IndicatorObject * io G_GNUC_UNUSED__attribute__((__unused__)), IndicatorObjectEntry * entry,
473 gpointer user_data)
474{
475 g_debug("Signal: Entry Removed");
476
477 gtk_container_foreach(GTK_CONTAINER(user_data)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((gtk_container_get_type ()))))))
, entry_removed_cb, entry);
478
479 return;
480}
481
482static void
483entry_moved_find_cb (GtkWidget * widget, gpointer userdata)
484{
485 gpointer * array = (gpointer *)userdata;
486 if (array[1] != NULL((void*)0)) {
487 return;
488 }
489
490 gpointer data = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
491
492 if (data != array[0]) {
493 return;
494 }
495
496 array[1] = widget;
497 return;
498}
499
500/* Gets called when an entry for an object was moved. */
501static void
502entry_moved (IndicatorObject * io, IndicatorObjectEntry * entry,
503 gint old G_GNUC_UNUSED__attribute__((__unused__)), gint new G_GNUC_UNUSED__attribute__((__unused__)), gpointer user_data)
504{
505 GtkWidget * menubar = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
506
507 gpointer array[2];
508 array[0] = entry;
509 array[1] = NULL((void*)0);
510
511 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, entry_moved_find_cb, array);
512 if (array[1] == NULL((void*)0)) {
513 g_warning("Moving an entry that isn't in our menus.");
514 return;
515 }
516
517 GtkWidget * mi = GTK_WIDGET(array[1])((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(array[1])), ((gtk_widget_get_type ()))))))
;
518 g_object_ref(G_OBJECT(mi)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
mi)), (((GType) ((20) << (2))))))))
);
519 gtk_container_remove(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, mi);
520
521 incoming_position_t position;
522 position.objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER))((gint) (glong) (g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
), "indicator-order-number")))
;
523 position.entryposition = indicator_object_get_location(io, entry);
524 position.menupos = 0;
525 position.found = FALSE(0);
526
527 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, place_in_menu, &position);
528
529 gtk_menu_shell_insert(GTK_MENU_SHELL(menubar)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_menu_shell_get_type ()))))))
, mi, position.menupos);
530 g_object_unref(G_OBJECT(mi)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
mi)), (((GType) ((20) << (2))))))))
);
531
532 return;
533}
534
535static void
536menu_show (IndicatorObject * io, IndicatorObjectEntry * entry,
537 guint32 timestamp, gpointer user_data)
538{
539 GtkWidget * menubar = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
540
541 if (entry == NULL((void*)0)) {
542 /* Close any open menus instead of opening one */
543 GList * entries = indicator_object_get_entries(io);
544 GList * iterator = NULL((void*)0);
545 for (iterator = entries; iterator != NULL((void*)0); iterator = g_list_next(iterator)((iterator) ? (((GList *)(iterator))->next) : ((void*)0))) {
546 IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)iterator->data;
547 gtk_menu_popdown(entrydata->menu);
548 }
549 g_list_free(entries);
550
551 /* And tell the menubar to exit activation mode too */
552 gtk_menu_shell_cancel(GTK_MENU_SHELL(menubar)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_menu_shell_get_type ()))))))
);
553 return;
554 }
555
556 // TODO: do something sensible here
557}
558
559static void
560update_accessible_desc(IndicatorObjectEntry * entry, GtkWidget * menuitem)
561{
562 /* FIXME: We need to deal with the use case where the contents of the
563 label overrides what is found in the atk object's name, or at least
564 orca speaks the label instead of the atk object name.
565 */
566 AtkObject * menuitem_obj = gtk_widget_get_accessible(menuitem);
567 if (menuitem_obj == NULL((void*)0)) {
568 /* Should there be an error printed here? */
569 return;
570 }
571
572 if (entry->accessible_desc != NULL((void*)0)) {
573 atk_object_set_name(menuitem_obj, entry->accessible_desc);
574 } else {
575 atk_object_set_name(menuitem_obj, "");
576 }
577 return;
578}
579
580static void
581load_indicator (MatePanelApplet *applet, GtkWidget * menubar, IndicatorObject *io, const gchar *name)
582{
583 /* Set the environment it's in */
584 indicator_object_set_environment(io, (const GStrv)indicator_env);
585
586 /* Attach the 'name' to the object */
587#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
588 int pos = 5000 - indicator_object_get_position(io);
589 if (pos > 5000) {
590 pos = name2order(name);
591 }
592#else
593 int pos = name2order(name);
594#endif
595
596 g_object_set_data(G_OBJECT(io)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
io)), (((GType) ((20) << (2))))))))
, IO_DATA_ORDER_NUMBER"indicator-order-number", GINT_TO_POINTER(pos)((gpointer) (glong) (pos)));
597
598 /* Connect to its signals */
599 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED, G_CALLBACK(entry_added), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("entry-added"), (((GCallback) (entry_added))), (menubar)
, ((void*)0), (GConnectFlags) 0)
;
600 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED, G_CALLBACK(entry_removed), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("entry-removed"), (((GCallback) (entry_removed))), (menubar
), ((void*)0), (GConnectFlags) 0)
;
601 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_MOVED, G_CALLBACK(entry_moved), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("entry-moved"), (((GCallback) (entry_moved))), (menubar)
, ((void*)0), (GConnectFlags) 0)
;
602 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_MENU_SHOW, G_CALLBACK(menu_show), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("menu-show"), (((GCallback) (menu_show))), (menubar), ((
void*)0), (GConnectFlags) 0)
;
603 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ACCESSIBLE_DESC_UPDATE, G_CALLBACK(accessible_desc_update), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("accessible-desc-update"), (((GCallback) (accessible_desc_update
))), (menubar), ((void*)0), (GConnectFlags) 0)
;
604
605 /* Track panel resize */
606 g_signal_connect_object(G_OBJECT(applet)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
applet)), (((GType) ((20) << (2))))))))
, "change-size", G_CALLBACK(entry_resized)((GCallback) (entry_resized)), G_OBJECT(io)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
io)), (((GType) ((20) << (2))))))))
, 0);
607
608 /* Work on the entries */
609 GList * entries = indicator_object_get_entries(io);
610 GList * entry = NULL((void*)0);
611
612 for (entry = entries; entry != NULL((void*)0); entry = g_list_next(entry)((entry) ? (((GList *)(entry))->next) : ((void*)0))) {
613 IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)entry->data;
614 entry_added(io, entrydata, menubar);
615 }
616
617 g_list_free(entries);
618}
619
620static gboolean
621load_module (const gchar * name, MatePanelApplet *applet, GtkWidget * menubar)
622{
623 g_debug("Looking at Module: %s", name);
624 g_return_val_if_fail(name != NULL, FALSE)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if (name != ((void*)0)) _g_boolean_var_ = 1; else _g_boolean_var_
= 0; _g_boolean_var_; }), 1))) { } else { g_return_if_fail_warning
("Indicator-Applet-Appmenu", ((const char*) (__func__)), "name != NULL"
); return ((0)); } } while (0)
;
625
626 if (!g_str_has_suffix(name, G_MODULE_SUFFIX"so")) {
627 return FALSE(0);
628 }
629
630 g_debug("Loading Module: %s", name);
631
632 /* Build the object for the module */
633 gchar * fullpath = g_build_filename(INDICATOR_DIR"/usr/lib64/indicators3/7/", name, NULL((void*)0));
634 IndicatorObject * io = indicator_object_new_from_file(fullpath);
635 g_free(fullpath);
636
637 load_indicator(applet, menubar, io, name);
638
639 return TRUE(!(0));
640}
641
642static void
643load_modules (MatePanelApplet *applet, GtkWidget *menubar, gint *indicators_loaded)
644{
645 if (g_file_test(INDICATOR_DIR"/usr/lib64/indicators3/7/", (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))) {
646 GDir * dir = g_dir_open(INDICATOR_DIR"/usr/lib64/indicators3/7/", 0, NULL((void*)0));
647
648 const gchar * name;
649 gint count = 0;
650 while ((name = g_dir_read_name(dir)) != NULL((void*)0)) {
651#ifdef INDICATOR_APPLET_APPMENU1
652 if (g_strcmp0(name, INDICATOR_SERVICE_APPMENU"libappmenu.so")) {
653 continue;
654 }
655#else
656 if (!g_strcmp0(name, INDICATOR_SERVICE_APPMENU"libappmenu.so")) {
657 continue;
658 }
659#endif
660#ifdef INDICATOR_APPLET
661 if (!g_strcmp0(name, INDICATOR_SERVICE_ME"libme.so")) {
662 continue;
663 }
664 if (!g_strcmp0(name, INDICATOR_SERVICE_DATETIME"libdatetime.so")) {
665 continue;
666 }
667#endif
668 if (load_module(name, applet, menubar)) {
669 count++;
670 }
671 }
672
673 *indicators_loaded += count;
674
675 g_dir_close (dir);
676 }
677}
678
679#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
680
681static void
682load_indicators_from_indicator_files (MatePanelApplet *applet, GtkWidget *menubar, gint *indicators_loaded)
683{
684 GDir *dir;
685 const gchar *name;
686 GError *error = NULL((void*)0);
687
688 dir = g_dir_open (INDICATOR_SERVICE_DIR, 0, &error);
689
690 if (!dir) {
691 g_warning ("unable to open indicator service file directory: %s", error->message);
692 g_error_free (error);
693
694 return;
695 }
696
697 gint count = 0;
698 while ((name = g_dir_read_name (dir))) {
699 gchar *filename;
700 IndicatorNg *indicator;
701
702 filename = g_build_filename (INDICATOR_SERVICE_DIR, name, NULL((void*)0));
703 indicator = indicator_ng_new_for_profile (filename, "desktop", &error);
704 g_free (filename);
705
706#ifdef INDICATOR_APPLET_APPMENU1
707 if (g_strcmp0(name, INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu")) {
708 continue;
709 }
710#else
711 if (!g_strcmp0(name, INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu")) {
712 continue;
713 }
714#endif
715#ifdef INDICATOR_APPLET
716 if (!g_strcmp0(name, INDICATOR_SERVICE_ME_NG"com.canonical.indicator.me")) {
717 continue;
718 }
719 if (!g_strcmp0(name, INDICATOR_SERVICE_DATETIME_NG"com.canonical.indicator.datetime")) {
720 continue;
721 }
722#endif
723
724 if (indicator) {
725 load_indicator(applet, menubar, INDICATOR_OBJECT (indicator)((((IndicatorObject*) g_type_check_instance_cast ((GTypeInstance
*) ((indicator)), ((indicator_object_get_type ()))))))
, name);
726 count++;
727 }else{
728 g_warning ("unable to load '%s': %s", name, error->message);
729 g_clear_error (&error);
730 }
731 }
732
733 *indicators_loaded += count;
734
735 g_dir_close (dir);
736}
737#endif /* HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG */
738
739static void
740hotkey_filter (char * keystring G_GNUC_UNUSED__attribute__((__unused__)), gpointer data)
741{
742 g_return_if_fail(GTK_IS_MENU_SHELL(data))do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((data)); GType __t = ((gtk_menu_shell_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet-Appmenu",
((const char*) (__func__)), "GTK_IS_MENU_SHELL(data)"); return
; } } while (0)
;
743
744 /* Oh, wow, it's us! */
745 GList * children = gtk_container_get_children(GTK_CONTAINER(data)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((gtk_container_get_type ()))))))
);
746 if (children == NULL((void*)0)) {
747 g_debug("Menubar has no children");
748 return;
749 }
750
751 gtk_menu_shell_select_item(GTK_MENU_SHELL(data)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((gtk_menu_shell_get_type ()))))))
, GTK_WIDGET(g_list_last(children)->data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(g_list_last(children)->data)), ((gtk_widget_get_type ()))
))))
);
752 g_list_free(children);
753 return;
754}
755
756static gboolean
757menubar_press (GtkWidget * widget,
758 GdkEventButton *event,
759 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
760{
761 if (event->button != 1) {
762 g_signal_stop_emission_by_name(widget, "button-press-event");
763 }
764
765 return FALSE(0);
766}
767
768static gboolean
769menubar_on_draw (GtkWidget * widget,
770 cairo_t * cr,
771 GtkWidget * menubar)
772{
773 /* FIXME: either port to gtk_render_focus or remove this function */
774 if (gtk_widget_has_focus(menubar))
775 gtk_paint_focus(gtk_widget_get_style(widget),
776 cr,
777 gtk_widget_get_state(menubar),
778 widget, "menubar-applet", 0, 0, -1, -1);
779
780 return FALSE(0);
781}
782
783static void
784about_cb (GtkAction *action G_GNUC_UNUSED__attribute__((__unused__)),
785 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
786{
787 static const gchar *authors[] = {
788 "Ted Gould <ted@canonical.com>",
789 NULL((void*)0)
790 };
791
792 static gchar *license[] = {
793 N_("This program is free software: you can redistribute it and/or modify it ""This program is free software: you can redistribute it and/or modify it "
"under the terms of the GNU General Public License version 3, as published "
"by the Free Software Foundation."
794 "under the terms of the GNU General Public License version 3, as published ""This program is free software: you can redistribute it and/or modify it "
"under the terms of the GNU General Public License version 3, as published "
"by the Free Software Foundation."
795 "by the Free Software Foundation.")"This program is free software: you can redistribute it and/or modify it "
"under the terms of the GNU General Public License version 3, as published "
"by the Free Software Foundation."
,
796 N_("This program is distributed in the hope that it will be useful, but ""This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
797 "WITHOUT ANY WARRANTY; without even the implied warranties of ""This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
798 "MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR ""This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
799 "PURPOSE. See the GNU General Public License for more details.")"This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
,
800 N_("You should have received a copy of the GNU General Public License along ""You should have received a copy of the GNU General Public License along "
"with this program. If not, see <http://www.gnu.org/licenses/>."
801 "with this program. If not, see <http://www.gnu.org/licenses/>.")"You should have received a copy of the GNU General Public License along "
"with this program. If not, see <http://www.gnu.org/licenses/>."
,
802 NULL((void*)0)
803 };
804 gchar *license_i18n;
805
806 license_i18n = g_strconcat (_(license[0])dcgettext (((void*)0), license[0], 5), "\n\n", _(license[1])dcgettext (((void*)0), license[1], 5), "\n\n", _(license[2])dcgettext (((void*)0), license[2], 5), NULL((void*)0));
807
808 gtk_show_about_dialog(NULL((void*)0),
809 "version", VERSION"1.24.0",
810 "copyright", _("Copyright \xc2\xa9 2009-2010 Canonical, Ltd.\n"dcgettext (((void*)0), "Copyright \xc2\xa9 2009-2010 Canonical, Ltd.\n"
"Copyright \xc2\xa9 2011-2020 MATE developers", 5)
811 "Copyright \xc2\xa9 2011-2020 MATE developers")dcgettext (((void*)0), "Copyright \xc2\xa9 2009-2010 Canonical, Ltd.\n"
"Copyright \xc2\xa9 2011-2020 MATE developers", 5)
,
812#ifdef INDICATOR_APPLET_APPMENU1
813 "comments", _("An applet to hold your application menus.")dcgettext (((void*)0), "An applet to hold your application menus."
, 5)
,
814#endif
815 "comments", _("An applet to hold all of the system indicators.")dcgettext (((void*)0), "An applet to hold all of the system indicators."
, 5)
,
816 "authors", authors,
817 "license", license_i18n,
818 "wrap-license", TRUE(!(0)),
819 "translator-credits", _("translator-credits")dcgettext (((void*)0), "translator-credits", 5),
820 "logo-icon-name", "mate-indicator-applet",
821 "icon-name", "mate-indicator-applet",
822 "website", "https://mate-desktop.org",
823 "website-label", _("MATE Website")dcgettext (((void*)0), "MATE Website", 5),
824 NULL((void*)0)
825 );
826
827 g_free (license_i18n);
828
829 return;
830}
831
832static gboolean
833swap_orient_cb (GtkWidget *item, gpointer data)
834{
835 GtkWidget *from = (GtkWidget *) data;
836 GtkWidget *to = (GtkWidget *) g_object_get_data(G_OBJECT(from)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
from)), (((GType) ((20) << (2))))))))
, "to");
837 g_object_ref(G_OBJECT(item)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
item)), (((GType) ((20) << (2))))))))
);
838 gtk_container_remove(GTK_CONTAINER(from)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((from)), ((gtk_container_get_type ()))))))
, item);
839 if (GTK_IS_LABEL(item)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(item)); GType __t = ((gtk_label_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; }))))
) {
840 switch(packdirection) {
841 case GTK_PACK_DIRECTION_LTR:
842 gtk_label_set_angle(GTK_LABEL(item)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(item)), ((gtk_label_get_type ()))))))
, 0.0);
843 break;
844 case GTK_PACK_DIRECTION_TTB:
845 gtk_label_set_angle(GTK_LABEL(item)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(item)), ((gtk_label_get_type ()))))))
,
846 (orient == MATE_PANEL_APPLET_ORIENT_LEFT) ?
847 270.0 : 90.0);
848 break;
849 default:
850 break;
851 }
852 }
853 gtk_box_pack_start(GTK_BOX(to)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((to
)), ((gtk_box_get_type ()))))))
, item, FALSE(0), FALSE(0), 0);
854 return TRUE(!(0));
855}
856
857static gboolean
858reorient_box_cb (GtkWidget *menuitem, gpointer data)
859{
860 GtkWidget *from = g_object_get_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "box");
861 GtkWidget *to = (packdirection == GTK_PACK_DIRECTION_LTR) ?
862 gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0) : gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
863 g_object_set_data(G_OBJECT(from)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
from)), (((GType) ((20) << (2))))))))
, "to", to);
864 gtk_container_foreach(GTK_CONTAINER(from)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((from)), ((gtk_container_get_type ()))))))
, (GtkCallback)swap_orient_cb,
865 from);
866 gtk_container_remove(GTK_CONTAINER(menuitem)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menuitem)), ((gtk_container_get_type ()))))))
, from);
867 gtk_container_add(GTK_CONTAINER(menuitem)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menuitem)), ((gtk_container_get_type ()))))))
, to);
868 g_object_set_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "box", to);
869 gtk_widget_show_all(menuitem);
870 return TRUE(!(0));
871}
872
873static gboolean
874matepanelapplet_reorient_cb (GtkWidget *applet, MatePanelAppletOrient neworient,
875 gpointer data)
876{
877 GtkWidget *menubar = (GtkWidget *)data;
878 if ((((neworient == MATE_PANEL_APPLET_ORIENT_UP) ||
879 (neworient == MATE_PANEL_APPLET_ORIENT_DOWN)) &&
880 ((orient == MATE_PANEL_APPLET_ORIENT_LEFT) ||
881 (orient == MATE_PANEL_APPLET_ORIENT_RIGHT))) ||
882 (((neworient == MATE_PANEL_APPLET_ORIENT_LEFT) ||
883 (neworient == MATE_PANEL_APPLET_ORIENT_RIGHT)) &&
884 ((orient == MATE_PANEL_APPLET_ORIENT_UP) ||
885 (orient == MATE_PANEL_APPLET_ORIENT_DOWN)))) {
886 packdirection = (packdirection == GTK_PACK_DIRECTION_LTR) ?
887 GTK_PACK_DIRECTION_TTB : GTK_PACK_DIRECTION_LTR;
888 gtk_menu_bar_set_pack_direction(GTK_MENU_BAR(menubar)((((GtkMenuBar*) g_type_check_instance_cast ((GTypeInstance*)
((menubar)), ((gtk_menu_bar_get_type ()))))))
,
889 packdirection);
890 orient = neworient;
891 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
,
892 (GtkCallback)reorient_box_cb, NULL((void*)0));
893 }
894 orient = neworient;
895 return FALSE(0);
896}
897
898#ifdef N_
899#undef N_
900#endif
901#define N_(x)x x
902
903static void
904log_to_file_cb (GObject * source_obj G_GNUC_UNUSED__attribute__((__unused__)),
905 GAsyncResult * result G_GNUC_UNUSED__attribute__((__unused__)), gpointer user_data)
906{
907 g_free(user_data);
908 return;
909}
910
911static void
912log_to_file (const gchar * domain G_GNUC_UNUSED__attribute__((__unused__)),
913 GLogLevelFlags level G_GNUC_UNUSED__attribute__((__unused__)),
914 const gchar * message,
915 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
916{
917 if (log_file == NULL((void*)0)) {
918 GError * error = NULL((void*)0);
919 gchar * filename = g_build_filename(g_get_user_cache_dir(), LOG_FILE_NAME"indicator-applet-appmenu.log", NULL((void*)0));
920 GFile * file = g_file_new_for_path(filename);
921 g_free(filename);
922
923 if (!g_file_test(g_get_user_cache_dir(), G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) {
924 GFile * cachedir = g_file_new_for_path(g_get_user_cache_dir());
925 g_file_make_directory_with_parents(cachedir, NULL((void*)0), &error);
926
927 if (error != NULL((void*)0)) {
928 g_error("Unable to make directory '%s' for log file: %s", g_get_user_cache_dir(), error->message);
929 return;
930 }
931 }
932
933 g_file_delete(file, NULL((void*)0), NULL((void*)0));
934
935 GFileIOStream * io = g_file_create_readwrite(file,
936 G_FILE_CREATE_REPLACE_DESTINATION, /* flags */
937 NULL((void*)0), /* cancelable */
938 &error); /* error */
939 if (error != NULL((void*)0)) {
940 g_error("Unable to replace file: %s", error->message);
941 return;
This statement is never executed
942 }
943
944 log_file = g_io_stream_get_output_stream(G_IO_STREAM(io)((((GIOStream*) g_type_check_instance_cast ((GTypeInstance*) (
(io)), ((g_io_stream_get_type ()))))))
);
945 }
946
947 gchar * outputstring = g_strdup_printf("%s\n", message);
948 g_output_stream_write_async(log_file,
949 outputstring, /* data */
950 strlen(outputstring), /* length */
951 G_PRIORITY_LOW300, /* priority */
952 NULL((void*)0), /* cancelable */
953 log_to_file_cb, /* callback */
954 outputstring); /* data */
955
956 return;
957}
958
959static gboolean
960applet_fill_cb (MatePanelApplet * applet, const gchar * iid G_GNUC_UNUSED__attribute__((__unused__)),
961 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
962{
963#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
964 ido_init();
965#endif
966
967 static const GtkActionEntry menu_actions[] = {
968 {"About", GTK_STOCK_ABOUT((GtkStock)"gtk-about"), N_("_About")"_About", NULL((void*)0), NULL((void*)0), G_CALLBACK(about_cb)((GCallback) (about_cb))}
969 };
970 static const gchar *menu_xml = "<menuitem name=\"About\" action=\"About\"/>";
971
972 static gboolean first_time = FALSE(0);
973 GtkWidget *menubar;
974 gint indicators_loaded = 0;
975 GtkActionGroup *action_group;
976
977 if (!first_time)
978 {
979 first_time = TRUE(!(0));
980#ifdef INDICATOR_APPLET
981 g_set_application_name(_("Indicator Applet")dcgettext (((void*)0), "Indicator Applet", 5));
982#endif
983#ifdef INDICATOR_APPLET_COMPLETE
984 g_set_application_name(_("Indicator Applet Complete")dcgettext (((void*)0), "Indicator Applet Complete", 5));
985#endif
986#ifdef INDICATOR_APPLET_APPMENU1
987 g_set_application_name(_("Indicator Applet Application Menu")dcgettext (((void*)0), "Indicator Applet Application Menu", 5
)
);
988#endif
989
990 g_log_set_default_handler(log_to_file, NULL((void*)0));
991
992 tomboy_keybinder_init();
993 }
994
995 /* Set panel options */
996 gtk_container_set_border_width(GTK_CONTAINER (applet)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_container_get_type ()))))))
, 0);
997 mate_panel_applet_set_flags(applet, MATE_PANEL_APPLET_EXPAND_MINOR);
998 menubar = gtk_menu_bar_new();
999 action_group = gtk_action_group_new ("Indicator Applet Actions");
1000 gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE"mate-indicator-applet");
1001 gtk_action_group_add_actions (action_group, menu_actions,
1002 G_N_ELEMENTS (menu_actions)(sizeof (menu_actions) / sizeof ((menu_actions)[0])),
1003 menubar);
1004 mate_panel_applet_setup_menu(applet, menu_xml, action_group);
1005 g_object_unref(action_group);
1006#ifdef INDICATOR_APPLET
1007 atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
),
1008 "indicator-applet");
1009#endif
1010#ifdef INDICATOR_APPLET_COMPLETE
1011 atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
),
1012 "indicator-applet-complete");
1013#endif
1014#ifdef INDICATOR_APPLET_APPMENU1
1015 atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
),
1016 "indicator-applet-appmenu");
1017#endif
1018
1019 /* Init some theme/icon stuff */
1020 gtk_icon_theme_append_search_path(gtk_icon_theme_get_default(),
1021 INDICATOR_ICONS_DIR"/usr/share/libindicator/icons/");
1022 /* g_debug("Icons directory: %s", INDICATOR_ICONS_DIR); */
1023 gtk_widget_set_name(GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
, "fast-user-switch-applet");
1024
1025 /* Build menubar */
1026 size = (mate_panel_applet_get_size (applet));
1027 orient = (mate_panel_applet_get_orient(applet));
1028 packdirection = ((orient == MATE_PANEL_APPLET_ORIENT_UP) ||
1029 (orient == MATE_PANEL_APPLET_ORIENT_DOWN)) ?
1030 GTK_PACK_DIRECTION_LTR : GTK_PACK_DIRECTION_TTB;
1031 gtk_menu_bar_set_pack_direction(GTK_MENU_BAR(menubar)((((GtkMenuBar*) g_type_check_instance_cast ((GTypeInstance*)
((menubar)), ((gtk_menu_bar_get_type ()))))))
,
1032 packdirection);
1033 gtk_widget_set_can_focus (menubar, TRUE(!(0)));
1034 gtk_widget_set_name(GTK_WIDGET (menubar)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(menubar)), ((gtk_widget_get_type ()))))))
, "fast-user-switch-menubar");
1035 g_signal_connect(menubar, "button-press-event", G_CALLBACK(menubar_press), NULL)g_signal_connect_data ((menubar), ("button-press-event"), (((
GCallback) (menubar_press))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
;
1036 g_signal_connect_after(menubar, "draw", G_CALLBACK(menubar_on_draw), menubar)g_signal_connect_data ((menubar), ("draw"), (((GCallback) (menubar_on_draw
))), (menubar), ((void*)0), G_CONNECT_AFTER)
;
1037 g_signal_connect(applet, "change-orient",g_signal_connect_data ((applet), ("change-orient"), (((GCallback
) (matepanelapplet_reorient_cb))), (menubar), ((void*)0), (GConnectFlags
) 0)
1038 G_CALLBACK(matepanelapplet_reorient_cb), menubar)g_signal_connect_data ((applet), ("change-orient"), (((GCallback
) (matepanelapplet_reorient_cb))), (menubar), ((void*)0), (GConnectFlags
) 0)
;
1039 gtk_container_set_border_width(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, 0);
1040
1041 /* Add in filter func */
1042 tomboy_keybinder_bind(hotkey_keycode, hotkey_filter, menubar);
1043
1044 load_modules(applet, menubar, &indicators_loaded);
1045#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
1046 load_indicators_from_indicator_files(applet, menubar, &indicators_loaded);
1047#endif
1048
1049 if (indicators_loaded == 0) {
1050 /* A label to allow for click through */
1051 GtkWidget * item = gtk_label_new(_("No Indicators")dcgettext (((void*)0), "No Indicators", 5));
1052 mate_panel_applet_set_background_widget(applet, item);
1053 gtk_container_add(GTK_CONTAINER(applet)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_container_get_type ()))))))
, item);
1054 gtk_widget_show(item);
1055 } else {
1056 gtk_container_add(GTK_CONTAINER(applet)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_container_get_type ()))))))
, menubar);
1057 mate_panel_applet_set_background_widget(applet, menubar);
1058 gtk_widget_show(menubar);
1059 }
1060
1061 gtk_widget_show(GTK_WIDGET(applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
);
1062
1063 return TRUE(!(0));
1064
1065}
diff --git a/2020-04-09-124840-6850-1@e69dd120803f_shadow/report-73d269.html b/2020-04-09-124840-6850-1@e69dd120803f_shadow/report-73d269.html new file mode 100644 index 0000000..da40295 --- /dev/null +++ b/2020-04-09-124840-6850-1@e69dd120803f_shadow/report-73d269.html @@ -0,0 +1,1412 @@ + + + +applet-main.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:applet-main.c
Warning:line 929, column 5
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name applet-main.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -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 -mrelocation-model static -mthread-model posix -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -momit-leaf-frame-pointer -resource-dir /usr/lib64/clang/9.0.1 -D HAVE_CONFIG_H -I . -I .. -D G_LOG_DOMAIN="Indicator-Applet-Appmenu" -D DATADIR="/usr/local/share" -D INDICATOR_DIR="/usr/lib64/indicators3/7/" -D INDICATOR_ICONS_DIR="/usr/share/libindicator/icons/" -D INDICATOR_APPLET_APPMENU -I ./.. -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/fribidi -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gio-unix-2.0 -I /usr/include/libdrm -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-panel-4.0/libmate-panel-applet -I /usr/include/libindicator3-0.4 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/fribidi -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gio-unix-2.0 -I /usr/include/libdrm -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/9.0.1/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wno-unused-parameter -Wno-sign-compare -fdebug-compilation-dir /rootdir/src -ferror-limit 19 -fmessage-length 0 -fobjc-runtime=gcc -fdiagnostics-show-option -vectorize-loops -vectorize-slp -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 -o /rootdir/html-report/2020-04-09-124840-6850-1 -x c applet-main.c +
+ + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2A small wrapper utility to load indicators and put them as menu items
3into the mate-panel using it's applet interface.
4
5Copyright 2009-2010 Canonical Ltd.
6
7Authors:
8 Ted Gould <ted@canonical.com>
9
10This program is free software: you can redistribute it and/or modify it
11under the terms of the GNU General Public License version 3, as published
12by the Free Software Foundation.
13
14This program is distributed in the hope that it will be useful, but
15WITHOUT ANY WARRANTY; without even the implied warranties of
16MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
17PURPOSE. See the GNU General Public License for more details.
18
19You should have received a copy of the GNU General Public License along
20with this program. If not, see <http://www.gnu.org/licenses/>.
21*/
22
23#include <stdlib.h>
24#include <string.h>
25#include <config.h>
26#include <glib/gi18n.h>
27#include <mate-panel-applet.h>
28#include <gdk/gdkkeysyms.h>
29#include <gtk/gtk.h>
30
31#if HAVE_UBUNTU_INDICATOR1
32
33#define INDICATOR_SERVICE_APPMENU"libappmenu.so" "libappmenu.so"
34#define INDICATOR_SERVICE_ME"libme.so" "libme.so"
35#define INDICATOR_SERVICE_DATETIME"libdatetime.so" "libdatetime.so"
36
37#define INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu" "com.canonical.indicator.appmenu"
38#define INDICATOR_SERVICE_ME_NG"com.canonical.indicator.me" "com.canonical.indicator.me"
39#define INDICATOR_SERVICE_DATETIME_NG"com.canonical.indicator.datetime" "com.canonical.indicator.datetime"
40
41#include <libindicator/indicator-object.h>
42#endif
43
44#if HAVE_AYATANA_INDICATOR
45
46#define INDICATOR_SERVICE_APPMENU"libappmenu.so" "libayatana-appmenu.so"
47#define INDICATOR_SERVICE_ME"libme.so" "libayatana-me.so"
48#define INDICATOR_SERVICE_DATETIME"libdatetime.so" "libayatana-datetime.so"
49
50#define INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu" "org.ayatana.indicator.appmenu"
51#define INDICATOR_SERVICE_ME_NG"com.canonical.indicator.me" "org.ayatana.indicator.me"
52#define INDICATOR_SERVICE_DATETIME_NG"com.canonical.indicator.datetime" "org.ayatana.indicator.datetime"
53
54#include <libayatana-indicator/indicator-object.h>
55#endif
56
57/* For new style indicators */
58
59#if HAVE_UBUNTU_INDICATOR1 && HAVE_UBUNTU_INDICATOR_NG
60
61#include <libido/libido.h>
62#include <libindicator/indicator-ng.h>
63
64#define INDICATOR_SERVICE_DIR "/usr/share/unity/indicators"
65
66#endif
67
68#if HAVE_AYATANA_INDICATOR && HAVE_AYATANA_INDICATOR_NG
69
70#include <libayatana-ido/libayatana-ido.h>
71#include <libayatana-indicator/indicator-ng.h>
72
73#define INDICATOR_SERVICE_DIR "/usr/share/ayatana/indicators"
74
75#endif
76
77#include "tomboykeybinder.h"
78
79static gchar * indicator_order[] = {
80#if HAVE_UBUNTU_INDICATOR1
81 "libapplication.so",
82 "libmessaging.so",
83 "libsoundmenu.so",
84 "libdatetime.so",
85 "libsession.so",
86#endif
87#if HAVE_AYATANA_INDICATOR
88 "libayatana-application.so",
89 "libayatana-messaging.so",
90 "libayatana-soundmenu.so",
91 "libayatana-datetime.so",
92 "libayatana-session.so",
93#endif
94 NULL((void*)0)
95};
96
97static GtkPackDirection packdirection;
98static MatePanelAppletOrient orient;
99static guint size;
100
101#define MENU_DATA_INDICATOR_OBJECT"indicator-object" "indicator-object"
102#define MENU_DATA_INDICATOR_ENTRY"indicator-entry" "indicator-entry"
103
104#define IO_DATA_ORDER_NUMBER"indicator-order-number" "indicator-order-number"
105
106static gboolean applet_fill_cb (MatePanelApplet * applet, const gchar * iid, gpointer data);
107
108static void update_accessible_desc (IndicatorObjectEntry * entry, GtkWidget * menuitem);
109
110/*************
111 * main
112 * ***********/
113
114#ifdef INDICATOR_APPLET
115MATE_PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletFactory",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
116 PANEL_TYPE_APPLET,int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
117 "indicator-applet",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
118 applet_fill_cb, NULL)int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
;
119#endif
120#ifdef INDICATOR_APPLET_COMPLETE
121MATE_PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletCompleteFactory",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
122 PANEL_TYPE_APPLET,int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
123 "indicator-applet-complete",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
124 applet_fill_cb, NULL)int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
;
125#endif
126#ifdef INDICATOR_APPLET_APPMENU1
127MATE_PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletAppmenuFactory",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
128 PANEL_TYPE_APPLET,int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
129 "indicator-applet-appmenu",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
130 applet_fill_cb, NULL)int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
;
131#endif
132
133/*************
134 * log files
135 * ***********/
136#ifdef INDICATOR_APPLET
137#define LOG_FILE_NAME"indicator-applet-appmenu.log" "indicator-applet.log"
138#endif
139#ifdef INDICATOR_APPLET_COMPLETE
140#define LOG_FILE_NAME"indicator-applet-appmenu.log" "indicator-applet-complete.log"
141#endif
142#ifdef INDICATOR_APPLET_APPMENU1
143#define LOG_FILE_NAME"indicator-applet-appmenu.log" "indicator-applet-appmenu.log"
144#endif
145GOutputStream * log_file = NULL((void*)0);
146
147/*****************
148 * Hotkey support
149 * **************/
150#ifdef INDICATOR_APPLET
151gchar * hotkey_keycode = "<Super>M";
152#endif
153#ifdef INDICATOR_APPLET_SESSION
154gchar * hotkey_keycode = "<Super>S";
155#endif
156#ifdef INDICATOR_APPLET_COMPLETE
157gchar * hotkey_keycode = "<Super>S";
158#endif
159#ifdef INDICATOR_APPLET_APPMENU1
160gchar * hotkey_keycode = "<Super>F1";
161#endif
162
163/********************
164 * Environment Names
165 * *******************/
166#ifdef INDICATOR_APPLET
167#define INDICATOR_SPECIFIC_ENV"indicator-applet-appmenu" "indicator-applet-original"
168#endif
169#ifdef INDICATOR_APPLET_COMPLETE
170#define INDICATOR_SPECIFIC_ENV"indicator-applet-appmenu" "indicator-applet-complete"
171#endif
172#ifdef INDICATOR_APPLET_APPMENU1
173#define INDICATOR_SPECIFIC_ENV"indicator-applet-appmenu" "indicator-applet-appmenu"
174#endif
175
176static const gchar * indicator_env[] = {
177 "indicator-applet",
178 INDICATOR_SPECIFIC_ENV"indicator-applet-appmenu",
179 NULL((void*)0)
180};
181
182/*************
183 * init function
184 * ***********/
185
186static gint
187name2order (const gchar * name) {
188 int i;
189
190 for (i = 0; indicator_order[i] != NULL((void*)0); i++) {
191 if (g_strcmp0(name, indicator_order[i]) == 0) {
192 return i;
193 }
194 }
195
196 return -1;
197}
198
199typedef struct _incoming_position_t incoming_position_t;
200struct _incoming_position_t {
201 gint objposition;
202 gint entryposition;
203 gint menupos;
204 gboolean found;
205};
206
207/* This function helps by determining where in the menu list
208 this new entry should be placed. It compares the objects
209 that they're on, and then the individual entries. Each
210 is progressively more expensive. */
211static void
212place_in_menu (GtkWidget * widget, gpointer user_data)
213{
214 incoming_position_t * position = (incoming_position_t *)user_data;
215 if (position->found) {
216 /* We've already been placed, just finish the foreach */
217 return;
218 }
219
220 IndicatorObject * io = INDICATOR_OBJECT(g_object_get_data(G_OBJECT(widget), MENU_DATA_INDICATOR_OBJECT))((((IndicatorObject*) g_type_check_instance_cast ((GTypeInstance
*) ((g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((widget)), (((GType) ((20) << (2)))
))))), "indicator-object"))), ((indicator_object_get_type ())
)))))
;
221 g_assert(io != NULL)do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_
; if (io != ((void*)0)) _g_boolean_var_ = 1; else _g_boolean_var_
= 0; _g_boolean_var_; }), 1)) ; else g_assertion_message_expr
("Indicator-Applet-Appmenu", "applet-main.c", 221, ((const char
*) (__func__)), "io != NULL"); } while (0)
;
222
223 gint objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER))((gint) (glong) (g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
), "indicator-order-number")))
;
224 /* We've already passed it, well, then this is where
225 we should be be. Stop! */
226 if (objposition > position->objposition) {
227 position->found = TRUE(!(0));
228 return;
229 }
230
231 /* The objects don't match yet, keep looking */
232 if (objposition < position->objposition) {
233 position->menupos++;
234 return;
235 }
236
237 /* The objects are the same, let's start looking at entries. */
238 IndicatorObjectEntry * entry = (IndicatorObjectEntry *)g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
239 gint entryposition = indicator_object_get_location(io, entry);
240
241 if (entryposition > position->entryposition) {
242 position->found = TRUE(!(0));
243 return;
244 }
245
246 if (entryposition < position->entryposition) {
247 position->menupos++;
248 return;
249 }
250
251 /* We've got the same object and the same entry. Well,
252 let's just put it right here then. */
253 position->found = TRUE(!(0));
254 return;
255}
256
257static void
258something_shown (GtkWidget * widget, gpointer user_data)
259{
260 GtkWidget * menuitem = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
261 gtk_widget_show(menuitem);
262}
263
264static void
265something_hidden (GtkWidget * widget, gpointer user_data)
266{
267 GtkWidget * menuitem = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
268 gtk_widget_hide(menuitem);
269}
270
271static void
272sensitive_cb (GObject * obj, GParamSpec * pspec, gpointer user_data)
273{
274 g_return_if_fail(GTK_IS_WIDGET(obj))do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((obj)); GType __t = ((gtk_widget_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet-Appmenu",
((const char*) (__func__)), "GTK_IS_WIDGET(obj)"); return; }
} while (0)
;
275 g_return_if_fail(GTK_IS_WIDGET(user_data))do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((gtk_widget_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet-Appmenu",
((const char*) (__func__)), "GTK_IS_WIDGET(user_data)"); return
; } } while (0)
;
276
277 gtk_widget_set_sensitive(GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
, gtk_widget_get_sensitive(GTK_WIDGET(obj)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(obj)), ((gtk_widget_get_type ()))))))
));
278 return;
279}
280
281static void
282entry_activated (GtkWidget * widget, gpointer user_data)
283{
284 g_return_if_fail(GTK_IS_WIDGET(widget))do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((gtk_widget_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet-Appmenu",
((const char*) (__func__)), "GTK_IS_WIDGET(widget)"); return
; } } while (0)
;
285 gpointer pio = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, "indicator");
286 g_return_if_fail(INDICATOR_IS_OBJECT(pio))do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((pio)); GType __t = ((indicator_object_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet-Appmenu",
((const char*) (__func__)), "INDICATOR_IS_OBJECT(pio)"); return
; } } while (0)
;
287 IndicatorObject * io = INDICATOR_OBJECT(pio)((((IndicatorObject*) g_type_check_instance_cast ((GTypeInstance
*) ((pio)), ((indicator_object_get_type ()))))))
;
288
289 return indicator_object_entry_activate(io, (IndicatorObjectEntry *)user_data, gtk_get_current_event_time());
290}
291
292static gboolean
293entry_scrolled (GtkWidget *menuitem, GdkEventScroll *event, gpointer data)
294{
295 IndicatorObject *io = g_object_get_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_OBJECT"indicator-object");
296 IndicatorObjectEntry *entry = g_object_get_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
297
298 g_return_val_if_fail(INDICATOR_IS_OBJECT(io), FALSE)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((io)); GType __t = ((indicator_object_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet-Appmenu",
((const char*) (__func__)), "INDICATOR_IS_OBJECT(io)"); return
((0)); } } while (0)
;
299
300 g_signal_emit_by_name (io, "scroll", 1, event->direction);
301 g_signal_emit_by_name (io, "scroll-entry", entry, 1, event->direction);
302 g_signal_emit_by_name (io, INDICATOR_OBJECT_SIGNAL_ENTRY_SCROLLED"entry-scrolled", entry, 1, event->direction);
303
304 return FALSE(0);
305}
306
307static void
308accessible_desc_update_cb (GtkWidget * widget, gpointer userdata)
309{
310 gpointer data = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
311
312 if (data != userdata) {
313 return;
314 }
315
316 IndicatorObjectEntry * entry = (IndicatorObjectEntry *)data;
317 update_accessible_desc(entry, widget);
318}
319
320static void
321accessible_desc_update (IndicatorObject * io, IndicatorObjectEntry * entry, GtkWidget * menubar)
322{
323 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, accessible_desc_update_cb, entry);
324 return;
325}
326
327#define PANEL_PADDING8 8
328static gboolean
329entry_resized (GtkWidget *applet, guint newsize, gpointer data)
330{
331 IndicatorObject *io = (IndicatorObject *)data;
332
333 size = newsize;
334
335 /* Work on the entries */
336 GList * entries = indicator_object_get_entries(io);
337 GList * entry = NULL((void*)0);
338
339 for (entry = entries; entry != NULL((void*)0); entry = g_list_next(entry)((entry) ? (((GList *)(entry))->next) : ((void*)0))) {
340 IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)entry->data;
341 if (entrydata->image != NULL((void*)0)) {
342 /* Resize to fit panel */
343 gtk_image_set_pixel_size (entrydata->image, size - PANEL_PADDING8);
344 }
345 }
346
347 return FALSE(0);
348}
349
350static void
351entry_added (IndicatorObject * io, IndicatorObjectEntry * entry, GtkWidget * menubar)
352{
353 g_debug("Signal: Entry Added");
354 gboolean something_visible = FALSE(0);
355 gboolean something_sensitive = FALSE(0);
356
357 GtkWidget * menuitem = gtk_menu_item_new();
358 GtkWidget * box = (packdirection == GTK_PACK_DIRECTION_LTR) ?
359 gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3) : gtk_box_new(GTK_ORIENTATION_VERTICAL, 3);
360
361 /* Allows indicators to receive mouse scroll event */
362 gtk_widget_add_events(GTK_WIDGET(menuitem)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(menuitem)), ((gtk_widget_get_type ()))))))
, GDK_SCROLL_MASK);
363
364 g_object_set_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "indicator", io);
365 g_object_set_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "box", box);
366
367 g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(entry_activated), entry)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((menuitem)), (((GType) ((20) << (2)
)))))))), ("activate"), (((GCallback) (entry_activated))), (entry
), ((void*)0), (GConnectFlags) 0)
;
368 g_signal_connect(G_OBJECT(menuitem), "scroll-event", G_CALLBACK(entry_scrolled), entry)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((menuitem)), (((GType) ((20) << (2)
)))))))), ("scroll-event"), (((GCallback) (entry_scrolled))),
(entry), ((void*)0), (GConnectFlags) 0)
;
369
370 if (entry->image != NULL((void*)0)) {
371 /* Resize to fit panel */
372 gtk_image_set_pixel_size (entry->image, size - PANEL_PADDING8);
373 gtk_box_pack_start(GTK_BOX(box)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((box
)), ((gtk_box_get_type ()))))))
, GTK_WIDGET(entry->image)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->image)), ((gtk_widget_get_type ()))))))
, FALSE(0), FALSE(0), 1);
374 if (gtk_widget_get_visible(GTK_WIDGET(entry->image)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->image)), ((gtk_widget_get_type ()))))))
)) {
375 something_visible = TRUE(!(0));
376 }
377
378 if (gtk_widget_get_sensitive(GTK_WIDGET(entry->image)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->image)), ((gtk_widget_get_type ()))))))
)) {
379 something_sensitive = TRUE(!(0));
380 }
381
382 g_signal_connect(G_OBJECT(entry->image), "show", G_CALLBACK(something_shown), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), ("show"), (((GCallback) (something_shown))), (menuitem
), ((void*)0), (GConnectFlags) 0)
;
383 g_signal_connect(G_OBJECT(entry->image), "hide", G_CALLBACK(something_hidden), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), ("hide"), (((GCallback) (something_hidden))), (
menuitem), ((void*)0), (GConnectFlags) 0)
;
384
385 g_signal_connect(G_OBJECT(entry->image), "notify::sensitive", G_CALLBACK(sensitive_cb), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), ("notify::sensitive"), (((GCallback) (sensitive_cb
))), (menuitem), ((void*)0), (GConnectFlags) 0)
;
386 }
387 if (entry->label != NULL((void*)0)) {
388 switch(packdirection) {
389 case GTK_PACK_DIRECTION_LTR:
390 gtk_label_set_angle(GTK_LABEL(entry->label)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_label_get_type ()))))))
, 0.0);
391 break;
392 case GTK_PACK_DIRECTION_TTB:
393 gtk_label_set_angle(GTK_LABEL(entry->label)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_label_get_type ()))))))
,
394 (orient == MATE_PANEL_APPLET_ORIENT_LEFT) ?
395 270.0 : 90.0);
396 break;
397 default:
398 break;
399 }
400 gtk_box_pack_start(GTK_BOX(box)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((box
)), ((gtk_box_get_type ()))))))
, GTK_WIDGET(entry->label)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_widget_get_type ()))))))
, FALSE(0), FALSE(0), 1);
401
402 if (gtk_widget_get_visible(GTK_WIDGET(entry->label)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_widget_get_type ()))))))
)) {
403 something_visible = TRUE(!(0));
404 }
405
406 if (gtk_widget_get_sensitive(GTK_WIDGET(entry->label)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_widget_get_type ()))))))
)) {
407 something_sensitive = TRUE(!(0));
408 }
409
410 g_signal_connect(G_OBJECT(entry->label), "show", G_CALLBACK(something_shown), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), ("show"), (((GCallback) (something_shown))), (menuitem
), ((void*)0), (GConnectFlags) 0)
;
411 g_signal_connect(G_OBJECT(entry->label), "hide", G_CALLBACK(something_hidden), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), ("hide"), (((GCallback) (something_hidden))), (
menuitem), ((void*)0), (GConnectFlags) 0)
;
412
413 g_signal_connect(G_OBJECT(entry->label), "notify::sensitive", G_CALLBACK(sensitive_cb), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), ("notify::sensitive"), (((GCallback) (sensitive_cb
))), (menuitem), ((void*)0), (GConnectFlags) 0)
;
414 }
415 gtk_container_add(GTK_CONTAINER(menuitem)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menuitem)), ((gtk_container_get_type ()))))))
, box);
416 gtk_widget_show(box);
417
418 if (entry->menu != NULL((void*)0)) {
419 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem)((((GtkMenuItem*) g_type_check_instance_cast ((GTypeInstance*
) ((menuitem)), ((gtk_menu_item_get_type ()))))))
, GTK_WIDGET(entry->menu)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->menu)), ((gtk_widget_get_type ()))))))
);
420 }
421
422 incoming_position_t position;
423 position.objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER))((gint) (glong) (g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
), "indicator-order-number")))
;
424 position.entryposition = indicator_object_get_location(io, entry);
425 position.menupos = 0;
426 position.found = FALSE(0);
427
428 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, place_in_menu, &position);
429
430 gtk_menu_shell_insert(GTK_MENU_SHELL(menubar)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_menu_shell_get_type ()))))))
, menuitem, position.menupos);
431
432 if (something_visible) {
433 if (entry->accessible_desc != NULL((void*)0)) {
434 update_accessible_desc(entry, menuitem);
435 }
436 gtk_widget_show(menuitem);
437 }
438 gtk_widget_set_sensitive(menuitem, something_sensitive);
439
440 g_object_set_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry", entry);
441 g_object_set_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_OBJECT"indicator-object", io);
442
443 return;
444}
445
446static void
447entry_removed_cb (GtkWidget * widget, gpointer userdata)
448{
449 gpointer data = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
450
451 if (data != userdata) {
452 return;
453 }
454
455 IndicatorObjectEntry * entry = (IndicatorObjectEntry *)data;
456 if (entry->label != NULL((void*)0)) {
457 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(something_shown), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_shown))), (widget
))
;
458 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(something_hidden), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_hidden))), (widget
))
;
459 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(sensitive_cb), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (sensitive_cb))), (widget)
)
;
460 }
461 if (entry->image != NULL((void*)0)) {
462 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(something_shown), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_shown))), (widget
))
;
463 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(something_hidden), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_hidden))), (widget
))
;
464 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(sensitive_cb), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (sensitive_cb))), (widget)
)
;
465 }
466
467 gtk_widget_destroy(widget);
468 return;
469}
470
471static void
472entry_removed (IndicatorObject * io G_GNUC_UNUSED__attribute__((__unused__)), IndicatorObjectEntry * entry,
473 gpointer user_data)
474{
475 g_debug("Signal: Entry Removed");
476
477 gtk_container_foreach(GTK_CONTAINER(user_data)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((gtk_container_get_type ()))))))
, entry_removed_cb, entry);
478
479 return;
480}
481
482static void
483entry_moved_find_cb (GtkWidget * widget, gpointer userdata)
484{
485 gpointer * array = (gpointer *)userdata;
486 if (array[1] != NULL((void*)0)) {
487 return;
488 }
489
490 gpointer data = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
491
492 if (data != array[0]) {
493 return;
494 }
495
496 array[1] = widget;
497 return;
498}
499
500/* Gets called when an entry for an object was moved. */
501static void
502entry_moved (IndicatorObject * io, IndicatorObjectEntry * entry,
503 gint old G_GNUC_UNUSED__attribute__((__unused__)), gint new G_GNUC_UNUSED__attribute__((__unused__)), gpointer user_data)
504{
505 GtkWidget * menubar = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
506
507 gpointer array[2];
508 array[0] = entry;
509 array[1] = NULL((void*)0);
510
511 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, entry_moved_find_cb, array);
512 if (array[1] == NULL((void*)0)) {
513 g_warning("Moving an entry that isn't in our menus.");
514 return;
515 }
516
517 GtkWidget * mi = GTK_WIDGET(array[1])((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(array[1])), ((gtk_widget_get_type ()))))))
;
518 g_object_ref(G_OBJECT(mi)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
mi)), (((GType) ((20) << (2))))))))
);
519 gtk_container_remove(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, mi);
520
521 incoming_position_t position;
522 position.objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER))((gint) (glong) (g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
), "indicator-order-number")))
;
523 position.entryposition = indicator_object_get_location(io, entry);
524 position.menupos = 0;
525 position.found = FALSE(0);
526
527 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, place_in_menu, &position);
528
529 gtk_menu_shell_insert(GTK_MENU_SHELL(menubar)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_menu_shell_get_type ()))))))
, mi, position.menupos);
530 g_object_unref(G_OBJECT(mi)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
mi)), (((GType) ((20) << (2))))))))
);
531
532 return;
533}
534
535static void
536menu_show (IndicatorObject * io, IndicatorObjectEntry * entry,
537 guint32 timestamp, gpointer user_data)
538{
539 GtkWidget * menubar = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
540
541 if (entry == NULL((void*)0)) {
542 /* Close any open menus instead of opening one */
543 GList * entries = indicator_object_get_entries(io);
544 GList * iterator = NULL((void*)0);
545 for (iterator = entries; iterator != NULL((void*)0); iterator = g_list_next(iterator)((iterator) ? (((GList *)(iterator))->next) : ((void*)0))) {
546 IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)iterator->data;
547 gtk_menu_popdown(entrydata->menu);
548 }
549 g_list_free(entries);
550
551 /* And tell the menubar to exit activation mode too */
552 gtk_menu_shell_cancel(GTK_MENU_SHELL(menubar)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_menu_shell_get_type ()))))))
);
553 return;
554 }
555
556 // TODO: do something sensible here
557}
558
559static void
560update_accessible_desc(IndicatorObjectEntry * entry, GtkWidget * menuitem)
561{
562 /* FIXME: We need to deal with the use case where the contents of the
563 label overrides what is found in the atk object's name, or at least
564 orca speaks the label instead of the atk object name.
565 */
566 AtkObject * menuitem_obj = gtk_widget_get_accessible(menuitem);
567 if (menuitem_obj == NULL((void*)0)) {
568 /* Should there be an error printed here? */
569 return;
570 }
571
572 if (entry->accessible_desc != NULL((void*)0)) {
573 atk_object_set_name(menuitem_obj, entry->accessible_desc);
574 } else {
575 atk_object_set_name(menuitem_obj, "");
576 }
577 return;
578}
579
580static void
581load_indicator (MatePanelApplet *applet, GtkWidget * menubar, IndicatorObject *io, const gchar *name)
582{
583 /* Set the environment it's in */
584 indicator_object_set_environment(io, (const GStrv)indicator_env);
585
586 /* Attach the 'name' to the object */
587#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
588 int pos = 5000 - indicator_object_get_position(io);
589 if (pos > 5000) {
590 pos = name2order(name);
591 }
592#else
593 int pos = name2order(name);
594#endif
595
596 g_object_set_data(G_OBJECT(io)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
io)), (((GType) ((20) << (2))))))))
, IO_DATA_ORDER_NUMBER"indicator-order-number", GINT_TO_POINTER(pos)((gpointer) (glong) (pos)));
597
598 /* Connect to its signals */
599 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED, G_CALLBACK(entry_added), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("entry-added"), (((GCallback) (entry_added))), (menubar)
, ((void*)0), (GConnectFlags) 0)
;
600 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED, G_CALLBACK(entry_removed), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("entry-removed"), (((GCallback) (entry_removed))), (menubar
), ((void*)0), (GConnectFlags) 0)
;
601 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_MOVED, G_CALLBACK(entry_moved), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("entry-moved"), (((GCallback) (entry_moved))), (menubar)
, ((void*)0), (GConnectFlags) 0)
;
602 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_MENU_SHOW, G_CALLBACK(menu_show), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("menu-show"), (((GCallback) (menu_show))), (menubar), ((
void*)0), (GConnectFlags) 0)
;
603 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ACCESSIBLE_DESC_UPDATE, G_CALLBACK(accessible_desc_update), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("accessible-desc-update"), (((GCallback) (accessible_desc_update
))), (menubar), ((void*)0), (GConnectFlags) 0)
;
604
605 /* Track panel resize */
606 g_signal_connect_object(G_OBJECT(applet)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
applet)), (((GType) ((20) << (2))))))))
, "change-size", G_CALLBACK(entry_resized)((GCallback) (entry_resized)), G_OBJECT(io)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
io)), (((GType) ((20) << (2))))))))
, 0);
607
608 /* Work on the entries */
609 GList * entries = indicator_object_get_entries(io);
610 GList * entry = NULL((void*)0);
611
612 for (entry = entries; entry != NULL((void*)0); entry = g_list_next(entry)((entry) ? (((GList *)(entry))->next) : ((void*)0))) {
613 IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)entry->data;
614 entry_added(io, entrydata, menubar);
615 }
616
617 g_list_free(entries);
618}
619
620static gboolean
621load_module (const gchar * name, MatePanelApplet *applet, GtkWidget * menubar)
622{
623 g_debug("Looking at Module: %s", name);
624 g_return_val_if_fail(name != NULL, FALSE)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if (name != ((void*)0)) _g_boolean_var_ = 1; else _g_boolean_var_
= 0; _g_boolean_var_; }), 1))) { } else { g_return_if_fail_warning
("Indicator-Applet-Appmenu", ((const char*) (__func__)), "name != NULL"
); return ((0)); } } while (0)
;
625
626 if (!g_str_has_suffix(name, G_MODULE_SUFFIX"so")) {
627 return FALSE(0);
628 }
629
630 g_debug("Loading Module: %s", name);
631
632 /* Build the object for the module */
633 gchar * fullpath = g_build_filename(INDICATOR_DIR"/usr/lib64/indicators3/7/", name, NULL((void*)0));
634 IndicatorObject * io = indicator_object_new_from_file(fullpath);
635 g_free(fullpath);
636
637 load_indicator(applet, menubar, io, name);
638
639 return TRUE(!(0));
640}
641
642static void
643load_modules (MatePanelApplet *applet, GtkWidget *menubar, gint *indicators_loaded)
644{
645 if (g_file_test(INDICATOR_DIR"/usr/lib64/indicators3/7/", (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))) {
646 GDir * dir = g_dir_open(INDICATOR_DIR"/usr/lib64/indicators3/7/", 0, NULL((void*)0));
647
648 const gchar * name;
649 gint count = 0;
650 while ((name = g_dir_read_name(dir)) != NULL((void*)0)) {
651#ifdef INDICATOR_APPLET_APPMENU1
652 if (g_strcmp0(name, INDICATOR_SERVICE_APPMENU"libappmenu.so")) {
653 continue;
654 }
655#else
656 if (!g_strcmp0(name, INDICATOR_SERVICE_APPMENU"libappmenu.so")) {
657 continue;
658 }
659#endif
660#ifdef INDICATOR_APPLET
661 if (!g_strcmp0(name, INDICATOR_SERVICE_ME"libme.so")) {
662 continue;
663 }
664 if (!g_strcmp0(name, INDICATOR_SERVICE_DATETIME"libdatetime.so")) {
665 continue;
666 }
667#endif
668 if (load_module(name, applet, menubar)) {
669 count++;
670 }
671 }
672
673 *indicators_loaded += count;
674
675 g_dir_close (dir);
676 }
677}
678
679#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
680
681static void
682load_indicators_from_indicator_files (MatePanelApplet *applet, GtkWidget *menubar, gint *indicators_loaded)
683{
684 GDir *dir;
685 const gchar *name;
686 GError *error = NULL((void*)0);
687
688 dir = g_dir_open (INDICATOR_SERVICE_DIR, 0, &error);
689
690 if (!dir) {
691 g_warning ("unable to open indicator service file directory: %s", error->message);
692 g_error_free (error);
693
694 return;
695 }
696
697 gint count = 0;
698 while ((name = g_dir_read_name (dir))) {
699 gchar *filename;
700 IndicatorNg *indicator;
701
702 filename = g_build_filename (INDICATOR_SERVICE_DIR, name, NULL((void*)0));
703 indicator = indicator_ng_new_for_profile (filename, "desktop", &error);
704 g_free (filename);
705
706#ifdef INDICATOR_APPLET_APPMENU1
707 if (g_strcmp0(name, INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu")) {
708 continue;
709 }
710#else
711 if (!g_strcmp0(name, INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu")) {
712 continue;
713 }
714#endif
715#ifdef INDICATOR_APPLET
716 if (!g_strcmp0(name, INDICATOR_SERVICE_ME_NG"com.canonical.indicator.me")) {
717 continue;
718 }
719 if (!g_strcmp0(name, INDICATOR_SERVICE_DATETIME_NG"com.canonical.indicator.datetime")) {
720 continue;
721 }
722#endif
723
724 if (indicator) {
725 load_indicator(applet, menubar, INDICATOR_OBJECT (indicator)((((IndicatorObject*) g_type_check_instance_cast ((GTypeInstance
*) ((indicator)), ((indicator_object_get_type ()))))))
, name);
726 count++;
727 }else{
728 g_warning ("unable to load '%s': %s", name, error->message);
729 g_clear_error (&error);
730 }
731 }
732
733 *indicators_loaded += count;
734
735 g_dir_close (dir);
736}
737#endif /* HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG */
738
739static void
740hotkey_filter (char * keystring G_GNUC_UNUSED__attribute__((__unused__)), gpointer data)
741{
742 g_return_if_fail(GTK_IS_MENU_SHELL(data))do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((data)); GType __t = ((gtk_menu_shell_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet-Appmenu",
((const char*) (__func__)), "GTK_IS_MENU_SHELL(data)"); return
; } } while (0)
;
743
744 /* Oh, wow, it's us! */
745 GList * children = gtk_container_get_children(GTK_CONTAINER(data)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((gtk_container_get_type ()))))))
);
746 if (children == NULL((void*)0)) {
747 g_debug("Menubar has no children");
748 return;
749 }
750
751 gtk_menu_shell_select_item(GTK_MENU_SHELL(data)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((gtk_menu_shell_get_type ()))))))
, GTK_WIDGET(g_list_last(children)->data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(g_list_last(children)->data)), ((gtk_widget_get_type ()))
))))
);
752 g_list_free(children);
753 return;
754}
755
756static gboolean
757menubar_press (GtkWidget * widget,
758 GdkEventButton *event,
759 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
760{
761 if (event->button != 1) {
762 g_signal_stop_emission_by_name(widget, "button-press-event");
763 }
764
765 return FALSE(0);
766}
767
768static gboolean
769menubar_on_draw (GtkWidget * widget,
770 cairo_t * cr,
771 GtkWidget * menubar)
772{
773 /* FIXME: either port to gtk_render_focus or remove this function */
774 if (gtk_widget_has_focus(menubar))
775 gtk_paint_focus(gtk_widget_get_style(widget),
776 cr,
777 gtk_widget_get_state(menubar),
778 widget, "menubar-applet", 0, 0, -1, -1);
779
780 return FALSE(0);
781}
782
783static void
784about_cb (GtkAction *action G_GNUC_UNUSED__attribute__((__unused__)),
785 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
786{
787 static const gchar *authors[] = {
788 "Ted Gould <ted@canonical.com>",
789 NULL((void*)0)
790 };
791
792 static gchar *license[] = {
793 N_("This program is free software: you can redistribute it and/or modify it ""This program is free software: you can redistribute it and/or modify it "
"under the terms of the GNU General Public License version 3, as published "
"by the Free Software Foundation."
794 "under the terms of the GNU General Public License version 3, as published ""This program is free software: you can redistribute it and/or modify it "
"under the terms of the GNU General Public License version 3, as published "
"by the Free Software Foundation."
795 "by the Free Software Foundation.")"This program is free software: you can redistribute it and/or modify it "
"under the terms of the GNU General Public License version 3, as published "
"by the Free Software Foundation."
,
796 N_("This program is distributed in the hope that it will be useful, but ""This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
797 "WITHOUT ANY WARRANTY; without even the implied warranties of ""This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
798 "MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR ""This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
799 "PURPOSE. See the GNU General Public License for more details.")"This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
,
800 N_("You should have received a copy of the GNU General Public License along ""You should have received a copy of the GNU General Public License along "
"with this program. If not, see <http://www.gnu.org/licenses/>."
801 "with this program. If not, see <http://www.gnu.org/licenses/>.")"You should have received a copy of the GNU General Public License along "
"with this program. If not, see <http://www.gnu.org/licenses/>."
,
802 NULL((void*)0)
803 };
804 gchar *license_i18n;
805
806 license_i18n = g_strconcat (_(license[0])dcgettext (((void*)0), license[0], 5), "\n\n", _(license[1])dcgettext (((void*)0), license[1], 5), "\n\n", _(license[2])dcgettext (((void*)0), license[2], 5), NULL((void*)0));
807
808 gtk_show_about_dialog(NULL((void*)0),
809 "version", VERSION"1.24.0",
810 "copyright", _("Copyright \xc2\xa9 2009-2010 Canonical, Ltd.\n"dcgettext (((void*)0), "Copyright \xc2\xa9 2009-2010 Canonical, Ltd.\n"
"Copyright \xc2\xa9 2011-2020 MATE developers", 5)
811 "Copyright \xc2\xa9 2011-2020 MATE developers")dcgettext (((void*)0), "Copyright \xc2\xa9 2009-2010 Canonical, Ltd.\n"
"Copyright \xc2\xa9 2011-2020 MATE developers", 5)
,
812#ifdef INDICATOR_APPLET_APPMENU1
813 "comments", _("An applet to hold your application menus.")dcgettext (((void*)0), "An applet to hold your application menus."
, 5)
,
814#endif
815 "comments", _("An applet to hold all of the system indicators.")dcgettext (((void*)0), "An applet to hold all of the system indicators."
, 5)
,
816 "authors", authors,
817 "license", license_i18n,
818 "wrap-license", TRUE(!(0)),
819 "translator-credits", _("translator-credits")dcgettext (((void*)0), "translator-credits", 5),
820 "logo-icon-name", "mate-indicator-applet",
821 "icon-name", "mate-indicator-applet",
822 "website", "https://mate-desktop.org",
823 "website-label", _("MATE Website")dcgettext (((void*)0), "MATE Website", 5),
824 NULL((void*)0)
825 );
826
827 g_free (license_i18n);
828
829 return;
830}
831
832static gboolean
833swap_orient_cb (GtkWidget *item, gpointer data)
834{
835 GtkWidget *from = (GtkWidget *) data;
836 GtkWidget *to = (GtkWidget *) g_object_get_data(G_OBJECT(from)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
from)), (((GType) ((20) << (2))))))))
, "to");
837 g_object_ref(G_OBJECT(item)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
item)), (((GType) ((20) << (2))))))))
);
838 gtk_container_remove(GTK_CONTAINER(from)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((from)), ((gtk_container_get_type ()))))))
, item);
839 if (GTK_IS_LABEL(item)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(item)); GType __t = ((gtk_label_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; }))))
) {
840 switch(packdirection) {
841 case GTK_PACK_DIRECTION_LTR:
842 gtk_label_set_angle(GTK_LABEL(item)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(item)), ((gtk_label_get_type ()))))))
, 0.0);
843 break;
844 case GTK_PACK_DIRECTION_TTB:
845 gtk_label_set_angle(GTK_LABEL(item)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(item)), ((gtk_label_get_type ()))))))
,
846 (orient == MATE_PANEL_APPLET_ORIENT_LEFT) ?
847 270.0 : 90.0);
848 break;
849 default:
850 break;
851 }
852 }
853 gtk_box_pack_start(GTK_BOX(to)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((to
)), ((gtk_box_get_type ()))))))
, item, FALSE(0), FALSE(0), 0);
854 return TRUE(!(0));
855}
856
857static gboolean
858reorient_box_cb (GtkWidget *menuitem, gpointer data)
859{
860 GtkWidget *from = g_object_get_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "box");
861 GtkWidget *to = (packdirection == GTK_PACK_DIRECTION_LTR) ?
862 gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0) : gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
863 g_object_set_data(G_OBJECT(from)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
from)), (((GType) ((20) << (2))))))))
, "to", to);
864 gtk_container_foreach(GTK_CONTAINER(from)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((from)), ((gtk_container_get_type ()))))))
, (GtkCallback)swap_orient_cb,
865 from);
866 gtk_container_remove(GTK_CONTAINER(menuitem)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menuitem)), ((gtk_container_get_type ()))))))
, from);
867 gtk_container_add(GTK_CONTAINER(menuitem)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menuitem)), ((gtk_container_get_type ()))))))
, to);
868 g_object_set_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "box", to);
869 gtk_widget_show_all(menuitem);
870 return TRUE(!(0));
871}
872
873static gboolean
874matepanelapplet_reorient_cb (GtkWidget *applet, MatePanelAppletOrient neworient,
875 gpointer data)
876{
877 GtkWidget *menubar = (GtkWidget *)data;
878 if ((((neworient == MATE_PANEL_APPLET_ORIENT_UP) ||
879 (neworient == MATE_PANEL_APPLET_ORIENT_DOWN)) &&
880 ((orient == MATE_PANEL_APPLET_ORIENT_LEFT) ||
881 (orient == MATE_PANEL_APPLET_ORIENT_RIGHT))) ||
882 (((neworient == MATE_PANEL_APPLET_ORIENT_LEFT) ||
883 (neworient == MATE_PANEL_APPLET_ORIENT_RIGHT)) &&
884 ((orient == MATE_PANEL_APPLET_ORIENT_UP) ||
885 (orient == MATE_PANEL_APPLET_ORIENT_DOWN)))) {
886 packdirection = (packdirection == GTK_PACK_DIRECTION_LTR) ?
887 GTK_PACK_DIRECTION_TTB : GTK_PACK_DIRECTION_LTR;
888 gtk_menu_bar_set_pack_direction(GTK_MENU_BAR(menubar)((((GtkMenuBar*) g_type_check_instance_cast ((GTypeInstance*)
((menubar)), ((gtk_menu_bar_get_type ()))))))
,
889 packdirection);
890 orient = neworient;
891 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
,
892 (GtkCallback)reorient_box_cb, NULL((void*)0));
893 }
894 orient = neworient;
895 return FALSE(0);
896}
897
898#ifdef N_
899#undef N_
900#endif
901#define N_(x)x x
902
903static void
904log_to_file_cb (GObject * source_obj G_GNUC_UNUSED__attribute__((__unused__)),
905 GAsyncResult * result G_GNUC_UNUSED__attribute__((__unused__)), gpointer user_data)
906{
907 g_free(user_data);
908 return;
909}
910
911static void
912log_to_file (const gchar * domain G_GNUC_UNUSED__attribute__((__unused__)),
913 GLogLevelFlags level G_GNUC_UNUSED__attribute__((__unused__)),
914 const gchar * message,
915 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
916{
917 if (log_file == NULL((void*)0)) {
918 GError * error = NULL((void*)0);
919 gchar * filename = g_build_filename(g_get_user_cache_dir(), LOG_FILE_NAME"indicator-applet-appmenu.log", NULL((void*)0));
920 GFile * file = g_file_new_for_path(filename);
921 g_free(filename);
922
923 if (!g_file_test(g_get_user_cache_dir(), G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) {
924 GFile * cachedir = g_file_new_for_path(g_get_user_cache_dir());
925 g_file_make_directory_with_parents(cachedir, NULL((void*)0), &error);
926
927 if (error != NULL((void*)0)) {
928 g_error("Unable to make directory '%s' for log file: %s", g_get_user_cache_dir(), error->message);
929 return;
This statement is never executed
930 }
931 }
932
933 g_file_delete(file, NULL((void*)0), NULL((void*)0));
934
935 GFileIOStream * io = g_file_create_readwrite(file,
936 G_FILE_CREATE_REPLACE_DESTINATION, /* flags */
937 NULL((void*)0), /* cancelable */
938 &error); /* error */
939 if (error != NULL((void*)0)) {
940 g_error("Unable to replace file: %s", error->message);
941 return;
942 }
943
944 log_file = g_io_stream_get_output_stream(G_IO_STREAM(io)((((GIOStream*) g_type_check_instance_cast ((GTypeInstance*) (
(io)), ((g_io_stream_get_type ()))))))
);
945 }
946
947 gchar * outputstring = g_strdup_printf("%s\n", message);
948 g_output_stream_write_async(log_file,
949 outputstring, /* data */
950 strlen(outputstring), /* length */
951 G_PRIORITY_LOW300, /* priority */
952 NULL((void*)0), /* cancelable */
953 log_to_file_cb, /* callback */
954 outputstring); /* data */
955
956 return;
957}
958
959static gboolean
960applet_fill_cb (MatePanelApplet * applet, const gchar * iid G_GNUC_UNUSED__attribute__((__unused__)),
961 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
962{
963#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
964 ido_init();
965#endif
966
967 static const GtkActionEntry menu_actions[] = {
968 {"About", GTK_STOCK_ABOUT((GtkStock)"gtk-about"), N_("_About")"_About", NULL((void*)0), NULL((void*)0), G_CALLBACK(about_cb)((GCallback) (about_cb))}
969 };
970 static const gchar *menu_xml = "<menuitem name=\"About\" action=\"About\"/>";
971
972 static gboolean first_time = FALSE(0);
973 GtkWidget *menubar;
974 gint indicators_loaded = 0;
975 GtkActionGroup *action_group;
976
977 if (!first_time)
978 {
979 first_time = TRUE(!(0));
980#ifdef INDICATOR_APPLET
981 g_set_application_name(_("Indicator Applet")dcgettext (((void*)0), "Indicator Applet", 5));
982#endif
983#ifdef INDICATOR_APPLET_COMPLETE
984 g_set_application_name(_("Indicator Applet Complete")dcgettext (((void*)0), "Indicator Applet Complete", 5));
985#endif
986#ifdef INDICATOR_APPLET_APPMENU1
987 g_set_application_name(_("Indicator Applet Application Menu")dcgettext (((void*)0), "Indicator Applet Application Menu", 5
)
);
988#endif
989
990 g_log_set_default_handler(log_to_file, NULL((void*)0));
991
992 tomboy_keybinder_init();
993 }
994
995 /* Set panel options */
996 gtk_container_set_border_width(GTK_CONTAINER (applet)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_container_get_type ()))))))
, 0);
997 mate_panel_applet_set_flags(applet, MATE_PANEL_APPLET_EXPAND_MINOR);
998 menubar = gtk_menu_bar_new();
999 action_group = gtk_action_group_new ("Indicator Applet Actions");
1000 gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE"mate-indicator-applet");
1001 gtk_action_group_add_actions (action_group, menu_actions,
1002 G_N_ELEMENTS (menu_actions)(sizeof (menu_actions) / sizeof ((menu_actions)[0])),
1003 menubar);
1004 mate_panel_applet_setup_menu(applet, menu_xml, action_group);
1005 g_object_unref(action_group);
1006#ifdef INDICATOR_APPLET
1007 atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
),
1008 "indicator-applet");
1009#endif
1010#ifdef INDICATOR_APPLET_COMPLETE
1011 atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
),
1012 "indicator-applet-complete");
1013#endif
1014#ifdef INDICATOR_APPLET_APPMENU1
1015 atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
),
1016 "indicator-applet-appmenu");
1017#endif
1018
1019 /* Init some theme/icon stuff */
1020 gtk_icon_theme_append_search_path(gtk_icon_theme_get_default(),
1021 INDICATOR_ICONS_DIR"/usr/share/libindicator/icons/");
1022 /* g_debug("Icons directory: %s", INDICATOR_ICONS_DIR); */
1023 gtk_widget_set_name(GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
, "fast-user-switch-applet");
1024
1025 /* Build menubar */
1026 size = (mate_panel_applet_get_size (applet));
1027 orient = (mate_panel_applet_get_orient(applet));
1028 packdirection = ((orient == MATE_PANEL_APPLET_ORIENT_UP) ||
1029 (orient == MATE_PANEL_APPLET_ORIENT_DOWN)) ?
1030 GTK_PACK_DIRECTION_LTR : GTK_PACK_DIRECTION_TTB;
1031 gtk_menu_bar_set_pack_direction(GTK_MENU_BAR(menubar)((((GtkMenuBar*) g_type_check_instance_cast ((GTypeInstance*)
((menubar)), ((gtk_menu_bar_get_type ()))))))
,
1032 packdirection);
1033 gtk_widget_set_can_focus (menubar, TRUE(!(0)));
1034 gtk_widget_set_name(GTK_WIDGET (menubar)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(menubar)), ((gtk_widget_get_type ()))))))
, "fast-user-switch-menubar");
1035 g_signal_connect(menubar, "button-press-event", G_CALLBACK(menubar_press), NULL)g_signal_connect_data ((menubar), ("button-press-event"), (((
GCallback) (menubar_press))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
;
1036 g_signal_connect_after(menubar, "draw", G_CALLBACK(menubar_on_draw), menubar)g_signal_connect_data ((menubar), ("draw"), (((GCallback) (menubar_on_draw
))), (menubar), ((void*)0), G_CONNECT_AFTER)
;
1037 g_signal_connect(applet, "change-orient",g_signal_connect_data ((applet), ("change-orient"), (((GCallback
) (matepanelapplet_reorient_cb))), (menubar), ((void*)0), (GConnectFlags
) 0)
1038 G_CALLBACK(matepanelapplet_reorient_cb), menubar)g_signal_connect_data ((applet), ("change-orient"), (((GCallback
) (matepanelapplet_reorient_cb))), (menubar), ((void*)0), (GConnectFlags
) 0)
;
1039 gtk_container_set_border_width(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, 0);
1040
1041 /* Add in filter func */
1042 tomboy_keybinder_bind(hotkey_keycode, hotkey_filter, menubar);
1043
1044 load_modules(applet, menubar, &indicators_loaded);
1045#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
1046 load_indicators_from_indicator_files(applet, menubar, &indicators_loaded);
1047#endif
1048
1049 if (indicators_loaded == 0) {
1050 /* A label to allow for click through */
1051 GtkWidget * item = gtk_label_new(_("No Indicators")dcgettext (((void*)0), "No Indicators", 5));
1052 mate_panel_applet_set_background_widget(applet, item);
1053 gtk_container_add(GTK_CONTAINER(applet)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_container_get_type ()))))))
, item);
1054 gtk_widget_show(item);
1055 } else {
1056 gtk_container_add(GTK_CONTAINER(applet)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_container_get_type ()))))))
, menubar);
1057 mate_panel_applet_set_background_widget(applet, menubar);
1058 gtk_widget_show(menubar);
1059 }
1060
1061 gtk_widget_show(GTK_WIDGET(applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
);
1062
1063 return TRUE(!(0));
1064
1065}
diff --git a/2020-04-09-124840-6850-1@e69dd120803f_shadow/report-918ee7.html b/2020-04-09-124840-6850-1@e69dd120803f_shadow/report-918ee7.html new file mode 100644 index 0000000..4f801fc --- /dev/null +++ b/2020-04-09-124840-6850-1@e69dd120803f_shadow/report-918ee7.html @@ -0,0 +1,1412 @@ + + + +applet-main.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:applet-main.c
Warning:line 941, column 4
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name applet-main.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -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 -mrelocation-model static -mthread-model posix -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -momit-leaf-frame-pointer -resource-dir /usr/lib64/clang/9.0.1 -D HAVE_CONFIG_H -I . -I .. -D G_LOG_DOMAIN="Indicator-Applet-Complete" -D DATADIR="/usr/local/share" -D INDICATOR_DIR="/usr/lib64/indicators3/7/" -D INDICATOR_ICONS_DIR="/usr/share/libindicator/icons/" -D INDICATOR_APPLET_COMPLETE -I ./.. -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/fribidi -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gio-unix-2.0 -I /usr/include/libdrm -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-panel-4.0/libmate-panel-applet -I /usr/include/libindicator3-0.4 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/fribidi -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gio-unix-2.0 -I /usr/include/libdrm -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/9.0.1/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wno-unused-parameter -Wno-sign-compare -fdebug-compilation-dir /rootdir/src -ferror-limit 19 -fmessage-length 0 -fobjc-runtime=gcc -fdiagnostics-show-option -vectorize-loops -vectorize-slp -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 -o /rootdir/html-report/2020-04-09-124840-6850-1 -x c applet-main.c +
+ + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2A small wrapper utility to load indicators and put them as menu items
3into the mate-panel using it's applet interface.
4
5Copyright 2009-2010 Canonical Ltd.
6
7Authors:
8 Ted Gould <ted@canonical.com>
9
10This program is free software: you can redistribute it and/or modify it
11under the terms of the GNU General Public License version 3, as published
12by the Free Software Foundation.
13
14This program is distributed in the hope that it will be useful, but
15WITHOUT ANY WARRANTY; without even the implied warranties of
16MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
17PURPOSE. See the GNU General Public License for more details.
18
19You should have received a copy of the GNU General Public License along
20with this program. If not, see <http://www.gnu.org/licenses/>.
21*/
22
23#include <stdlib.h>
24#include <string.h>
25#include <config.h>
26#include <glib/gi18n.h>
27#include <mate-panel-applet.h>
28#include <gdk/gdkkeysyms.h>
29#include <gtk/gtk.h>
30
31#if HAVE_UBUNTU_INDICATOR1
32
33#define INDICATOR_SERVICE_APPMENU"libappmenu.so" "libappmenu.so"
34#define INDICATOR_SERVICE_ME"libme.so" "libme.so"
35#define INDICATOR_SERVICE_DATETIME"libdatetime.so" "libdatetime.so"
36
37#define INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu" "com.canonical.indicator.appmenu"
38#define INDICATOR_SERVICE_ME_NG"com.canonical.indicator.me" "com.canonical.indicator.me"
39#define INDICATOR_SERVICE_DATETIME_NG"com.canonical.indicator.datetime" "com.canonical.indicator.datetime"
40
41#include <libindicator/indicator-object.h>
42#endif
43
44#if HAVE_AYATANA_INDICATOR
45
46#define INDICATOR_SERVICE_APPMENU"libappmenu.so" "libayatana-appmenu.so"
47#define INDICATOR_SERVICE_ME"libme.so" "libayatana-me.so"
48#define INDICATOR_SERVICE_DATETIME"libdatetime.so" "libayatana-datetime.so"
49
50#define INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu" "org.ayatana.indicator.appmenu"
51#define INDICATOR_SERVICE_ME_NG"com.canonical.indicator.me" "org.ayatana.indicator.me"
52#define INDICATOR_SERVICE_DATETIME_NG"com.canonical.indicator.datetime" "org.ayatana.indicator.datetime"
53
54#include <libayatana-indicator/indicator-object.h>
55#endif
56
57/* For new style indicators */
58
59#if HAVE_UBUNTU_INDICATOR1 && HAVE_UBUNTU_INDICATOR_NG
60
61#include <libido/libido.h>
62#include <libindicator/indicator-ng.h>
63
64#define INDICATOR_SERVICE_DIR "/usr/share/unity/indicators"
65
66#endif
67
68#if HAVE_AYATANA_INDICATOR && HAVE_AYATANA_INDICATOR_NG
69
70#include <libayatana-ido/libayatana-ido.h>
71#include <libayatana-indicator/indicator-ng.h>
72
73#define INDICATOR_SERVICE_DIR "/usr/share/ayatana/indicators"
74
75#endif
76
77#include "tomboykeybinder.h"
78
79static gchar * indicator_order[] = {
80#if HAVE_UBUNTU_INDICATOR1
81 "libapplication.so",
82 "libmessaging.so",
83 "libsoundmenu.so",
84 "libdatetime.so",
85 "libsession.so",
86#endif
87#if HAVE_AYATANA_INDICATOR
88 "libayatana-application.so",
89 "libayatana-messaging.so",
90 "libayatana-soundmenu.so",
91 "libayatana-datetime.so",
92 "libayatana-session.so",
93#endif
94 NULL((void*)0)
95};
96
97static GtkPackDirection packdirection;
98static MatePanelAppletOrient orient;
99static guint size;
100
101#define MENU_DATA_INDICATOR_OBJECT"indicator-object" "indicator-object"
102#define MENU_DATA_INDICATOR_ENTRY"indicator-entry" "indicator-entry"
103
104#define IO_DATA_ORDER_NUMBER"indicator-order-number" "indicator-order-number"
105
106static gboolean applet_fill_cb (MatePanelApplet * applet, const gchar * iid, gpointer data);
107
108static void update_accessible_desc (IndicatorObjectEntry * entry, GtkWidget * menuitem);
109
110/*************
111 * main
112 * ***********/
113
114#ifdef INDICATOR_APPLET
115MATE_PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletFactory",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
116 PANEL_TYPE_APPLET,int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
117 "indicator-applet",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
118 applet_fill_cb, NULL)int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
;
119#endif
120#ifdef INDICATOR_APPLET_COMPLETE1
121MATE_PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletCompleteFactory",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
122 PANEL_TYPE_APPLET,int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
123 "indicator-applet-complete",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
124 applet_fill_cb, NULL)int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
;
125#endif
126#ifdef INDICATOR_APPLET_APPMENU
127MATE_PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletAppmenuFactory",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
128 PANEL_TYPE_APPLET,int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
129 "indicator-applet-appmenu",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
130 applet_fill_cb, NULL)int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
;
131#endif
132
133/*************
134 * log files
135 * ***********/
136#ifdef INDICATOR_APPLET
137#define LOG_FILE_NAME"indicator-applet-complete.log" "indicator-applet.log"
138#endif
139#ifdef INDICATOR_APPLET_COMPLETE1
140#define LOG_FILE_NAME"indicator-applet-complete.log" "indicator-applet-complete.log"
141#endif
142#ifdef INDICATOR_APPLET_APPMENU
143#define LOG_FILE_NAME"indicator-applet-complete.log" "indicator-applet-appmenu.log"
144#endif
145GOutputStream * log_file = NULL((void*)0);
146
147/*****************
148 * Hotkey support
149 * **************/
150#ifdef INDICATOR_APPLET
151gchar * hotkey_keycode = "<Super>M";
152#endif
153#ifdef INDICATOR_APPLET_SESSION
154gchar * hotkey_keycode = "<Super>S";
155#endif
156#ifdef INDICATOR_APPLET_COMPLETE1
157gchar * hotkey_keycode = "<Super>S";
158#endif
159#ifdef INDICATOR_APPLET_APPMENU
160gchar * hotkey_keycode = "<Super>F1";
161#endif
162
163/********************
164 * Environment Names
165 * *******************/
166#ifdef INDICATOR_APPLET
167#define INDICATOR_SPECIFIC_ENV"indicator-applet-complete" "indicator-applet-original"
168#endif
169#ifdef INDICATOR_APPLET_COMPLETE1
170#define INDICATOR_SPECIFIC_ENV"indicator-applet-complete" "indicator-applet-complete"
171#endif
172#ifdef INDICATOR_APPLET_APPMENU
173#define INDICATOR_SPECIFIC_ENV"indicator-applet-complete" "indicator-applet-appmenu"
174#endif
175
176static const gchar * indicator_env[] = {
177 "indicator-applet",
178 INDICATOR_SPECIFIC_ENV"indicator-applet-complete",
179 NULL((void*)0)
180};
181
182/*************
183 * init function
184 * ***********/
185
186static gint
187name2order (const gchar * name) {
188 int i;
189
190 for (i = 0; indicator_order[i] != NULL((void*)0); i++) {
191 if (g_strcmp0(name, indicator_order[i]) == 0) {
192 return i;
193 }
194 }
195
196 return -1;
197}
198
199typedef struct _incoming_position_t incoming_position_t;
200struct _incoming_position_t {
201 gint objposition;
202 gint entryposition;
203 gint menupos;
204 gboolean found;
205};
206
207/* This function helps by determining where in the menu list
208 this new entry should be placed. It compares the objects
209 that they're on, and then the individual entries. Each
210 is progressively more expensive. */
211static void
212place_in_menu (GtkWidget * widget, gpointer user_data)
213{
214 incoming_position_t * position = (incoming_position_t *)user_data;
215 if (position->found) {
216 /* We've already been placed, just finish the foreach */
217 return;
218 }
219
220 IndicatorObject * io = INDICATOR_OBJECT(g_object_get_data(G_OBJECT(widget), MENU_DATA_INDICATOR_OBJECT))((((IndicatorObject*) g_type_check_instance_cast ((GTypeInstance
*) ((g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((widget)), (((GType) ((20) << (2)))
))))), "indicator-object"))), ((indicator_object_get_type ())
)))))
;
221 g_assert(io != NULL)do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_
; if (io != ((void*)0)) _g_boolean_var_ = 1; else _g_boolean_var_
= 0; _g_boolean_var_; }), 1)) ; else g_assertion_message_expr
("Indicator-Applet-Complete", "applet-main.c", 221, ((const char
*) (__func__)), "io != NULL"); } while (0)
;
222
223 gint objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER))((gint) (glong) (g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
), "indicator-order-number")))
;
224 /* We've already passed it, well, then this is where
225 we should be be. Stop! */
226 if (objposition > position->objposition) {
227 position->found = TRUE(!(0));
228 return;
229 }
230
231 /* The objects don't match yet, keep looking */
232 if (objposition < position->objposition) {
233 position->menupos++;
234 return;
235 }
236
237 /* The objects are the same, let's start looking at entries. */
238 IndicatorObjectEntry * entry = (IndicatorObjectEntry *)g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
239 gint entryposition = indicator_object_get_location(io, entry);
240
241 if (entryposition > position->entryposition) {
242 position->found = TRUE(!(0));
243 return;
244 }
245
246 if (entryposition < position->entryposition) {
247 position->menupos++;
248 return;
249 }
250
251 /* We've got the same object and the same entry. Well,
252 let's just put it right here then. */
253 position->found = TRUE(!(0));
254 return;
255}
256
257static void
258something_shown (GtkWidget * widget, gpointer user_data)
259{
260 GtkWidget * menuitem = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
261 gtk_widget_show(menuitem);
262}
263
264static void
265something_hidden (GtkWidget * widget, gpointer user_data)
266{
267 GtkWidget * menuitem = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
268 gtk_widget_hide(menuitem);
269}
270
271static void
272sensitive_cb (GObject * obj, GParamSpec * pspec, gpointer user_data)
273{
274 g_return_if_fail(GTK_IS_WIDGET(obj))do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((obj)); GType __t = ((gtk_widget_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet-Complete"
, ((const char*) (__func__)), "GTK_IS_WIDGET(obj)"); return; }
} while (0)
;
275 g_return_if_fail(GTK_IS_WIDGET(user_data))do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((gtk_widget_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet-Complete"
, ((const char*) (__func__)), "GTK_IS_WIDGET(user_data)"); return
; } } while (0)
;
276
277 gtk_widget_set_sensitive(GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
, gtk_widget_get_sensitive(GTK_WIDGET(obj)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(obj)), ((gtk_widget_get_type ()))))))
));
278 return;
279}
280
281static void
282entry_activated (GtkWidget * widget, gpointer user_data)
283{
284 g_return_if_fail(GTK_IS_WIDGET(widget))do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((gtk_widget_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet-Complete"
, ((const char*) (__func__)), "GTK_IS_WIDGET(widget)"); return
; } } while (0)
;
285 gpointer pio = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, "indicator");
286 g_return_if_fail(INDICATOR_IS_OBJECT(pio))do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((pio)); GType __t = ((indicator_object_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet-Complete"
, ((const char*) (__func__)), "INDICATOR_IS_OBJECT(pio)"); return
; } } while (0)
;
287 IndicatorObject * io = INDICATOR_OBJECT(pio)((((IndicatorObject*) g_type_check_instance_cast ((GTypeInstance
*) ((pio)), ((indicator_object_get_type ()))))))
;
288
289 return indicator_object_entry_activate(io, (IndicatorObjectEntry *)user_data, gtk_get_current_event_time());
290}
291
292static gboolean
293entry_scrolled (GtkWidget *menuitem, GdkEventScroll *event, gpointer data)
294{
295 IndicatorObject *io = g_object_get_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_OBJECT"indicator-object");
296 IndicatorObjectEntry *entry = g_object_get_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
297
298 g_return_val_if_fail(INDICATOR_IS_OBJECT(io), FALSE)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((io)); GType __t = ((indicator_object_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet-Complete"
, ((const char*) (__func__)), "INDICATOR_IS_OBJECT(io)"); return
((0)); } } while (0)
;
299
300 g_signal_emit_by_name (io, "scroll", 1, event->direction);
301 g_signal_emit_by_name (io, "scroll-entry", entry, 1, event->direction);
302 g_signal_emit_by_name (io, INDICATOR_OBJECT_SIGNAL_ENTRY_SCROLLED"entry-scrolled", entry, 1, event->direction);
303
304 return FALSE(0);
305}
306
307static void
308accessible_desc_update_cb (GtkWidget * widget, gpointer userdata)
309{
310 gpointer data = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
311
312 if (data != userdata) {
313 return;
314 }
315
316 IndicatorObjectEntry * entry = (IndicatorObjectEntry *)data;
317 update_accessible_desc(entry, widget);
318}
319
320static void
321accessible_desc_update (IndicatorObject * io, IndicatorObjectEntry * entry, GtkWidget * menubar)
322{
323 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, accessible_desc_update_cb, entry);
324 return;
325}
326
327#define PANEL_PADDING8 8
328static gboolean
329entry_resized (GtkWidget *applet, guint newsize, gpointer data)
330{
331 IndicatorObject *io = (IndicatorObject *)data;
332
333 size = newsize;
334
335 /* Work on the entries */
336 GList * entries = indicator_object_get_entries(io);
337 GList * entry = NULL((void*)0);
338
339 for (entry = entries; entry != NULL((void*)0); entry = g_list_next(entry)((entry) ? (((GList *)(entry))->next) : ((void*)0))) {
340 IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)entry->data;
341 if (entrydata->image != NULL((void*)0)) {
342 /* Resize to fit panel */
343 gtk_image_set_pixel_size (entrydata->image, size - PANEL_PADDING8);
344 }
345 }
346
347 return FALSE(0);
348}
349
350static void
351entry_added (IndicatorObject * io, IndicatorObjectEntry * entry, GtkWidget * menubar)
352{
353 g_debug("Signal: Entry Added");
354 gboolean something_visible = FALSE(0);
355 gboolean something_sensitive = FALSE(0);
356
357 GtkWidget * menuitem = gtk_menu_item_new();
358 GtkWidget * box = (packdirection == GTK_PACK_DIRECTION_LTR) ?
359 gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3) : gtk_box_new(GTK_ORIENTATION_VERTICAL, 3);
360
361 /* Allows indicators to receive mouse scroll event */
362 gtk_widget_add_events(GTK_WIDGET(menuitem)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(menuitem)), ((gtk_widget_get_type ()))))))
, GDK_SCROLL_MASK);
363
364 g_object_set_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "indicator", io);
365 g_object_set_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "box", box);
366
367 g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(entry_activated), entry)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((menuitem)), (((GType) ((20) << (2)
)))))))), ("activate"), (((GCallback) (entry_activated))), (entry
), ((void*)0), (GConnectFlags) 0)
;
368 g_signal_connect(G_OBJECT(menuitem), "scroll-event", G_CALLBACK(entry_scrolled), entry)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((menuitem)), (((GType) ((20) << (2)
)))))))), ("scroll-event"), (((GCallback) (entry_scrolled))),
(entry), ((void*)0), (GConnectFlags) 0)
;
369
370 if (entry->image != NULL((void*)0)) {
371 /* Resize to fit panel */
372 gtk_image_set_pixel_size (entry->image, size - PANEL_PADDING8);
373 gtk_box_pack_start(GTK_BOX(box)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((box
)), ((gtk_box_get_type ()))))))
, GTK_WIDGET(entry->image)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->image)), ((gtk_widget_get_type ()))))))
, FALSE(0), FALSE(0), 1);
374 if (gtk_widget_get_visible(GTK_WIDGET(entry->image)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->image)), ((gtk_widget_get_type ()))))))
)) {
375 something_visible = TRUE(!(0));
376 }
377
378 if (gtk_widget_get_sensitive(GTK_WIDGET(entry->image)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->image)), ((gtk_widget_get_type ()))))))
)) {
379 something_sensitive = TRUE(!(0));
380 }
381
382 g_signal_connect(G_OBJECT(entry->image), "show", G_CALLBACK(something_shown), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), ("show"), (((GCallback) (something_shown))), (menuitem
), ((void*)0), (GConnectFlags) 0)
;
383 g_signal_connect(G_OBJECT(entry->image), "hide", G_CALLBACK(something_hidden), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), ("hide"), (((GCallback) (something_hidden))), (
menuitem), ((void*)0), (GConnectFlags) 0)
;
384
385 g_signal_connect(G_OBJECT(entry->image), "notify::sensitive", G_CALLBACK(sensitive_cb), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), ("notify::sensitive"), (((GCallback) (sensitive_cb
))), (menuitem), ((void*)0), (GConnectFlags) 0)
;
386 }
387 if (entry->label != NULL((void*)0)) {
388 switch(packdirection) {
389 case GTK_PACK_DIRECTION_LTR:
390 gtk_label_set_angle(GTK_LABEL(entry->label)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_label_get_type ()))))))
, 0.0);
391 break;
392 case GTK_PACK_DIRECTION_TTB:
393 gtk_label_set_angle(GTK_LABEL(entry->label)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_label_get_type ()))))))
,
394 (orient == MATE_PANEL_APPLET_ORIENT_LEFT) ?
395 270.0 : 90.0);
396 break;
397 default:
398 break;
399 }
400 gtk_box_pack_start(GTK_BOX(box)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((box
)), ((gtk_box_get_type ()))))))
, GTK_WIDGET(entry->label)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_widget_get_type ()))))))
, FALSE(0), FALSE(0), 1);
401
402 if (gtk_widget_get_visible(GTK_WIDGET(entry->label)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_widget_get_type ()))))))
)) {
403 something_visible = TRUE(!(0));
404 }
405
406 if (gtk_widget_get_sensitive(GTK_WIDGET(entry->label)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_widget_get_type ()))))))
)) {
407 something_sensitive = TRUE(!(0));
408 }
409
410 g_signal_connect(G_OBJECT(entry->label), "show", G_CALLBACK(something_shown), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), ("show"), (((GCallback) (something_shown))), (menuitem
), ((void*)0), (GConnectFlags) 0)
;
411 g_signal_connect(G_OBJECT(entry->label), "hide", G_CALLBACK(something_hidden), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), ("hide"), (((GCallback) (something_hidden))), (
menuitem), ((void*)0), (GConnectFlags) 0)
;
412
413 g_signal_connect(G_OBJECT(entry->label), "notify::sensitive", G_CALLBACK(sensitive_cb), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), ("notify::sensitive"), (((GCallback) (sensitive_cb
))), (menuitem), ((void*)0), (GConnectFlags) 0)
;
414 }
415 gtk_container_add(GTK_CONTAINER(menuitem)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menuitem)), ((gtk_container_get_type ()))))))
, box);
416 gtk_widget_show(box);
417
418 if (entry->menu != NULL((void*)0)) {
419 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem)((((GtkMenuItem*) g_type_check_instance_cast ((GTypeInstance*
) ((menuitem)), ((gtk_menu_item_get_type ()))))))
, GTK_WIDGET(entry->menu)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->menu)), ((gtk_widget_get_type ()))))))
);
420 }
421
422 incoming_position_t position;
423 position.objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER))((gint) (glong) (g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
), "indicator-order-number")))
;
424 position.entryposition = indicator_object_get_location(io, entry);
425 position.menupos = 0;
426 position.found = FALSE(0);
427
428 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, place_in_menu, &position);
429
430 gtk_menu_shell_insert(GTK_MENU_SHELL(menubar)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_menu_shell_get_type ()))))))
, menuitem, position.menupos);
431
432 if (something_visible) {
433 if (entry->accessible_desc != NULL((void*)0)) {
434 update_accessible_desc(entry, menuitem);
435 }
436 gtk_widget_show(menuitem);
437 }
438 gtk_widget_set_sensitive(menuitem, something_sensitive);
439
440 g_object_set_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry", entry);
441 g_object_set_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_OBJECT"indicator-object", io);
442
443 return;
444}
445
446static void
447entry_removed_cb (GtkWidget * widget, gpointer userdata)
448{
449 gpointer data = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
450
451 if (data != userdata) {
452 return;
453 }
454
455 IndicatorObjectEntry * entry = (IndicatorObjectEntry *)data;
456 if (entry->label != NULL((void*)0)) {
457 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(something_shown), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_shown))), (widget
))
;
458 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(something_hidden), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_hidden))), (widget
))
;
459 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(sensitive_cb), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (sensitive_cb))), (widget)
)
;
460 }
461 if (entry->image != NULL((void*)0)) {
462 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(something_shown), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_shown))), (widget
))
;
463 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(something_hidden), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_hidden))), (widget
))
;
464 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(sensitive_cb), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (sensitive_cb))), (widget)
)
;
465 }
466
467 gtk_widget_destroy(widget);
468 return;
469}
470
471static void
472entry_removed (IndicatorObject * io G_GNUC_UNUSED__attribute__((__unused__)), IndicatorObjectEntry * entry,
473 gpointer user_data)
474{
475 g_debug("Signal: Entry Removed");
476
477 gtk_container_foreach(GTK_CONTAINER(user_data)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((gtk_container_get_type ()))))))
, entry_removed_cb, entry);
478
479 return;
480}
481
482static void
483entry_moved_find_cb (GtkWidget * widget, gpointer userdata)
484{
485 gpointer * array = (gpointer *)userdata;
486 if (array[1] != NULL((void*)0)) {
487 return;
488 }
489
490 gpointer data = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
491
492 if (data != array[0]) {
493 return;
494 }
495
496 array[1] = widget;
497 return;
498}
499
500/* Gets called when an entry for an object was moved. */
501static void
502entry_moved (IndicatorObject * io, IndicatorObjectEntry * entry,
503 gint old G_GNUC_UNUSED__attribute__((__unused__)), gint new G_GNUC_UNUSED__attribute__((__unused__)), gpointer user_data)
504{
505 GtkWidget * menubar = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
506
507 gpointer array[2];
508 array[0] = entry;
509 array[1] = NULL((void*)0);
510
511 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, entry_moved_find_cb, array);
512 if (array[1] == NULL((void*)0)) {
513 g_warning("Moving an entry that isn't in our menus.");
514 return;
515 }
516
517 GtkWidget * mi = GTK_WIDGET(array[1])((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(array[1])), ((gtk_widget_get_type ()))))))
;
518 g_object_ref(G_OBJECT(mi)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
mi)), (((GType) ((20) << (2))))))))
);
519 gtk_container_remove(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, mi);
520
521 incoming_position_t position;
522 position.objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER))((gint) (glong) (g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
), "indicator-order-number")))
;
523 position.entryposition = indicator_object_get_location(io, entry);
524 position.menupos = 0;
525 position.found = FALSE(0);
526
527 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, place_in_menu, &position);
528
529 gtk_menu_shell_insert(GTK_MENU_SHELL(menubar)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_menu_shell_get_type ()))))))
, mi, position.menupos);
530 g_object_unref(G_OBJECT(mi)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
mi)), (((GType) ((20) << (2))))))))
);
531
532 return;
533}
534
535static void
536menu_show (IndicatorObject * io, IndicatorObjectEntry * entry,
537 guint32 timestamp, gpointer user_data)
538{
539 GtkWidget * menubar = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
540
541 if (entry == NULL((void*)0)) {
542 /* Close any open menus instead of opening one */
543 GList * entries = indicator_object_get_entries(io);
544 GList * iterator = NULL((void*)0);
545 for (iterator = entries; iterator != NULL((void*)0); iterator = g_list_next(iterator)((iterator) ? (((GList *)(iterator))->next) : ((void*)0))) {
546 IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)iterator->data;
547 gtk_menu_popdown(entrydata->menu);
548 }
549 g_list_free(entries);
550
551 /* And tell the menubar to exit activation mode too */
552 gtk_menu_shell_cancel(GTK_MENU_SHELL(menubar)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_menu_shell_get_type ()))))))
);
553 return;
554 }
555
556 // TODO: do something sensible here
557}
558
559static void
560update_accessible_desc(IndicatorObjectEntry * entry, GtkWidget * menuitem)
561{
562 /* FIXME: We need to deal with the use case where the contents of the
563 label overrides what is found in the atk object's name, or at least
564 orca speaks the label instead of the atk object name.
565 */
566 AtkObject * menuitem_obj = gtk_widget_get_accessible(menuitem);
567 if (menuitem_obj == NULL((void*)0)) {
568 /* Should there be an error printed here? */
569 return;
570 }
571
572 if (entry->accessible_desc != NULL((void*)0)) {
573 atk_object_set_name(menuitem_obj, entry->accessible_desc);
574 } else {
575 atk_object_set_name(menuitem_obj, "");
576 }
577 return;
578}
579
580static void
581load_indicator (MatePanelApplet *applet, GtkWidget * menubar, IndicatorObject *io, const gchar *name)
582{
583 /* Set the environment it's in */
584 indicator_object_set_environment(io, (const GStrv)indicator_env);
585
586 /* Attach the 'name' to the object */
587#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
588 int pos = 5000 - indicator_object_get_position(io);
589 if (pos > 5000) {
590 pos = name2order(name);
591 }
592#else
593 int pos = name2order(name);
594#endif
595
596 g_object_set_data(G_OBJECT(io)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
io)), (((GType) ((20) << (2))))))))
, IO_DATA_ORDER_NUMBER"indicator-order-number", GINT_TO_POINTER(pos)((gpointer) (glong) (pos)));
597
598 /* Connect to its signals */
599 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED, G_CALLBACK(entry_added), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("entry-added"), (((GCallback) (entry_added))), (menubar)
, ((void*)0), (GConnectFlags) 0)
;
600 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED, G_CALLBACK(entry_removed), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("entry-removed"), (((GCallback) (entry_removed))), (menubar
), ((void*)0), (GConnectFlags) 0)
;
601 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_MOVED, G_CALLBACK(entry_moved), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("entry-moved"), (((GCallback) (entry_moved))), (menubar)
, ((void*)0), (GConnectFlags) 0)
;
602 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_MENU_SHOW, G_CALLBACK(menu_show), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("menu-show"), (((GCallback) (menu_show))), (menubar), ((
void*)0), (GConnectFlags) 0)
;
603 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ACCESSIBLE_DESC_UPDATE, G_CALLBACK(accessible_desc_update), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("accessible-desc-update"), (((GCallback) (accessible_desc_update
))), (menubar), ((void*)0), (GConnectFlags) 0)
;
604
605 /* Track panel resize */
606 g_signal_connect_object(G_OBJECT(applet)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
applet)), (((GType) ((20) << (2))))))))
, "change-size", G_CALLBACK(entry_resized)((GCallback) (entry_resized)), G_OBJECT(io)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
io)), (((GType) ((20) << (2))))))))
, 0);
607
608 /* Work on the entries */
609 GList * entries = indicator_object_get_entries(io);
610 GList * entry = NULL((void*)0);
611
612 for (entry = entries; entry != NULL((void*)0); entry = g_list_next(entry)((entry) ? (((GList *)(entry))->next) : ((void*)0))) {
613 IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)entry->data;
614 entry_added(io, entrydata, menubar);
615 }
616
617 g_list_free(entries);
618}
619
620static gboolean
621load_module (const gchar * name, MatePanelApplet *applet, GtkWidget * menubar)
622{
623 g_debug("Looking at Module: %s", name);
624 g_return_val_if_fail(name != NULL, FALSE)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if (name != ((void*)0)) _g_boolean_var_ = 1; else _g_boolean_var_
= 0; _g_boolean_var_; }), 1))) { } else { g_return_if_fail_warning
("Indicator-Applet-Complete", ((const char*) (__func__)), "name != NULL"
); return ((0)); } } while (0)
;
625
626 if (!g_str_has_suffix(name, G_MODULE_SUFFIX"so")) {
627 return FALSE(0);
628 }
629
630 g_debug("Loading Module: %s", name);
631
632 /* Build the object for the module */
633 gchar * fullpath = g_build_filename(INDICATOR_DIR"/usr/lib64/indicators3/7/", name, NULL((void*)0));
634 IndicatorObject * io = indicator_object_new_from_file(fullpath);
635 g_free(fullpath);
636
637 load_indicator(applet, menubar, io, name);
638
639 return TRUE(!(0));
640}
641
642static void
643load_modules (MatePanelApplet *applet, GtkWidget *menubar, gint *indicators_loaded)
644{
645 if (g_file_test(INDICATOR_DIR"/usr/lib64/indicators3/7/", (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))) {
646 GDir * dir = g_dir_open(INDICATOR_DIR"/usr/lib64/indicators3/7/", 0, NULL((void*)0));
647
648 const gchar * name;
649 gint count = 0;
650 while ((name = g_dir_read_name(dir)) != NULL((void*)0)) {
651#ifdef INDICATOR_APPLET_APPMENU
652 if (g_strcmp0(name, INDICATOR_SERVICE_APPMENU"libappmenu.so")) {
653 continue;
654 }
655#else
656 if (!g_strcmp0(name, INDICATOR_SERVICE_APPMENU"libappmenu.so")) {
657 continue;
658 }
659#endif
660#ifdef INDICATOR_APPLET
661 if (!g_strcmp0(name, INDICATOR_SERVICE_ME"libme.so")) {
662 continue;
663 }
664 if (!g_strcmp0(name, INDICATOR_SERVICE_DATETIME"libdatetime.so")) {
665 continue;
666 }
667#endif
668 if (load_module(name, applet, menubar)) {
669 count++;
670 }
671 }
672
673 *indicators_loaded += count;
674
675 g_dir_close (dir);
676 }
677}
678
679#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
680
681static void
682load_indicators_from_indicator_files (MatePanelApplet *applet, GtkWidget *menubar, gint *indicators_loaded)
683{
684 GDir *dir;
685 const gchar *name;
686 GError *error = NULL((void*)0);
687
688 dir = g_dir_open (INDICATOR_SERVICE_DIR, 0, &error);
689
690 if (!dir) {
691 g_warning ("unable to open indicator service file directory: %s", error->message);
692 g_error_free (error);
693
694 return;
695 }
696
697 gint count = 0;
698 while ((name = g_dir_read_name (dir))) {
699 gchar *filename;
700 IndicatorNg *indicator;
701
702 filename = g_build_filename (INDICATOR_SERVICE_DIR, name, NULL((void*)0));
703 indicator = indicator_ng_new_for_profile (filename, "desktop", &error);
704 g_free (filename);
705
706#ifdef INDICATOR_APPLET_APPMENU
707 if (g_strcmp0(name, INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu")) {
708 continue;
709 }
710#else
711 if (!g_strcmp0(name, INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu")) {
712 continue;
713 }
714#endif
715#ifdef INDICATOR_APPLET
716 if (!g_strcmp0(name, INDICATOR_SERVICE_ME_NG"com.canonical.indicator.me")) {
717 continue;
718 }
719 if (!g_strcmp0(name, INDICATOR_SERVICE_DATETIME_NG"com.canonical.indicator.datetime")) {
720 continue;
721 }
722#endif
723
724 if (indicator) {
725 load_indicator(applet, menubar, INDICATOR_OBJECT (indicator)((((IndicatorObject*) g_type_check_instance_cast ((GTypeInstance
*) ((indicator)), ((indicator_object_get_type ()))))))
, name);
726 count++;
727 }else{
728 g_warning ("unable to load '%s': %s", name, error->message);
729 g_clear_error (&error);
730 }
731 }
732
733 *indicators_loaded += count;
734
735 g_dir_close (dir);
736}
737#endif /* HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG */
738
739static void
740hotkey_filter (char * keystring G_GNUC_UNUSED__attribute__((__unused__)), gpointer data)
741{
742 g_return_if_fail(GTK_IS_MENU_SHELL(data))do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((data)); GType __t = ((gtk_menu_shell_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet-Complete"
, ((const char*) (__func__)), "GTK_IS_MENU_SHELL(data)"); return
; } } while (0)
;
743
744 /* Oh, wow, it's us! */
745 GList * children = gtk_container_get_children(GTK_CONTAINER(data)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((gtk_container_get_type ()))))))
);
746 if (children == NULL((void*)0)) {
747 g_debug("Menubar has no children");
748 return;
749 }
750
751 gtk_menu_shell_select_item(GTK_MENU_SHELL(data)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((gtk_menu_shell_get_type ()))))))
, GTK_WIDGET(g_list_last(children)->data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(g_list_last(children)->data)), ((gtk_widget_get_type ()))
))))
);
752 g_list_free(children);
753 return;
754}
755
756static gboolean
757menubar_press (GtkWidget * widget,
758 GdkEventButton *event,
759 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
760{
761 if (event->button != 1) {
762 g_signal_stop_emission_by_name(widget, "button-press-event");
763 }
764
765 return FALSE(0);
766}
767
768static gboolean
769menubar_on_draw (GtkWidget * widget,
770 cairo_t * cr,
771 GtkWidget * menubar)
772{
773 /* FIXME: either port to gtk_render_focus or remove this function */
774 if (gtk_widget_has_focus(menubar))
775 gtk_paint_focus(gtk_widget_get_style(widget),
776 cr,
777 gtk_widget_get_state(menubar),
778 widget, "menubar-applet", 0, 0, -1, -1);
779
780 return FALSE(0);
781}
782
783static void
784about_cb (GtkAction *action G_GNUC_UNUSED__attribute__((__unused__)),
785 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
786{
787 static const gchar *authors[] = {
788 "Ted Gould <ted@canonical.com>",
789 NULL((void*)0)
790 };
791
792 static gchar *license[] = {
793 N_("This program is free software: you can redistribute it and/or modify it ""This program is free software: you can redistribute it and/or modify it "
"under the terms of the GNU General Public License version 3, as published "
"by the Free Software Foundation."
794 "under the terms of the GNU General Public License version 3, as published ""This program is free software: you can redistribute it and/or modify it "
"under the terms of the GNU General Public License version 3, as published "
"by the Free Software Foundation."
795 "by the Free Software Foundation.")"This program is free software: you can redistribute it and/or modify it "
"under the terms of the GNU General Public License version 3, as published "
"by the Free Software Foundation."
,
796 N_("This program is distributed in the hope that it will be useful, but ""This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
797 "WITHOUT ANY WARRANTY; without even the implied warranties of ""This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
798 "MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR ""This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
799 "PURPOSE. See the GNU General Public License for more details.")"This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
,
800 N_("You should have received a copy of the GNU General Public License along ""You should have received a copy of the GNU General Public License along "
"with this program. If not, see <http://www.gnu.org/licenses/>."
801 "with this program. If not, see <http://www.gnu.org/licenses/>.")"You should have received a copy of the GNU General Public License along "
"with this program. If not, see <http://www.gnu.org/licenses/>."
,
802 NULL((void*)0)
803 };
804 gchar *license_i18n;
805
806 license_i18n = g_strconcat (_(license[0])dcgettext (((void*)0), license[0], 5), "\n\n", _(license[1])dcgettext (((void*)0), license[1], 5), "\n\n", _(license[2])dcgettext (((void*)0), license[2], 5), NULL((void*)0));
807
808 gtk_show_about_dialog(NULL((void*)0),
809 "version", VERSION"1.24.0",
810 "copyright", _("Copyright \xc2\xa9 2009-2010 Canonical, Ltd.\n"dcgettext (((void*)0), "Copyright \xc2\xa9 2009-2010 Canonical, Ltd.\n"
"Copyright \xc2\xa9 2011-2020 MATE developers", 5)
811 "Copyright \xc2\xa9 2011-2020 MATE developers")dcgettext (((void*)0), "Copyright \xc2\xa9 2009-2010 Canonical, Ltd.\n"
"Copyright \xc2\xa9 2011-2020 MATE developers", 5)
,
812#ifdef INDICATOR_APPLET_APPMENU
813 "comments", _("An applet to hold your application menus.")dcgettext (((void*)0), "An applet to hold your application menus."
, 5)
,
814#endif
815 "comments", _("An applet to hold all of the system indicators.")dcgettext (((void*)0), "An applet to hold all of the system indicators."
, 5)
,
816 "authors", authors,
817 "license", license_i18n,
818 "wrap-license", TRUE(!(0)),
819 "translator-credits", _("translator-credits")dcgettext (((void*)0), "translator-credits", 5),
820 "logo-icon-name", "mate-indicator-applet",
821 "icon-name", "mate-indicator-applet",
822 "website", "https://mate-desktop.org",
823 "website-label", _("MATE Website")dcgettext (((void*)0), "MATE Website", 5),
824 NULL((void*)0)
825 );
826
827 g_free (license_i18n);
828
829 return;
830}
831
832static gboolean
833swap_orient_cb (GtkWidget *item, gpointer data)
834{
835 GtkWidget *from = (GtkWidget *) data;
836 GtkWidget *to = (GtkWidget *) g_object_get_data(G_OBJECT(from)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
from)), (((GType) ((20) << (2))))))))
, "to");
837 g_object_ref(G_OBJECT(item)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
item)), (((GType) ((20) << (2))))))))
);
838 gtk_container_remove(GTK_CONTAINER(from)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((from)), ((gtk_container_get_type ()))))))
, item);
839 if (GTK_IS_LABEL(item)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(item)); GType __t = ((gtk_label_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; }))))
) {
840 switch(packdirection) {
841 case GTK_PACK_DIRECTION_LTR:
842 gtk_label_set_angle(GTK_LABEL(item)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(item)), ((gtk_label_get_type ()))))))
, 0.0);
843 break;
844 case GTK_PACK_DIRECTION_TTB:
845 gtk_label_set_angle(GTK_LABEL(item)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(item)), ((gtk_label_get_type ()))))))
,
846 (orient == MATE_PANEL_APPLET_ORIENT_LEFT) ?
847 270.0 : 90.0);
848 break;
849 default:
850 break;
851 }
852 }
853 gtk_box_pack_start(GTK_BOX(to)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((to
)), ((gtk_box_get_type ()))))))
, item, FALSE(0), FALSE(0), 0);
854 return TRUE(!(0));
855}
856
857static gboolean
858reorient_box_cb (GtkWidget *menuitem, gpointer data)
859{
860 GtkWidget *from = g_object_get_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "box");
861 GtkWidget *to = (packdirection == GTK_PACK_DIRECTION_LTR) ?
862 gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0) : gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
863 g_object_set_data(G_OBJECT(from)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
from)), (((GType) ((20) << (2))))))))
, "to", to);
864 gtk_container_foreach(GTK_CONTAINER(from)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((from)), ((gtk_container_get_type ()))))))
, (GtkCallback)swap_orient_cb,
865 from);
866 gtk_container_remove(GTK_CONTAINER(menuitem)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menuitem)), ((gtk_container_get_type ()))))))
, from);
867 gtk_container_add(GTK_CONTAINER(menuitem)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menuitem)), ((gtk_container_get_type ()))))))
, to);
868 g_object_set_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "box", to);
869 gtk_widget_show_all(menuitem);
870 return TRUE(!(0));
871}
872
873static gboolean
874matepanelapplet_reorient_cb (GtkWidget *applet, MatePanelAppletOrient neworient,
875 gpointer data)
876{
877 GtkWidget *menubar = (GtkWidget *)data;
878 if ((((neworient == MATE_PANEL_APPLET_ORIENT_UP) ||
879 (neworient == MATE_PANEL_APPLET_ORIENT_DOWN)) &&
880 ((orient == MATE_PANEL_APPLET_ORIENT_LEFT) ||
881 (orient == MATE_PANEL_APPLET_ORIENT_RIGHT))) ||
882 (((neworient == MATE_PANEL_APPLET_ORIENT_LEFT) ||
883 (neworient == MATE_PANEL_APPLET_ORIENT_RIGHT)) &&
884 ((orient == MATE_PANEL_APPLET_ORIENT_UP) ||
885 (orient == MATE_PANEL_APPLET_ORIENT_DOWN)))) {
886 packdirection = (packdirection == GTK_PACK_DIRECTION_LTR) ?
887 GTK_PACK_DIRECTION_TTB : GTK_PACK_DIRECTION_LTR;
888 gtk_menu_bar_set_pack_direction(GTK_MENU_BAR(menubar)((((GtkMenuBar*) g_type_check_instance_cast ((GTypeInstance*)
((menubar)), ((gtk_menu_bar_get_type ()))))))
,
889 packdirection);
890 orient = neworient;
891 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
,
892 (GtkCallback)reorient_box_cb, NULL((void*)0));
893 }
894 orient = neworient;
895 return FALSE(0);
896}
897
898#ifdef N_
899#undef N_
900#endif
901#define N_(x)x x
902
903static void
904log_to_file_cb (GObject * source_obj G_GNUC_UNUSED__attribute__((__unused__)),
905 GAsyncResult * result G_GNUC_UNUSED__attribute__((__unused__)), gpointer user_data)
906{
907 g_free(user_data);
908 return;
909}
910
911static void
912log_to_file (const gchar * domain G_GNUC_UNUSED__attribute__((__unused__)),
913 GLogLevelFlags level G_GNUC_UNUSED__attribute__((__unused__)),
914 const gchar * message,
915 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
916{
917 if (log_file == NULL((void*)0)) {
918 GError * error = NULL((void*)0);
919 gchar * filename = g_build_filename(g_get_user_cache_dir(), LOG_FILE_NAME"indicator-applet-complete.log", NULL((void*)0));
920 GFile * file = g_file_new_for_path(filename);
921 g_free(filename);
922
923 if (!g_file_test(g_get_user_cache_dir(), G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) {
924 GFile * cachedir = g_file_new_for_path(g_get_user_cache_dir());
925 g_file_make_directory_with_parents(cachedir, NULL((void*)0), &error);
926
927 if (error != NULL((void*)0)) {
928 g_error("Unable to make directory '%s' for log file: %s", g_get_user_cache_dir(), error->message);
929 return;
930 }
931 }
932
933 g_file_delete(file, NULL((void*)0), NULL((void*)0));
934
935 GFileIOStream * io = g_file_create_readwrite(file,
936 G_FILE_CREATE_REPLACE_DESTINATION, /* flags */
937 NULL((void*)0), /* cancelable */
938 &error); /* error */
939 if (error != NULL((void*)0)) {
940 g_error("Unable to replace file: %s", error->message);
941 return;
This statement is never executed
942 }
943
944 log_file = g_io_stream_get_output_stream(G_IO_STREAM(io)((((GIOStream*) g_type_check_instance_cast ((GTypeInstance*) (
(io)), ((g_io_stream_get_type ()))))))
);
945 }
946
947 gchar * outputstring = g_strdup_printf("%s\n", message);
948 g_output_stream_write_async(log_file,
949 outputstring, /* data */
950 strlen(outputstring), /* length */
951 G_PRIORITY_LOW300, /* priority */
952 NULL((void*)0), /* cancelable */
953 log_to_file_cb, /* callback */
954 outputstring); /* data */
955
956 return;
957}
958
959static gboolean
960applet_fill_cb (MatePanelApplet * applet, const gchar * iid G_GNUC_UNUSED__attribute__((__unused__)),
961 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
962{
963#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
964 ido_init();
965#endif
966
967 static const GtkActionEntry menu_actions[] = {
968 {"About", GTK_STOCK_ABOUT((GtkStock)"gtk-about"), N_("_About")"_About", NULL((void*)0), NULL((void*)0), G_CALLBACK(about_cb)((GCallback) (about_cb))}
969 };
970 static const gchar *menu_xml = "<menuitem name=\"About\" action=\"About\"/>";
971
972 static gboolean first_time = FALSE(0);
973 GtkWidget *menubar;
974 gint indicators_loaded = 0;
975 GtkActionGroup *action_group;
976
977 if (!first_time)
978 {
979 first_time = TRUE(!(0));
980#ifdef INDICATOR_APPLET
981 g_set_application_name(_("Indicator Applet")dcgettext (((void*)0), "Indicator Applet", 5));
982#endif
983#ifdef INDICATOR_APPLET_COMPLETE1
984 g_set_application_name(_("Indicator Applet Complete")dcgettext (((void*)0), "Indicator Applet Complete", 5));
985#endif
986#ifdef INDICATOR_APPLET_APPMENU
987 g_set_application_name(_("Indicator Applet Application Menu")dcgettext (((void*)0), "Indicator Applet Application Menu", 5
)
);
988#endif
989
990 g_log_set_default_handler(log_to_file, NULL((void*)0));
991
992 tomboy_keybinder_init();
993 }
994
995 /* Set panel options */
996 gtk_container_set_border_width(GTK_CONTAINER (applet)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_container_get_type ()))))))
, 0);
997 mate_panel_applet_set_flags(applet, MATE_PANEL_APPLET_EXPAND_MINOR);
998 menubar = gtk_menu_bar_new();
999 action_group = gtk_action_group_new ("Indicator Applet Actions");
1000 gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE"mate-indicator-applet");
1001 gtk_action_group_add_actions (action_group, menu_actions,
1002 G_N_ELEMENTS (menu_actions)(sizeof (menu_actions) / sizeof ((menu_actions)[0])),
1003 menubar);
1004 mate_panel_applet_setup_menu(applet, menu_xml, action_group);
1005 g_object_unref(action_group);
1006#ifdef INDICATOR_APPLET
1007 atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
),
1008 "indicator-applet");
1009#endif
1010#ifdef INDICATOR_APPLET_COMPLETE1
1011 atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
),
1012 "indicator-applet-complete");
1013#endif
1014#ifdef INDICATOR_APPLET_APPMENU
1015 atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
),
1016 "indicator-applet-appmenu");
1017#endif
1018
1019 /* Init some theme/icon stuff */
1020 gtk_icon_theme_append_search_path(gtk_icon_theme_get_default(),
1021 INDICATOR_ICONS_DIR"/usr/share/libindicator/icons/");
1022 /* g_debug("Icons directory: %s", INDICATOR_ICONS_DIR); */
1023 gtk_widget_set_name(GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
, "fast-user-switch-applet");
1024
1025 /* Build menubar */
1026 size = (mate_panel_applet_get_size (applet));
1027 orient = (mate_panel_applet_get_orient(applet));
1028 packdirection = ((orient == MATE_PANEL_APPLET_ORIENT_UP) ||
1029 (orient == MATE_PANEL_APPLET_ORIENT_DOWN)) ?
1030 GTK_PACK_DIRECTION_LTR : GTK_PACK_DIRECTION_TTB;
1031 gtk_menu_bar_set_pack_direction(GTK_MENU_BAR(menubar)((((GtkMenuBar*) g_type_check_instance_cast ((GTypeInstance*)
((menubar)), ((gtk_menu_bar_get_type ()))))))
,
1032 packdirection);
1033 gtk_widget_set_can_focus (menubar, TRUE(!(0)));
1034 gtk_widget_set_name(GTK_WIDGET (menubar)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(menubar)), ((gtk_widget_get_type ()))))))
, "fast-user-switch-menubar");
1035 g_signal_connect(menubar, "button-press-event", G_CALLBACK(menubar_press), NULL)g_signal_connect_data ((menubar), ("button-press-event"), (((
GCallback) (menubar_press))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
;
1036 g_signal_connect_after(menubar, "draw", G_CALLBACK(menubar_on_draw), menubar)g_signal_connect_data ((menubar), ("draw"), (((GCallback) (menubar_on_draw
))), (menubar), ((void*)0), G_CONNECT_AFTER)
;
1037 g_signal_connect(applet, "change-orient",g_signal_connect_data ((applet), ("change-orient"), (((GCallback
) (matepanelapplet_reorient_cb))), (menubar), ((void*)0), (GConnectFlags
) 0)
1038 G_CALLBACK(matepanelapplet_reorient_cb), menubar)g_signal_connect_data ((applet), ("change-orient"), (((GCallback
) (matepanelapplet_reorient_cb))), (menubar), ((void*)0), (GConnectFlags
) 0)
;
1039 gtk_container_set_border_width(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, 0);
1040
1041 /* Add in filter func */
1042 tomboy_keybinder_bind(hotkey_keycode, hotkey_filter, menubar);
1043
1044 load_modules(applet, menubar, &indicators_loaded);
1045#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
1046 load_indicators_from_indicator_files(applet, menubar, &indicators_loaded);
1047#endif
1048
1049 if (indicators_loaded == 0) {
1050 /* A label to allow for click through */
1051 GtkWidget * item = gtk_label_new(_("No Indicators")dcgettext (((void*)0), "No Indicators", 5));
1052 mate_panel_applet_set_background_widget(applet, item);
1053 gtk_container_add(GTK_CONTAINER(applet)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_container_get_type ()))))))
, item);
1054 gtk_widget_show(item);
1055 } else {
1056 gtk_container_add(GTK_CONTAINER(applet)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_container_get_type ()))))))
, menubar);
1057 mate_panel_applet_set_background_widget(applet, menubar);
1058 gtk_widget_show(menubar);
1059 }
1060
1061 gtk_widget_show(GTK_WIDGET(applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
);
1062
1063 return TRUE(!(0));
1064
1065}
diff --git a/2020-04-09-124840-6850-1@e69dd120803f_shadow/report-ed246f.html b/2020-04-09-124840-6850-1@e69dd120803f_shadow/report-ed246f.html new file mode 100644 index 0000000..79f0cc9 --- /dev/null +++ b/2020-04-09-124840-6850-1@e69dd120803f_shadow/report-ed246f.html @@ -0,0 +1,1412 @@ + + + +applet-main.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:applet-main.c
Warning:line 941, column 4
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name applet-main.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -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 -mrelocation-model static -mthread-model posix -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -momit-leaf-frame-pointer -resource-dir /usr/lib64/clang/9.0.1 -D HAVE_CONFIG_H -I . -I .. -D G_LOG_DOMAIN="Indicator-Applet" -D DATADIR="/usr/local/share" -D INDICATOR_DIR="/usr/lib64/indicators3/7/" -D INDICATOR_ICONS_DIR="/usr/share/libindicator/icons/" -D INDICATOR_APPLET -I ./.. -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/fribidi -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gio-unix-2.0 -I /usr/include/libdrm -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-panel-4.0/libmate-panel-applet -I /usr/include/libindicator3-0.4 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/fribidi -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gio-unix-2.0 -I /usr/include/libdrm -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/9.0.1/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wno-unused-parameter -Wno-sign-compare -fdebug-compilation-dir /rootdir/src -ferror-limit 19 -fmessage-length 0 -fobjc-runtime=gcc -fdiagnostics-show-option -vectorize-loops -vectorize-slp -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 -o /rootdir/html-report/2020-04-09-124840-6850-1 -x c applet-main.c +
+ + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2A small wrapper utility to load indicators and put them as menu items
3into the mate-panel using it's applet interface.
4
5Copyright 2009-2010 Canonical Ltd.
6
7Authors:
8 Ted Gould <ted@canonical.com>
9
10This program is free software: you can redistribute it and/or modify it
11under the terms of the GNU General Public License version 3, as published
12by the Free Software Foundation.
13
14This program is distributed in the hope that it will be useful, but
15WITHOUT ANY WARRANTY; without even the implied warranties of
16MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
17PURPOSE. See the GNU General Public License for more details.
18
19You should have received a copy of the GNU General Public License along
20with this program. If not, see <http://www.gnu.org/licenses/>.
21*/
22
23#include <stdlib.h>
24#include <string.h>
25#include <config.h>
26#include <glib/gi18n.h>
27#include <mate-panel-applet.h>
28#include <gdk/gdkkeysyms.h>
29#include <gtk/gtk.h>
30
31#if HAVE_UBUNTU_INDICATOR1
32
33#define INDICATOR_SERVICE_APPMENU"libappmenu.so" "libappmenu.so"
34#define INDICATOR_SERVICE_ME"libme.so" "libme.so"
35#define INDICATOR_SERVICE_DATETIME"libdatetime.so" "libdatetime.so"
36
37#define INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu" "com.canonical.indicator.appmenu"
38#define INDICATOR_SERVICE_ME_NG"com.canonical.indicator.me" "com.canonical.indicator.me"
39#define INDICATOR_SERVICE_DATETIME_NG"com.canonical.indicator.datetime" "com.canonical.indicator.datetime"
40
41#include <libindicator/indicator-object.h>
42#endif
43
44#if HAVE_AYATANA_INDICATOR
45
46#define INDICATOR_SERVICE_APPMENU"libappmenu.so" "libayatana-appmenu.so"
47#define INDICATOR_SERVICE_ME"libme.so" "libayatana-me.so"
48#define INDICATOR_SERVICE_DATETIME"libdatetime.so" "libayatana-datetime.so"
49
50#define INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu" "org.ayatana.indicator.appmenu"
51#define INDICATOR_SERVICE_ME_NG"com.canonical.indicator.me" "org.ayatana.indicator.me"
52#define INDICATOR_SERVICE_DATETIME_NG"com.canonical.indicator.datetime" "org.ayatana.indicator.datetime"
53
54#include <libayatana-indicator/indicator-object.h>
55#endif
56
57/* For new style indicators */
58
59#if HAVE_UBUNTU_INDICATOR1 && HAVE_UBUNTU_INDICATOR_NG
60
61#include <libido/libido.h>
62#include <libindicator/indicator-ng.h>
63
64#define INDICATOR_SERVICE_DIR "/usr/share/unity/indicators"
65
66#endif
67
68#if HAVE_AYATANA_INDICATOR && HAVE_AYATANA_INDICATOR_NG
69
70#include <libayatana-ido/libayatana-ido.h>
71#include <libayatana-indicator/indicator-ng.h>
72
73#define INDICATOR_SERVICE_DIR "/usr/share/ayatana/indicators"
74
75#endif
76
77#include "tomboykeybinder.h"
78
79static gchar * indicator_order[] = {
80#if HAVE_UBUNTU_INDICATOR1
81 "libapplication.so",
82 "libmessaging.so",
83 "libsoundmenu.so",
84 "libdatetime.so",
85 "libsession.so",
86#endif
87#if HAVE_AYATANA_INDICATOR
88 "libayatana-application.so",
89 "libayatana-messaging.so",
90 "libayatana-soundmenu.so",
91 "libayatana-datetime.so",
92 "libayatana-session.so",
93#endif
94 NULL((void*)0)
95};
96
97static GtkPackDirection packdirection;
98static MatePanelAppletOrient orient;
99static guint size;
100
101#define MENU_DATA_INDICATOR_OBJECT"indicator-object" "indicator-object"
102#define MENU_DATA_INDICATOR_ENTRY"indicator-entry" "indicator-entry"
103
104#define IO_DATA_ORDER_NUMBER"indicator-order-number" "indicator-order-number"
105
106static gboolean applet_fill_cb (MatePanelApplet * applet, const gchar * iid, gpointer data);
107
108static void update_accessible_desc (IndicatorObjectEntry * entry, GtkWidget * menuitem);
109
110/*************
111 * main
112 * ***********/
113
114#ifdef INDICATOR_APPLET1
115MATE_PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletFactory",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
116 PANEL_TYPE_APPLET,int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
117 "indicator-applet",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
118 applet_fill_cb, NULL)int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
;
119#endif
120#ifdef INDICATOR_APPLET_COMPLETE
121MATE_PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletCompleteFactory",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
122 PANEL_TYPE_APPLET,int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
123 "indicator-applet-complete",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
124 applet_fill_cb, NULL)int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletCompleteFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
;
125#endif
126#ifdef INDICATOR_APPLET_APPMENU
127MATE_PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletAppmenuFactory",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
128 PANEL_TYPE_APPLET,int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
129 "indicator-applet-appmenu",int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
130 applet_fill_cb, NULL)int main(int argc, char* argv[]) { GOptionContext* context; GError
* error; int retval; do { bindtextdomain ("mate-indicator-applet"
, "/usr/local/share/locale"); bind_textdomain_codeset ("mate-indicator-applet"
, "UTF-8"); if ((!(0))) textdomain ("mate-indicator-applet");
} while (0); context = g_option_context_new(""); g_option_context_add_group
(context, gtk_get_option_group((!(0)))); error = ((void*)0);
if (!g_option_context_parse (context, &argc, &argv, &
error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n"
, error->message); g_error_free (error); } else { g_printerr
("Cannot parse arguments.\n"); } g_option_context_free (context
); return 1; } gtk_init (&argc, &argv); retval = mate_panel_applet_factory_main
("IndicatorAppletAppmenuFactory",(!(0)), (mate_panel_applet_get_type
()), applet_fill_cb, ((void*)0)); g_option_context_free (context
); return retval; }
;
131#endif
132
133/*************
134 * log files
135 * ***********/
136#ifdef INDICATOR_APPLET1
137#define LOG_FILE_NAME"indicator-applet.log" "indicator-applet.log"
138#endif
139#ifdef INDICATOR_APPLET_COMPLETE
140#define LOG_FILE_NAME"indicator-applet.log" "indicator-applet-complete.log"
141#endif
142#ifdef INDICATOR_APPLET_APPMENU
143#define LOG_FILE_NAME"indicator-applet.log" "indicator-applet-appmenu.log"
144#endif
145GOutputStream * log_file = NULL((void*)0);
146
147/*****************
148 * Hotkey support
149 * **************/
150#ifdef INDICATOR_APPLET1
151gchar * hotkey_keycode = "<Super>M";
152#endif
153#ifdef INDICATOR_APPLET_SESSION
154gchar * hotkey_keycode = "<Super>S";
155#endif
156#ifdef INDICATOR_APPLET_COMPLETE
157gchar * hotkey_keycode = "<Super>S";
158#endif
159#ifdef INDICATOR_APPLET_APPMENU
160gchar * hotkey_keycode = "<Super>F1";
161#endif
162
163/********************
164 * Environment Names
165 * *******************/
166#ifdef INDICATOR_APPLET1
167#define INDICATOR_SPECIFIC_ENV"indicator-applet-original" "indicator-applet-original"
168#endif
169#ifdef INDICATOR_APPLET_COMPLETE
170#define INDICATOR_SPECIFIC_ENV"indicator-applet-original" "indicator-applet-complete"
171#endif
172#ifdef INDICATOR_APPLET_APPMENU
173#define INDICATOR_SPECIFIC_ENV"indicator-applet-original" "indicator-applet-appmenu"
174#endif
175
176static const gchar * indicator_env[] = {
177 "indicator-applet",
178 INDICATOR_SPECIFIC_ENV"indicator-applet-original",
179 NULL((void*)0)
180};
181
182/*************
183 * init function
184 * ***********/
185
186static gint
187name2order (const gchar * name) {
188 int i;
189
190 for (i = 0; indicator_order[i] != NULL((void*)0); i++) {
191 if (g_strcmp0(name, indicator_order[i]) == 0) {
192 return i;
193 }
194 }
195
196 return -1;
197}
198
199typedef struct _incoming_position_t incoming_position_t;
200struct _incoming_position_t {
201 gint objposition;
202 gint entryposition;
203 gint menupos;
204 gboolean found;
205};
206
207/* This function helps by determining where in the menu list
208 this new entry should be placed. It compares the objects
209 that they're on, and then the individual entries. Each
210 is progressively more expensive. */
211static void
212place_in_menu (GtkWidget * widget, gpointer user_data)
213{
214 incoming_position_t * position = (incoming_position_t *)user_data;
215 if (position->found) {
216 /* We've already been placed, just finish the foreach */
217 return;
218 }
219
220 IndicatorObject * io = INDICATOR_OBJECT(g_object_get_data(G_OBJECT(widget), MENU_DATA_INDICATOR_OBJECT))((((IndicatorObject*) g_type_check_instance_cast ((GTypeInstance
*) ((g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((widget)), (((GType) ((20) << (2)))
))))), "indicator-object"))), ((indicator_object_get_type ())
)))))
;
221 g_assert(io != NULL)do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_
; if (io != ((void*)0)) _g_boolean_var_ = 1; else _g_boolean_var_
= 0; _g_boolean_var_; }), 1)) ; else g_assertion_message_expr
("Indicator-Applet", "applet-main.c", 221, ((const char*) (__func__
)), "io != NULL"); } while (0)
;
222
223 gint objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER))((gint) (glong) (g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
), "indicator-order-number")))
;
224 /* We've already passed it, well, then this is where
225 we should be be. Stop! */
226 if (objposition > position->objposition) {
227 position->found = TRUE(!(0));
228 return;
229 }
230
231 /* The objects don't match yet, keep looking */
232 if (objposition < position->objposition) {
233 position->menupos++;
234 return;
235 }
236
237 /* The objects are the same, let's start looking at entries. */
238 IndicatorObjectEntry * entry = (IndicatorObjectEntry *)g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
239 gint entryposition = indicator_object_get_location(io, entry);
240
241 if (entryposition > position->entryposition) {
242 position->found = TRUE(!(0));
243 return;
244 }
245
246 if (entryposition < position->entryposition) {
247 position->menupos++;
248 return;
249 }
250
251 /* We've got the same object and the same entry. Well,
252 let's just put it right here then. */
253 position->found = TRUE(!(0));
254 return;
255}
256
257static void
258something_shown (GtkWidget * widget, gpointer user_data)
259{
260 GtkWidget * menuitem = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
261 gtk_widget_show(menuitem);
262}
263
264static void
265something_hidden (GtkWidget * widget, gpointer user_data)
266{
267 GtkWidget * menuitem = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
268 gtk_widget_hide(menuitem);
269}
270
271static void
272sensitive_cb (GObject * obj, GParamSpec * pspec, gpointer user_data)
273{
274 g_return_if_fail(GTK_IS_WIDGET(obj))do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((obj)); GType __t = ((gtk_widget_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet", ((const
char*) (__func__)), "GTK_IS_WIDGET(obj)"); return; } } while
(0)
;
275 g_return_if_fail(GTK_IS_WIDGET(user_data))do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((user_data)); GType __t = ((gtk_widget_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet", ((const
char*) (__func__)), "GTK_IS_WIDGET(user_data)"); return; } }
while (0)
;
276
277 gtk_widget_set_sensitive(GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
, gtk_widget_get_sensitive(GTK_WIDGET(obj)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(obj)), ((gtk_widget_get_type ()))))))
));
278 return;
279}
280
281static void
282entry_activated (GtkWidget * widget, gpointer user_data)
283{
284 g_return_if_fail(GTK_IS_WIDGET(widget))do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((gtk_widget_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet", ((const
char*) (__func__)), "GTK_IS_WIDGET(widget)"); return; } } while
(0)
;
285 gpointer pio = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, "indicator");
286 g_return_if_fail(INDICATOR_IS_OBJECT(pio))do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((pio)); GType __t = ((indicator_object_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet", ((const
char*) (__func__)), "INDICATOR_IS_OBJECT(pio)"); return; } }
while (0)
;
287 IndicatorObject * io = INDICATOR_OBJECT(pio)((((IndicatorObject*) g_type_check_instance_cast ((GTypeInstance
*) ((pio)), ((indicator_object_get_type ()))))))
;
288
289 return indicator_object_entry_activate(io, (IndicatorObjectEntry *)user_data, gtk_get_current_event_time());
290}
291
292static gboolean
293entry_scrolled (GtkWidget *menuitem, GdkEventScroll *event, gpointer data)
294{
295 IndicatorObject *io = g_object_get_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_OBJECT"indicator-object");
296 IndicatorObjectEntry *entry = g_object_get_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
297
298 g_return_val_if_fail(INDICATOR_IS_OBJECT(io), FALSE)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((io)); GType __t = ((indicator_object_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet", ((const
char*) (__func__)), "INDICATOR_IS_OBJECT(io)"); return ((0))
; } } while (0)
;
299
300 g_signal_emit_by_name (io, "scroll", 1, event->direction);
301 g_signal_emit_by_name (io, "scroll-entry", entry, 1, event->direction);
302 g_signal_emit_by_name (io, INDICATOR_OBJECT_SIGNAL_ENTRY_SCROLLED"entry-scrolled", entry, 1, event->direction);
303
304 return FALSE(0);
305}
306
307static void
308accessible_desc_update_cb (GtkWidget * widget, gpointer userdata)
309{
310 gpointer data = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
311
312 if (data != userdata) {
313 return;
314 }
315
316 IndicatorObjectEntry * entry = (IndicatorObjectEntry *)data;
317 update_accessible_desc(entry, widget);
318}
319
320static void
321accessible_desc_update (IndicatorObject * io, IndicatorObjectEntry * entry, GtkWidget * menubar)
322{
323 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, accessible_desc_update_cb, entry);
324 return;
325}
326
327#define PANEL_PADDING8 8
328static gboolean
329entry_resized (GtkWidget *applet, guint newsize, gpointer data)
330{
331 IndicatorObject *io = (IndicatorObject *)data;
332
333 size = newsize;
334
335 /* Work on the entries */
336 GList * entries = indicator_object_get_entries(io);
337 GList * entry = NULL((void*)0);
338
339 for (entry = entries; entry != NULL((void*)0); entry = g_list_next(entry)((entry) ? (((GList *)(entry))->next) : ((void*)0))) {
340 IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)entry->data;
341 if (entrydata->image != NULL((void*)0)) {
342 /* Resize to fit panel */
343 gtk_image_set_pixel_size (entrydata->image, size - PANEL_PADDING8);
344 }
345 }
346
347 return FALSE(0);
348}
349
350static void
351entry_added (IndicatorObject * io, IndicatorObjectEntry * entry, GtkWidget * menubar)
352{
353 g_debug("Signal: Entry Added");
354 gboolean something_visible = FALSE(0);
355 gboolean something_sensitive = FALSE(0);
356
357 GtkWidget * menuitem = gtk_menu_item_new();
358 GtkWidget * box = (packdirection == GTK_PACK_DIRECTION_LTR) ?
359 gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3) : gtk_box_new(GTK_ORIENTATION_VERTICAL, 3);
360
361 /* Allows indicators to receive mouse scroll event */
362 gtk_widget_add_events(GTK_WIDGET(menuitem)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(menuitem)), ((gtk_widget_get_type ()))))))
, GDK_SCROLL_MASK);
363
364 g_object_set_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "indicator", io);
365 g_object_set_data (G_OBJECT (menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "box", box);
366
367 g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(entry_activated), entry)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((menuitem)), (((GType) ((20) << (2)
)))))))), ("activate"), (((GCallback) (entry_activated))), (entry
), ((void*)0), (GConnectFlags) 0)
;
368 g_signal_connect(G_OBJECT(menuitem), "scroll-event", G_CALLBACK(entry_scrolled), entry)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((menuitem)), (((GType) ((20) << (2)
)))))))), ("scroll-event"), (((GCallback) (entry_scrolled))),
(entry), ((void*)0), (GConnectFlags) 0)
;
369
370 if (entry->image != NULL((void*)0)) {
371 /* Resize to fit panel */
372 gtk_image_set_pixel_size (entry->image, size - PANEL_PADDING8);
373 gtk_box_pack_start(GTK_BOX(box)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((box
)), ((gtk_box_get_type ()))))))
, GTK_WIDGET(entry->image)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->image)), ((gtk_widget_get_type ()))))))
, FALSE(0), FALSE(0), 1);
374 if (gtk_widget_get_visible(GTK_WIDGET(entry->image)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->image)), ((gtk_widget_get_type ()))))))
)) {
375 something_visible = TRUE(!(0));
376 }
377
378 if (gtk_widget_get_sensitive(GTK_WIDGET(entry->image)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->image)), ((gtk_widget_get_type ()))))))
)) {
379 something_sensitive = TRUE(!(0));
380 }
381
382 g_signal_connect(G_OBJECT(entry->image), "show", G_CALLBACK(something_shown), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), ("show"), (((GCallback) (something_shown))), (menuitem
), ((void*)0), (GConnectFlags) 0)
;
383 g_signal_connect(G_OBJECT(entry->image), "hide", G_CALLBACK(something_hidden), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), ("hide"), (((GCallback) (something_hidden))), (
menuitem), ((void*)0), (GConnectFlags) 0)
;
384
385 g_signal_connect(G_OBJECT(entry->image), "notify::sensitive", G_CALLBACK(sensitive_cb), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), ("notify::sensitive"), (((GCallback) (sensitive_cb
))), (menuitem), ((void*)0), (GConnectFlags) 0)
;
386 }
387 if (entry->label != NULL((void*)0)) {
388 switch(packdirection) {
389 case GTK_PACK_DIRECTION_LTR:
390 gtk_label_set_angle(GTK_LABEL(entry->label)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_label_get_type ()))))))
, 0.0);
391 break;
392 case GTK_PACK_DIRECTION_TTB:
393 gtk_label_set_angle(GTK_LABEL(entry->label)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_label_get_type ()))))))
,
394 (orient == MATE_PANEL_APPLET_ORIENT_LEFT) ?
395 270.0 : 90.0);
396 break;
397 default:
398 break;
399 }
400 gtk_box_pack_start(GTK_BOX(box)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((box
)), ((gtk_box_get_type ()))))))
, GTK_WIDGET(entry->label)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_widget_get_type ()))))))
, FALSE(0), FALSE(0), 1);
401
402 if (gtk_widget_get_visible(GTK_WIDGET(entry->label)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_widget_get_type ()))))))
)) {
403 something_visible = TRUE(!(0));
404 }
405
406 if (gtk_widget_get_sensitive(GTK_WIDGET(entry->label)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->label)), ((gtk_widget_get_type ()))))))
)) {
407 something_sensitive = TRUE(!(0));
408 }
409
410 g_signal_connect(G_OBJECT(entry->label), "show", G_CALLBACK(something_shown), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), ("show"), (((GCallback) (something_shown))), (menuitem
), ((void*)0), (GConnectFlags) 0)
;
411 g_signal_connect(G_OBJECT(entry->label), "hide", G_CALLBACK(something_hidden), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), ("hide"), (((GCallback) (something_hidden))), (
menuitem), ((void*)0), (GConnectFlags) 0)
;
412
413 g_signal_connect(G_OBJECT(entry->label), "notify::sensitive", G_CALLBACK(sensitive_cb), menuitem)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), ("notify::sensitive"), (((GCallback) (sensitive_cb
))), (menuitem), ((void*)0), (GConnectFlags) 0)
;
414 }
415 gtk_container_add(GTK_CONTAINER(menuitem)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menuitem)), ((gtk_container_get_type ()))))))
, box);
416 gtk_widget_show(box);
417
418 if (entry->menu != NULL((void*)0)) {
419 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem)((((GtkMenuItem*) g_type_check_instance_cast ((GTypeInstance*
) ((menuitem)), ((gtk_menu_item_get_type ()))))))
, GTK_WIDGET(entry->menu)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(entry->menu)), ((gtk_widget_get_type ()))))))
);
420 }
421
422 incoming_position_t position;
423 position.objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER))((gint) (glong) (g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
), "indicator-order-number")))
;
424 position.entryposition = indicator_object_get_location(io, entry);
425 position.menupos = 0;
426 position.found = FALSE(0);
427
428 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, place_in_menu, &position);
429
430 gtk_menu_shell_insert(GTK_MENU_SHELL(menubar)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_menu_shell_get_type ()))))))
, menuitem, position.menupos);
431
432 if (something_visible) {
433 if (entry->accessible_desc != NULL((void*)0)) {
434 update_accessible_desc(entry, menuitem);
435 }
436 gtk_widget_show(menuitem);
437 }
438 gtk_widget_set_sensitive(menuitem, something_sensitive);
439
440 g_object_set_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry", entry);
441 g_object_set_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_OBJECT"indicator-object", io);
442
443 return;
444}
445
446static void
447entry_removed_cb (GtkWidget * widget, gpointer userdata)
448{
449 gpointer data = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
450
451 if (data != userdata) {
452 return;
453 }
454
455 IndicatorObjectEntry * entry = (IndicatorObjectEntry *)data;
456 if (entry->label != NULL((void*)0)) {
457 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(something_shown), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_shown))), (widget
))
;
458 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(something_hidden), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_hidden))), (widget
))
;
459 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(sensitive_cb), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->label)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (sensitive_cb))), (widget)
)
;
460 }
461 if (entry->image != NULL((void*)0)) {
462 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(something_shown), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_shown))), (widget
))
;
463 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(something_hidden), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (something_hidden))), (widget
))
;
464 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(sensitive_cb), widget)g_signal_handlers_disconnect_matched ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((entry->image)), (((GType) ((20) <<
(2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA
), 0, 0, ((void*)0), (((GCallback) (sensitive_cb))), (widget)
)
;
465 }
466
467 gtk_widget_destroy(widget);
468 return;
469}
470
471static void
472entry_removed (IndicatorObject * io G_GNUC_UNUSED__attribute__((__unused__)), IndicatorObjectEntry * entry,
473 gpointer user_data)
474{
475 g_debug("Signal: Entry Removed");
476
477 gtk_container_foreach(GTK_CONTAINER(user_data)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((gtk_container_get_type ()))))))
, entry_removed_cb, entry);
478
479 return;
480}
481
482static void
483entry_moved_find_cb (GtkWidget * widget, gpointer userdata)
484{
485 gpointer * array = (gpointer *)userdata;
486 if (array[1] != NULL((void*)0)) {
487 return;
488 }
489
490 gpointer data = g_object_get_data(G_OBJECT(widget)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
widget)), (((GType) ((20) << (2))))))))
, MENU_DATA_INDICATOR_ENTRY"indicator-entry");
491
492 if (data != array[0]) {
493 return;
494 }
495
496 array[1] = widget;
497 return;
498}
499
500/* Gets called when an entry for an object was moved. */
501static void
502entry_moved (IndicatorObject * io, IndicatorObjectEntry * entry,
503 gint old G_GNUC_UNUSED__attribute__((__unused__)), gint new G_GNUC_UNUSED__attribute__((__unused__)), gpointer user_data)
504{
505 GtkWidget * menubar = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
506
507 gpointer array[2];
508 array[0] = entry;
509 array[1] = NULL((void*)0);
510
511 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, entry_moved_find_cb, array);
512 if (array[1] == NULL((void*)0)) {
513 g_warning("Moving an entry that isn't in our menus.");
514 return;
515 }
516
517 GtkWidget * mi = GTK_WIDGET(array[1])((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(array[1])), ((gtk_widget_get_type ()))))))
;
518 g_object_ref(G_OBJECT(mi)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
mi)), (((GType) ((20) << (2))))))))
);
519 gtk_container_remove(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, mi);
520
521 incoming_position_t position;
522 position.objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER))((gint) (glong) (g_object_get_data(((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
), "indicator-order-number")))
;
523 position.entryposition = indicator_object_get_location(io, entry);
524 position.menupos = 0;
525 position.found = FALSE(0);
526
527 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, place_in_menu, &position);
528
529 gtk_menu_shell_insert(GTK_MENU_SHELL(menubar)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_menu_shell_get_type ()))))))
, mi, position.menupos);
530 g_object_unref(G_OBJECT(mi)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
mi)), (((GType) ((20) << (2))))))))
);
531
532 return;
533}
534
535static void
536menu_show (IndicatorObject * io, IndicatorObjectEntry * entry,
537 guint32 timestamp, gpointer user_data)
538{
539 GtkWidget * menubar = GTK_WIDGET(user_data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(user_data)), ((gtk_widget_get_type ()))))))
;
540
541 if (entry == NULL((void*)0)) {
542 /* Close any open menus instead of opening one */
543 GList * entries = indicator_object_get_entries(io);
544 GList * iterator = NULL((void*)0);
545 for (iterator = entries; iterator != NULL((void*)0); iterator = g_list_next(iterator)((iterator) ? (((GList *)(iterator))->next) : ((void*)0))) {
546 IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)iterator->data;
547 gtk_menu_popdown(entrydata->menu);
548 }
549 g_list_free(entries);
550
551 /* And tell the menubar to exit activation mode too */
552 gtk_menu_shell_cancel(GTK_MENU_SHELL(menubar)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_menu_shell_get_type ()))))))
);
553 return;
554 }
555
556 // TODO: do something sensible here
557}
558
559static void
560update_accessible_desc(IndicatorObjectEntry * entry, GtkWidget * menuitem)
561{
562 /* FIXME: We need to deal with the use case where the contents of the
563 label overrides what is found in the atk object's name, or at least
564 orca speaks the label instead of the atk object name.
565 */
566 AtkObject * menuitem_obj = gtk_widget_get_accessible(menuitem);
567 if (menuitem_obj == NULL((void*)0)) {
568 /* Should there be an error printed here? */
569 return;
570 }
571
572 if (entry->accessible_desc != NULL((void*)0)) {
573 atk_object_set_name(menuitem_obj, entry->accessible_desc);
574 } else {
575 atk_object_set_name(menuitem_obj, "");
576 }
577 return;
578}
579
580static void
581load_indicator (MatePanelApplet *applet, GtkWidget * menubar, IndicatorObject *io, const gchar *name)
582{
583 /* Set the environment it's in */
584 indicator_object_set_environment(io, (const GStrv)indicator_env);
585
586 /* Attach the 'name' to the object */
587#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
588 int pos = 5000 - indicator_object_get_position(io);
589 if (pos > 5000) {
590 pos = name2order(name);
591 }
592#else
593 int pos = name2order(name);
594#endif
595
596 g_object_set_data(G_OBJECT(io)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
io)), (((GType) ((20) << (2))))))))
, IO_DATA_ORDER_NUMBER"indicator-order-number", GINT_TO_POINTER(pos)((gpointer) (glong) (pos)));
597
598 /* Connect to its signals */
599 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED, G_CALLBACK(entry_added), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("entry-added"), (((GCallback) (entry_added))), (menubar)
, ((void*)0), (GConnectFlags) 0)
;
600 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED, G_CALLBACK(entry_removed), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("entry-removed"), (((GCallback) (entry_removed))), (menubar
), ((void*)0), (GConnectFlags) 0)
;
601 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_MOVED, G_CALLBACK(entry_moved), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("entry-moved"), (((GCallback) (entry_moved))), (menubar)
, ((void*)0), (GConnectFlags) 0)
;
602 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_MENU_SHOW, G_CALLBACK(menu_show), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("menu-show"), (((GCallback) (menu_show))), (menubar), ((
void*)0), (GConnectFlags) 0)
;
603 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ACCESSIBLE_DESC_UPDATE, G_CALLBACK(accessible_desc_update), menubar)g_signal_connect_data ((((((GObject*) g_type_check_instance_cast
((GTypeInstance*) ((io)), (((GType) ((20) << (2)))))))
)), ("accessible-desc-update"), (((GCallback) (accessible_desc_update
))), (menubar), ((void*)0), (GConnectFlags) 0)
;
604
605 /* Track panel resize */
606 g_signal_connect_object(G_OBJECT(applet)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
applet)), (((GType) ((20) << (2))))))))
, "change-size", G_CALLBACK(entry_resized)((GCallback) (entry_resized)), G_OBJECT(io)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
io)), (((GType) ((20) << (2))))))))
, 0);
607
608 /* Work on the entries */
609 GList * entries = indicator_object_get_entries(io);
610 GList * entry = NULL((void*)0);
611
612 for (entry = entries; entry != NULL((void*)0); entry = g_list_next(entry)((entry) ? (((GList *)(entry))->next) : ((void*)0))) {
613 IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)entry->data;
614 entry_added(io, entrydata, menubar);
615 }
616
617 g_list_free(entries);
618}
619
620static gboolean
621load_module (const gchar * name, MatePanelApplet *applet, GtkWidget * menubar)
622{
623 g_debug("Looking at Module: %s", name);
624 g_return_val_if_fail(name != NULL, FALSE)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if (name != ((void*)0)) _g_boolean_var_ = 1; else _g_boolean_var_
= 0; _g_boolean_var_; }), 1))) { } else { g_return_if_fail_warning
("Indicator-Applet", ((const char*) (__func__)), "name != NULL"
); return ((0)); } } while (0)
;
625
626 if (!g_str_has_suffix(name, G_MODULE_SUFFIX"so")) {
627 return FALSE(0);
628 }
629
630 g_debug("Loading Module: %s", name);
631
632 /* Build the object for the module */
633 gchar * fullpath = g_build_filename(INDICATOR_DIR"/usr/lib64/indicators3/7/", name, NULL((void*)0));
634 IndicatorObject * io = indicator_object_new_from_file(fullpath);
635 g_free(fullpath);
636
637 load_indicator(applet, menubar, io, name);
638
639 return TRUE(!(0));
640}
641
642static void
643load_modules (MatePanelApplet *applet, GtkWidget *menubar, gint *indicators_loaded)
644{
645 if (g_file_test(INDICATOR_DIR"/usr/lib64/indicators3/7/", (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))) {
646 GDir * dir = g_dir_open(INDICATOR_DIR"/usr/lib64/indicators3/7/", 0, NULL((void*)0));
647
648 const gchar * name;
649 gint count = 0;
650 while ((name = g_dir_read_name(dir)) != NULL((void*)0)) {
651#ifdef INDICATOR_APPLET_APPMENU
652 if (g_strcmp0(name, INDICATOR_SERVICE_APPMENU"libappmenu.so")) {
653 continue;
654 }
655#else
656 if (!g_strcmp0(name, INDICATOR_SERVICE_APPMENU"libappmenu.so")) {
657 continue;
658 }
659#endif
660#ifdef INDICATOR_APPLET1
661 if (!g_strcmp0(name, INDICATOR_SERVICE_ME"libme.so")) {
662 continue;
663 }
664 if (!g_strcmp0(name, INDICATOR_SERVICE_DATETIME"libdatetime.so")) {
665 continue;
666 }
667#endif
668 if (load_module(name, applet, menubar)) {
669 count++;
670 }
671 }
672
673 *indicators_loaded += count;
674
675 g_dir_close (dir);
676 }
677}
678
679#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
680
681static void
682load_indicators_from_indicator_files (MatePanelApplet *applet, GtkWidget *menubar, gint *indicators_loaded)
683{
684 GDir *dir;
685 const gchar *name;
686 GError *error = NULL((void*)0);
687
688 dir = g_dir_open (INDICATOR_SERVICE_DIR, 0, &error);
689
690 if (!dir) {
691 g_warning ("unable to open indicator service file directory: %s", error->message);
692 g_error_free (error);
693
694 return;
695 }
696
697 gint count = 0;
698 while ((name = g_dir_read_name (dir))) {
699 gchar *filename;
700 IndicatorNg *indicator;
701
702 filename = g_build_filename (INDICATOR_SERVICE_DIR, name, NULL((void*)0));
703 indicator = indicator_ng_new_for_profile (filename, "desktop", &error);
704 g_free (filename);
705
706#ifdef INDICATOR_APPLET_APPMENU
707 if (g_strcmp0(name, INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu")) {
708 continue;
709 }
710#else
711 if (!g_strcmp0(name, INDICATOR_SERVICE_APPMENU_NG"com.canonical.indicator.appmenu")) {
712 continue;
713 }
714#endif
715#ifdef INDICATOR_APPLET1
716 if (!g_strcmp0(name, INDICATOR_SERVICE_ME_NG"com.canonical.indicator.me")) {
717 continue;
718 }
719 if (!g_strcmp0(name, INDICATOR_SERVICE_DATETIME_NG"com.canonical.indicator.datetime")) {
720 continue;
721 }
722#endif
723
724 if (indicator) {
725 load_indicator(applet, menubar, INDICATOR_OBJECT (indicator)((((IndicatorObject*) g_type_check_instance_cast ((GTypeInstance
*) ((indicator)), ((indicator_object_get_type ()))))))
, name);
726 count++;
727 }else{
728 g_warning ("unable to load '%s': %s", name, error->message);
729 g_clear_error (&error);
730 }
731 }
732
733 *indicators_loaded += count;
734
735 g_dir_close (dir);
736}
737#endif /* HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG */
738
739static void
740hotkey_filter (char * keystring G_GNUC_UNUSED__attribute__((__unused__)), gpointer data)
741{
742 g_return_if_fail(GTK_IS_MENU_SHELL(data))do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_
; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((data)); GType __t = ((gtk_menu_shell_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; }))))) _g_boolean_var_
= 1; else _g_boolean_var_ = 0; _g_boolean_var_; }), 1))) { }
else { g_return_if_fail_warning ("Indicator-Applet", ((const
char*) (__func__)), "GTK_IS_MENU_SHELL(data)"); return; } } while
(0)
;
743
744 /* Oh, wow, it's us! */
745 GList * children = gtk_container_get_children(GTK_CONTAINER(data)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((gtk_container_get_type ()))))))
);
746 if (children == NULL((void*)0)) {
747 g_debug("Menubar has no children");
748 return;
749 }
750
751 gtk_menu_shell_select_item(GTK_MENU_SHELL(data)((((GtkMenuShell*) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((gtk_menu_shell_get_type ()))))))
, GTK_WIDGET(g_list_last(children)->data)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(g_list_last(children)->data)), ((gtk_widget_get_type ()))
))))
);
752 g_list_free(children);
753 return;
754}
755
756static gboolean
757menubar_press (GtkWidget * widget,
758 GdkEventButton *event,
759 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
760{
761 if (event->button != 1) {
762 g_signal_stop_emission_by_name(widget, "button-press-event");
763 }
764
765 return FALSE(0);
766}
767
768static gboolean
769menubar_on_draw (GtkWidget * widget,
770 cairo_t * cr,
771 GtkWidget * menubar)
772{
773 /* FIXME: either port to gtk_render_focus or remove this function */
774 if (gtk_widget_has_focus(menubar))
775 gtk_paint_focus(gtk_widget_get_style(widget),
776 cr,
777 gtk_widget_get_state(menubar),
778 widget, "menubar-applet", 0, 0, -1, -1);
779
780 return FALSE(0);
781}
782
783static void
784about_cb (GtkAction *action G_GNUC_UNUSED__attribute__((__unused__)),
785 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
786{
787 static const gchar *authors[] = {
788 "Ted Gould <ted@canonical.com>",
789 NULL((void*)0)
790 };
791
792 static gchar *license[] = {
793 N_("This program is free software: you can redistribute it and/or modify it ""This program is free software: you can redistribute it and/or modify it "
"under the terms of the GNU General Public License version 3, as published "
"by the Free Software Foundation."
794 "under the terms of the GNU General Public License version 3, as published ""This program is free software: you can redistribute it and/or modify it "
"under the terms of the GNU General Public License version 3, as published "
"by the Free Software Foundation."
795 "by the Free Software Foundation.")"This program is free software: you can redistribute it and/or modify it "
"under the terms of the GNU General Public License version 3, as published "
"by the Free Software Foundation."
,
796 N_("This program is distributed in the hope that it will be useful, but ""This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
797 "WITHOUT ANY WARRANTY; without even the implied warranties of ""This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
798 "MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR ""This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
799 "PURPOSE. See the GNU General Public License for more details.")"This program is distributed in the hope that it will be useful, but "
"WITHOUT ANY WARRANTY; without even the implied warranties of "
"MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
"PURPOSE. See the GNU General Public License for more details."
,
800 N_("You should have received a copy of the GNU General Public License along ""You should have received a copy of the GNU General Public License along "
"with this program. If not, see <http://www.gnu.org/licenses/>."
801 "with this program. If not, see <http://www.gnu.org/licenses/>.")"You should have received a copy of the GNU General Public License along "
"with this program. If not, see <http://www.gnu.org/licenses/>."
,
802 NULL((void*)0)
803 };
804 gchar *license_i18n;
805
806 license_i18n = g_strconcat (_(license[0])dcgettext (((void*)0), license[0], 5), "\n\n", _(license[1])dcgettext (((void*)0), license[1], 5), "\n\n", _(license[2])dcgettext (((void*)0), license[2], 5), NULL((void*)0));
807
808 gtk_show_about_dialog(NULL((void*)0),
809 "version", VERSION"1.24.0",
810 "copyright", _("Copyright \xc2\xa9 2009-2010 Canonical, Ltd.\n"dcgettext (((void*)0), "Copyright \xc2\xa9 2009-2010 Canonical, Ltd.\n"
"Copyright \xc2\xa9 2011-2020 MATE developers", 5)
811 "Copyright \xc2\xa9 2011-2020 MATE developers")dcgettext (((void*)0), "Copyright \xc2\xa9 2009-2010 Canonical, Ltd.\n"
"Copyright \xc2\xa9 2011-2020 MATE developers", 5)
,
812#ifdef INDICATOR_APPLET_APPMENU
813 "comments", _("An applet to hold your application menus.")dcgettext (((void*)0), "An applet to hold your application menus."
, 5)
,
814#endif
815 "comments", _("An applet to hold all of the system indicators.")dcgettext (((void*)0), "An applet to hold all of the system indicators."
, 5)
,
816 "authors", authors,
817 "license", license_i18n,
818 "wrap-license", TRUE(!(0)),
819 "translator-credits", _("translator-credits")dcgettext (((void*)0), "translator-credits", 5),
820 "logo-icon-name", "mate-indicator-applet",
821 "icon-name", "mate-indicator-applet",
822 "website", "https://mate-desktop.org",
823 "website-label", _("MATE Website")dcgettext (((void*)0), "MATE Website", 5),
824 NULL((void*)0)
825 );
826
827 g_free (license_i18n);
828
829 return;
830}
831
832static gboolean
833swap_orient_cb (GtkWidget *item, gpointer data)
834{
835 GtkWidget *from = (GtkWidget *) data;
836 GtkWidget *to = (GtkWidget *) g_object_get_data(G_OBJECT(from)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
from)), (((GType) ((20) << (2))))))))
, "to");
837 g_object_ref(G_OBJECT(item)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
item)), (((GType) ((20) << (2))))))))
);
838 gtk_container_remove(GTK_CONTAINER(from)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((from)), ((gtk_container_get_type ()))))))
, item);
839 if (GTK_IS_LABEL(item)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(item)); GType __t = ((gtk_label_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; }))))
) {
840 switch(packdirection) {
841 case GTK_PACK_DIRECTION_LTR:
842 gtk_label_set_angle(GTK_LABEL(item)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(item)), ((gtk_label_get_type ()))))))
, 0.0);
843 break;
844 case GTK_PACK_DIRECTION_TTB:
845 gtk_label_set_angle(GTK_LABEL(item)((((GtkLabel*) g_type_check_instance_cast ((GTypeInstance*) (
(item)), ((gtk_label_get_type ()))))))
,
846 (orient == MATE_PANEL_APPLET_ORIENT_LEFT) ?
847 270.0 : 90.0);
848 break;
849 default:
850 break;
851 }
852 }
853 gtk_box_pack_start(GTK_BOX(to)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((to
)), ((gtk_box_get_type ()))))))
, item, FALSE(0), FALSE(0), 0);
854 return TRUE(!(0));
855}
856
857static gboolean
858reorient_box_cb (GtkWidget *menuitem, gpointer data)
859{
860 GtkWidget *from = g_object_get_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "box");
861 GtkWidget *to = (packdirection == GTK_PACK_DIRECTION_LTR) ?
862 gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0) : gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
863 g_object_set_data(G_OBJECT(from)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
from)), (((GType) ((20) << (2))))))))
, "to", to);
864 gtk_container_foreach(GTK_CONTAINER(from)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((from)), ((gtk_container_get_type ()))))))
, (GtkCallback)swap_orient_cb,
865 from);
866 gtk_container_remove(GTK_CONTAINER(menuitem)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menuitem)), ((gtk_container_get_type ()))))))
, from);
867 gtk_container_add(GTK_CONTAINER(menuitem)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menuitem)), ((gtk_container_get_type ()))))))
, to);
868 g_object_set_data(G_OBJECT(menuitem)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
menuitem)), (((GType) ((20) << (2))))))))
, "box", to);
869 gtk_widget_show_all(menuitem);
870 return TRUE(!(0));
871}
872
873static gboolean
874matepanelapplet_reorient_cb (GtkWidget *applet, MatePanelAppletOrient neworient,
875 gpointer data)
876{
877 GtkWidget *menubar = (GtkWidget *)data;
878 if ((((neworient == MATE_PANEL_APPLET_ORIENT_UP) ||
879 (neworient == MATE_PANEL_APPLET_ORIENT_DOWN)) &&
880 ((orient == MATE_PANEL_APPLET_ORIENT_LEFT) ||
881 (orient == MATE_PANEL_APPLET_ORIENT_RIGHT))) ||
882 (((neworient == MATE_PANEL_APPLET_ORIENT_LEFT) ||
883 (neworient == MATE_PANEL_APPLET_ORIENT_RIGHT)) &&
884 ((orient == MATE_PANEL_APPLET_ORIENT_UP) ||
885 (orient == MATE_PANEL_APPLET_ORIENT_DOWN)))) {
886 packdirection = (packdirection == GTK_PACK_DIRECTION_LTR) ?
887 GTK_PACK_DIRECTION_TTB : GTK_PACK_DIRECTION_LTR;
888 gtk_menu_bar_set_pack_direction(GTK_MENU_BAR(menubar)((((GtkMenuBar*) g_type_check_instance_cast ((GTypeInstance*)
((menubar)), ((gtk_menu_bar_get_type ()))))))
,
889 packdirection);
890 orient = neworient;
891 gtk_container_foreach(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
,
892 (GtkCallback)reorient_box_cb, NULL((void*)0));
893 }
894 orient = neworient;
895 return FALSE(0);
896}
897
898#ifdef N_
899#undef N_
900#endif
901#define N_(x)x x
902
903static void
904log_to_file_cb (GObject * source_obj G_GNUC_UNUSED__attribute__((__unused__)),
905 GAsyncResult * result G_GNUC_UNUSED__attribute__((__unused__)), gpointer user_data)
906{
907 g_free(user_data);
908 return;
909}
910
911static void
912log_to_file (const gchar * domain G_GNUC_UNUSED__attribute__((__unused__)),
913 GLogLevelFlags level G_GNUC_UNUSED__attribute__((__unused__)),
914 const gchar * message,
915 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
916{
917 if (log_file == NULL((void*)0)) {
918 GError * error = NULL((void*)0);
919 gchar * filename = g_build_filename(g_get_user_cache_dir(), LOG_FILE_NAME"indicator-applet.log", NULL((void*)0));
920 GFile * file = g_file_new_for_path(filename);
921 g_free(filename);
922
923 if (!g_file_test(g_get_user_cache_dir(), G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) {
924 GFile * cachedir = g_file_new_for_path(g_get_user_cache_dir());
925 g_file_make_directory_with_parents(cachedir, NULL((void*)0), &error);
926
927 if (error != NULL((void*)0)) {
928 g_error("Unable to make directory '%s' for log file: %s", g_get_user_cache_dir(), error->message);
929 return;
930 }
931 }
932
933 g_file_delete(file, NULL((void*)0), NULL((void*)0));
934
935 GFileIOStream * io = g_file_create_readwrite(file,
936 G_FILE_CREATE_REPLACE_DESTINATION, /* flags */
937 NULL((void*)0), /* cancelable */
938 &error); /* error */
939 if (error != NULL((void*)0)) {
940 g_error("Unable to replace file: %s", error->message);
941 return;
This statement is never executed
942 }
943
944 log_file = g_io_stream_get_output_stream(G_IO_STREAM(io)((((GIOStream*) g_type_check_instance_cast ((GTypeInstance*) (
(io)), ((g_io_stream_get_type ()))))))
);
945 }
946
947 gchar * outputstring = g_strdup_printf("%s\n", message);
948 g_output_stream_write_async(log_file,
949 outputstring, /* data */
950 strlen(outputstring), /* length */
951 G_PRIORITY_LOW300, /* priority */
952 NULL((void*)0), /* cancelable */
953 log_to_file_cb, /* callback */
954 outputstring); /* data */
955
956 return;
957}
958
959static gboolean
960applet_fill_cb (MatePanelApplet * applet, const gchar * iid G_GNUC_UNUSED__attribute__((__unused__)),
961 gpointer data G_GNUC_UNUSED__attribute__((__unused__)))
962{
963#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
964 ido_init();
965#endif
966
967 static const GtkActionEntry menu_actions[] = {
968 {"About", GTK_STOCK_ABOUT((GtkStock)"gtk-about"), N_("_About")"_About", NULL((void*)0), NULL((void*)0), G_CALLBACK(about_cb)((GCallback) (about_cb))}
969 };
970 static const gchar *menu_xml = "<menuitem name=\"About\" action=\"About\"/>";
971
972 static gboolean first_time = FALSE(0);
973 GtkWidget *menubar;
974 gint indicators_loaded = 0;
975 GtkActionGroup *action_group;
976
977 if (!first_time)
978 {
979 first_time = TRUE(!(0));
980#ifdef INDICATOR_APPLET1
981 g_set_application_name(_("Indicator Applet")dcgettext (((void*)0), "Indicator Applet", 5));
982#endif
983#ifdef INDICATOR_APPLET_COMPLETE
984 g_set_application_name(_("Indicator Applet Complete")dcgettext (((void*)0), "Indicator Applet Complete", 5));
985#endif
986#ifdef INDICATOR_APPLET_APPMENU
987 g_set_application_name(_("Indicator Applet Application Menu")dcgettext (((void*)0), "Indicator Applet Application Menu", 5
)
);
988#endif
989
990 g_log_set_default_handler(log_to_file, NULL((void*)0));
991
992 tomboy_keybinder_init();
993 }
994
995 /* Set panel options */
996 gtk_container_set_border_width(GTK_CONTAINER (applet)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_container_get_type ()))))))
, 0);
997 mate_panel_applet_set_flags(applet, MATE_PANEL_APPLET_EXPAND_MINOR);
998 menubar = gtk_menu_bar_new();
999 action_group = gtk_action_group_new ("Indicator Applet Actions");
1000 gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE"mate-indicator-applet");
1001 gtk_action_group_add_actions (action_group, menu_actions,
1002 G_N_ELEMENTS (menu_actions)(sizeof (menu_actions) / sizeof ((menu_actions)[0])),
1003 menubar);
1004 mate_panel_applet_setup_menu(applet, menu_xml, action_group);
1005 g_object_unref(action_group);
1006#ifdef INDICATOR_APPLET1
1007 atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
),
1008 "indicator-applet");
1009#endif
1010#ifdef INDICATOR_APPLET_COMPLETE
1011 atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
),
1012 "indicator-applet-complete");
1013#endif
1014#ifdef INDICATOR_APPLET_APPMENU
1015 atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
),
1016 "indicator-applet-appmenu");
1017#endif
1018
1019 /* Init some theme/icon stuff */
1020 gtk_icon_theme_append_search_path(gtk_icon_theme_get_default(),
1021 INDICATOR_ICONS_DIR"/usr/share/libindicator/icons/");
1022 /* g_debug("Icons directory: %s", INDICATOR_ICONS_DIR); */
1023 gtk_widget_set_name(GTK_WIDGET (applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
, "fast-user-switch-applet");
1024
1025 /* Build menubar */
1026 size = (mate_panel_applet_get_size (applet));
1027 orient = (mate_panel_applet_get_orient(applet));
1028 packdirection = ((orient == MATE_PANEL_APPLET_ORIENT_UP) ||
1029 (orient == MATE_PANEL_APPLET_ORIENT_DOWN)) ?
1030 GTK_PACK_DIRECTION_LTR : GTK_PACK_DIRECTION_TTB;
1031 gtk_menu_bar_set_pack_direction(GTK_MENU_BAR(menubar)((((GtkMenuBar*) g_type_check_instance_cast ((GTypeInstance*)
((menubar)), ((gtk_menu_bar_get_type ()))))))
,
1032 packdirection);
1033 gtk_widget_set_can_focus (menubar, TRUE(!(0)));
1034 gtk_widget_set_name(GTK_WIDGET (menubar)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(menubar)), ((gtk_widget_get_type ()))))))
, "fast-user-switch-menubar");
1035 g_signal_connect(menubar, "button-press-event", G_CALLBACK(menubar_press), NULL)g_signal_connect_data ((menubar), ("button-press-event"), (((
GCallback) (menubar_press))), (((void*)0)), ((void*)0), (GConnectFlags
) 0)
;
1036 g_signal_connect_after(menubar, "draw", G_CALLBACK(menubar_on_draw), menubar)g_signal_connect_data ((menubar), ("draw"), (((GCallback) (menubar_on_draw
))), (menubar), ((void*)0), G_CONNECT_AFTER)
;
1037 g_signal_connect(applet, "change-orient",g_signal_connect_data ((applet), ("change-orient"), (((GCallback
) (matepanelapplet_reorient_cb))), (menubar), ((void*)0), (GConnectFlags
) 0)
1038 G_CALLBACK(matepanelapplet_reorient_cb), menubar)g_signal_connect_data ((applet), ("change-orient"), (((GCallback
) (matepanelapplet_reorient_cb))), (menubar), ((void*)0), (GConnectFlags
) 0)
;
1039 gtk_container_set_border_width(GTK_CONTAINER(menubar)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((menubar)), ((gtk_container_get_type ()))))))
, 0);
1040
1041 /* Add in filter func */
1042 tomboy_keybinder_bind(hotkey_keycode, hotkey_filter, menubar);
1043
1044 load_modules(applet, menubar, &indicators_loaded);
1045#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
1046 load_indicators_from_indicator_files(applet, menubar, &indicators_loaded);
1047#endif
1048
1049 if (indicators_loaded == 0) {
1050 /* A label to allow for click through */
1051 GtkWidget * item = gtk_label_new(_("No Indicators")dcgettext (((void*)0), "No Indicators", 5));
1052 mate_panel_applet_set_background_widget(applet, item);
1053 gtk_container_add(GTK_CONTAINER(applet)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_container_get_type ()))))))
, item);
1054 gtk_widget_show(item);
1055 } else {
1056 gtk_container_add(GTK_CONTAINER(applet)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((applet)), ((gtk_container_get_type ()))))))
, menubar);
1057 mate_panel_applet_set_background_widget(applet, menubar);
1058 gtk_widget_show(menubar);
1059 }
1060
1061 gtk_widget_show(GTK_WIDGET(applet)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(applet)), ((gtk_widget_get_type ()))))))
);
1062
1063 return TRUE(!(0));
1064
1065}
diff --git a/2020-04-09-124840-6850-1@e69dd120803f_shadow/scanview.css b/2020-04-09-124840-6850-1@e69dd120803f_shadow/scanview.css new file mode 100644 index 0000000..cf8a5a6 --- /dev/null +++ b/2020-04-09-124840-6850-1@e69dd120803f_shadow/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/2020-04-09-124840-6850-1@e69dd120803f_shadow/sorttable.js b/2020-04-09-124840-6850-1@e69dd120803f_shadow/sorttable.js new file mode 100644 index 0000000..32faa07 --- /dev/null +++ b/2020-04-09-124840-6850-1@e69dd120803f_shadow/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(" + + + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
/* eggaccelerators.c
+ * Copyright (C) 2002  Red Hat, Inc.; Copyright 1998, 2001 Tim Janik
+ * Developed by Havoc Pennington, Tim Janik
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
+ */
+
+#include "eggaccelerators.h"
+
+#include <string.h>
+#include <gdk/gdkx.h>
+#include <gdk/gdkkeysyms.h>
+
+enum
+{
+  EGG_MODMAP_ENTRY_SHIFT   = 0,
+  EGG_MODMAP_ENTRY_LOCK    = 1,
+  EGG_MODMAP_ENTRY_CONTROL = 2,
+  EGG_MODMAP_ENTRY_MOD1    = 3,
+  EGG_MODMAP_ENTRY_MOD2    = 4,
+  EGG_MODMAP_ENTRY_MOD3    = 5,
+  EGG_MODMAP_ENTRY_MOD4    = 6,
+  EGG_MODMAP_ENTRY_MOD5    = 7,
+  EGG_MODMAP_ENTRY_LAST    = 8
+};
+
+#define MODMAP_ENTRY_TO_MODIFIER(x) (1 << (x))
+
+typedef struct
+{
+  EggVirtualModifierType mapping[EGG_MODMAP_ENTRY_LAST];
+
+} EggModmap;
+
+const EggModmap* egg_keymap_get_modmap (GdkKeymap *keymap);
+
+static inline gboolean
+is_alt (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'a' || string[1] == 'A') &&
+	  (string[2] == 'l' || string[2] == 'L') &&
+	  (string[3] == 't' || string[3] == 'T') &&
+	  (string[4] == '>'));
+}
+
+static inline gboolean
+is_ctl (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'c' || string[1] == 'C') &&
+	  (string[2] == 't' || string[2] == 'T') &&
+	  (string[3] == 'l' || string[3] == 'L') &&
+	  (string[4] == '>'));
+}
+
+static inline gboolean
+is_modx (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'm' || string[1] == 'M') &&
+	  (string[2] == 'o' || string[2] == 'O') &&
+	  (string[3] == 'd' || string[3] == 'D') &&
+	  (string[4] >= '1' && string[4] <= '5') &&
+	  (string[5] == '>'));
+}
+
+static inline gboolean
+is_ctrl (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'c' || string[1] == 'C') &&
+	  (string[2] == 't' || string[2] == 'T') &&
+	  (string[3] == 'r' || string[3] == 'R') &&
+	  (string[4] == 'l' || string[4] == 'L') &&
+	  (string[5] == '>'));
+}
+
+static inline gboolean
+is_shft (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 's' || string[1] == 'S') &&
+	  (string[2] == 'h' || string[2] == 'H') &&
+	  (string[3] == 'f' || string[3] == 'F') &&
+	  (string[4] == 't' || string[4] == 'T') &&
+	  (string[5] == '>'));
+}
+
+static inline gboolean
+is_shift (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 's' || string[1] == 'S') &&
+	  (string[2] == 'h' || string[2] == 'H') &&
+	  (string[3] == 'i' || string[3] == 'I') &&
+	  (string[4] == 'f' || string[4] == 'F') &&
+	  (string[5] == 't' || string[5] == 'T') &&
+	  (string[6] == '>'));
+}
+
+static inline gboolean
+is_control (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'c' || string[1] == 'C') &&
+	  (string[2] == 'o' || string[2] == 'O') &&
+	  (string[3] == 'n' || string[3] == 'N') &&
+	  (string[4] == 't' || string[4] == 'T') &&
+	  (string[5] == 'r' || string[5] == 'R') &&
+	  (string[6] == 'o' || string[6] == 'O') &&
+	  (string[7] == 'l' || string[7] == 'L') &&
+	  (string[8] == '>'));
+}
+
+static inline gboolean
+is_release (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'r' || string[1] == 'R') &&
+	  (string[2] == 'e' || string[2] == 'E') &&
+	  (string[3] == 'l' || string[3] == 'L') &&
+	  (string[4] == 'e' || string[4] == 'E') &&
+	  (string[5] == 'a' || string[5] == 'A') &&
+	  (string[6] == 's' || string[6] == 'S') &&
+	  (string[7] == 'e' || string[7] == 'E') &&
+	  (string[8] == '>'));
+}
+
+static inline gboolean
+is_meta (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'm' || string[1] == 'M') &&
+	  (string[2] == 'e' || string[2] == 'E') &&
+	  (string[3] == 't' || string[3] == 'T') &&
+	  (string[4] == 'a' || string[4] == 'A') &&
+	  (string[5] == '>'));
+}
+
+static inline gboolean
+is_super (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 's' || string[1] == 'S') &&
+	  (string[2] == 'u' || string[2] == 'U') &&
+	  (string[3] == 'p' || string[3] == 'P') &&
+	  (string[4] == 'e' || string[4] == 'E') &&
+	  (string[5] == 'r' || string[5] == 'R') &&
+	  (string[6] == '>'));
+}
+
+static inline gboolean
+is_hyper (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'h' || string[1] == 'H') &&
+	  (string[2] == 'y' || string[2] == 'Y') &&
+	  (string[3] == 'p' || string[3] == 'P') &&
+	  (string[4] == 'e' || string[4] == 'E') &&
+	  (string[5] == 'r' || string[5] == 'R') &&
+	  (string[6] == '>'));
+}
+
+/**
+ * egg_accelerator_parse_virtual:
+ * @accelerator:      string representing an accelerator
+ * @accelerator_key:  return location for accelerator keyval
+ * @accelerator_mods: return location for accelerator modifier mask
+ *
+ * Parses a string representing a virtual accelerator. The format
+ * looks like "&lt;Control&gt;a" or "&lt;Shift&gt;&lt;Alt&gt;F1" or
+ * "&lt;Release&gt;z" (the last one is for key release).  The parser
+ * is fairly liberal and allows lower or upper case, and also
+ * abbreviations such as "&lt;Ctl&gt;" and "&lt;Ctrl&gt;".
+ *
+ * If the parse fails, @accelerator_key and @accelerator_mods will
+ * be set to 0 (zero) and %FALSE will be returned. If the string contains
+ * only modifiers, @accelerator_key will be set to 0 but %TRUE will be
+ * returned.
+ *
+ * The virtual vs. concrete accelerator distinction is a relic of
+ * how the X Window System works; there are modifiers Mod2-Mod5 that
+ * can represent various keyboard keys (numlock, meta, hyper, etc.),
+ * the virtual modifier represents the keyboard key, the concrete
+ * modifier the actual Mod2-Mod5 bits in the key press event.
+ *
+ * Returns: %TRUE on success.
+ */
+gboolean
+egg_accelerator_parse_virtual (const gchar            *accelerator,
+                               guint                  *accelerator_key,
+                               EggVirtualModifierType *accelerator_mods)
+{
+  guint keyval;
+  GdkModifierType mods;
+  gint len;
+  gboolean bad_keyval;
+
+  if (accelerator_key)
+    *accelerator_key = 0;
+  if (accelerator_mods)
+    *accelerator_mods = 0;
+
+  g_return_val_if_fail (accelerator != NULL, FALSE);
+
+  bad_keyval = FALSE;
+
+  keyval = 0;
+  mods = 0;
+  len = strlen (accelerator);
+  while (len)
+    {
+      if (*accelerator == '<')
+	{
+	  if (len >= 9 && is_release (accelerator))
+	    {
+	      accelerator += 9;
+	      len -= 9;
+	      mods |= EGG_VIRTUAL_RELEASE_MASK;
+	    }
+	  else if (len >= 9 && is_control (accelerator))
+	    {
+	      accelerator += 9;
+	      len -= 9;
+	      mods |= EGG_VIRTUAL_CONTROL_MASK;
+	    }
+	  else if (len >= 7 && is_shift (accelerator))
+	    {
+	      accelerator += 7;
+	      len -= 7;
+	      mods |= EGG_VIRTUAL_SHIFT_MASK;
+	    }
+	  else if (len >= 6 && is_shft (accelerator))
+	    {
+	      accelerator += 6;
+	      len -= 6;
+	      mods |= EGG_VIRTUAL_SHIFT_MASK;
+	    }
+	  else if (len >= 6 && is_ctrl (accelerator))
+	    {
+	      accelerator += 6;
+	      len -= 6;
+	      mods |= EGG_VIRTUAL_CONTROL_MASK;
+	    }
+	  else if (len >= 6 && is_modx (accelerator))
+	    {
+	      static const guint mod_vals[] = {
+		EGG_VIRTUAL_ALT_MASK, EGG_VIRTUAL_MOD2_MASK, EGG_VIRTUAL_MOD3_MASK,
+		EGG_VIRTUAL_MOD4_MASK, EGG_VIRTUAL_MOD5_MASK
+	      };
+
+	      len -= 6;
+	      accelerator += 4;
+	      mods |= mod_vals[*accelerator - '1'];
+	      accelerator += 2;
+	    }
+	  else if (len >= 5 && is_ctl (accelerator))
+	    {
+	      accelerator += 5;
+	      len -= 5;
+	      mods |= EGG_VIRTUAL_CONTROL_MASK;
+	    }
+	  else if (len >= 5 && is_alt (accelerator))
+	    {
+	      accelerator += 5;
+	      len -= 5;
+	      mods |= EGG_VIRTUAL_ALT_MASK;
+	    }
+          else if (len >= 6 && is_meta (accelerator))
+	    {
+	      accelerator += 6;
+	      len -= 6;
+	      mods |= EGG_VIRTUAL_META_MASK;
+	    }
+          else if (len >= 7 && is_hyper (accelerator))
+	    {
+	      accelerator += 7;
+	      len -= 7;
+	      mods |= EGG_VIRTUAL_HYPER_MASK;
+	    }
+          else if (len >= 7 && is_super (accelerator))
+	    {
+	      accelerator += 7;
+	      len -= 7;
+	      mods |= EGG_VIRTUAL_SUPER_MASK;
+	    }
+	  else
+	    {
+	      gchar last_ch;
+
+	      last_ch = *accelerator;
+	      while (last_ch && last_ch != '>')
+		{
+		  last_ch = *accelerator;
+		  accelerator += 1;
+		  len -= 1;
+		}
+	    }
+	}
+      else
+	{
+          keyval = gdk_keyval_from_name (accelerator);
+
+          if (keyval == 0)
+            bad_keyval = TRUE;
+
+          accelerator += len;
+          len -= len;
+	}
+    }
+
+  if (accelerator_key)
+    *accelerator_key = gdk_keyval_to_lower (keyval);
+  if (accelerator_mods)
+    *accelerator_mods = mods;
+
+  return !bad_keyval;
+}
+
+void
+egg_keymap_resolve_virtual_modifiers (GdkKeymap              *keymap,
+                                      EggVirtualModifierType  virtual_mods,
+                                      GdkModifierType        *concrete_mods)
+{
+  GdkModifierType concrete;
+  int i;
+  const EggModmap *modmap;
+
+  g_return_if_fail (GDK_IS_KEYMAP (keymap));
+  g_return_if_fail (concrete_mods != NULL);
+
+  modmap = egg_keymap_get_modmap (keymap);
+
+  /* Not so sure about this algorithm. */
+
+  concrete = 0;
+  i = 0;
+  while (i < EGG_MODMAP_ENTRY_LAST)
+    {
+      if (modmap->mapping[i] & virtual_mods)
+        concrete |= (1 << i);
+
+      ++i;
+    }
+
+  *concrete_mods = concrete;
+}
+
+void
+egg_keymap_virtualize_modifiers (GdkKeymap              *keymap,
+                                 GdkModifierType         concrete_mods,
+                                 EggVirtualModifierType *virtual_mods)
+{
+  GdkModifierType virtual;
+  int i;
+  const EggModmap *modmap;
+
+  g_return_if_fail (GDK_IS_KEYMAP (keymap));
+  g_return_if_fail (virtual_mods != NULL);
+
+  modmap = egg_keymap_get_modmap (keymap);
+
+  /* Not so sure about this algorithm. */
+
+  virtual = 0;
+  i = 0;
+  while (i < EGG_MODMAP_ENTRY_LAST)
+    {
+      if ((1 << i) & concrete_mods)
+        {
+          EggVirtualModifierType cleaned;
+
+          cleaned = modmap->mapping[i] & ~(EGG_VIRTUAL_MOD2_MASK |
+                                           EGG_VIRTUAL_MOD3_MASK |
+                                           EGG_VIRTUAL_MOD4_MASK |
+                                           EGG_VIRTUAL_MOD5_MASK);
+
+          if (cleaned != 0)
+            {
+              virtual |= cleaned;
+            }
+          else
+            {
+              /* Rather than dropping mod2->mod5 if not bound,
+               * go ahead and use the concrete names
+               */
+              virtual |= modmap->mapping[i];
+            }
+        }
+
+      ++i;
+    }
+
+  *virtual_mods = virtual;
+}
+
+static void
+reload_modmap (GdkKeymap *keymap,
+               EggModmap *modmap)
+{
+  XModifierKeymap *xmodmap;
+  int map_size;
+  int i;
+
+  /* FIXME multihead */
+  xmodmap = XGetModifierMapping (gdk_x11_get_default_xdisplay ());
+
+  memset (modmap->mapping, 0, sizeof (modmap->mapping));
+
+  /* there are 8 modifiers, and the first 3 are shift, shift lock,
+   * and control
+   */
+  map_size = 8 * xmodmap->max_keypermod;
+  i = 3 * xmodmap->max_keypermod;
+  while (i < map_size)
+    {
+      /* get the key code at this point in the map,
+       * see if its keysym is one we're interested in
+       */
+      int keycode = xmodmap->modifiermap[i];
+      GdkKeymapKey *keys;
+      guint *keyvals;
+      int n_entries;
+      int j;
+      EggVirtualModifierType mask;
+
+      keys = NULL;
+      keyvals = NULL;
+      n_entries = 0;
+
+      gdk_keymap_get_entries_for_keycode (keymap,
+                                          keycode,
+                                          &keys, &keyvals, &n_entries);
+
+      mask = 0;
+      j = 0;
+      while (j < n_entries)
+        {
+          if (keyvals[j] == GDK_KEY_Num_Lock)
+            mask |= EGG_VIRTUAL_NUM_LOCK_MASK;
+          else if (keyvals[j] == GDK_KEY_Scroll_Lock)
+            mask |= EGG_VIRTUAL_SCROLL_LOCK_MASK;
+          else if (keyvals[j] == GDK_KEY_Meta_L ||
+                   keyvals[j] == GDK_KEY_Meta_R)
+            mask |= EGG_VIRTUAL_META_MASK;
+          else if (keyvals[j] == GDK_KEY_Hyper_L ||
+                   keyvals[j] == GDK_KEY_Hyper_R)
+            mask |= EGG_VIRTUAL_HYPER_MASK;
+          else if (keyvals[j] == GDK_KEY_Super_L ||
+                   keyvals[j] == GDK_KEY_Super_R)
+            mask |= EGG_VIRTUAL_SUPER_MASK;
+          else if (keyvals[j] == GDK_KEY_Mode_switch)
+            mask |= EGG_VIRTUAL_MODE_SWITCH_MASK;
+
+          ++j;
+        }
+
+      /* Mod1Mask is 1 << 3 for example, i.e. the
+       * fourth modifier, i / keyspermod is the modifier
+       * index
+       */
+      modmap->mapping[i/xmodmap->max_keypermod] |= mask;
+
+      g_free (keyvals);
+      g_free (keys);
+
+      ++i;
+    }
+
+  /* Add in the not-really-virtual fixed entries */
+  modmap->mapping[EGG_MODMAP_ENTRY_SHIFT] |= EGG_VIRTUAL_SHIFT_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_CONTROL] |= EGG_VIRTUAL_CONTROL_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_LOCK] |= EGG_VIRTUAL_LOCK_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD1] |= EGG_VIRTUAL_ALT_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD2] |= EGG_VIRTUAL_MOD2_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD3] |= EGG_VIRTUAL_MOD3_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD4] |= EGG_VIRTUAL_MOD4_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD5] |= EGG_VIRTUAL_MOD5_MASK;
+
+  XFreeModifiermap (xmodmap);
+}
+
+const EggModmap*
+egg_keymap_get_modmap (GdkKeymap *keymap)
+{
+  EggModmap *modmap;
+
+  /* This is all a hack, much simpler when we can just
+   * modify GDK directly.
+   */
+
+  modmap = g_object_get_data (G_OBJECT (keymap),
+                              "egg-modmap");
+
+  if (modmap == NULL)
+    {
+      modmap = g_new0 (EggModmap, 1);
+
+      /* FIXME modify keymap change events with an event filter
+       * and force a reload if we get one
+       */
+
+      reload_modmap (keymap, modmap);
+
+      g_object_set_data_full (G_OBJECT (keymap),
+                              "egg-modmap",
+                              modmap,
+                              g_free);
+    }
+
+  g_assert (modmap != NULL);
+
+  return modmap;
+}
+
+
+
+ + + diff --git a/2020-04-09-124910-1519-cppcheck@e69dd120803f_shadow/index.html b/2020-04-09-124910-1519-cppcheck@e69dd120803f_shadow/index.html new file mode 100644 index 0000000..812f8b5 --- /dev/null +++ b/2020-04-09-124910-1519-cppcheck@e69dd120803f_shadow/index.html @@ -0,0 +1,101 @@ + + + + + + Cppcheck - HTML report - mate-indicator-applet + + + + + + + +
+ + + + + + + +
LineIdCWESeverityMessage
0missingIncludeSysteminformationCppcheck cannot find all the include files (use --check-config for details)
src/eggaccelerators.c
321duplicateExpression398styleSame expression on both sides of '-='.
+
+ + + diff --git a/2020-04-09-124910-1519-cppcheck@e69dd120803f_shadow/stats.html b/2020-04-09-124910-1519-cppcheck@e69dd120803f_shadow/stats.html new file mode 100644 index 0000000..14ae0d4 --- /dev/null +++ b/2020-04-09-124910-1519-cppcheck@e69dd120803f_shadow/stats.html @@ -0,0 +1,89 @@ + + + + + + Cppcheck - HTML report - mate-indicator-applet + + + + + + + +
+

Top 10 files for style severity, total findings: 1
+   1  src/eggaccelerators.c
+

+ +
+ + + diff --git a/2020-04-09-124910-1519-cppcheck@e69dd120803f_shadow/style.css b/2020-04-09-124910-1519-cppcheck@e69dd120803f_shadow/style.css new file mode 100644 index 0000000..c39571c --- /dev/null +++ b/2020-04-09-124910-1519-cppcheck@e69dd120803f_shadow/style.css @@ -0,0 +1,149 @@ + +body { + font: 13px Arial, Verdana, Sans-Serif; + margin: 0; + width: auto; +} + +h1 { + margin: 10px; +} + +#footer > p { + margin: 4px; +} + +.error { + background-color: #ffb7b7; +} + +.error2 { + background-color: #faa; + border: 1px dotted black; + display: inline-block; + margin-left: 4px; +} + +.inconclusive { + background-color: #B6B6B4; +} + +.inconclusive2 { + background-color: #B6B6B4; + border: 1px dotted black; + display: inline-block; + margin-left: 4px; +} + +div.verbose { + display: inline-block; + vertical-align: top; + cursor: help; +} + +div.verbose div.content { + display: none; + position: absolute; + padding: 10px; + margin: 4px; + max-width: 40%; + white-space: pre-wrap; + border: 1px solid black; + background-color: #FFFFCC; + cursor: auto; +} + +.highlight .hll { + padding: 1px; +} + +#header { + border-bottom: thin solid #aaa; +} + +#menu { + float: left; + margin-top: 5px; + text-align: left; + width: 150px; + /*height: 75%;*/ + position: fixed; + overflow: auto; + z-index: 1; +} + +#menu_index { + float: left; + margin-top: 5px; + padding-left: 5px; + text-align: left; + width: 300px; + /*height: 75%;*/ + position: fixed; + overflow: auto; + z-index: 1; +} + +#menu > a { + display: block; + margin-left: 10px; + font: 12px; + z-index: 1; +} + +#filename { + margin-left: 10px; + font: 12px; + z-index: 1; +} + +.highlighttable { + background-color:white; + z-index: 10; + position: relative; + margin: -10 px; +} + +#content { + background-color: white; + -webkit-box-sizing: content-box; + -moz-box-sizing: content-box; + box-sizing: content-box; + float: left; + margin: 5px; + margin-left: 10px; + padding: 0 10px 10px 10px; + width: 80%; + padding-left: 150px; +} + +#content_index { + background-color: white; + -webkit-box-sizing: content-box; + -moz-box-sizing: content-box; + box-sizing: content-box; + float: left; + margin: 5px; + margin-left: 10px; + padding: 0 10px 10px 10px; + width: 80%; + padding-left: 300px; +} + +.linenos { + border-right: thin solid #aaa; + color: lightgray; + padding-right: 6px; +} + +#footer { + border-top: thin solid #aaa; + clear: both; + font-size: 90%; + margin-top: 5px; +} + +#footer ul { + list-style-type: none; + padding-left: 0; +} diff --git a/2020-04-09-125606-1816-cppcheck@42f0ae6627b3_unreachable-code/0.html b/2020-04-09-125606-1816-cppcheck@42f0ae6627b3_unreachable-code/0.html new file mode 100644 index 0000000..31ac0e7 --- /dev/null +++ b/2020-04-09-125606-1816-cppcheck@42f0ae6627b3_unreachable-code/0.html @@ -0,0 +1,2280 @@ + + + + + + Cppcheck - HTML report - mate-indicator-applet + + + + + + + +
+
   1
+   2
+   3
+   4
+   5
+   6
+   7
+   8
+   9
+  10
+  11
+  12
+  13
+  14
+  15
+  16
+  17
+  18
+  19
+  20
+  21
+  22
+  23
+  24
+  25
+  26
+  27
+  28
+  29
+  30
+  31
+  32
+  33
+  34
+  35
+  36
+  37
+  38
+  39
+  40
+  41
+  42
+  43
+  44
+  45
+  46
+  47
+  48
+  49
+  50
+  51
+  52
+  53
+  54
+  55
+  56
+  57
+  58
+  59
+  60
+  61
+  62
+  63
+  64
+  65
+  66
+  67
+  68
+  69
+  70
+  71
+  72
+  73
+  74
+  75
+  76
+  77
+  78
+  79
+  80
+  81
+  82
+  83
+  84
+  85
+  86
+  87
+  88
+  89
+  90
+  91
+  92
+  93
+  94
+  95
+  96
+  97
+  98
+  99
+ 100
+ 101
+ 102
+ 103
+ 104
+ 105
+ 106
+ 107
+ 108
+ 109
+ 110
+ 111
+ 112
+ 113
+ 114
+ 115
+ 116
+ 117
+ 118
+ 119
+ 120
+ 121
+ 122
+ 123
+ 124
+ 125
+ 126
+ 127
+ 128
+ 129
+ 130
+ 131
+ 132
+ 133
+ 134
+ 135
+ 136
+ 137
+ 138
+ 139
+ 140
+ 141
+ 142
+ 143
+ 144
+ 145
+ 146
+ 147
+ 148
+ 149
+ 150
+ 151
+ 152
+ 153
+ 154
+ 155
+ 156
+ 157
+ 158
+ 159
+ 160
+ 161
+ 162
+ 163
+ 164
+ 165
+ 166
+ 167
+ 168
+ 169
+ 170
+ 171
+ 172
+ 173
+ 174
+ 175
+ 176
+ 177
+ 178
+ 179
+ 180
+ 181
+ 182
+ 183
+ 184
+ 185
+ 186
+ 187
+ 188
+ 189
+ 190
+ 191
+ 192
+ 193
+ 194
+ 195
+ 196
+ 197
+ 198
+ 199
+ 200
+ 201
+ 202
+ 203
+ 204
+ 205
+ 206
+ 207
+ 208
+ 209
+ 210
+ 211
+ 212
+ 213
+ 214
+ 215
+ 216
+ 217
+ 218
+ 219
+ 220
+ 221
+ 222
+ 223
+ 224
+ 225
+ 226
+ 227
+ 228
+ 229
+ 230
+ 231
+ 232
+ 233
+ 234
+ 235
+ 236
+ 237
+ 238
+ 239
+ 240
+ 241
+ 242
+ 243
+ 244
+ 245
+ 246
+ 247
+ 248
+ 249
+ 250
+ 251
+ 252
+ 253
+ 254
+ 255
+ 256
+ 257
+ 258
+ 259
+ 260
+ 261
+ 262
+ 263
+ 264
+ 265
+ 266
+ 267
+ 268
+ 269
+ 270
+ 271
+ 272
+ 273
+ 274
+ 275
+ 276
+ 277
+ 278
+ 279
+ 280
+ 281
+ 282
+ 283
+ 284
+ 285
+ 286
+ 287
+ 288
+ 289
+ 290
+ 291
+ 292
+ 293
+ 294
+ 295
+ 296
+ 297
+ 298
+ 299
+ 300
+ 301
+ 302
+ 303
+ 304
+ 305
+ 306
+ 307
+ 308
+ 309
+ 310
+ 311
+ 312
+ 313
+ 314
+ 315
+ 316
+ 317
+ 318
+ 319
+ 320
+ 321
+ 322
+ 323
+ 324
+ 325
+ 326
+ 327
+ 328
+ 329
+ 330
+ 331
+ 332
+ 333
+ 334
+ 335
+ 336
+ 337
+ 338
+ 339
+ 340
+ 341
+ 342
+ 343
+ 344
+ 345
+ 346
+ 347
+ 348
+ 349
+ 350
+ 351
+ 352
+ 353
+ 354
+ 355
+ 356
+ 357
+ 358
+ 359
+ 360
+ 361
+ 362
+ 363
+ 364
+ 365
+ 366
+ 367
+ 368
+ 369
+ 370
+ 371
+ 372
+ 373
+ 374
+ 375
+ 376
+ 377
+ 378
+ 379
+ 380
+ 381
+ 382
+ 383
+ 384
+ 385
+ 386
+ 387
+ 388
+ 389
+ 390
+ 391
+ 392
+ 393
+ 394
+ 395
+ 396
+ 397
+ 398
+ 399
+ 400
+ 401
+ 402
+ 403
+ 404
+ 405
+ 406
+ 407
+ 408
+ 409
+ 410
+ 411
+ 412
+ 413
+ 414
+ 415
+ 416
+ 417
+ 418
+ 419
+ 420
+ 421
+ 422
+ 423
+ 424
+ 425
+ 426
+ 427
+ 428
+ 429
+ 430
+ 431
+ 432
+ 433
+ 434
+ 435
+ 436
+ 437
+ 438
+ 439
+ 440
+ 441
+ 442
+ 443
+ 444
+ 445
+ 446
+ 447
+ 448
+ 449
+ 450
+ 451
+ 452
+ 453
+ 454
+ 455
+ 456
+ 457
+ 458
+ 459
+ 460
+ 461
+ 462
+ 463
+ 464
+ 465
+ 466
+ 467
+ 468
+ 469
+ 470
+ 471
+ 472
+ 473
+ 474
+ 475
+ 476
+ 477
+ 478
+ 479
+ 480
+ 481
+ 482
+ 483
+ 484
+ 485
+ 486
+ 487
+ 488
+ 489
+ 490
+ 491
+ 492
+ 493
+ 494
+ 495
+ 496
+ 497
+ 498
+ 499
+ 500
+ 501
+ 502
+ 503
+ 504
+ 505
+ 506
+ 507
+ 508
+ 509
+ 510
+ 511
+ 512
+ 513
+ 514
+ 515
+ 516
+ 517
+ 518
+ 519
+ 520
+ 521
+ 522
+ 523
+ 524
+ 525
+ 526
+ 527
+ 528
+ 529
+ 530
+ 531
+ 532
+ 533
+ 534
+ 535
+ 536
+ 537
+ 538
+ 539
+ 540
+ 541
+ 542
+ 543
+ 544
+ 545
+ 546
+ 547
+ 548
+ 549
+ 550
+ 551
+ 552
+ 553
+ 554
+ 555
+ 556
+ 557
+ 558
+ 559
+ 560
+ 561
+ 562
+ 563
+ 564
+ 565
+ 566
+ 567
+ 568
+ 569
+ 570
+ 571
+ 572
+ 573
+ 574
+ 575
+ 576
+ 577
+ 578
+ 579
+ 580
+ 581
+ 582
+ 583
+ 584
+ 585
+ 586
+ 587
+ 588
+ 589
+ 590
+ 591
+ 592
+ 593
+ 594
+ 595
+ 596
+ 597
+ 598
+ 599
+ 600
+ 601
+ 602
+ 603
+ 604
+ 605
+ 606
+ 607
+ 608
+ 609
+ 610
+ 611
+ 612
+ 613
+ 614
+ 615
+ 616
+ 617
+ 618
+ 619
+ 620
+ 621
+ 622
+ 623
+ 624
+ 625
+ 626
+ 627
+ 628
+ 629
+ 630
+ 631
+ 632
+ 633
+ 634
+ 635
+ 636
+ 637
+ 638
+ 639
+ 640
+ 641
+ 642
+ 643
+ 644
+ 645
+ 646
+ 647
+ 648
+ 649
+ 650
+ 651
+ 652
+ 653
+ 654
+ 655
+ 656
+ 657
+ 658
+ 659
+ 660
+ 661
+ 662
+ 663
+ 664
+ 665
+ 666
+ 667
+ 668
+ 669
+ 670
+ 671
+ 672
+ 673
+ 674
+ 675
+ 676
+ 677
+ 678
+ 679
+ 680
+ 681
+ 682
+ 683
+ 684
+ 685
+ 686
+ 687
+ 688
+ 689
+ 690
+ 691
+ 692
+ 693
+ 694
+ 695
+ 696
+ 697
+ 698
+ 699
+ 700
+ 701
+ 702
+ 703
+ 704
+ 705
+ 706
+ 707
+ 708
+ 709
+ 710
+ 711
+ 712
+ 713
+ 714
+ 715
+ 716
+ 717
+ 718
+ 719
+ 720
+ 721
+ 722
+ 723
+ 724
+ 725
+ 726
+ 727
+ 728
+ 729
+ 730
+ 731
+ 732
+ 733
+ 734
+ 735
+ 736
+ 737
+ 738
+ 739
+ 740
+ 741
+ 742
+ 743
+ 744
+ 745
+ 746
+ 747
+ 748
+ 749
+ 750
+ 751
+ 752
+ 753
+ 754
+ 755
+ 756
+ 757
+ 758
+ 759
+ 760
+ 761
+ 762
+ 763
+ 764
+ 765
+ 766
+ 767
+ 768
+ 769
+ 770
+ 771
+ 772
+ 773
+ 774
+ 775
+ 776
+ 777
+ 778
+ 779
+ 780
+ 781
+ 782
+ 783
+ 784
+ 785
+ 786
+ 787
+ 788
+ 789
+ 790
+ 791
+ 792
+ 793
+ 794
+ 795
+ 796
+ 797
+ 798
+ 799
+ 800
+ 801
+ 802
+ 803
+ 804
+ 805
+ 806
+ 807
+ 808
+ 809
+ 810
+ 811
+ 812
+ 813
+ 814
+ 815
+ 816
+ 817
+ 818
+ 819
+ 820
+ 821
+ 822
+ 823
+ 824
+ 825
+ 826
+ 827
+ 828
+ 829
+ 830
+ 831
+ 832
+ 833
+ 834
+ 835
+ 836
+ 837
+ 838
+ 839
+ 840
+ 841
+ 842
+ 843
+ 844
+ 845
+ 846
+ 847
+ 848
+ 849
+ 850
+ 851
+ 852
+ 853
+ 854
+ 855
+ 856
+ 857
+ 858
+ 859
+ 860
+ 861
+ 862
+ 863
+ 864
+ 865
+ 866
+ 867
+ 868
+ 869
+ 870
+ 871
+ 872
+ 873
+ 874
+ 875
+ 876
+ 877
+ 878
+ 879
+ 880
+ 881
+ 882
+ 883
+ 884
+ 885
+ 886
+ 887
+ 888
+ 889
+ 890
+ 891
+ 892
+ 893
+ 894
+ 895
+ 896
+ 897
+ 898
+ 899
+ 900
+ 901
+ 902
+ 903
+ 904
+ 905
+ 906
+ 907
+ 908
+ 909
+ 910
+ 911
+ 912
+ 913
+ 914
+ 915
+ 916
+ 917
+ 918
+ 919
+ 920
+ 921
+ 922
+ 923
+ 924
+ 925
+ 926
+ 927
+ 928
+ 929
+ 930
+ 931
+ 932
+ 933
+ 934
+ 935
+ 936
+ 937
+ 938
+ 939
+ 940
+ 941
+ 942
+ 943
+ 944
+ 945
+ 946
+ 947
+ 948
+ 949
+ 950
+ 951
+ 952
+ 953
+ 954
+ 955
+ 956
+ 957
+ 958
+ 959
+ 960
+ 961
+ 962
+ 963
+ 964
+ 965
+ 966
+ 967
+ 968
+ 969
+ 970
+ 971
+ 972
+ 973
+ 974
+ 975
+ 976
+ 977
+ 978
+ 979
+ 980
+ 981
+ 982
+ 983
+ 984
+ 985
+ 986
+ 987
+ 988
+ 989
+ 990
+ 991
+ 992
+ 993
+ 994
+ 995
+ 996
+ 997
+ 998
+ 999
+1000
+1001
+1002
+1003
+1004
+1005
+1006
+1007
+1008
+1009
+1010
+1011
+1012
+1013
+1014
+1015
+1016
+1017
+1018
+1019
+1020
+1021
+1022
+1023
+1024
+1025
+1026
+1027
+1028
+1029
+1030
+1031
+1032
+1033
+1034
+1035
+1036
+1037
+1038
+1039
+1040
+1041
+1042
+1043
+1044
+1045
+1046
+1047
+1048
+1049
+1050
+1051
+1052
+1053
+1054
+1055
+1056
+1057
+1058
+1059
+1060
+1061
+1062
+1063
/*
+A small wrapper utility to load indicators and put them as menu items
+into the mate-panel using it's applet interface.
+
+Copyright 2009-2010 Canonical Ltd.
+
+Authors:
+    Ted Gould <ted@canonical.com>
+
+This program is free software: you can redistribute it and/or modify it
+under the terms of the GNU General Public License version 3, as published
+by the Free Software Foundation.
+
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranties of
+MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
+PURPOSE.  See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along
+with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include <stdlib.h>
+#include <string.h>
+#include <config.h>
+#include <glib/gi18n.h>
+#include <mate-panel-applet.h>
+#include <gdk/gdkkeysyms.h>
+#include <gtk/gtk.h>
+
+#if HAVE_UBUNTU_INDICATOR
+
+#define INDICATOR_SERVICE_APPMENU	"libappmenu.so"
+#define INDICATOR_SERVICE_ME		"libme.so"
+#define INDICATOR_SERVICE_DATETIME	"libdatetime.so"
+
+#define INDICATOR_SERVICE_APPMENU_NG	"com.canonical.indicator.appmenu"
+#define INDICATOR_SERVICE_ME_NG		"com.canonical.indicator.me"
+#define INDICATOR_SERVICE_DATETIME_NG	"com.canonical.indicator.datetime"
+
+#include <libindicator/indicator-object.h>
+#endif
+
+#if HAVE_AYATANA_INDICATOR
+
+#define INDICATOR_SERVICE_APPMENU	"libayatana-appmenu.so"
+#define INDICATOR_SERVICE_ME		"libayatana-me.so"
+#define INDICATOR_SERVICE_DATETIME	"libayatana-datetime.so"
+
+#define INDICATOR_SERVICE_APPMENU_NG	"org.ayatana.indicator.appmenu"
+#define INDICATOR_SERVICE_ME_NG		"org.ayatana.indicator.me"
+#define INDICATOR_SERVICE_DATETIME_NG	"org.ayatana.indicator.datetime"
+
+#include <libayatana-indicator/indicator-object.h>
+#endif
+
+/* For new style indicators */
+
+#if HAVE_UBUNTU_INDICATOR && HAVE_UBUNTU_INDICATOR_NG
+
+#include <libido/libido.h>
+#include <libindicator/indicator-ng.h>
+
+#define INDICATOR_SERVICE_DIR "/usr/share/unity/indicators"
+
+#endif
+
+#if HAVE_AYATANA_INDICATOR && HAVE_AYATANA_INDICATOR_NG
+
+#include <libayatana-ido/libayatana-ido.h>
+#include <libayatana-indicator/indicator-ng.h>
+
+#define INDICATOR_SERVICE_DIR "/usr/share/ayatana/indicators"
+
+#endif
+
+#include "tomboykeybinder.h"
+
+static gchar * indicator_order[] = {
+#if HAVE_UBUNTU_INDICATOR
+	"libapplication.so",
+	"libmessaging.so",
+	"libsoundmenu.so",
+	"libdatetime.so",
+	"libsession.so",
+#endif
+#if HAVE_AYATANA_INDICATOR
+	"libayatana-application.so",
+	"libayatana-messaging.so",
+	"libayatana-soundmenu.so",
+	"libayatana-datetime.so",
+	"libayatana-session.so",
+#endif
+	NULL
+};
+
+static GtkPackDirection packdirection;
+static MatePanelAppletOrient orient;
+static guint size;
+
+#define  MENU_DATA_INDICATOR_OBJECT  "indicator-object"
+#define  MENU_DATA_INDICATOR_ENTRY   "indicator-entry"
+
+#define  IO_DATA_ORDER_NUMBER        "indicator-order-number"
+
+static gboolean     applet_fill_cb (MatePanelApplet * applet, const gchar * iid, gpointer data);
+
+static void update_accessible_desc (IndicatorObjectEntry * entry, GtkWidget * menuitem);
+
+/*************
+ * main
+ * ***********/
+
+#ifdef INDICATOR_APPLET
+MATE_PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletFactory",
+               PANEL_TYPE_APPLET,
+               "indicator-applet",
+               applet_fill_cb, NULL);
+#endif
+#ifdef INDICATOR_APPLET_COMPLETE
+MATE_PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletCompleteFactory",
+               PANEL_TYPE_APPLET,
+               "indicator-applet-complete",
+               applet_fill_cb, NULL);
+#endif
+#ifdef INDICATOR_APPLET_APPMENU
+MATE_PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletAppmenuFactory",
+               PANEL_TYPE_APPLET,
+               "indicator-applet-appmenu",
+               applet_fill_cb, NULL);
+#endif
+
+/*************
+ * log files
+ * ***********/
+#ifdef INDICATOR_APPLET
+#define LOG_FILE_NAME  "indicator-applet.log"
+#endif
+#ifdef INDICATOR_APPLET_COMPLETE
+#define LOG_FILE_NAME  "indicator-applet-complete.log"
+#endif
+#ifdef INDICATOR_APPLET_APPMENU
+#define LOG_FILE_NAME  "indicator-applet-appmenu.log"
+#endif
+GOutputStream * log_file = NULL;
+
+/*****************
+ * Hotkey support
+ * **************/
+#ifdef INDICATOR_APPLET
+gchar * hotkey_keycode = "<Super>M";
+#endif
+#ifdef INDICATOR_APPLET_SESSION
+gchar * hotkey_keycode = "<Super>S";
+#endif
+#ifdef INDICATOR_APPLET_COMPLETE
+gchar * hotkey_keycode = "<Super>S";
+#endif
+#ifdef INDICATOR_APPLET_APPMENU
+gchar * hotkey_keycode = "<Super>F1";
+#endif
+
+/********************
+ * Environment Names
+ * *******************/
+#ifdef INDICATOR_APPLET
+#define INDICATOR_SPECIFIC_ENV  "indicator-applet-original"
+#endif
+#ifdef INDICATOR_APPLET_COMPLETE
+#define INDICATOR_SPECIFIC_ENV  "indicator-applet-complete"
+#endif
+#ifdef INDICATOR_APPLET_APPMENU
+#define INDICATOR_SPECIFIC_ENV  "indicator-applet-appmenu"
+#endif
+
+static const gchar * indicator_env[] = {
+	"indicator-applet",
+	INDICATOR_SPECIFIC_ENV,
+	NULL
+};
+
+/*************
+ * init function
+ * ***********/
+
+static gint
+name2order (const gchar * name) {
+	int i;
+
+	for (i = 0; indicator_order[i] != NULL; i++) {
+		if (g_strcmp0(name, indicator_order[i]) == 0) {
+			return i;
+		}
+	}
+
+	return -1;
+}
+
+typedef struct _incoming_position_t incoming_position_t;
+struct _incoming_position_t {
+	gint objposition;
+	gint entryposition;
+	gint menupos;
+	gboolean found;
+};
+
+/* This function helps by determining where in the menu list
+   this new entry should be placed.  It compares the objects
+   that they're on, and then the individual entries.  Each
+   is progressively more expensive. */
+static void
+place_in_menu (GtkWidget * widget, gpointer user_data)
+{
+	incoming_position_t * position = (incoming_position_t *)user_data;
+	if (position->found) {
+		/* We've already been placed, just finish the foreach */
+		return;
+	}
+
+	IndicatorObject * io = INDICATOR_OBJECT(g_object_get_data(G_OBJECT(widget), MENU_DATA_INDICATOR_OBJECT));
+	g_assert(io != NULL);
+
+	gint objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER));
+	/* We've already passed it, well, then this is where
+	   we should be be.  Stop! */
+	if (objposition > position->objposition) {
+		position->found = TRUE;
+		return;
+	}
+
+	/* The objects don't match yet, keep looking */
+	if (objposition < position->objposition) {
+		position->menupos++;
+		return;
+	}
+
+	/* The objects are the same, let's start looking at entries. */
+	IndicatorObjectEntry * entry = (IndicatorObjectEntry *)g_object_get_data(G_OBJECT(widget), MENU_DATA_INDICATOR_ENTRY);
+	gint entryposition = indicator_object_get_location(io, entry);
+
+	if (entryposition > position->entryposition) {
+		position->found = TRUE;
+		return;
+	}
+
+	if (entryposition < position->entryposition) {
+		position->menupos++;
+		return;
+	}
+
+	/* We've got the same object and the same entry.  Well,
+	   let's just put it right here then. */
+	position->found = TRUE;
+	return;
+}
+
+static void
+something_shown (GtkWidget * widget, gpointer user_data)
+{
+	GtkWidget * menuitem = GTK_WIDGET(user_data);
+	gtk_widget_show(menuitem);
+}
+
+static void
+something_hidden (GtkWidget * widget, gpointer user_data)
+{
+	GtkWidget * menuitem = GTK_WIDGET(user_data);
+	gtk_widget_hide(menuitem);
+}
+
+static void
+sensitive_cb (GObject * obj, GParamSpec * pspec, gpointer user_data)
+{
+	g_return_if_fail(GTK_IS_WIDGET(obj));
+	g_return_if_fail(GTK_IS_WIDGET(user_data));
+
+	gtk_widget_set_sensitive(GTK_WIDGET(user_data), gtk_widget_get_sensitive(GTK_WIDGET(obj)));
+	return;
+}
+
+static void
+entry_activated (GtkWidget * widget, gpointer user_data)
+{
+	g_return_if_fail(GTK_IS_WIDGET(widget));
+	gpointer pio = g_object_get_data(G_OBJECT(widget), "indicator");
+	g_return_if_fail(INDICATOR_IS_OBJECT(pio));
+	IndicatorObject * io = INDICATOR_OBJECT(pio);
+
+	return indicator_object_entry_activate(io, (IndicatorObjectEntry *)user_data, gtk_get_current_event_time());
+}
+
+static gboolean
+entry_scrolled (GtkWidget *menuitem, GdkEventScroll *event, gpointer data)
+{
+	IndicatorObject *io = g_object_get_data (G_OBJECT (menuitem), MENU_DATA_INDICATOR_OBJECT);
+	IndicatorObjectEntry *entry = g_object_get_data (G_OBJECT (menuitem), MENU_DATA_INDICATOR_ENTRY);
+
+	g_return_val_if_fail(INDICATOR_IS_OBJECT(io), FALSE);
+
+	g_signal_emit_by_name (io, "scroll", 1, event->direction);
+	g_signal_emit_by_name (io, "scroll-entry", entry, 1, event->direction);
+	g_signal_emit_by_name (io, INDICATOR_OBJECT_SIGNAL_ENTRY_SCROLLED, entry, 1, event->direction);
+
+	return FALSE;
+}
+
+static void
+accessible_desc_update_cb (GtkWidget * widget, gpointer userdata)
+{
+	gpointer data = g_object_get_data(G_OBJECT(widget), MENU_DATA_INDICATOR_ENTRY);
+
+	if (data != userdata) {
+		return;
+	}
+
+	IndicatorObjectEntry * entry = (IndicatorObjectEntry *)data;
+	update_accessible_desc(entry, widget);
+}
+
+static void
+accessible_desc_update (IndicatorObject * io, IndicatorObjectEntry * entry, GtkWidget * menubar)
+{
+	gtk_container_foreach(GTK_CONTAINER(menubar), accessible_desc_update_cb, entry);
+	return;
+}
+
+#define PANEL_PADDING 8
+static gboolean
+entry_resized (GtkWidget *applet, guint newsize, gpointer data)
+{
+	IndicatorObject *io = (IndicatorObject *)data;
+
+	size = newsize;
+
+	/* Work on the entries */
+	GList * entries = indicator_object_get_entries(io);
+	GList * entry = NULL;
+
+	for (entry = entries; entry != NULL; entry = g_list_next(entry)) {
+		IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)entry->data;
+		if (entrydata->image != NULL) {
+			/* Resize to fit panel */
+			gtk_image_set_pixel_size (entrydata->image, size - PANEL_PADDING);
+		}
+	}
+
+	return FALSE;
+}
+
+static void
+entry_added (IndicatorObject * io, IndicatorObjectEntry * entry, GtkWidget * menubar)
+{
+	g_debug("Signal: Entry Added");
+	gboolean something_visible = FALSE;
+	gboolean something_sensitive = FALSE;
+
+	GtkWidget * menuitem = gtk_menu_item_new();
+	GtkWidget * box = (packdirection == GTK_PACK_DIRECTION_LTR) ?
+		gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3) : gtk_box_new(GTK_ORIENTATION_VERTICAL, 3);
+
+	/* Allows indicators to receive mouse scroll event */
+	gtk_widget_add_events(GTK_WIDGET(menuitem), GDK_SCROLL_MASK);
+
+	g_object_set_data (G_OBJECT (menuitem), "indicator", io);
+	g_object_set_data (G_OBJECT (menuitem), "box", box);
+
+	g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(entry_activated), entry);
+	g_signal_connect(G_OBJECT(menuitem), "scroll-event", G_CALLBACK(entry_scrolled), entry);
+
+	if (entry->image != NULL) {
+		/* Resize to fit panel */
+		gtk_image_set_pixel_size (entry->image, size - PANEL_PADDING);
+		gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(entry->image), FALSE, FALSE, 1);
+		if (gtk_widget_get_visible(GTK_WIDGET(entry->image))) {
+			something_visible = TRUE;
+		}
+
+		if (gtk_widget_get_sensitive(GTK_WIDGET(entry->image))) {
+			something_sensitive = TRUE;
+		}
+
+		g_signal_connect(G_OBJECT(entry->image), "show", G_CALLBACK(something_shown), menuitem);
+		g_signal_connect(G_OBJECT(entry->image), "hide", G_CALLBACK(something_hidden), menuitem);
+
+		g_signal_connect(G_OBJECT(entry->image), "notify::sensitive", G_CALLBACK(sensitive_cb), menuitem);
+	}
+	if (entry->label != NULL) {
+		switch(packdirection) {
+			case GTK_PACK_DIRECTION_LTR:
+				gtk_label_set_angle(GTK_LABEL(entry->label), 0.0);
+				break;
+			case GTK_PACK_DIRECTION_TTB:
+				gtk_label_set_angle(GTK_LABEL(entry->label),
+						(orient == MATE_PANEL_APPLET_ORIENT_LEFT) ?
+						270.0 : 90.0);
+				break;
+			default:
+				break;
+		}
+		gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(entry->label), FALSE, FALSE, 1);
+
+		if (gtk_widget_get_visible(GTK_WIDGET(entry->label))) {
+			something_visible = TRUE;
+		}
+
+		if (gtk_widget_get_sensitive(GTK_WIDGET(entry->label))) {
+			something_sensitive = TRUE;
+		}
+
+		g_signal_connect(G_OBJECT(entry->label), "show", G_CALLBACK(something_shown), menuitem);
+		g_signal_connect(G_OBJECT(entry->label), "hide", G_CALLBACK(something_hidden), menuitem);
+
+		g_signal_connect(G_OBJECT(entry->label), "notify::sensitive", G_CALLBACK(sensitive_cb), menuitem);
+	}
+	gtk_container_add(GTK_CONTAINER(menuitem), box);
+	gtk_widget_show(box);
+
+	if (entry->menu != NULL) {
+		gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), GTK_WIDGET(entry->menu));
+	}
+
+	incoming_position_t position;
+	position.objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER));
+	position.entryposition = indicator_object_get_location(io, entry);
+	position.menupos = 0;
+	position.found = FALSE;
+
+	gtk_container_foreach(GTK_CONTAINER(menubar), place_in_menu, &position);
+
+	gtk_menu_shell_insert(GTK_MENU_SHELL(menubar), menuitem, position.menupos);
+
+	if (something_visible) {
+		if (entry->accessible_desc != NULL) {
+			update_accessible_desc(entry, menuitem);
+		}
+		gtk_widget_show(menuitem);
+	}
+	gtk_widget_set_sensitive(menuitem, something_sensitive);
+
+	g_object_set_data(G_OBJECT(menuitem), MENU_DATA_INDICATOR_ENTRY,  entry);
+	g_object_set_data(G_OBJECT(menuitem), MENU_DATA_INDICATOR_OBJECT, io);
+
+	return;
+}
+
+static void
+entry_removed_cb (GtkWidget * widget, gpointer userdata)
+{
+	gpointer data = g_object_get_data(G_OBJECT(widget), MENU_DATA_INDICATOR_ENTRY);
+
+	if (data != userdata) {
+		return;
+	}
+
+	IndicatorObjectEntry * entry = (IndicatorObjectEntry *)data;
+	if (entry->label != NULL) {
+		g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(something_shown), widget);
+		g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(something_hidden), widget);
+		g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(sensitive_cb), widget);
+	}
+	if (entry->image != NULL) {
+		g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(something_shown), widget);
+		g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(something_hidden), widget);
+		g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(sensitive_cb), widget);
+	}
+
+	gtk_widget_destroy(widget);
+	return;
+}
+
+static void
+entry_removed (IndicatorObject * io G_GNUC_UNUSED, IndicatorObjectEntry * entry,
+               gpointer user_data)
+{
+	g_debug("Signal: Entry Removed");
+
+	gtk_container_foreach(GTK_CONTAINER(user_data), entry_removed_cb, entry);
+
+	return;
+}
+
+static void
+entry_moved_find_cb (GtkWidget * widget, gpointer userdata)
+{
+	gpointer * array = (gpointer *)userdata;
+	if (array[1] != NULL) {
+		return;
+	}
+
+	gpointer data = g_object_get_data(G_OBJECT(widget), MENU_DATA_INDICATOR_ENTRY);
+
+	if (data != array[0]) {
+		return;
+	}
+
+	array[1] = widget;
+	return;
+}
+
+/* Gets called when an entry for an object was moved. */
+static void
+entry_moved (IndicatorObject * io, IndicatorObjectEntry * entry,
+             gint old G_GNUC_UNUSED, gint new G_GNUC_UNUSED, gpointer user_data)
+{
+	GtkWidget * menubar = GTK_WIDGET(user_data);
+
+	gpointer array[2];
+	array[0] = entry;
+	array[1] = NULL;
+
+	gtk_container_foreach(GTK_CONTAINER(menubar), entry_moved_find_cb, array);
+	if (array[1] == NULL) {
+		g_warning("Moving an entry that isn't in our menus.");
+		return;
+	}
+
+	GtkWidget * mi = GTK_WIDGET(array[1]);
+	g_object_ref(G_OBJECT(mi));
+	gtk_container_remove(GTK_CONTAINER(menubar), mi);
+
+	incoming_position_t position;
+	position.objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER));
+	position.entryposition = indicator_object_get_location(io, entry);
+	position.menupos = 0;
+	position.found = FALSE;
+
+	gtk_container_foreach(GTK_CONTAINER(menubar), place_in_menu, &position);
+
+	gtk_menu_shell_insert(GTK_MENU_SHELL(menubar), mi, position.menupos);
+	g_object_unref(G_OBJECT(mi));
+
+	return;
+}
+
+static void
+menu_show (IndicatorObject * io, IndicatorObjectEntry * entry,<--- Shadowed declaration
+           guint32 timestamp, gpointer user_data)
+{
+	GtkWidget * menubar = GTK_WIDGET(user_data);
+
+	if (entry == NULL) {
+		/* Close any open menus instead of opening one */
+		GList * entries = indicator_object_get_entries(io);
+		GList * entry = NULL;<--- Shadow variable
+		for (entry = entries; entry != NULL; entry = g_list_next(entry)) {
+			IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)entry->data;
+			gtk_menu_popdown(entrydata->menu);
+		}
+		g_list_free(entries);
+
+		/* And tell the menubar to exit activation mode too */
+		gtk_menu_shell_cancel(GTK_MENU_SHELL(menubar));
+		return;
+	}
+
+	// TODO: do something sensible here
+}
+
+static void
+update_accessible_desc(IndicatorObjectEntry * entry, GtkWidget * menuitem)
+{
+	/* FIXME: We need to deal with the use case where the contents of the
+	   label overrides what is found in the atk object's name, or at least
+	   orca speaks the label instead of the atk object name.
+	 */
+	AtkObject * menuitem_obj = gtk_widget_get_accessible(menuitem);
+	if (menuitem_obj == NULL) {
+		/* Should there be an error printed here? */
+		return;
+	}
+
+	if (entry->accessible_desc != NULL) {
+		atk_object_set_name(menuitem_obj, entry->accessible_desc);
+	} else {
+		atk_object_set_name(menuitem_obj, "");
+	}
+	return;
+}
+
+static void
+load_indicator (MatePanelApplet *applet, GtkWidget * menubar, IndicatorObject *io, const gchar *name)
+{
+	/* Set the environment it's in */
+	indicator_object_set_environment(io, (const GStrv)indicator_env);
+
+	/* Attach the 'name' to the object */
+#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
+	int pos = 5000 - indicator_object_get_position(io);
+	if (pos > 5000) {
+		pos = name2order(name);
+	}
+#else
+	int pos = name2order(name);
+#endif
+
+	g_object_set_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER, GINT_TO_POINTER(pos));
+
+	/* Connect to its signals */
+	g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED,   G_CALLBACK(entry_added),    menubar);
+	g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED, G_CALLBACK(entry_removed),  menubar);
+	g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_MOVED,   G_CALLBACK(entry_moved),    menubar);
+	g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_MENU_SHOW,     G_CALLBACK(menu_show),      menubar);
+	g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ACCESSIBLE_DESC_UPDATE, G_CALLBACK(accessible_desc_update), menubar);
+
+	/* Track panel resize */
+	g_signal_connect_object(G_OBJECT(applet), "change-size", G_CALLBACK(entry_resized), G_OBJECT(io), 0);
+
+	/* Work on the entries */
+	GList * entries = indicator_object_get_entries(io);
+	GList * entry = NULL;
+
+	for (entry = entries; entry != NULL; entry = g_list_next(entry)) {
+		IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)entry->data;
+		entry_added(io, entrydata, menubar);
+	}
+
+	g_list_free(entries);
+}
+
+static gboolean
+load_module (const gchar * name, MatePanelApplet *applet, GtkWidget * menubar)
+{
+	g_debug("Looking at Module: %s", name);
+	g_return_val_if_fail(name != NULL, FALSE);
+
+	if (!g_str_has_suffix(name, G_MODULE_SUFFIX)) {
+		return FALSE;
+	}
+
+	g_debug("Loading Module: %s", name);
+
+	/* Build the object for the module */
+	gchar * fullpath = g_build_filename(INDICATOR_DIR, name, NULL);
+	IndicatorObject * io = indicator_object_new_from_file(fullpath);
+	g_free(fullpath);
+
+	load_indicator(applet, menubar, io, name);
+
+	return TRUE;
+}
+
+static void
+load_modules (MatePanelApplet *applet, GtkWidget *menubar, gint *indicators_loaded)
+{
+	if (g_file_test(INDICATOR_DIR, (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))) {
+		GDir * dir = g_dir_open(INDICATOR_DIR, 0, NULL);
+
+		const gchar * name;
+		gint count = 0;
+		while ((name = g_dir_read_name(dir)) != NULL) {
+#ifdef INDICATOR_APPLET_APPMENU
+			if (g_strcmp0(name, INDICATOR_SERVICE_APPMENU)) {
+				continue;
+			}
+#else
+			if (!g_strcmp0(name, INDICATOR_SERVICE_APPMENU)) {
+				continue;
+			}
+#endif
+#ifdef INDICATOR_APPLET
+			if (!g_strcmp0(name, INDICATOR_SERVICE_ME)) {
+				continue;
+			}
+			if (!g_strcmp0(name, INDICATOR_SERVICE_DATETIME)) {
+				continue;
+			}
+#endif
+			if (load_module(name, applet, menubar)) {
+				count++;
+			}
+		}
+
+		*indicators_loaded += count;
+
+		g_dir_close (dir);
+	}
+}
+
+#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
+
+static void
+load_indicators_from_indicator_files (MatePanelApplet *applet, GtkWidget *menubar, gint *indicators_loaded)
+{
+	GDir *dir;
+	const gchar *name;
+	GError *error = NULL;
+
+	dir = g_dir_open (INDICATOR_SERVICE_DIR, 0, &error);
+
+	if (!dir) {
+		g_warning ("unable to open indicator service file directory: %s", error->message);
+		g_error_free (error);
+
+		return;
+	}
+
+	gint count = 0;
+	while ((name = g_dir_read_name (dir))) {
+		gchar *filename;
+		IndicatorNg *indicator;
+
+		filename = g_build_filename (INDICATOR_SERVICE_DIR, name, NULL);
+		indicator = indicator_ng_new_for_profile (filename, "desktop", &error);
+		g_free (filename);
+
+#ifdef INDICATOR_APPLET_APPMENU
+		if (g_strcmp0(name, INDICATOR_SERVICE_APPMENU_NG)) {
+			continue;
+		}
+#else
+		if (!g_strcmp0(name, INDICATOR_SERVICE_APPMENU_NG)) {
+			continue;
+		}
+#endif
+#ifdef INDICATOR_APPLET
+		if (!g_strcmp0(name, INDICATOR_SERVICE_ME_NG)) {
+			continue;
+		}
+		if (!g_strcmp0(name, INDICATOR_SERVICE_DATETIME_NG)) {
+			continue;
+		}
+#endif
+
+		if (indicator) {
+			load_indicator(applet, menubar, INDICATOR_OBJECT (indicator), name);
+			count++;
+		}else{
+			g_warning ("unable to load '%s': %s", name, error->message);
+			g_clear_error (&error);
+		}
+	}
+
+	*indicators_loaded += count;
+
+	g_dir_close (dir);
+}
+#endif  /* HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG */
+
+static void
+hotkey_filter (char * keystring G_GNUC_UNUSED, gpointer data)
+{
+	g_return_if_fail(GTK_IS_MENU_SHELL(data));
+
+	/* Oh, wow, it's us! */
+	GList * children = gtk_container_get_children(GTK_CONTAINER(data));
+	if (children == NULL) {
+		g_debug("Menubar has no children");
+		return;
+	}
+
+	gtk_menu_shell_select_item(GTK_MENU_SHELL(data), GTK_WIDGET(g_list_last(children)->data));
+	g_list_free(children);
+	return;
+}
+
+static gboolean
+menubar_press (GtkWidget * widget,
+                    GdkEventButton *event,
+                    gpointer data G_GNUC_UNUSED)
+{
+	if (event->button != 1) {
+		g_signal_stop_emission_by_name(widget, "button-press-event");
+	}
+
+	return FALSE;
+}
+
+static gboolean
+menubar_on_draw (GtkWidget * widget,
+                 cairo_t * cr,
+                 GtkWidget * menubar)
+{
+	/* FIXME: either port to gtk_render_focus or remove this function */
+	if (gtk_widget_has_focus(menubar))
+		gtk_paint_focus(gtk_widget_get_style(widget),
+		                cr,
+		                gtk_widget_get_state(menubar),
+		                widget, "menubar-applet", 0, 0, -1, -1);
+
+	return FALSE;
+}
+
+static void
+about_cb (GtkAction *action G_GNUC_UNUSED,
+          gpointer   data G_GNUC_UNUSED)
+{
+	static const gchar *authors[] = {
+		"Ted Gould <ted@canonical.com>",
+		NULL
+	};
+
+	static gchar *license[] = {
+        N_("This program is free software: you can redistribute it and/or modify it "
+           "under the terms of the GNU General Public License version 3, as published "
+           "by the Free Software Foundation."),
+        N_("This program is distributed in the hope that it will be useful, but "
+           "WITHOUT ANY WARRANTY; without even the implied warranties of "
+           "MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
+           "PURPOSE.  See the GNU General Public License for more details."),
+        N_("You should have received a copy of the GNU General Public License along "
+           "with this program.  If not, see <http://www.gnu.org/licenses/>."),
+		NULL
+	};
+	gchar *license_i18n;
+
+	license_i18n = g_strconcat (_(license[0]), "\n\n", _(license[1]), "\n\n", _(license[2]), NULL);
+
+	gtk_show_about_dialog(NULL,
+		"version", VERSION,
+		"copyright", _("Copyright \xc2\xa9 2009-2010 Canonical, Ltd.\n"
+		               "Copyright \xc2\xa9 2011-2020 MATE developers"),
+#ifdef INDICATOR_APPLET_APPMENU
+		"comments", _("An applet to hold your application menus."),
+#endif
+		"comments", _("An applet to hold all of the system indicators."),
+		"authors", authors,
+		"license", license_i18n,
+		"wrap-license", TRUE,
+		"translator-credits", _("translator-credits"),
+		"logo-icon-name", "mate-indicator-applet",
+		"icon-name", "mate-indicator-applet",
+		"website", "https://mate-desktop.org",
+		"website-label", _("MATE Website"),
+		NULL
+	);
+
+	g_free (license_i18n);
+
+	return;
+}
+
+static gboolean
+swap_orient_cb (GtkWidget *item, gpointer data)
+{
+	GtkWidget *from = (GtkWidget *) data;
+	GtkWidget *to = (GtkWidget *) g_object_get_data(G_OBJECT(from), "to");
+	g_object_ref(G_OBJECT(item));
+	gtk_container_remove(GTK_CONTAINER(from), item);
+	if (GTK_IS_LABEL(item)) {
+			switch(packdirection) {
+			case GTK_PACK_DIRECTION_LTR:
+				gtk_label_set_angle(GTK_LABEL(item), 0.0);
+				break;
+			case GTK_PACK_DIRECTION_TTB:
+				gtk_label_set_angle(GTK_LABEL(item),
+						(orient == MATE_PANEL_APPLET_ORIENT_LEFT) ?
+						270.0 : 90.0);
+				break;
+			default:
+				break;
+		}
+	}
+	gtk_box_pack_start(GTK_BOX(to), item, FALSE, FALSE, 0);
+	return TRUE;
+}
+
+static gboolean
+reorient_box_cb (GtkWidget *menuitem, gpointer data)
+{
+	GtkWidget *from = g_object_get_data(G_OBJECT(menuitem), "box");
+	GtkWidget *to = (packdirection == GTK_PACK_DIRECTION_LTR) ?
+		gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0) : gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
+	g_object_set_data(G_OBJECT(from), "to", to);
+	gtk_container_foreach(GTK_CONTAINER(from), (GtkCallback)swap_orient_cb,
+			from);
+	gtk_container_remove(GTK_CONTAINER(menuitem), from);
+	gtk_container_add(GTK_CONTAINER(menuitem), to);
+	g_object_set_data(G_OBJECT(menuitem), "box", to);
+	gtk_widget_show_all(menuitem);
+	return TRUE;
+}
+
+static gboolean
+matepanelapplet_reorient_cb (GtkWidget *applet, MatePanelAppletOrient neworient,
+		gpointer data)
+{
+	GtkWidget *menubar = (GtkWidget *)data;
+	if ((((neworient == MATE_PANEL_APPLET_ORIENT_UP) ||
+			(neworient == MATE_PANEL_APPLET_ORIENT_DOWN)) &&
+			((orient == MATE_PANEL_APPLET_ORIENT_LEFT) ||
+			(orient == MATE_PANEL_APPLET_ORIENT_RIGHT))) ||
+			(((neworient == MATE_PANEL_APPLET_ORIENT_LEFT) ||
+			(neworient == MATE_PANEL_APPLET_ORIENT_RIGHT)) &&
+			((orient == MATE_PANEL_APPLET_ORIENT_UP) ||
+			(orient == MATE_PANEL_APPLET_ORIENT_DOWN)))) {
+		packdirection = (packdirection == GTK_PACK_DIRECTION_LTR) ?
+				GTK_PACK_DIRECTION_TTB : GTK_PACK_DIRECTION_LTR;
+		gtk_menu_bar_set_pack_direction(GTK_MENU_BAR(menubar),
+				packdirection);
+		orient = neworient;
+		gtk_container_foreach(GTK_CONTAINER(menubar),
+				(GtkCallback)reorient_box_cb, NULL);
+	}
+	orient = neworient;
+	return FALSE;
+}
+
+#ifdef N_
+#undef N_
+#endif
+#define N_(x) x
+
+static void
+log_to_file_cb (GObject * source_obj G_GNUC_UNUSED,
+                GAsyncResult * result G_GNUC_UNUSED, gpointer user_data)
+{
+	g_free(user_data);
+	return;
+}
+
+static void
+log_to_file (const gchar * domain G_GNUC_UNUSED,
+             GLogLevelFlags level G_GNUC_UNUSED,
+             const gchar * message,
+             gpointer data G_GNUC_UNUSED)
+{
+	if (log_file == NULL) {
+		GError * error = NULL;
+		gchar * filename = g_build_filename(g_get_user_cache_dir(), LOG_FILE_NAME, NULL);
+		GFile * file = g_file_new_for_path(filename);
+		g_free(filename);
+
+		if (!g_file_test(g_get_user_cache_dir(), G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) {
+			GFile * cachedir = g_file_new_for_path(g_get_user_cache_dir());
+			g_file_make_directory_with_parents(cachedir, NULL, &error);
+
+			if (error != NULL) {
+				g_error("Unable to make directory '%s' for log file: %s", g_get_user_cache_dir(), error->message);
+			}
+		}
+
+		g_file_delete(file, NULL, NULL);
+
+		GFileIOStream * io = g_file_create_readwrite(file,
+		                          G_FILE_CREATE_REPLACE_DESTINATION, /* flags */
+		                          NULL, /* cancelable */
+		                          &error); /* error */
+		if (error != NULL) {
+			g_error("Unable to replace file: %s", error->message);
+		}
+
+		log_file = g_io_stream_get_output_stream(G_IO_STREAM(io));
+	}
+
+	gchar * outputstring = g_strdup_printf("%s\n", message);
+	g_output_stream_write_async(log_file,
+	                            outputstring, /* data */
+	                            strlen(outputstring), /* length */
+	                            G_PRIORITY_LOW, /* priority */
+	                            NULL, /* cancelable */
+	                            log_to_file_cb, /* callback */
+	                            outputstring); /* data */
+
+	return;
+}
+
+static gboolean
+applet_fill_cb (MatePanelApplet * applet, const gchar * iid G_GNUC_UNUSED,
+                gpointer data G_GNUC_UNUSED)
+{
+#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
+	ido_init();
+#endif
+
+	static const GtkActionEntry menu_actions[] = {
+		{"About", GTK_STOCK_ABOUT, N_("_About"), NULL, NULL, G_CALLBACK(about_cb)}
+	};
+	static const gchar *menu_xml = "<menuitem name=\"About\" action=\"About\"/>";
+
+	static gboolean first_time = FALSE;
+	GtkWidget *menubar;
+	gint indicators_loaded = 0;
+	GtkActionGroup *action_group;
+
+	if (!first_time)
+	{
+		first_time = TRUE;
+#ifdef INDICATOR_APPLET
+		g_set_application_name(_("Indicator Applet"));
+#endif
+#ifdef INDICATOR_APPLET_COMPLETE
+		g_set_application_name(_("Indicator Applet Complete"));
+#endif
+#ifdef INDICATOR_APPLET_APPMENU
+		g_set_application_name(_("Indicator Applet Application Menu"));
+#endif
+
+		g_log_set_default_handler(log_to_file, NULL);
+
+		tomboy_keybinder_init();
+	}
+
+	/* Set panel options */
+	gtk_container_set_border_width(GTK_CONTAINER (applet), 0);
+	mate_panel_applet_set_flags(applet, MATE_PANEL_APPLET_EXPAND_MINOR);
+	menubar = gtk_menu_bar_new();
+	action_group = gtk_action_group_new ("Indicator Applet Actions");
+	gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
+	gtk_action_group_add_actions (action_group, menu_actions,
+	                              G_N_ELEMENTS (menu_actions),
+	                              menubar);
+	mate_panel_applet_setup_menu(applet, menu_xml, action_group);
+	g_object_unref(action_group);
+#ifdef INDICATOR_APPLET
+	atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)),
+	                     "indicator-applet");
+#endif
+#ifdef INDICATOR_APPLET_COMPLETE
+	atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)),
+	                     "indicator-applet-complete");
+#endif
+#ifdef INDICATOR_APPLET_APPMENU
+	atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)),
+	                     "indicator-applet-appmenu");
+#endif
+
+	/* Init some theme/icon stuff */
+	gtk_icon_theme_append_search_path(gtk_icon_theme_get_default(),
+	                                  INDICATOR_ICONS_DIR);
+	/* g_debug("Icons directory: %s", INDICATOR_ICONS_DIR); */
+	gtk_widget_set_name(GTK_WIDGET (applet), "fast-user-switch-applet");
+
+	/* Build menubar */
+	size = (mate_panel_applet_get_size (applet));
+	orient = (mate_panel_applet_get_orient(applet));
+	packdirection = ((orient == MATE_PANEL_APPLET_ORIENT_UP) ||
+			(orient == MATE_PANEL_APPLET_ORIENT_DOWN)) ?
+			GTK_PACK_DIRECTION_LTR : GTK_PACK_DIRECTION_TTB;
+	gtk_menu_bar_set_pack_direction(GTK_MENU_BAR(menubar),
+			packdirection);
+	gtk_widget_set_can_focus (menubar, TRUE);
+	gtk_widget_set_name(GTK_WIDGET (menubar), "fast-user-switch-menubar");
+	g_signal_connect(menubar, "button-press-event", G_CALLBACK(menubar_press), NULL);
+	g_signal_connect_after(menubar, "draw", G_CALLBACK(menubar_on_draw), menubar);
+	g_signal_connect(applet, "change-orient",
+			G_CALLBACK(matepanelapplet_reorient_cb), menubar);
+	gtk_container_set_border_width(GTK_CONTAINER(menubar), 0);
+
+	/* Add in filter func */
+	tomboy_keybinder_bind(hotkey_keycode, hotkey_filter, menubar);
+
+	load_modules(applet, menubar, &indicators_loaded);
+#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
+	load_indicators_from_indicator_files(applet, menubar, &indicators_loaded);
+#endif
+
+	if (indicators_loaded == 0) {
+		/* A label to allow for click through */
+		GtkWidget * item = gtk_label_new(_("No Indicators"));
+		mate_panel_applet_set_background_widget(applet, item);
+		gtk_container_add(GTK_CONTAINER(applet), item);
+		gtk_widget_show(item);
+	} else {
+		gtk_container_add(GTK_CONTAINER(applet), menubar);
+		mate_panel_applet_set_background_widget(applet, menubar);
+		gtk_widget_show(menubar);
+	}
+
+	gtk_widget_show(GTK_WIDGET(applet));
+
+	return TRUE;
+
+}
+
+
+
+ + + diff --git a/2020-04-09-125606-1816-cppcheck@42f0ae6627b3_unreachable-code/1.html b/2020-04-09-125606-1816-cppcheck@42f0ae6627b3_unreachable-code/1.html new file mode 100644 index 0000000..6bc0c8a --- /dev/null +++ b/2020-04-09-125606-1816-cppcheck@42f0ae6627b3_unreachable-code/1.html @@ -0,0 +1,1208 @@ + + + + + + Cppcheck - HTML report - mate-indicator-applet + + + + + + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
/* eggaccelerators.c
+ * Copyright (C) 2002  Red Hat, Inc.; Copyright 1998, 2001 Tim Janik
+ * Developed by Havoc Pennington, Tim Janik
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
+ */
+
+#include "eggaccelerators.h"
+
+#include <string.h>
+#include <gdk/gdkx.h>
+#include <gdk/gdkkeysyms.h>
+
+enum
+{
+  EGG_MODMAP_ENTRY_SHIFT   = 0,
+  EGG_MODMAP_ENTRY_LOCK    = 1,
+  EGG_MODMAP_ENTRY_CONTROL = 2,
+  EGG_MODMAP_ENTRY_MOD1    = 3,
+  EGG_MODMAP_ENTRY_MOD2    = 4,
+  EGG_MODMAP_ENTRY_MOD3    = 5,
+  EGG_MODMAP_ENTRY_MOD4    = 6,
+  EGG_MODMAP_ENTRY_MOD5    = 7,
+  EGG_MODMAP_ENTRY_LAST    = 8
+};
+
+#define MODMAP_ENTRY_TO_MODIFIER(x) (1 << (x))
+
+typedef struct
+{
+  EggVirtualModifierType mapping[EGG_MODMAP_ENTRY_LAST];
+
+} EggModmap;
+
+const EggModmap* egg_keymap_get_modmap (GdkKeymap *keymap);
+
+static inline gboolean
+is_alt (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'a' || string[1] == 'A') &&
+	  (string[2] == 'l' || string[2] == 'L') &&
+	  (string[3] == 't' || string[3] == 'T') &&
+	  (string[4] == '>'));
+}
+
+static inline gboolean
+is_ctl (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'c' || string[1] == 'C') &&
+	  (string[2] == 't' || string[2] == 'T') &&
+	  (string[3] == 'l' || string[3] == 'L') &&
+	  (string[4] == '>'));
+}
+
+static inline gboolean
+is_modx (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'm' || string[1] == 'M') &&
+	  (string[2] == 'o' || string[2] == 'O') &&
+	  (string[3] == 'd' || string[3] == 'D') &&
+	  (string[4] >= '1' && string[4] <= '5') &&
+	  (string[5] == '>'));
+}
+
+static inline gboolean
+is_ctrl (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'c' || string[1] == 'C') &&
+	  (string[2] == 't' || string[2] == 'T') &&
+	  (string[3] == 'r' || string[3] == 'R') &&
+	  (string[4] == 'l' || string[4] == 'L') &&
+	  (string[5] == '>'));
+}
+
+static inline gboolean
+is_shft (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 's' || string[1] == 'S') &&
+	  (string[2] == 'h' || string[2] == 'H') &&
+	  (string[3] == 'f' || string[3] == 'F') &&
+	  (string[4] == 't' || string[4] == 'T') &&
+	  (string[5] == '>'));
+}
+
+static inline gboolean
+is_shift (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 's' || string[1] == 'S') &&
+	  (string[2] == 'h' || string[2] == 'H') &&
+	  (string[3] == 'i' || string[3] == 'I') &&
+	  (string[4] == 'f' || string[4] == 'F') &&
+	  (string[5] == 't' || string[5] == 'T') &&
+	  (string[6] == '>'));
+}
+
+static inline gboolean
+is_control (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'c' || string[1] == 'C') &&
+	  (string[2] == 'o' || string[2] == 'O') &&
+	  (string[3] == 'n' || string[3] == 'N') &&
+	  (string[4] == 't' || string[4] == 'T') &&
+	  (string[5] == 'r' || string[5] == 'R') &&
+	  (string[6] == 'o' || string[6] == 'O') &&
+	  (string[7] == 'l' || string[7] == 'L') &&
+	  (string[8] == '>'));
+}
+
+static inline gboolean
+is_release (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'r' || string[1] == 'R') &&
+	  (string[2] == 'e' || string[2] == 'E') &&
+	  (string[3] == 'l' || string[3] == 'L') &&
+	  (string[4] == 'e' || string[4] == 'E') &&
+	  (string[5] == 'a' || string[5] == 'A') &&
+	  (string[6] == 's' || string[6] == 'S') &&
+	  (string[7] == 'e' || string[7] == 'E') &&
+	  (string[8] == '>'));
+}
+
+static inline gboolean
+is_meta (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'm' || string[1] == 'M') &&
+	  (string[2] == 'e' || string[2] == 'E') &&
+	  (string[3] == 't' || string[3] == 'T') &&
+	  (string[4] == 'a' || string[4] == 'A') &&
+	  (string[5] == '>'));
+}
+
+static inline gboolean
+is_super (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 's' || string[1] == 'S') &&
+	  (string[2] == 'u' || string[2] == 'U') &&
+	  (string[3] == 'p' || string[3] == 'P') &&
+	  (string[4] == 'e' || string[4] == 'E') &&
+	  (string[5] == 'r' || string[5] == 'R') &&
+	  (string[6] == '>'));
+}
+
+static inline gboolean
+is_hyper (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'h' || string[1] == 'H') &&
+	  (string[2] == 'y' || string[2] == 'Y') &&
+	  (string[3] == 'p' || string[3] == 'P') &&
+	  (string[4] == 'e' || string[4] == 'E') &&
+	  (string[5] == 'r' || string[5] == 'R') &&
+	  (string[6] == '>'));
+}
+
+/**
+ * egg_accelerator_parse_virtual:
+ * @accelerator:      string representing an accelerator
+ * @accelerator_key:  return location for accelerator keyval
+ * @accelerator_mods: return location for accelerator modifier mask
+ *
+ * Parses a string representing a virtual accelerator. The format
+ * looks like "&lt;Control&gt;a" or "&lt;Shift&gt;&lt;Alt&gt;F1" or
+ * "&lt;Release&gt;z" (the last one is for key release).  The parser
+ * is fairly liberal and allows lower or upper case, and also
+ * abbreviations such as "&lt;Ctl&gt;" and "&lt;Ctrl&gt;".
+ *
+ * If the parse fails, @accelerator_key and @accelerator_mods will
+ * be set to 0 (zero) and %FALSE will be returned. If the string contains
+ * only modifiers, @accelerator_key will be set to 0 but %TRUE will be
+ * returned.
+ *
+ * The virtual vs. concrete accelerator distinction is a relic of
+ * how the X Window System works; there are modifiers Mod2-Mod5 that
+ * can represent various keyboard keys (numlock, meta, hyper, etc.),
+ * the virtual modifier represents the keyboard key, the concrete
+ * modifier the actual Mod2-Mod5 bits in the key press event.
+ *
+ * Returns: %TRUE on success.
+ */
+gboolean
+egg_accelerator_parse_virtual (const gchar            *accelerator,
+                               guint                  *accelerator_key,
+                               EggVirtualModifierType *accelerator_mods)
+{
+  guint keyval;
+  GdkModifierType mods;
+  gint len;
+  gboolean bad_keyval;
+
+  if (accelerator_key)
+    *accelerator_key = 0;
+  if (accelerator_mods)
+    *accelerator_mods = 0;
+
+  g_return_val_if_fail (accelerator != NULL, FALSE);
+
+  bad_keyval = FALSE;
+
+  keyval = 0;
+  mods = 0;
+  len = strlen (accelerator);
+  while (len)
+    {
+      if (*accelerator == '<')
+	{
+	  if (len >= 9 && is_release (accelerator))
+	    {
+	      accelerator += 9;
+	      len -= 9;
+	      mods |= EGG_VIRTUAL_RELEASE_MASK;
+	    }
+	  else if (len >= 9 && is_control (accelerator))
+	    {
+	      accelerator += 9;
+	      len -= 9;
+	      mods |= EGG_VIRTUAL_CONTROL_MASK;
+	    }
+	  else if (len >= 7 && is_shift (accelerator))
+	    {
+	      accelerator += 7;
+	      len -= 7;
+	      mods |= EGG_VIRTUAL_SHIFT_MASK;
+	    }
+	  else if (len >= 6 && is_shft (accelerator))
+	    {
+	      accelerator += 6;
+	      len -= 6;
+	      mods |= EGG_VIRTUAL_SHIFT_MASK;
+	    }
+	  else if (len >= 6 && is_ctrl (accelerator))
+	    {
+	      accelerator += 6;
+	      len -= 6;
+	      mods |= EGG_VIRTUAL_CONTROL_MASK;
+	    }
+	  else if (len >= 6 && is_modx (accelerator))
+	    {
+	      static const guint mod_vals[] = {
+		EGG_VIRTUAL_ALT_MASK, EGG_VIRTUAL_MOD2_MASK, EGG_VIRTUAL_MOD3_MASK,
+		EGG_VIRTUAL_MOD4_MASK, EGG_VIRTUAL_MOD5_MASK
+	      };
+
+	      len -= 6;
+	      accelerator += 4;
+	      mods |= mod_vals[*accelerator - '1'];
+	      accelerator += 2;
+	    }
+	  else if (len >= 5 && is_ctl (accelerator))
+	    {
+	      accelerator += 5;
+	      len -= 5;
+	      mods |= EGG_VIRTUAL_CONTROL_MASK;
+	    }
+	  else if (len >= 5 && is_alt (accelerator))
+	    {
+	      accelerator += 5;
+	      len -= 5;
+	      mods |= EGG_VIRTUAL_ALT_MASK;
+	    }
+          else if (len >= 6 && is_meta (accelerator))
+	    {
+	      accelerator += 6;
+	      len -= 6;
+	      mods |= EGG_VIRTUAL_META_MASK;
+	    }
+          else if (len >= 7 && is_hyper (accelerator))
+	    {
+	      accelerator += 7;
+	      len -= 7;
+	      mods |= EGG_VIRTUAL_HYPER_MASK;
+	    }
+          else if (len >= 7 && is_super (accelerator))
+	    {
+	      accelerator += 7;
+	      len -= 7;
+	      mods |= EGG_VIRTUAL_SUPER_MASK;
+	    }
+	  else
+	    {
+	      gchar last_ch;
+
+	      last_ch = *accelerator;
+	      while (last_ch && last_ch != '>')
+		{
+		  last_ch = *accelerator;
+		  accelerator += 1;
+		  len -= 1;
+		}
+	    }
+	}
+      else
+	{
+          keyval = gdk_keyval_from_name (accelerator);
+
+          if (keyval == 0)
+            bad_keyval = TRUE;
+
+          accelerator += len;
+          len -= len;
+	}
+    }
+
+  if (accelerator_key)
+    *accelerator_key = gdk_keyval_to_lower (keyval);
+  if (accelerator_mods)
+    *accelerator_mods = mods;
+
+  return !bad_keyval;
+}
+
+void
+egg_keymap_resolve_virtual_modifiers (GdkKeymap              *keymap,
+                                      EggVirtualModifierType  virtual_mods,
+                                      GdkModifierType        *concrete_mods)
+{
+  GdkModifierType concrete;
+  int i;
+  const EggModmap *modmap;
+
+  g_return_if_fail (GDK_IS_KEYMAP (keymap));
+  g_return_if_fail (concrete_mods != NULL);
+
+  modmap = egg_keymap_get_modmap (keymap);
+
+  /* Not so sure about this algorithm. */
+
+  concrete = 0;
+  i = 0;
+  while (i < EGG_MODMAP_ENTRY_LAST)
+    {
+      if (modmap->mapping[i] & virtual_mods)
+        concrete |= (1 << i);
+
+      ++i;
+    }
+
+  *concrete_mods = concrete;
+}
+
+void
+egg_keymap_virtualize_modifiers (GdkKeymap              *keymap,
+                                 GdkModifierType         concrete_mods,
+                                 EggVirtualModifierType *virtual_mods)
+{
+  GdkModifierType virtual;
+  int i;
+  const EggModmap *modmap;
+
+  g_return_if_fail (GDK_IS_KEYMAP (keymap));
+  g_return_if_fail (virtual_mods != NULL);
+
+  modmap = egg_keymap_get_modmap (keymap);
+
+  /* Not so sure about this algorithm. */
+
+  virtual = 0;
+  i = 0;
+  while (i < EGG_MODMAP_ENTRY_LAST)
+    {
+      if ((1 << i) & concrete_mods)
+        {
+          EggVirtualModifierType cleaned;
+
+          cleaned = modmap->mapping[i] & ~(EGG_VIRTUAL_MOD2_MASK |
+                                           EGG_VIRTUAL_MOD3_MASK |
+                                           EGG_VIRTUAL_MOD4_MASK |
+                                           EGG_VIRTUAL_MOD5_MASK);
+
+          if (cleaned != 0)
+            {
+              virtual |= cleaned;
+            }
+          else
+            {
+              /* Rather than dropping mod2->mod5 if not bound,
+               * go ahead and use the concrete names
+               */
+              virtual |= modmap->mapping[i];
+            }
+        }
+
+      ++i;
+    }
+
+  *virtual_mods = virtual;
+}
+
+static void
+reload_modmap (GdkKeymap *keymap,
+               EggModmap *modmap)
+{
+  XModifierKeymap *xmodmap;
+  int map_size;
+  int i;
+
+  /* FIXME multihead */
+  xmodmap = XGetModifierMapping (gdk_x11_get_default_xdisplay ());
+
+  memset (modmap->mapping, 0, sizeof (modmap->mapping));
+
+  /* there are 8 modifiers, and the first 3 are shift, shift lock,
+   * and control
+   */
+  map_size = 8 * xmodmap->max_keypermod;
+  i = 3 * xmodmap->max_keypermod;
+  while (i < map_size)
+    {
+      /* get the key code at this point in the map,
+       * see if its keysym is one we're interested in
+       */
+      int keycode = xmodmap->modifiermap[i];
+      GdkKeymapKey *keys;
+      guint *keyvals;
+      int n_entries;
+      int j;
+      EggVirtualModifierType mask;
+
+      keys = NULL;
+      keyvals = NULL;
+      n_entries = 0;
+
+      gdk_keymap_get_entries_for_keycode (keymap,
+                                          keycode,
+                                          &keys, &keyvals, &n_entries);
+
+      mask = 0;
+      j = 0;
+      while (j < n_entries)
+        {
+          if (keyvals[j] == GDK_KEY_Num_Lock)
+            mask |= EGG_VIRTUAL_NUM_LOCK_MASK;
+          else if (keyvals[j] == GDK_KEY_Scroll_Lock)
+            mask |= EGG_VIRTUAL_SCROLL_LOCK_MASK;
+          else if (keyvals[j] == GDK_KEY_Meta_L ||
+                   keyvals[j] == GDK_KEY_Meta_R)
+            mask |= EGG_VIRTUAL_META_MASK;
+          else if (keyvals[j] == GDK_KEY_Hyper_L ||
+                   keyvals[j] == GDK_KEY_Hyper_R)
+            mask |= EGG_VIRTUAL_HYPER_MASK;
+          else if (keyvals[j] == GDK_KEY_Super_L ||
+                   keyvals[j] == GDK_KEY_Super_R)
+            mask |= EGG_VIRTUAL_SUPER_MASK;
+          else if (keyvals[j] == GDK_KEY_Mode_switch)
+            mask |= EGG_VIRTUAL_MODE_SWITCH_MASK;
+
+          ++j;
+        }
+
+      /* Mod1Mask is 1 << 3 for example, i.e. the
+       * fourth modifier, i / keyspermod is the modifier
+       * index
+       */
+      modmap->mapping[i/xmodmap->max_keypermod] |= mask;
+
+      g_free (keyvals);
+      g_free (keys);
+
+      ++i;
+    }
+
+  /* Add in the not-really-virtual fixed entries */
+  modmap->mapping[EGG_MODMAP_ENTRY_SHIFT] |= EGG_VIRTUAL_SHIFT_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_CONTROL] |= EGG_VIRTUAL_CONTROL_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_LOCK] |= EGG_VIRTUAL_LOCK_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD1] |= EGG_VIRTUAL_ALT_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD2] |= EGG_VIRTUAL_MOD2_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD3] |= EGG_VIRTUAL_MOD3_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD4] |= EGG_VIRTUAL_MOD4_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD5] |= EGG_VIRTUAL_MOD5_MASK;
+
+  XFreeModifiermap (xmodmap);
+}
+
+const EggModmap*
+egg_keymap_get_modmap (GdkKeymap *keymap)
+{
+  EggModmap *modmap;
+
+  /* This is all a hack, much simpler when we can just
+   * modify GDK directly.
+   */
+
+  modmap = g_object_get_data (G_OBJECT (keymap),
+                              "egg-modmap");
+
+  if (modmap == NULL)
+    {
+      modmap = g_new0 (EggModmap, 1);
+
+      /* FIXME modify keymap change events with an event filter
+       * and force a reload if we get one
+       */
+
+      reload_modmap (keymap, modmap);
+
+      g_object_set_data_full (G_OBJECT (keymap),
+                              "egg-modmap",
+                              modmap,
+                              g_free);
+    }
+
+  g_assert (modmap != NULL);
+
+  return modmap;
+}
+
+
+
+ + + diff --git a/2020-04-09-125606-1816-cppcheck@42f0ae6627b3_unreachable-code/index.html b/2020-04-09-125606-1816-cppcheck@42f0ae6627b3_unreachable-code/index.html new file mode 100644 index 0000000..390cedb --- /dev/null +++ b/2020-04-09-125606-1816-cppcheck@42f0ae6627b3_unreachable-code/index.html @@ -0,0 +1,104 @@ + + + + + + Cppcheck - HTML report - mate-indicator-applet + + + + + + + +
+ + + + + + + + + +
LineIdCWESeverityMessage
0missingIncludeSysteminformationCppcheck cannot find all the include files (use --check-config for details)
src/applet-main.c
544shadowArgument398styleLocal variable 'entry' shadows outer argument
src/eggaccelerators.c
321duplicateExpression398styleSame expression on both sides of '-='.
+
+ + + diff --git a/2020-04-09-125606-1816-cppcheck@42f0ae6627b3_unreachable-code/stats.html b/2020-04-09-125606-1816-cppcheck@42f0ae6627b3_unreachable-code/stats.html new file mode 100644 index 0000000..490b8a8 --- /dev/null +++ b/2020-04-09-125606-1816-cppcheck@42f0ae6627b3_unreachable-code/stats.html @@ -0,0 +1,90 @@ + + + + + + Cppcheck - HTML report - mate-indicator-applet + + + + + + + +
+

Top 10 files for style severity, total findings: 2
+   1  src/eggaccelerators.c
+   1  src/applet-main.c
+

+ +
+ + + diff --git a/2020-04-09-125606-1816-cppcheck@42f0ae6627b3_unreachable-code/style.css b/2020-04-09-125606-1816-cppcheck@42f0ae6627b3_unreachable-code/style.css new file mode 100644 index 0000000..c39571c --- /dev/null +++ b/2020-04-09-125606-1816-cppcheck@42f0ae6627b3_unreachable-code/style.css @@ -0,0 +1,149 @@ + +body { + font: 13px Arial, Verdana, Sans-Serif; + margin: 0; + width: auto; +} + +h1 { + margin: 10px; +} + +#footer > p { + margin: 4px; +} + +.error { + background-color: #ffb7b7; +} + +.error2 { + background-color: #faa; + border: 1px dotted black; + display: inline-block; + margin-left: 4px; +} + +.inconclusive { + background-color: #B6B6B4; +} + +.inconclusive2 { + background-color: #B6B6B4; + border: 1px dotted black; + display: inline-block; + margin-left: 4px; +} + +div.verbose { + display: inline-block; + vertical-align: top; + cursor: help; +} + +div.verbose div.content { + display: none; + position: absolute; + padding: 10px; + margin: 4px; + max-width: 40%; + white-space: pre-wrap; + border: 1px solid black; + background-color: #FFFFCC; + cursor: auto; +} + +.highlight .hll { + padding: 1px; +} + +#header { + border-bottom: thin solid #aaa; +} + +#menu { + float: left; + margin-top: 5px; + text-align: left; + width: 150px; + /*height: 75%;*/ + position: fixed; + overflow: auto; + z-index: 1; +} + +#menu_index { + float: left; + margin-top: 5px; + padding-left: 5px; + text-align: left; + width: 300px; + /*height: 75%;*/ + position: fixed; + overflow: auto; + z-index: 1; +} + +#menu > a { + display: block; + margin-left: 10px; + font: 12px; + z-index: 1; +} + +#filename { + margin-left: 10px; + font: 12px; + z-index: 1; +} + +.highlighttable { + background-color:white; + z-index: 10; + position: relative; + margin: -10 px; +} + +#content { + background-color: white; + -webkit-box-sizing: content-box; + -moz-box-sizing: content-box; + box-sizing: content-box; + float: left; + margin: 5px; + margin-left: 10px; + padding: 0 10px 10px 10px; + width: 80%; + padding-left: 150px; +} + +#content_index { + background-color: white; + -webkit-box-sizing: content-box; + -moz-box-sizing: content-box; + box-sizing: content-box; + float: left; + margin: 5px; + margin-left: 10px; + padding: 0 10px 10px 10px; + width: 80%; + padding-left: 300px; +} + +.linenos { + border-right: thin solid #aaa; + color: lightgray; + padding-right: 6px; +} + +#footer { + border-top: thin solid #aaa; + clear: both; + font-size: 90%; + margin-top: 5px; +} + +#footer ul { + list-style-type: none; + padding-left: 0; +} diff --git a/2020-04-14-235716-6997-cppcheck@8f98359bb878_master/0.html b/2020-04-14-235716-6997-cppcheck@8f98359bb878_master/0.html new file mode 100644 index 0000000..31ac0e7 --- /dev/null +++ b/2020-04-14-235716-6997-cppcheck@8f98359bb878_master/0.html @@ -0,0 +1,2280 @@ + + + + + + Cppcheck - HTML report - mate-indicator-applet + + + + + + + +
+
   1
+   2
+   3
+   4
+   5
+   6
+   7
+   8
+   9
+  10
+  11
+  12
+  13
+  14
+  15
+  16
+  17
+  18
+  19
+  20
+  21
+  22
+  23
+  24
+  25
+  26
+  27
+  28
+  29
+  30
+  31
+  32
+  33
+  34
+  35
+  36
+  37
+  38
+  39
+  40
+  41
+  42
+  43
+  44
+  45
+  46
+  47
+  48
+  49
+  50
+  51
+  52
+  53
+  54
+  55
+  56
+  57
+  58
+  59
+  60
+  61
+  62
+  63
+  64
+  65
+  66
+  67
+  68
+  69
+  70
+  71
+  72
+  73
+  74
+  75
+  76
+  77
+  78
+  79
+  80
+  81
+  82
+  83
+  84
+  85
+  86
+  87
+  88
+  89
+  90
+  91
+  92
+  93
+  94
+  95
+  96
+  97
+  98
+  99
+ 100
+ 101
+ 102
+ 103
+ 104
+ 105
+ 106
+ 107
+ 108
+ 109
+ 110
+ 111
+ 112
+ 113
+ 114
+ 115
+ 116
+ 117
+ 118
+ 119
+ 120
+ 121
+ 122
+ 123
+ 124
+ 125
+ 126
+ 127
+ 128
+ 129
+ 130
+ 131
+ 132
+ 133
+ 134
+ 135
+ 136
+ 137
+ 138
+ 139
+ 140
+ 141
+ 142
+ 143
+ 144
+ 145
+ 146
+ 147
+ 148
+ 149
+ 150
+ 151
+ 152
+ 153
+ 154
+ 155
+ 156
+ 157
+ 158
+ 159
+ 160
+ 161
+ 162
+ 163
+ 164
+ 165
+ 166
+ 167
+ 168
+ 169
+ 170
+ 171
+ 172
+ 173
+ 174
+ 175
+ 176
+ 177
+ 178
+ 179
+ 180
+ 181
+ 182
+ 183
+ 184
+ 185
+ 186
+ 187
+ 188
+ 189
+ 190
+ 191
+ 192
+ 193
+ 194
+ 195
+ 196
+ 197
+ 198
+ 199
+ 200
+ 201
+ 202
+ 203
+ 204
+ 205
+ 206
+ 207
+ 208
+ 209
+ 210
+ 211
+ 212
+ 213
+ 214
+ 215
+ 216
+ 217
+ 218
+ 219
+ 220
+ 221
+ 222
+ 223
+ 224
+ 225
+ 226
+ 227
+ 228
+ 229
+ 230
+ 231
+ 232
+ 233
+ 234
+ 235
+ 236
+ 237
+ 238
+ 239
+ 240
+ 241
+ 242
+ 243
+ 244
+ 245
+ 246
+ 247
+ 248
+ 249
+ 250
+ 251
+ 252
+ 253
+ 254
+ 255
+ 256
+ 257
+ 258
+ 259
+ 260
+ 261
+ 262
+ 263
+ 264
+ 265
+ 266
+ 267
+ 268
+ 269
+ 270
+ 271
+ 272
+ 273
+ 274
+ 275
+ 276
+ 277
+ 278
+ 279
+ 280
+ 281
+ 282
+ 283
+ 284
+ 285
+ 286
+ 287
+ 288
+ 289
+ 290
+ 291
+ 292
+ 293
+ 294
+ 295
+ 296
+ 297
+ 298
+ 299
+ 300
+ 301
+ 302
+ 303
+ 304
+ 305
+ 306
+ 307
+ 308
+ 309
+ 310
+ 311
+ 312
+ 313
+ 314
+ 315
+ 316
+ 317
+ 318
+ 319
+ 320
+ 321
+ 322
+ 323
+ 324
+ 325
+ 326
+ 327
+ 328
+ 329
+ 330
+ 331
+ 332
+ 333
+ 334
+ 335
+ 336
+ 337
+ 338
+ 339
+ 340
+ 341
+ 342
+ 343
+ 344
+ 345
+ 346
+ 347
+ 348
+ 349
+ 350
+ 351
+ 352
+ 353
+ 354
+ 355
+ 356
+ 357
+ 358
+ 359
+ 360
+ 361
+ 362
+ 363
+ 364
+ 365
+ 366
+ 367
+ 368
+ 369
+ 370
+ 371
+ 372
+ 373
+ 374
+ 375
+ 376
+ 377
+ 378
+ 379
+ 380
+ 381
+ 382
+ 383
+ 384
+ 385
+ 386
+ 387
+ 388
+ 389
+ 390
+ 391
+ 392
+ 393
+ 394
+ 395
+ 396
+ 397
+ 398
+ 399
+ 400
+ 401
+ 402
+ 403
+ 404
+ 405
+ 406
+ 407
+ 408
+ 409
+ 410
+ 411
+ 412
+ 413
+ 414
+ 415
+ 416
+ 417
+ 418
+ 419
+ 420
+ 421
+ 422
+ 423
+ 424
+ 425
+ 426
+ 427
+ 428
+ 429
+ 430
+ 431
+ 432
+ 433
+ 434
+ 435
+ 436
+ 437
+ 438
+ 439
+ 440
+ 441
+ 442
+ 443
+ 444
+ 445
+ 446
+ 447
+ 448
+ 449
+ 450
+ 451
+ 452
+ 453
+ 454
+ 455
+ 456
+ 457
+ 458
+ 459
+ 460
+ 461
+ 462
+ 463
+ 464
+ 465
+ 466
+ 467
+ 468
+ 469
+ 470
+ 471
+ 472
+ 473
+ 474
+ 475
+ 476
+ 477
+ 478
+ 479
+ 480
+ 481
+ 482
+ 483
+ 484
+ 485
+ 486
+ 487
+ 488
+ 489
+ 490
+ 491
+ 492
+ 493
+ 494
+ 495
+ 496
+ 497
+ 498
+ 499
+ 500
+ 501
+ 502
+ 503
+ 504
+ 505
+ 506
+ 507
+ 508
+ 509
+ 510
+ 511
+ 512
+ 513
+ 514
+ 515
+ 516
+ 517
+ 518
+ 519
+ 520
+ 521
+ 522
+ 523
+ 524
+ 525
+ 526
+ 527
+ 528
+ 529
+ 530
+ 531
+ 532
+ 533
+ 534
+ 535
+ 536
+ 537
+ 538
+ 539
+ 540
+ 541
+ 542
+ 543
+ 544
+ 545
+ 546
+ 547
+ 548
+ 549
+ 550
+ 551
+ 552
+ 553
+ 554
+ 555
+ 556
+ 557
+ 558
+ 559
+ 560
+ 561
+ 562
+ 563
+ 564
+ 565
+ 566
+ 567
+ 568
+ 569
+ 570
+ 571
+ 572
+ 573
+ 574
+ 575
+ 576
+ 577
+ 578
+ 579
+ 580
+ 581
+ 582
+ 583
+ 584
+ 585
+ 586
+ 587
+ 588
+ 589
+ 590
+ 591
+ 592
+ 593
+ 594
+ 595
+ 596
+ 597
+ 598
+ 599
+ 600
+ 601
+ 602
+ 603
+ 604
+ 605
+ 606
+ 607
+ 608
+ 609
+ 610
+ 611
+ 612
+ 613
+ 614
+ 615
+ 616
+ 617
+ 618
+ 619
+ 620
+ 621
+ 622
+ 623
+ 624
+ 625
+ 626
+ 627
+ 628
+ 629
+ 630
+ 631
+ 632
+ 633
+ 634
+ 635
+ 636
+ 637
+ 638
+ 639
+ 640
+ 641
+ 642
+ 643
+ 644
+ 645
+ 646
+ 647
+ 648
+ 649
+ 650
+ 651
+ 652
+ 653
+ 654
+ 655
+ 656
+ 657
+ 658
+ 659
+ 660
+ 661
+ 662
+ 663
+ 664
+ 665
+ 666
+ 667
+ 668
+ 669
+ 670
+ 671
+ 672
+ 673
+ 674
+ 675
+ 676
+ 677
+ 678
+ 679
+ 680
+ 681
+ 682
+ 683
+ 684
+ 685
+ 686
+ 687
+ 688
+ 689
+ 690
+ 691
+ 692
+ 693
+ 694
+ 695
+ 696
+ 697
+ 698
+ 699
+ 700
+ 701
+ 702
+ 703
+ 704
+ 705
+ 706
+ 707
+ 708
+ 709
+ 710
+ 711
+ 712
+ 713
+ 714
+ 715
+ 716
+ 717
+ 718
+ 719
+ 720
+ 721
+ 722
+ 723
+ 724
+ 725
+ 726
+ 727
+ 728
+ 729
+ 730
+ 731
+ 732
+ 733
+ 734
+ 735
+ 736
+ 737
+ 738
+ 739
+ 740
+ 741
+ 742
+ 743
+ 744
+ 745
+ 746
+ 747
+ 748
+ 749
+ 750
+ 751
+ 752
+ 753
+ 754
+ 755
+ 756
+ 757
+ 758
+ 759
+ 760
+ 761
+ 762
+ 763
+ 764
+ 765
+ 766
+ 767
+ 768
+ 769
+ 770
+ 771
+ 772
+ 773
+ 774
+ 775
+ 776
+ 777
+ 778
+ 779
+ 780
+ 781
+ 782
+ 783
+ 784
+ 785
+ 786
+ 787
+ 788
+ 789
+ 790
+ 791
+ 792
+ 793
+ 794
+ 795
+ 796
+ 797
+ 798
+ 799
+ 800
+ 801
+ 802
+ 803
+ 804
+ 805
+ 806
+ 807
+ 808
+ 809
+ 810
+ 811
+ 812
+ 813
+ 814
+ 815
+ 816
+ 817
+ 818
+ 819
+ 820
+ 821
+ 822
+ 823
+ 824
+ 825
+ 826
+ 827
+ 828
+ 829
+ 830
+ 831
+ 832
+ 833
+ 834
+ 835
+ 836
+ 837
+ 838
+ 839
+ 840
+ 841
+ 842
+ 843
+ 844
+ 845
+ 846
+ 847
+ 848
+ 849
+ 850
+ 851
+ 852
+ 853
+ 854
+ 855
+ 856
+ 857
+ 858
+ 859
+ 860
+ 861
+ 862
+ 863
+ 864
+ 865
+ 866
+ 867
+ 868
+ 869
+ 870
+ 871
+ 872
+ 873
+ 874
+ 875
+ 876
+ 877
+ 878
+ 879
+ 880
+ 881
+ 882
+ 883
+ 884
+ 885
+ 886
+ 887
+ 888
+ 889
+ 890
+ 891
+ 892
+ 893
+ 894
+ 895
+ 896
+ 897
+ 898
+ 899
+ 900
+ 901
+ 902
+ 903
+ 904
+ 905
+ 906
+ 907
+ 908
+ 909
+ 910
+ 911
+ 912
+ 913
+ 914
+ 915
+ 916
+ 917
+ 918
+ 919
+ 920
+ 921
+ 922
+ 923
+ 924
+ 925
+ 926
+ 927
+ 928
+ 929
+ 930
+ 931
+ 932
+ 933
+ 934
+ 935
+ 936
+ 937
+ 938
+ 939
+ 940
+ 941
+ 942
+ 943
+ 944
+ 945
+ 946
+ 947
+ 948
+ 949
+ 950
+ 951
+ 952
+ 953
+ 954
+ 955
+ 956
+ 957
+ 958
+ 959
+ 960
+ 961
+ 962
+ 963
+ 964
+ 965
+ 966
+ 967
+ 968
+ 969
+ 970
+ 971
+ 972
+ 973
+ 974
+ 975
+ 976
+ 977
+ 978
+ 979
+ 980
+ 981
+ 982
+ 983
+ 984
+ 985
+ 986
+ 987
+ 988
+ 989
+ 990
+ 991
+ 992
+ 993
+ 994
+ 995
+ 996
+ 997
+ 998
+ 999
+1000
+1001
+1002
+1003
+1004
+1005
+1006
+1007
+1008
+1009
+1010
+1011
+1012
+1013
+1014
+1015
+1016
+1017
+1018
+1019
+1020
+1021
+1022
+1023
+1024
+1025
+1026
+1027
+1028
+1029
+1030
+1031
+1032
+1033
+1034
+1035
+1036
+1037
+1038
+1039
+1040
+1041
+1042
+1043
+1044
+1045
+1046
+1047
+1048
+1049
+1050
+1051
+1052
+1053
+1054
+1055
+1056
+1057
+1058
+1059
+1060
+1061
+1062
+1063
/*
+A small wrapper utility to load indicators and put them as menu items
+into the mate-panel using it's applet interface.
+
+Copyright 2009-2010 Canonical Ltd.
+
+Authors:
+    Ted Gould <ted@canonical.com>
+
+This program is free software: you can redistribute it and/or modify it
+under the terms of the GNU General Public License version 3, as published
+by the Free Software Foundation.
+
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranties of
+MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
+PURPOSE.  See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along
+with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include <stdlib.h>
+#include <string.h>
+#include <config.h>
+#include <glib/gi18n.h>
+#include <mate-panel-applet.h>
+#include <gdk/gdkkeysyms.h>
+#include <gtk/gtk.h>
+
+#if HAVE_UBUNTU_INDICATOR
+
+#define INDICATOR_SERVICE_APPMENU	"libappmenu.so"
+#define INDICATOR_SERVICE_ME		"libme.so"
+#define INDICATOR_SERVICE_DATETIME	"libdatetime.so"
+
+#define INDICATOR_SERVICE_APPMENU_NG	"com.canonical.indicator.appmenu"
+#define INDICATOR_SERVICE_ME_NG		"com.canonical.indicator.me"
+#define INDICATOR_SERVICE_DATETIME_NG	"com.canonical.indicator.datetime"
+
+#include <libindicator/indicator-object.h>
+#endif
+
+#if HAVE_AYATANA_INDICATOR
+
+#define INDICATOR_SERVICE_APPMENU	"libayatana-appmenu.so"
+#define INDICATOR_SERVICE_ME		"libayatana-me.so"
+#define INDICATOR_SERVICE_DATETIME	"libayatana-datetime.so"
+
+#define INDICATOR_SERVICE_APPMENU_NG	"org.ayatana.indicator.appmenu"
+#define INDICATOR_SERVICE_ME_NG		"org.ayatana.indicator.me"
+#define INDICATOR_SERVICE_DATETIME_NG	"org.ayatana.indicator.datetime"
+
+#include <libayatana-indicator/indicator-object.h>
+#endif
+
+/* For new style indicators */
+
+#if HAVE_UBUNTU_INDICATOR && HAVE_UBUNTU_INDICATOR_NG
+
+#include <libido/libido.h>
+#include <libindicator/indicator-ng.h>
+
+#define INDICATOR_SERVICE_DIR "/usr/share/unity/indicators"
+
+#endif
+
+#if HAVE_AYATANA_INDICATOR && HAVE_AYATANA_INDICATOR_NG
+
+#include <libayatana-ido/libayatana-ido.h>
+#include <libayatana-indicator/indicator-ng.h>
+
+#define INDICATOR_SERVICE_DIR "/usr/share/ayatana/indicators"
+
+#endif
+
+#include "tomboykeybinder.h"
+
+static gchar * indicator_order[] = {
+#if HAVE_UBUNTU_INDICATOR
+	"libapplication.so",
+	"libmessaging.so",
+	"libsoundmenu.so",
+	"libdatetime.so",
+	"libsession.so",
+#endif
+#if HAVE_AYATANA_INDICATOR
+	"libayatana-application.so",
+	"libayatana-messaging.so",
+	"libayatana-soundmenu.so",
+	"libayatana-datetime.so",
+	"libayatana-session.so",
+#endif
+	NULL
+};
+
+static GtkPackDirection packdirection;
+static MatePanelAppletOrient orient;
+static guint size;
+
+#define  MENU_DATA_INDICATOR_OBJECT  "indicator-object"
+#define  MENU_DATA_INDICATOR_ENTRY   "indicator-entry"
+
+#define  IO_DATA_ORDER_NUMBER        "indicator-order-number"
+
+static gboolean     applet_fill_cb (MatePanelApplet * applet, const gchar * iid, gpointer data);
+
+static void update_accessible_desc (IndicatorObjectEntry * entry, GtkWidget * menuitem);
+
+/*************
+ * main
+ * ***********/
+
+#ifdef INDICATOR_APPLET
+MATE_PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletFactory",
+               PANEL_TYPE_APPLET,
+               "indicator-applet",
+               applet_fill_cb, NULL);
+#endif
+#ifdef INDICATOR_APPLET_COMPLETE
+MATE_PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletCompleteFactory",
+               PANEL_TYPE_APPLET,
+               "indicator-applet-complete",
+               applet_fill_cb, NULL);
+#endif
+#ifdef INDICATOR_APPLET_APPMENU
+MATE_PANEL_APPLET_OUT_PROCESS_FACTORY ("IndicatorAppletAppmenuFactory",
+               PANEL_TYPE_APPLET,
+               "indicator-applet-appmenu",
+               applet_fill_cb, NULL);
+#endif
+
+/*************
+ * log files
+ * ***********/
+#ifdef INDICATOR_APPLET
+#define LOG_FILE_NAME  "indicator-applet.log"
+#endif
+#ifdef INDICATOR_APPLET_COMPLETE
+#define LOG_FILE_NAME  "indicator-applet-complete.log"
+#endif
+#ifdef INDICATOR_APPLET_APPMENU
+#define LOG_FILE_NAME  "indicator-applet-appmenu.log"
+#endif
+GOutputStream * log_file = NULL;
+
+/*****************
+ * Hotkey support
+ * **************/
+#ifdef INDICATOR_APPLET
+gchar * hotkey_keycode = "<Super>M";
+#endif
+#ifdef INDICATOR_APPLET_SESSION
+gchar * hotkey_keycode = "<Super>S";
+#endif
+#ifdef INDICATOR_APPLET_COMPLETE
+gchar * hotkey_keycode = "<Super>S";
+#endif
+#ifdef INDICATOR_APPLET_APPMENU
+gchar * hotkey_keycode = "<Super>F1";
+#endif
+
+/********************
+ * Environment Names
+ * *******************/
+#ifdef INDICATOR_APPLET
+#define INDICATOR_SPECIFIC_ENV  "indicator-applet-original"
+#endif
+#ifdef INDICATOR_APPLET_COMPLETE
+#define INDICATOR_SPECIFIC_ENV  "indicator-applet-complete"
+#endif
+#ifdef INDICATOR_APPLET_APPMENU
+#define INDICATOR_SPECIFIC_ENV  "indicator-applet-appmenu"
+#endif
+
+static const gchar * indicator_env[] = {
+	"indicator-applet",
+	INDICATOR_SPECIFIC_ENV,
+	NULL
+};
+
+/*************
+ * init function
+ * ***********/
+
+static gint
+name2order (const gchar * name) {
+	int i;
+
+	for (i = 0; indicator_order[i] != NULL; i++) {
+		if (g_strcmp0(name, indicator_order[i]) == 0) {
+			return i;
+		}
+	}
+
+	return -1;
+}
+
+typedef struct _incoming_position_t incoming_position_t;
+struct _incoming_position_t {
+	gint objposition;
+	gint entryposition;
+	gint menupos;
+	gboolean found;
+};
+
+/* This function helps by determining where in the menu list
+   this new entry should be placed.  It compares the objects
+   that they're on, and then the individual entries.  Each
+   is progressively more expensive. */
+static void
+place_in_menu (GtkWidget * widget, gpointer user_data)
+{
+	incoming_position_t * position = (incoming_position_t *)user_data;
+	if (position->found) {
+		/* We've already been placed, just finish the foreach */
+		return;
+	}
+
+	IndicatorObject * io = INDICATOR_OBJECT(g_object_get_data(G_OBJECT(widget), MENU_DATA_INDICATOR_OBJECT));
+	g_assert(io != NULL);
+
+	gint objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER));
+	/* We've already passed it, well, then this is where
+	   we should be be.  Stop! */
+	if (objposition > position->objposition) {
+		position->found = TRUE;
+		return;
+	}
+
+	/* The objects don't match yet, keep looking */
+	if (objposition < position->objposition) {
+		position->menupos++;
+		return;
+	}
+
+	/* The objects are the same, let's start looking at entries. */
+	IndicatorObjectEntry * entry = (IndicatorObjectEntry *)g_object_get_data(G_OBJECT(widget), MENU_DATA_INDICATOR_ENTRY);
+	gint entryposition = indicator_object_get_location(io, entry);
+
+	if (entryposition > position->entryposition) {
+		position->found = TRUE;
+		return;
+	}
+
+	if (entryposition < position->entryposition) {
+		position->menupos++;
+		return;
+	}
+
+	/* We've got the same object and the same entry.  Well,
+	   let's just put it right here then. */
+	position->found = TRUE;
+	return;
+}
+
+static void
+something_shown (GtkWidget * widget, gpointer user_data)
+{
+	GtkWidget * menuitem = GTK_WIDGET(user_data);
+	gtk_widget_show(menuitem);
+}
+
+static void
+something_hidden (GtkWidget * widget, gpointer user_data)
+{
+	GtkWidget * menuitem = GTK_WIDGET(user_data);
+	gtk_widget_hide(menuitem);
+}
+
+static void
+sensitive_cb (GObject * obj, GParamSpec * pspec, gpointer user_data)
+{
+	g_return_if_fail(GTK_IS_WIDGET(obj));
+	g_return_if_fail(GTK_IS_WIDGET(user_data));
+
+	gtk_widget_set_sensitive(GTK_WIDGET(user_data), gtk_widget_get_sensitive(GTK_WIDGET(obj)));
+	return;
+}
+
+static void
+entry_activated (GtkWidget * widget, gpointer user_data)
+{
+	g_return_if_fail(GTK_IS_WIDGET(widget));
+	gpointer pio = g_object_get_data(G_OBJECT(widget), "indicator");
+	g_return_if_fail(INDICATOR_IS_OBJECT(pio));
+	IndicatorObject * io = INDICATOR_OBJECT(pio);
+
+	return indicator_object_entry_activate(io, (IndicatorObjectEntry *)user_data, gtk_get_current_event_time());
+}
+
+static gboolean
+entry_scrolled (GtkWidget *menuitem, GdkEventScroll *event, gpointer data)
+{
+	IndicatorObject *io = g_object_get_data (G_OBJECT (menuitem), MENU_DATA_INDICATOR_OBJECT);
+	IndicatorObjectEntry *entry = g_object_get_data (G_OBJECT (menuitem), MENU_DATA_INDICATOR_ENTRY);
+
+	g_return_val_if_fail(INDICATOR_IS_OBJECT(io), FALSE);
+
+	g_signal_emit_by_name (io, "scroll", 1, event->direction);
+	g_signal_emit_by_name (io, "scroll-entry", entry, 1, event->direction);
+	g_signal_emit_by_name (io, INDICATOR_OBJECT_SIGNAL_ENTRY_SCROLLED, entry, 1, event->direction);
+
+	return FALSE;
+}
+
+static void
+accessible_desc_update_cb (GtkWidget * widget, gpointer userdata)
+{
+	gpointer data = g_object_get_data(G_OBJECT(widget), MENU_DATA_INDICATOR_ENTRY);
+
+	if (data != userdata) {
+		return;
+	}
+
+	IndicatorObjectEntry * entry = (IndicatorObjectEntry *)data;
+	update_accessible_desc(entry, widget);
+}
+
+static void
+accessible_desc_update (IndicatorObject * io, IndicatorObjectEntry * entry, GtkWidget * menubar)
+{
+	gtk_container_foreach(GTK_CONTAINER(menubar), accessible_desc_update_cb, entry);
+	return;
+}
+
+#define PANEL_PADDING 8
+static gboolean
+entry_resized (GtkWidget *applet, guint newsize, gpointer data)
+{
+	IndicatorObject *io = (IndicatorObject *)data;
+
+	size = newsize;
+
+	/* Work on the entries */
+	GList * entries = indicator_object_get_entries(io);
+	GList * entry = NULL;
+
+	for (entry = entries; entry != NULL; entry = g_list_next(entry)) {
+		IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)entry->data;
+		if (entrydata->image != NULL) {
+			/* Resize to fit panel */
+			gtk_image_set_pixel_size (entrydata->image, size - PANEL_PADDING);
+		}
+	}
+
+	return FALSE;
+}
+
+static void
+entry_added (IndicatorObject * io, IndicatorObjectEntry * entry, GtkWidget * menubar)
+{
+	g_debug("Signal: Entry Added");
+	gboolean something_visible = FALSE;
+	gboolean something_sensitive = FALSE;
+
+	GtkWidget * menuitem = gtk_menu_item_new();
+	GtkWidget * box = (packdirection == GTK_PACK_DIRECTION_LTR) ?
+		gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3) : gtk_box_new(GTK_ORIENTATION_VERTICAL, 3);
+
+	/* Allows indicators to receive mouse scroll event */
+	gtk_widget_add_events(GTK_WIDGET(menuitem), GDK_SCROLL_MASK);
+
+	g_object_set_data (G_OBJECT (menuitem), "indicator", io);
+	g_object_set_data (G_OBJECT (menuitem), "box", box);
+
+	g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(entry_activated), entry);
+	g_signal_connect(G_OBJECT(menuitem), "scroll-event", G_CALLBACK(entry_scrolled), entry);
+
+	if (entry->image != NULL) {
+		/* Resize to fit panel */
+		gtk_image_set_pixel_size (entry->image, size - PANEL_PADDING);
+		gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(entry->image), FALSE, FALSE, 1);
+		if (gtk_widget_get_visible(GTK_WIDGET(entry->image))) {
+			something_visible = TRUE;
+		}
+
+		if (gtk_widget_get_sensitive(GTK_WIDGET(entry->image))) {
+			something_sensitive = TRUE;
+		}
+
+		g_signal_connect(G_OBJECT(entry->image), "show", G_CALLBACK(something_shown), menuitem);
+		g_signal_connect(G_OBJECT(entry->image), "hide", G_CALLBACK(something_hidden), menuitem);
+
+		g_signal_connect(G_OBJECT(entry->image), "notify::sensitive", G_CALLBACK(sensitive_cb), menuitem);
+	}
+	if (entry->label != NULL) {
+		switch(packdirection) {
+			case GTK_PACK_DIRECTION_LTR:
+				gtk_label_set_angle(GTK_LABEL(entry->label), 0.0);
+				break;
+			case GTK_PACK_DIRECTION_TTB:
+				gtk_label_set_angle(GTK_LABEL(entry->label),
+						(orient == MATE_PANEL_APPLET_ORIENT_LEFT) ?
+						270.0 : 90.0);
+				break;
+			default:
+				break;
+		}
+		gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(entry->label), FALSE, FALSE, 1);
+
+		if (gtk_widget_get_visible(GTK_WIDGET(entry->label))) {
+			something_visible = TRUE;
+		}
+
+		if (gtk_widget_get_sensitive(GTK_WIDGET(entry->label))) {
+			something_sensitive = TRUE;
+		}
+
+		g_signal_connect(G_OBJECT(entry->label), "show", G_CALLBACK(something_shown), menuitem);
+		g_signal_connect(G_OBJECT(entry->label), "hide", G_CALLBACK(something_hidden), menuitem);
+
+		g_signal_connect(G_OBJECT(entry->label), "notify::sensitive", G_CALLBACK(sensitive_cb), menuitem);
+	}
+	gtk_container_add(GTK_CONTAINER(menuitem), box);
+	gtk_widget_show(box);
+
+	if (entry->menu != NULL) {
+		gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), GTK_WIDGET(entry->menu));
+	}
+
+	incoming_position_t position;
+	position.objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER));
+	position.entryposition = indicator_object_get_location(io, entry);
+	position.menupos = 0;
+	position.found = FALSE;
+
+	gtk_container_foreach(GTK_CONTAINER(menubar), place_in_menu, &position);
+
+	gtk_menu_shell_insert(GTK_MENU_SHELL(menubar), menuitem, position.menupos);
+
+	if (something_visible) {
+		if (entry->accessible_desc != NULL) {
+			update_accessible_desc(entry, menuitem);
+		}
+		gtk_widget_show(menuitem);
+	}
+	gtk_widget_set_sensitive(menuitem, something_sensitive);
+
+	g_object_set_data(G_OBJECT(menuitem), MENU_DATA_INDICATOR_ENTRY,  entry);
+	g_object_set_data(G_OBJECT(menuitem), MENU_DATA_INDICATOR_OBJECT, io);
+
+	return;
+}
+
+static void
+entry_removed_cb (GtkWidget * widget, gpointer userdata)
+{
+	gpointer data = g_object_get_data(G_OBJECT(widget), MENU_DATA_INDICATOR_ENTRY);
+
+	if (data != userdata) {
+		return;
+	}
+
+	IndicatorObjectEntry * entry = (IndicatorObjectEntry *)data;
+	if (entry->label != NULL) {
+		g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(something_shown), widget);
+		g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(something_hidden), widget);
+		g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(sensitive_cb), widget);
+	}
+	if (entry->image != NULL) {
+		g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(something_shown), widget);
+		g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(something_hidden), widget);
+		g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(sensitive_cb), widget);
+	}
+
+	gtk_widget_destroy(widget);
+	return;
+}
+
+static void
+entry_removed (IndicatorObject * io G_GNUC_UNUSED, IndicatorObjectEntry * entry,
+               gpointer user_data)
+{
+	g_debug("Signal: Entry Removed");
+
+	gtk_container_foreach(GTK_CONTAINER(user_data), entry_removed_cb, entry);
+
+	return;
+}
+
+static void
+entry_moved_find_cb (GtkWidget * widget, gpointer userdata)
+{
+	gpointer * array = (gpointer *)userdata;
+	if (array[1] != NULL) {
+		return;
+	}
+
+	gpointer data = g_object_get_data(G_OBJECT(widget), MENU_DATA_INDICATOR_ENTRY);
+
+	if (data != array[0]) {
+		return;
+	}
+
+	array[1] = widget;
+	return;
+}
+
+/* Gets called when an entry for an object was moved. */
+static void
+entry_moved (IndicatorObject * io, IndicatorObjectEntry * entry,
+             gint old G_GNUC_UNUSED, gint new G_GNUC_UNUSED, gpointer user_data)
+{
+	GtkWidget * menubar = GTK_WIDGET(user_data);
+
+	gpointer array[2];
+	array[0] = entry;
+	array[1] = NULL;
+
+	gtk_container_foreach(GTK_CONTAINER(menubar), entry_moved_find_cb, array);
+	if (array[1] == NULL) {
+		g_warning("Moving an entry that isn't in our menus.");
+		return;
+	}
+
+	GtkWidget * mi = GTK_WIDGET(array[1]);
+	g_object_ref(G_OBJECT(mi));
+	gtk_container_remove(GTK_CONTAINER(menubar), mi);
+
+	incoming_position_t position;
+	position.objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER));
+	position.entryposition = indicator_object_get_location(io, entry);
+	position.menupos = 0;
+	position.found = FALSE;
+
+	gtk_container_foreach(GTK_CONTAINER(menubar), place_in_menu, &position);
+
+	gtk_menu_shell_insert(GTK_MENU_SHELL(menubar), mi, position.menupos);
+	g_object_unref(G_OBJECT(mi));
+
+	return;
+}
+
+static void
+menu_show (IndicatorObject * io, IndicatorObjectEntry * entry,<--- Shadowed declaration
+           guint32 timestamp, gpointer user_data)
+{
+	GtkWidget * menubar = GTK_WIDGET(user_data);
+
+	if (entry == NULL) {
+		/* Close any open menus instead of opening one */
+		GList * entries = indicator_object_get_entries(io);
+		GList * entry = NULL;<--- Shadow variable
+		for (entry = entries; entry != NULL; entry = g_list_next(entry)) {
+			IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)entry->data;
+			gtk_menu_popdown(entrydata->menu);
+		}
+		g_list_free(entries);
+
+		/* And tell the menubar to exit activation mode too */
+		gtk_menu_shell_cancel(GTK_MENU_SHELL(menubar));
+		return;
+	}
+
+	// TODO: do something sensible here
+}
+
+static void
+update_accessible_desc(IndicatorObjectEntry * entry, GtkWidget * menuitem)
+{
+	/* FIXME: We need to deal with the use case where the contents of the
+	   label overrides what is found in the atk object's name, or at least
+	   orca speaks the label instead of the atk object name.
+	 */
+	AtkObject * menuitem_obj = gtk_widget_get_accessible(menuitem);
+	if (menuitem_obj == NULL) {
+		/* Should there be an error printed here? */
+		return;
+	}
+
+	if (entry->accessible_desc != NULL) {
+		atk_object_set_name(menuitem_obj, entry->accessible_desc);
+	} else {
+		atk_object_set_name(menuitem_obj, "");
+	}
+	return;
+}
+
+static void
+load_indicator (MatePanelApplet *applet, GtkWidget * menubar, IndicatorObject *io, const gchar *name)
+{
+	/* Set the environment it's in */
+	indicator_object_set_environment(io, (const GStrv)indicator_env);
+
+	/* Attach the 'name' to the object */
+#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
+	int pos = 5000 - indicator_object_get_position(io);
+	if (pos > 5000) {
+		pos = name2order(name);
+	}
+#else
+	int pos = name2order(name);
+#endif
+
+	g_object_set_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER, GINT_TO_POINTER(pos));
+
+	/* Connect to its signals */
+	g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED,   G_CALLBACK(entry_added),    menubar);
+	g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED, G_CALLBACK(entry_removed),  menubar);
+	g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_MOVED,   G_CALLBACK(entry_moved),    menubar);
+	g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_MENU_SHOW,     G_CALLBACK(menu_show),      menubar);
+	g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ACCESSIBLE_DESC_UPDATE, G_CALLBACK(accessible_desc_update), menubar);
+
+	/* Track panel resize */
+	g_signal_connect_object(G_OBJECT(applet), "change-size", G_CALLBACK(entry_resized), G_OBJECT(io), 0);
+
+	/* Work on the entries */
+	GList * entries = indicator_object_get_entries(io);
+	GList * entry = NULL;
+
+	for (entry = entries; entry != NULL; entry = g_list_next(entry)) {
+		IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)entry->data;
+		entry_added(io, entrydata, menubar);
+	}
+
+	g_list_free(entries);
+}
+
+static gboolean
+load_module (const gchar * name, MatePanelApplet *applet, GtkWidget * menubar)
+{
+	g_debug("Looking at Module: %s", name);
+	g_return_val_if_fail(name != NULL, FALSE);
+
+	if (!g_str_has_suffix(name, G_MODULE_SUFFIX)) {
+		return FALSE;
+	}
+
+	g_debug("Loading Module: %s", name);
+
+	/* Build the object for the module */
+	gchar * fullpath = g_build_filename(INDICATOR_DIR, name, NULL);
+	IndicatorObject * io = indicator_object_new_from_file(fullpath);
+	g_free(fullpath);
+
+	load_indicator(applet, menubar, io, name);
+
+	return TRUE;
+}
+
+static void
+load_modules (MatePanelApplet *applet, GtkWidget *menubar, gint *indicators_loaded)
+{
+	if (g_file_test(INDICATOR_DIR, (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))) {
+		GDir * dir = g_dir_open(INDICATOR_DIR, 0, NULL);
+
+		const gchar * name;
+		gint count = 0;
+		while ((name = g_dir_read_name(dir)) != NULL) {
+#ifdef INDICATOR_APPLET_APPMENU
+			if (g_strcmp0(name, INDICATOR_SERVICE_APPMENU)) {
+				continue;
+			}
+#else
+			if (!g_strcmp0(name, INDICATOR_SERVICE_APPMENU)) {
+				continue;
+			}
+#endif
+#ifdef INDICATOR_APPLET
+			if (!g_strcmp0(name, INDICATOR_SERVICE_ME)) {
+				continue;
+			}
+			if (!g_strcmp0(name, INDICATOR_SERVICE_DATETIME)) {
+				continue;
+			}
+#endif
+			if (load_module(name, applet, menubar)) {
+				count++;
+			}
+		}
+
+		*indicators_loaded += count;
+
+		g_dir_close (dir);
+	}
+}
+
+#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
+
+static void
+load_indicators_from_indicator_files (MatePanelApplet *applet, GtkWidget *menubar, gint *indicators_loaded)
+{
+	GDir *dir;
+	const gchar *name;
+	GError *error = NULL;
+
+	dir = g_dir_open (INDICATOR_SERVICE_DIR, 0, &error);
+
+	if (!dir) {
+		g_warning ("unable to open indicator service file directory: %s", error->message);
+		g_error_free (error);
+
+		return;
+	}
+
+	gint count = 0;
+	while ((name = g_dir_read_name (dir))) {
+		gchar *filename;
+		IndicatorNg *indicator;
+
+		filename = g_build_filename (INDICATOR_SERVICE_DIR, name, NULL);
+		indicator = indicator_ng_new_for_profile (filename, "desktop", &error);
+		g_free (filename);
+
+#ifdef INDICATOR_APPLET_APPMENU
+		if (g_strcmp0(name, INDICATOR_SERVICE_APPMENU_NG)) {
+			continue;
+		}
+#else
+		if (!g_strcmp0(name, INDICATOR_SERVICE_APPMENU_NG)) {
+			continue;
+		}
+#endif
+#ifdef INDICATOR_APPLET
+		if (!g_strcmp0(name, INDICATOR_SERVICE_ME_NG)) {
+			continue;
+		}
+		if (!g_strcmp0(name, INDICATOR_SERVICE_DATETIME_NG)) {
+			continue;
+		}
+#endif
+
+		if (indicator) {
+			load_indicator(applet, menubar, INDICATOR_OBJECT (indicator), name);
+			count++;
+		}else{
+			g_warning ("unable to load '%s': %s", name, error->message);
+			g_clear_error (&error);
+		}
+	}
+
+	*indicators_loaded += count;
+
+	g_dir_close (dir);
+}
+#endif  /* HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG */
+
+static void
+hotkey_filter (char * keystring G_GNUC_UNUSED, gpointer data)
+{
+	g_return_if_fail(GTK_IS_MENU_SHELL(data));
+
+	/* Oh, wow, it's us! */
+	GList * children = gtk_container_get_children(GTK_CONTAINER(data));
+	if (children == NULL) {
+		g_debug("Menubar has no children");
+		return;
+	}
+
+	gtk_menu_shell_select_item(GTK_MENU_SHELL(data), GTK_WIDGET(g_list_last(children)->data));
+	g_list_free(children);
+	return;
+}
+
+static gboolean
+menubar_press (GtkWidget * widget,
+                    GdkEventButton *event,
+                    gpointer data G_GNUC_UNUSED)
+{
+	if (event->button != 1) {
+		g_signal_stop_emission_by_name(widget, "button-press-event");
+	}
+
+	return FALSE;
+}
+
+static gboolean
+menubar_on_draw (GtkWidget * widget,
+                 cairo_t * cr,
+                 GtkWidget * menubar)
+{
+	/* FIXME: either port to gtk_render_focus or remove this function */
+	if (gtk_widget_has_focus(menubar))
+		gtk_paint_focus(gtk_widget_get_style(widget),
+		                cr,
+		                gtk_widget_get_state(menubar),
+		                widget, "menubar-applet", 0, 0, -1, -1);
+
+	return FALSE;
+}
+
+static void
+about_cb (GtkAction *action G_GNUC_UNUSED,
+          gpointer   data G_GNUC_UNUSED)
+{
+	static const gchar *authors[] = {
+		"Ted Gould <ted@canonical.com>",
+		NULL
+	};
+
+	static gchar *license[] = {
+        N_("This program is free software: you can redistribute it and/or modify it "
+           "under the terms of the GNU General Public License version 3, as published "
+           "by the Free Software Foundation."),
+        N_("This program is distributed in the hope that it will be useful, but "
+           "WITHOUT ANY WARRANTY; without even the implied warranties of "
+           "MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR "
+           "PURPOSE.  See the GNU General Public License for more details."),
+        N_("You should have received a copy of the GNU General Public License along "
+           "with this program.  If not, see <http://www.gnu.org/licenses/>."),
+		NULL
+	};
+	gchar *license_i18n;
+
+	license_i18n = g_strconcat (_(license[0]), "\n\n", _(license[1]), "\n\n", _(license[2]), NULL);
+
+	gtk_show_about_dialog(NULL,
+		"version", VERSION,
+		"copyright", _("Copyright \xc2\xa9 2009-2010 Canonical, Ltd.\n"
+		               "Copyright \xc2\xa9 2011-2020 MATE developers"),
+#ifdef INDICATOR_APPLET_APPMENU
+		"comments", _("An applet to hold your application menus."),
+#endif
+		"comments", _("An applet to hold all of the system indicators."),
+		"authors", authors,
+		"license", license_i18n,
+		"wrap-license", TRUE,
+		"translator-credits", _("translator-credits"),
+		"logo-icon-name", "mate-indicator-applet",
+		"icon-name", "mate-indicator-applet",
+		"website", "https://mate-desktop.org",
+		"website-label", _("MATE Website"),
+		NULL
+	);
+
+	g_free (license_i18n);
+
+	return;
+}
+
+static gboolean
+swap_orient_cb (GtkWidget *item, gpointer data)
+{
+	GtkWidget *from = (GtkWidget *) data;
+	GtkWidget *to = (GtkWidget *) g_object_get_data(G_OBJECT(from), "to");
+	g_object_ref(G_OBJECT(item));
+	gtk_container_remove(GTK_CONTAINER(from), item);
+	if (GTK_IS_LABEL(item)) {
+			switch(packdirection) {
+			case GTK_PACK_DIRECTION_LTR:
+				gtk_label_set_angle(GTK_LABEL(item), 0.0);
+				break;
+			case GTK_PACK_DIRECTION_TTB:
+				gtk_label_set_angle(GTK_LABEL(item),
+						(orient == MATE_PANEL_APPLET_ORIENT_LEFT) ?
+						270.0 : 90.0);
+				break;
+			default:
+				break;
+		}
+	}
+	gtk_box_pack_start(GTK_BOX(to), item, FALSE, FALSE, 0);
+	return TRUE;
+}
+
+static gboolean
+reorient_box_cb (GtkWidget *menuitem, gpointer data)
+{
+	GtkWidget *from = g_object_get_data(G_OBJECT(menuitem), "box");
+	GtkWidget *to = (packdirection == GTK_PACK_DIRECTION_LTR) ?
+		gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0) : gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
+	g_object_set_data(G_OBJECT(from), "to", to);
+	gtk_container_foreach(GTK_CONTAINER(from), (GtkCallback)swap_orient_cb,
+			from);
+	gtk_container_remove(GTK_CONTAINER(menuitem), from);
+	gtk_container_add(GTK_CONTAINER(menuitem), to);
+	g_object_set_data(G_OBJECT(menuitem), "box", to);
+	gtk_widget_show_all(menuitem);
+	return TRUE;
+}
+
+static gboolean
+matepanelapplet_reorient_cb (GtkWidget *applet, MatePanelAppletOrient neworient,
+		gpointer data)
+{
+	GtkWidget *menubar = (GtkWidget *)data;
+	if ((((neworient == MATE_PANEL_APPLET_ORIENT_UP) ||
+			(neworient == MATE_PANEL_APPLET_ORIENT_DOWN)) &&
+			((orient == MATE_PANEL_APPLET_ORIENT_LEFT) ||
+			(orient == MATE_PANEL_APPLET_ORIENT_RIGHT))) ||
+			(((neworient == MATE_PANEL_APPLET_ORIENT_LEFT) ||
+			(neworient == MATE_PANEL_APPLET_ORIENT_RIGHT)) &&
+			((orient == MATE_PANEL_APPLET_ORIENT_UP) ||
+			(orient == MATE_PANEL_APPLET_ORIENT_DOWN)))) {
+		packdirection = (packdirection == GTK_PACK_DIRECTION_LTR) ?
+				GTK_PACK_DIRECTION_TTB : GTK_PACK_DIRECTION_LTR;
+		gtk_menu_bar_set_pack_direction(GTK_MENU_BAR(menubar),
+				packdirection);
+		orient = neworient;
+		gtk_container_foreach(GTK_CONTAINER(menubar),
+				(GtkCallback)reorient_box_cb, NULL);
+	}
+	orient = neworient;
+	return FALSE;
+}
+
+#ifdef N_
+#undef N_
+#endif
+#define N_(x) x
+
+static void
+log_to_file_cb (GObject * source_obj G_GNUC_UNUSED,
+                GAsyncResult * result G_GNUC_UNUSED, gpointer user_data)
+{
+	g_free(user_data);
+	return;
+}
+
+static void
+log_to_file (const gchar * domain G_GNUC_UNUSED,
+             GLogLevelFlags level G_GNUC_UNUSED,
+             const gchar * message,
+             gpointer data G_GNUC_UNUSED)
+{
+	if (log_file == NULL) {
+		GError * error = NULL;
+		gchar * filename = g_build_filename(g_get_user_cache_dir(), LOG_FILE_NAME, NULL);
+		GFile * file = g_file_new_for_path(filename);
+		g_free(filename);
+
+		if (!g_file_test(g_get_user_cache_dir(), G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) {
+			GFile * cachedir = g_file_new_for_path(g_get_user_cache_dir());
+			g_file_make_directory_with_parents(cachedir, NULL, &error);
+
+			if (error != NULL) {
+				g_error("Unable to make directory '%s' for log file: %s", g_get_user_cache_dir(), error->message);
+			}
+		}
+
+		g_file_delete(file, NULL, NULL);
+
+		GFileIOStream * io = g_file_create_readwrite(file,
+		                          G_FILE_CREATE_REPLACE_DESTINATION, /* flags */
+		                          NULL, /* cancelable */
+		                          &error); /* error */
+		if (error != NULL) {
+			g_error("Unable to replace file: %s", error->message);
+		}
+
+		log_file = g_io_stream_get_output_stream(G_IO_STREAM(io));
+	}
+
+	gchar * outputstring = g_strdup_printf("%s\n", message);
+	g_output_stream_write_async(log_file,
+	                            outputstring, /* data */
+	                            strlen(outputstring), /* length */
+	                            G_PRIORITY_LOW, /* priority */
+	                            NULL, /* cancelable */
+	                            log_to_file_cb, /* callback */
+	                            outputstring); /* data */
+
+	return;
+}
+
+static gboolean
+applet_fill_cb (MatePanelApplet * applet, const gchar * iid G_GNUC_UNUSED,
+                gpointer data G_GNUC_UNUSED)
+{
+#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
+	ido_init();
+#endif
+
+	static const GtkActionEntry menu_actions[] = {
+		{"About", GTK_STOCK_ABOUT, N_("_About"), NULL, NULL, G_CALLBACK(about_cb)}
+	};
+	static const gchar *menu_xml = "<menuitem name=\"About\" action=\"About\"/>";
+
+	static gboolean first_time = FALSE;
+	GtkWidget *menubar;
+	gint indicators_loaded = 0;
+	GtkActionGroup *action_group;
+
+	if (!first_time)
+	{
+		first_time = TRUE;
+#ifdef INDICATOR_APPLET
+		g_set_application_name(_("Indicator Applet"));
+#endif
+#ifdef INDICATOR_APPLET_COMPLETE
+		g_set_application_name(_("Indicator Applet Complete"));
+#endif
+#ifdef INDICATOR_APPLET_APPMENU
+		g_set_application_name(_("Indicator Applet Application Menu"));
+#endif
+
+		g_log_set_default_handler(log_to_file, NULL);
+
+		tomboy_keybinder_init();
+	}
+
+	/* Set panel options */
+	gtk_container_set_border_width(GTK_CONTAINER (applet), 0);
+	mate_panel_applet_set_flags(applet, MATE_PANEL_APPLET_EXPAND_MINOR);
+	menubar = gtk_menu_bar_new();
+	action_group = gtk_action_group_new ("Indicator Applet Actions");
+	gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
+	gtk_action_group_add_actions (action_group, menu_actions,
+	                              G_N_ELEMENTS (menu_actions),
+	                              menubar);
+	mate_panel_applet_setup_menu(applet, menu_xml, action_group);
+	g_object_unref(action_group);
+#ifdef INDICATOR_APPLET
+	atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)),
+	                     "indicator-applet");
+#endif
+#ifdef INDICATOR_APPLET_COMPLETE
+	atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)),
+	                     "indicator-applet-complete");
+#endif
+#ifdef INDICATOR_APPLET_APPMENU
+	atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)),
+	                     "indicator-applet-appmenu");
+#endif
+
+	/* Init some theme/icon stuff */
+	gtk_icon_theme_append_search_path(gtk_icon_theme_get_default(),
+	                                  INDICATOR_ICONS_DIR);
+	/* g_debug("Icons directory: %s", INDICATOR_ICONS_DIR); */
+	gtk_widget_set_name(GTK_WIDGET (applet), "fast-user-switch-applet");
+
+	/* Build menubar */
+	size = (mate_panel_applet_get_size (applet));
+	orient = (mate_panel_applet_get_orient(applet));
+	packdirection = ((orient == MATE_PANEL_APPLET_ORIENT_UP) ||
+			(orient == MATE_PANEL_APPLET_ORIENT_DOWN)) ?
+			GTK_PACK_DIRECTION_LTR : GTK_PACK_DIRECTION_TTB;
+	gtk_menu_bar_set_pack_direction(GTK_MENU_BAR(menubar),
+			packdirection);
+	gtk_widget_set_can_focus (menubar, TRUE);
+	gtk_widget_set_name(GTK_WIDGET (menubar), "fast-user-switch-menubar");
+	g_signal_connect(menubar, "button-press-event", G_CALLBACK(menubar_press), NULL);
+	g_signal_connect_after(menubar, "draw", G_CALLBACK(menubar_on_draw), menubar);
+	g_signal_connect(applet, "change-orient",
+			G_CALLBACK(matepanelapplet_reorient_cb), menubar);
+	gtk_container_set_border_width(GTK_CONTAINER(menubar), 0);
+
+	/* Add in filter func */
+	tomboy_keybinder_bind(hotkey_keycode, hotkey_filter, menubar);
+
+	load_modules(applet, menubar, &indicators_loaded);
+#if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
+	load_indicators_from_indicator_files(applet, menubar, &indicators_loaded);
+#endif
+
+	if (indicators_loaded == 0) {
+		/* A label to allow for click through */
+		GtkWidget * item = gtk_label_new(_("No Indicators"));
+		mate_panel_applet_set_background_widget(applet, item);
+		gtk_container_add(GTK_CONTAINER(applet), item);
+		gtk_widget_show(item);
+	} else {
+		gtk_container_add(GTK_CONTAINER(applet), menubar);
+		mate_panel_applet_set_background_widget(applet, menubar);
+		gtk_widget_show(menubar);
+	}
+
+	gtk_widget_show(GTK_WIDGET(applet));
+
+	return TRUE;
+
+}
+
+
+
+ + + diff --git a/2020-04-14-235716-6997-cppcheck@8f98359bb878_master/1.html b/2020-04-14-235716-6997-cppcheck@8f98359bb878_master/1.html new file mode 100644 index 0000000..6bc0c8a --- /dev/null +++ b/2020-04-14-235716-6997-cppcheck@8f98359bb878_master/1.html @@ -0,0 +1,1208 @@ + + + + + + Cppcheck - HTML report - mate-indicator-applet + + + + + + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
/* eggaccelerators.c
+ * Copyright (C) 2002  Red Hat, Inc.; Copyright 1998, 2001 Tim Janik
+ * Developed by Havoc Pennington, Tim Janik
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
+ */
+
+#include "eggaccelerators.h"
+
+#include <string.h>
+#include <gdk/gdkx.h>
+#include <gdk/gdkkeysyms.h>
+
+enum
+{
+  EGG_MODMAP_ENTRY_SHIFT   = 0,
+  EGG_MODMAP_ENTRY_LOCK    = 1,
+  EGG_MODMAP_ENTRY_CONTROL = 2,
+  EGG_MODMAP_ENTRY_MOD1    = 3,
+  EGG_MODMAP_ENTRY_MOD2    = 4,
+  EGG_MODMAP_ENTRY_MOD3    = 5,
+  EGG_MODMAP_ENTRY_MOD4    = 6,
+  EGG_MODMAP_ENTRY_MOD5    = 7,
+  EGG_MODMAP_ENTRY_LAST    = 8
+};
+
+#define MODMAP_ENTRY_TO_MODIFIER(x) (1 << (x))
+
+typedef struct
+{
+  EggVirtualModifierType mapping[EGG_MODMAP_ENTRY_LAST];
+
+} EggModmap;
+
+const EggModmap* egg_keymap_get_modmap (GdkKeymap *keymap);
+
+static inline gboolean
+is_alt (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'a' || string[1] == 'A') &&
+	  (string[2] == 'l' || string[2] == 'L') &&
+	  (string[3] == 't' || string[3] == 'T') &&
+	  (string[4] == '>'));
+}
+
+static inline gboolean
+is_ctl (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'c' || string[1] == 'C') &&
+	  (string[2] == 't' || string[2] == 'T') &&
+	  (string[3] == 'l' || string[3] == 'L') &&
+	  (string[4] == '>'));
+}
+
+static inline gboolean
+is_modx (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'm' || string[1] == 'M') &&
+	  (string[2] == 'o' || string[2] == 'O') &&
+	  (string[3] == 'd' || string[3] == 'D') &&
+	  (string[4] >= '1' && string[4] <= '5') &&
+	  (string[5] == '>'));
+}
+
+static inline gboolean
+is_ctrl (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'c' || string[1] == 'C') &&
+	  (string[2] == 't' || string[2] == 'T') &&
+	  (string[3] == 'r' || string[3] == 'R') &&
+	  (string[4] == 'l' || string[4] == 'L') &&
+	  (string[5] == '>'));
+}
+
+static inline gboolean
+is_shft (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 's' || string[1] == 'S') &&
+	  (string[2] == 'h' || string[2] == 'H') &&
+	  (string[3] == 'f' || string[3] == 'F') &&
+	  (string[4] == 't' || string[4] == 'T') &&
+	  (string[5] == '>'));
+}
+
+static inline gboolean
+is_shift (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 's' || string[1] == 'S') &&
+	  (string[2] == 'h' || string[2] == 'H') &&
+	  (string[3] == 'i' || string[3] == 'I') &&
+	  (string[4] == 'f' || string[4] == 'F') &&
+	  (string[5] == 't' || string[5] == 'T') &&
+	  (string[6] == '>'));
+}
+
+static inline gboolean
+is_control (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'c' || string[1] == 'C') &&
+	  (string[2] == 'o' || string[2] == 'O') &&
+	  (string[3] == 'n' || string[3] == 'N') &&
+	  (string[4] == 't' || string[4] == 'T') &&
+	  (string[5] == 'r' || string[5] == 'R') &&
+	  (string[6] == 'o' || string[6] == 'O') &&
+	  (string[7] == 'l' || string[7] == 'L') &&
+	  (string[8] == '>'));
+}
+
+static inline gboolean
+is_release (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'r' || string[1] == 'R') &&
+	  (string[2] == 'e' || string[2] == 'E') &&
+	  (string[3] == 'l' || string[3] == 'L') &&
+	  (string[4] == 'e' || string[4] == 'E') &&
+	  (string[5] == 'a' || string[5] == 'A') &&
+	  (string[6] == 's' || string[6] == 'S') &&
+	  (string[7] == 'e' || string[7] == 'E') &&
+	  (string[8] == '>'));
+}
+
+static inline gboolean
+is_meta (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'm' || string[1] == 'M') &&
+	  (string[2] == 'e' || string[2] == 'E') &&
+	  (string[3] == 't' || string[3] == 'T') &&
+	  (string[4] == 'a' || string[4] == 'A') &&
+	  (string[5] == '>'));
+}
+
+static inline gboolean
+is_super (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 's' || string[1] == 'S') &&
+	  (string[2] == 'u' || string[2] == 'U') &&
+	  (string[3] == 'p' || string[3] == 'P') &&
+	  (string[4] == 'e' || string[4] == 'E') &&
+	  (string[5] == 'r' || string[5] == 'R') &&
+	  (string[6] == '>'));
+}
+
+static inline gboolean
+is_hyper (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'h' || string[1] == 'H') &&
+	  (string[2] == 'y' || string[2] == 'Y') &&
+	  (string[3] == 'p' || string[3] == 'P') &&
+	  (string[4] == 'e' || string[4] == 'E') &&
+	  (string[5] == 'r' || string[5] == 'R') &&
+	  (string[6] == '>'));
+}
+
+/**
+ * egg_accelerator_parse_virtual:
+ * @accelerator:      string representing an accelerator
+ * @accelerator_key:  return location for accelerator keyval
+ * @accelerator_mods: return location for accelerator modifier mask
+ *
+ * Parses a string representing a virtual accelerator. The format
+ * looks like "&lt;Control&gt;a" or "&lt;Shift&gt;&lt;Alt&gt;F1" or
+ * "&lt;Release&gt;z" (the last one is for key release).  The parser
+ * is fairly liberal and allows lower or upper case, and also
+ * abbreviations such as "&lt;Ctl&gt;" and "&lt;Ctrl&gt;".
+ *
+ * If the parse fails, @accelerator_key and @accelerator_mods will
+ * be set to 0 (zero) and %FALSE will be returned. If the string contains
+ * only modifiers, @accelerator_key will be set to 0 but %TRUE will be
+ * returned.
+ *
+ * The virtual vs. concrete accelerator distinction is a relic of
+ * how the X Window System works; there are modifiers Mod2-Mod5 that
+ * can represent various keyboard keys (numlock, meta, hyper, etc.),
+ * the virtual modifier represents the keyboard key, the concrete
+ * modifier the actual Mod2-Mod5 bits in the key press event.
+ *
+ * Returns: %TRUE on success.
+ */
+gboolean
+egg_accelerator_parse_virtual (const gchar            *accelerator,
+                               guint                  *accelerator_key,
+                               EggVirtualModifierType *accelerator_mods)
+{
+  guint keyval;
+  GdkModifierType mods;
+  gint len;
+  gboolean bad_keyval;
+
+  if (accelerator_key)
+    *accelerator_key = 0;
+  if (accelerator_mods)
+    *accelerator_mods = 0;
+
+  g_return_val_if_fail (accelerator != NULL, FALSE);
+
+  bad_keyval = FALSE;
+
+  keyval = 0;
+  mods = 0;
+  len = strlen (accelerator);
+  while (len)
+    {
+      if (*accelerator == '<')
+	{
+	  if (len >= 9 && is_release (accelerator))
+	    {
+	      accelerator += 9;
+	      len -= 9;
+	      mods |= EGG_VIRTUAL_RELEASE_MASK;
+	    }
+	  else if (len >= 9 && is_control (accelerator))
+	    {
+	      accelerator += 9;
+	      len -= 9;
+	      mods |= EGG_VIRTUAL_CONTROL_MASK;
+	    }
+	  else if (len >= 7 && is_shift (accelerator))
+	    {
+	      accelerator += 7;
+	      len -= 7;
+	      mods |= EGG_VIRTUAL_SHIFT_MASK;
+	    }
+	  else if (len >= 6 && is_shft (accelerator))
+	    {
+	      accelerator += 6;
+	      len -= 6;
+	      mods |= EGG_VIRTUAL_SHIFT_MASK;
+	    }
+	  else if (len >= 6 && is_ctrl (accelerator))
+	    {
+	      accelerator += 6;
+	      len -= 6;
+	      mods |= EGG_VIRTUAL_CONTROL_MASK;
+	    }
+	  else if (len >= 6 && is_modx (accelerator))
+	    {
+	      static const guint mod_vals[] = {
+		EGG_VIRTUAL_ALT_MASK, EGG_VIRTUAL_MOD2_MASK, EGG_VIRTUAL_MOD3_MASK,
+		EGG_VIRTUAL_MOD4_MASK, EGG_VIRTUAL_MOD5_MASK
+	      };
+
+	      len -= 6;
+	      accelerator += 4;
+	      mods |= mod_vals[*accelerator - '1'];
+	      accelerator += 2;
+	    }
+	  else if (len >= 5 && is_ctl (accelerator))
+	    {
+	      accelerator += 5;
+	      len -= 5;
+	      mods |= EGG_VIRTUAL_CONTROL_MASK;
+	    }
+	  else if (len >= 5 && is_alt (accelerator))
+	    {
+	      accelerator += 5;
+	      len -= 5;
+	      mods |= EGG_VIRTUAL_ALT_MASK;
+	    }
+          else if (len >= 6 && is_meta (accelerator))
+	    {
+	      accelerator += 6;
+	      len -= 6;
+	      mods |= EGG_VIRTUAL_META_MASK;
+	    }
+          else if (len >= 7 && is_hyper (accelerator))
+	    {
+	      accelerator += 7;
+	      len -= 7;
+	      mods |= EGG_VIRTUAL_HYPER_MASK;
+	    }
+          else if (len >= 7 && is_super (accelerator))
+	    {
+	      accelerator += 7;
+	      len -= 7;
+	      mods |= EGG_VIRTUAL_SUPER_MASK;
+	    }
+	  else
+	    {
+	      gchar last_ch;
+
+	      last_ch = *accelerator;
+	      while (last_ch && last_ch != '>')
+		{
+		  last_ch = *accelerator;
+		  accelerator += 1;
+		  len -= 1;
+		}
+	    }
+	}
+      else
+	{
+          keyval = gdk_keyval_from_name (accelerator);
+
+          if (keyval == 0)
+            bad_keyval = TRUE;
+
+          accelerator += len;
+          len -= len;
+	}
+    }
+
+  if (accelerator_key)
+    *accelerator_key = gdk_keyval_to_lower (keyval);
+  if (accelerator_mods)
+    *accelerator_mods = mods;
+
+  return !bad_keyval;
+}
+
+void
+egg_keymap_resolve_virtual_modifiers (GdkKeymap              *keymap,
+                                      EggVirtualModifierType  virtual_mods,
+                                      GdkModifierType        *concrete_mods)
+{
+  GdkModifierType concrete;
+  int i;
+  const EggModmap *modmap;
+
+  g_return_if_fail (GDK_IS_KEYMAP (keymap));
+  g_return_if_fail (concrete_mods != NULL);
+
+  modmap = egg_keymap_get_modmap (keymap);
+
+  /* Not so sure about this algorithm. */
+
+  concrete = 0;
+  i = 0;
+  while (i < EGG_MODMAP_ENTRY_LAST)
+    {
+      if (modmap->mapping[i] & virtual_mods)
+        concrete |= (1 << i);
+
+      ++i;
+    }
+
+  *concrete_mods = concrete;
+}
+
+void
+egg_keymap_virtualize_modifiers (GdkKeymap              *keymap,
+                                 GdkModifierType         concrete_mods,
+                                 EggVirtualModifierType *virtual_mods)
+{
+  GdkModifierType virtual;
+  int i;
+  const EggModmap *modmap;
+
+  g_return_if_fail (GDK_IS_KEYMAP (keymap));
+  g_return_if_fail (virtual_mods != NULL);
+
+  modmap = egg_keymap_get_modmap (keymap);
+
+  /* Not so sure about this algorithm. */
+
+  virtual = 0;
+  i = 0;
+  while (i < EGG_MODMAP_ENTRY_LAST)
+    {
+      if ((1 << i) & concrete_mods)
+        {
+          EggVirtualModifierType cleaned;
+
+          cleaned = modmap->mapping[i] & ~(EGG_VIRTUAL_MOD2_MASK |
+                                           EGG_VIRTUAL_MOD3_MASK |
+                                           EGG_VIRTUAL_MOD4_MASK |
+                                           EGG_VIRTUAL_MOD5_MASK);
+
+          if (cleaned != 0)
+            {
+              virtual |= cleaned;
+            }
+          else
+            {
+              /* Rather than dropping mod2->mod5 if not bound,
+               * go ahead and use the concrete names
+               */
+              virtual |= modmap->mapping[i];
+            }
+        }
+
+      ++i;
+    }
+
+  *virtual_mods = virtual;
+}
+
+static void
+reload_modmap (GdkKeymap *keymap,
+               EggModmap *modmap)
+{
+  XModifierKeymap *xmodmap;
+  int map_size;
+  int i;
+
+  /* FIXME multihead */
+  xmodmap = XGetModifierMapping (gdk_x11_get_default_xdisplay ());
+
+  memset (modmap->mapping, 0, sizeof (modmap->mapping));
+
+  /* there are 8 modifiers, and the first 3 are shift, shift lock,
+   * and control
+   */
+  map_size = 8 * xmodmap->max_keypermod;
+  i = 3 * xmodmap->max_keypermod;
+  while (i < map_size)
+    {
+      /* get the key code at this point in the map,
+       * see if its keysym is one we're interested in
+       */
+      int keycode = xmodmap->modifiermap[i];
+      GdkKeymapKey *keys;
+      guint *keyvals;
+      int n_entries;
+      int j;
+      EggVirtualModifierType mask;
+
+      keys = NULL;
+      keyvals = NULL;
+      n_entries = 0;
+
+      gdk_keymap_get_entries_for_keycode (keymap,
+                                          keycode,
+                                          &keys, &keyvals, &n_entries);
+
+      mask = 0;
+      j = 0;
+      while (j < n_entries)
+        {
+          if (keyvals[j] == GDK_KEY_Num_Lock)
+            mask |= EGG_VIRTUAL_NUM_LOCK_MASK;
+          else if (keyvals[j] == GDK_KEY_Scroll_Lock)
+            mask |= EGG_VIRTUAL_SCROLL_LOCK_MASK;
+          else if (keyvals[j] == GDK_KEY_Meta_L ||
+                   keyvals[j] == GDK_KEY_Meta_R)
+            mask |= EGG_VIRTUAL_META_MASK;
+          else if (keyvals[j] == GDK_KEY_Hyper_L ||
+                   keyvals[j] == GDK_KEY_Hyper_R)
+            mask |= EGG_VIRTUAL_HYPER_MASK;
+          else if (keyvals[j] == GDK_KEY_Super_L ||
+                   keyvals[j] == GDK_KEY_Super_R)
+            mask |= EGG_VIRTUAL_SUPER_MASK;
+          else if (keyvals[j] == GDK_KEY_Mode_switch)
+            mask |= EGG_VIRTUAL_MODE_SWITCH_MASK;
+
+          ++j;
+        }
+
+      /* Mod1Mask is 1 << 3 for example, i.e. the
+       * fourth modifier, i / keyspermod is the modifier
+       * index
+       */
+      modmap->mapping[i/xmodmap->max_keypermod] |= mask;
+
+      g_free (keyvals);
+      g_free (keys);
+
+      ++i;
+    }
+
+  /* Add in the not-really-virtual fixed entries */
+  modmap->mapping[EGG_MODMAP_ENTRY_SHIFT] |= EGG_VIRTUAL_SHIFT_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_CONTROL] |= EGG_VIRTUAL_CONTROL_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_LOCK] |= EGG_VIRTUAL_LOCK_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD1] |= EGG_VIRTUAL_ALT_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD2] |= EGG_VIRTUAL_MOD2_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD3] |= EGG_VIRTUAL_MOD3_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD4] |= EGG_VIRTUAL_MOD4_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD5] |= EGG_VIRTUAL_MOD5_MASK;
+
+  XFreeModifiermap (xmodmap);
+}
+
+const EggModmap*
+egg_keymap_get_modmap (GdkKeymap *keymap)
+{
+  EggModmap *modmap;
+
+  /* This is all a hack, much simpler when we can just
+   * modify GDK directly.
+   */
+
+  modmap = g_object_get_data (G_OBJECT (keymap),
+                              "egg-modmap");
+
+  if (modmap == NULL)
+    {
+      modmap = g_new0 (EggModmap, 1);
+
+      /* FIXME modify keymap change events with an event filter
+       * and force a reload if we get one
+       */
+
+      reload_modmap (keymap, modmap);
+
+      g_object_set_data_full (G_OBJECT (keymap),
+                              "egg-modmap",
+                              modmap,
+                              g_free);
+    }
+
+  g_assert (modmap != NULL);
+
+  return modmap;
+}
+
+
+
+ + + diff --git a/2020-04-14-235716-6997-cppcheck@8f98359bb878_master/index.html b/2020-04-14-235716-6997-cppcheck@8f98359bb878_master/index.html new file mode 100644 index 0000000..390cedb --- /dev/null +++ b/2020-04-14-235716-6997-cppcheck@8f98359bb878_master/index.html @@ -0,0 +1,104 @@ + + + + + + Cppcheck - HTML report - mate-indicator-applet + + + + + + + +
+ + + + + + + + + +
LineIdCWESeverityMessage
0missingIncludeSysteminformationCppcheck cannot find all the include files (use --check-config for details)
src/applet-main.c
544shadowArgument398styleLocal variable 'entry' shadows outer argument
src/eggaccelerators.c
321duplicateExpression398styleSame expression on both sides of '-='.
+
+ + + diff --git a/2020-04-14-235716-6997-cppcheck@8f98359bb878_master/stats.html b/2020-04-14-235716-6997-cppcheck@8f98359bb878_master/stats.html new file mode 100644 index 0000000..490b8a8 --- /dev/null +++ b/2020-04-14-235716-6997-cppcheck@8f98359bb878_master/stats.html @@ -0,0 +1,90 @@ + + + + + + Cppcheck - HTML report - mate-indicator-applet + + + + + + + +
+

Top 10 files for style severity, total findings: 2
+   1  src/eggaccelerators.c
+   1  src/applet-main.c
+

+ +
+ + + diff --git a/2020-04-14-235716-6997-cppcheck@8f98359bb878_master/style.css b/2020-04-14-235716-6997-cppcheck@8f98359bb878_master/style.css new file mode 100644 index 0000000..c39571c --- /dev/null +++ b/2020-04-14-235716-6997-cppcheck@8f98359bb878_master/style.css @@ -0,0 +1,149 @@ + +body { + font: 13px Arial, Verdana, Sans-Serif; + margin: 0; + width: auto; +} + +h1 { + margin: 10px; +} + +#footer > p { + margin: 4px; +} + +.error { + background-color: #ffb7b7; +} + +.error2 { + background-color: #faa; + border: 1px dotted black; + display: inline-block; + margin-left: 4px; +} + +.inconclusive { + background-color: #B6B6B4; +} + +.inconclusive2 { + background-color: #B6B6B4; + border: 1px dotted black; + display: inline-block; + margin-left: 4px; +} + +div.verbose { + display: inline-block; + vertical-align: top; + cursor: help; +} + +div.verbose div.content { + display: none; + position: absolute; + padding: 10px; + margin: 4px; + max-width: 40%; + white-space: pre-wrap; + border: 1px solid black; + background-color: #FFFFCC; + cursor: auto; +} + +.highlight .hll { + padding: 1px; +} + +#header { + border-bottom: thin solid #aaa; +} + +#menu { + float: left; + margin-top: 5px; + text-align: left; + width: 150px; + /*height: 75%;*/ + position: fixed; + overflow: auto; + z-index: 1; +} + +#menu_index { + float: left; + margin-top: 5px; + padding-left: 5px; + text-align: left; + width: 300px; + /*height: 75%;*/ + position: fixed; + overflow: auto; + z-index: 1; +} + +#menu > a { + display: block; + margin-left: 10px; + font: 12px; + z-index: 1; +} + +#filename { + margin-left: 10px; + font: 12px; + z-index: 1; +} + +.highlighttable { + background-color:white; + z-index: 10; + position: relative; + margin: -10 px; +} + +#content { + background-color: white; + -webkit-box-sizing: content-box; + -moz-box-sizing: content-box; + box-sizing: content-box; + float: left; + margin: 5px; + margin-left: 10px; + padding: 0 10px 10px 10px; + width: 80%; + padding-left: 150px; +} + +#content_index { + background-color: white; + -webkit-box-sizing: content-box; + -moz-box-sizing: content-box; + box-sizing: content-box; + float: left; + margin: 5px; + margin-left: 10px; + padding: 0 10px 10px 10px; + width: 80%; + padding-left: 300px; +} + +.linenos { + border-right: thin solid #aaa; + color: lightgray; + padding-right: 6px; +} + +#footer { + border-top: thin solid #aaa; + clear: both; + font-size: 90%; + margin-top: 5px; +} + +#footer ul { + list-style-type: none; + padding-left: 0; +} diff --git a/2020-04-15-000052-4762-cppcheck@60c698e3785f_master/0.html b/2020-04-15-000052-4762-cppcheck@60c698e3785f_master/0.html new file mode 100644 index 0000000..dfb584a --- /dev/null +++ b/2020-04-15-000052-4762-cppcheck@60c698e3785f_master/0.html @@ -0,0 +1,1208 @@ + + + + + + Cppcheck - HTML report - mate-indicator-applet + + + + + + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
/* eggaccelerators.c
+ * Copyright (C) 2002  Red Hat, Inc.; Copyright 1998, 2001 Tim Janik
+ * Developed by Havoc Pennington, Tim Janik
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
+ */
+
+#include "eggaccelerators.h"
+
+#include <string.h>
+#include <gdk/gdkx.h>
+#include <gdk/gdkkeysyms.h>
+
+enum
+{
+  EGG_MODMAP_ENTRY_SHIFT   = 0,
+  EGG_MODMAP_ENTRY_LOCK    = 1,
+  EGG_MODMAP_ENTRY_CONTROL = 2,
+  EGG_MODMAP_ENTRY_MOD1    = 3,
+  EGG_MODMAP_ENTRY_MOD2    = 4,
+  EGG_MODMAP_ENTRY_MOD3    = 5,
+  EGG_MODMAP_ENTRY_MOD4    = 6,
+  EGG_MODMAP_ENTRY_MOD5    = 7,
+  EGG_MODMAP_ENTRY_LAST    = 8
+};
+
+#define MODMAP_ENTRY_TO_MODIFIER(x) (1 << (x))
+
+typedef struct
+{
+  EggVirtualModifierType mapping[EGG_MODMAP_ENTRY_LAST];
+
+} EggModmap;
+
+const EggModmap* egg_keymap_get_modmap (GdkKeymap *keymap);
+
+static inline gboolean
+is_alt (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'a' || string[1] == 'A') &&
+	  (string[2] == 'l' || string[2] == 'L') &&
+	  (string[3] == 't' || string[3] == 'T') &&
+	  (string[4] == '>'));
+}
+
+static inline gboolean
+is_ctl (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'c' || string[1] == 'C') &&
+	  (string[2] == 't' || string[2] == 'T') &&
+	  (string[3] == 'l' || string[3] == 'L') &&
+	  (string[4] == '>'));
+}
+
+static inline gboolean
+is_modx (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'm' || string[1] == 'M') &&
+	  (string[2] == 'o' || string[2] == 'O') &&
+	  (string[3] == 'd' || string[3] == 'D') &&
+	  (string[4] >= '1' && string[4] <= '5') &&
+	  (string[5] == '>'));
+}
+
+static inline gboolean
+is_ctrl (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'c' || string[1] == 'C') &&
+	  (string[2] == 't' || string[2] == 'T') &&
+	  (string[3] == 'r' || string[3] == 'R') &&
+	  (string[4] == 'l' || string[4] == 'L') &&
+	  (string[5] == '>'));
+}
+
+static inline gboolean
+is_shft (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 's' || string[1] == 'S') &&
+	  (string[2] == 'h' || string[2] == 'H') &&
+	  (string[3] == 'f' || string[3] == 'F') &&
+	  (string[4] == 't' || string[4] == 'T') &&
+	  (string[5] == '>'));
+}
+
+static inline gboolean
+is_shift (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 's' || string[1] == 'S') &&
+	  (string[2] == 'h' || string[2] == 'H') &&
+	  (string[3] == 'i' || string[3] == 'I') &&
+	  (string[4] == 'f' || string[4] == 'F') &&
+	  (string[5] == 't' || string[5] == 'T') &&
+	  (string[6] == '>'));
+}
+
+static inline gboolean
+is_control (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'c' || string[1] == 'C') &&
+	  (string[2] == 'o' || string[2] == 'O') &&
+	  (string[3] == 'n' || string[3] == 'N') &&
+	  (string[4] == 't' || string[4] == 'T') &&
+	  (string[5] == 'r' || string[5] == 'R') &&
+	  (string[6] == 'o' || string[6] == 'O') &&
+	  (string[7] == 'l' || string[7] == 'L') &&
+	  (string[8] == '>'));
+}
+
+static inline gboolean
+is_release (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'r' || string[1] == 'R') &&
+	  (string[2] == 'e' || string[2] == 'E') &&
+	  (string[3] == 'l' || string[3] == 'L') &&
+	  (string[4] == 'e' || string[4] == 'E') &&
+	  (string[5] == 'a' || string[5] == 'A') &&
+	  (string[6] == 's' || string[6] == 'S') &&
+	  (string[7] == 'e' || string[7] == 'E') &&
+	  (string[8] == '>'));
+}
+
+static inline gboolean
+is_meta (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'm' || string[1] == 'M') &&
+	  (string[2] == 'e' || string[2] == 'E') &&
+	  (string[3] == 't' || string[3] == 'T') &&
+	  (string[4] == 'a' || string[4] == 'A') &&
+	  (string[5] == '>'));
+}
+
+static inline gboolean
+is_super (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 's' || string[1] == 'S') &&
+	  (string[2] == 'u' || string[2] == 'U') &&
+	  (string[3] == 'p' || string[3] == 'P') &&
+	  (string[4] == 'e' || string[4] == 'E') &&
+	  (string[5] == 'r' || string[5] == 'R') &&
+	  (string[6] == '>'));
+}
+
+static inline gboolean
+is_hyper (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'h' || string[1] == 'H') &&
+	  (string[2] == 'y' || string[2] == 'Y') &&
+	  (string[3] == 'p' || string[3] == 'P') &&
+	  (string[4] == 'e' || string[4] == 'E') &&
+	  (string[5] == 'r' || string[5] == 'R') &&
+	  (string[6] == '>'));
+}
+
+/**
+ * egg_accelerator_parse_virtual:
+ * @accelerator:      string representing an accelerator
+ * @accelerator_key:  return location for accelerator keyval
+ * @accelerator_mods: return location for accelerator modifier mask
+ *
+ * Parses a string representing a virtual accelerator. The format
+ * looks like "&lt;Control&gt;a" or "&lt;Shift&gt;&lt;Alt&gt;F1" or
+ * "&lt;Release&gt;z" (the last one is for key release).  The parser
+ * is fairly liberal and allows lower or upper case, and also
+ * abbreviations such as "&lt;Ctl&gt;" and "&lt;Ctrl&gt;".
+ *
+ * If the parse fails, @accelerator_key and @accelerator_mods will
+ * be set to 0 (zero) and %FALSE will be returned. If the string contains
+ * only modifiers, @accelerator_key will be set to 0 but %TRUE will be
+ * returned.
+ *
+ * The virtual vs. concrete accelerator distinction is a relic of
+ * how the X Window System works; there are modifiers Mod2-Mod5 that
+ * can represent various keyboard keys (numlock, meta, hyper, etc.),
+ * the virtual modifier represents the keyboard key, the concrete
+ * modifier the actual Mod2-Mod5 bits in the key press event.
+ *
+ * Returns: %TRUE on success.
+ */
+gboolean
+egg_accelerator_parse_virtual (const gchar            *accelerator,
+                               guint                  *accelerator_key,
+                               EggVirtualModifierType *accelerator_mods)
+{
+  guint keyval;
+  GdkModifierType mods;
+  gint len;
+  gboolean bad_keyval;
+
+  if (accelerator_key)
+    *accelerator_key = 0;
+  if (accelerator_mods)
+    *accelerator_mods = 0;
+
+  g_return_val_if_fail (accelerator != NULL, FALSE);
+
+  bad_keyval = FALSE;
+
+  keyval = 0;
+  mods = 0;
+  len = strlen (accelerator);
+  while (len)
+    {
+      if (*accelerator == '<')
+	{
+	  if (len >= 9 && is_release (accelerator))
+	    {
+	      accelerator += 9;
+	      len -= 9;
+	      mods |= EGG_VIRTUAL_RELEASE_MASK;
+	    }
+	  else if (len >= 9 && is_control (accelerator))
+	    {
+	      accelerator += 9;
+	      len -= 9;
+	      mods |= EGG_VIRTUAL_CONTROL_MASK;
+	    }
+	  else if (len >= 7 && is_shift (accelerator))
+	    {
+	      accelerator += 7;
+	      len -= 7;
+	      mods |= EGG_VIRTUAL_SHIFT_MASK;
+	    }
+	  else if (len >= 6 && is_shft (accelerator))
+	    {
+	      accelerator += 6;
+	      len -= 6;
+	      mods |= EGG_VIRTUAL_SHIFT_MASK;
+	    }
+	  else if (len >= 6 && is_ctrl (accelerator))
+	    {
+	      accelerator += 6;
+	      len -= 6;
+	      mods |= EGG_VIRTUAL_CONTROL_MASK;
+	    }
+	  else if (len >= 6 && is_modx (accelerator))
+	    {
+	      static const guint mod_vals[] = {
+		EGG_VIRTUAL_ALT_MASK, EGG_VIRTUAL_MOD2_MASK, EGG_VIRTUAL_MOD3_MASK,
+		EGG_VIRTUAL_MOD4_MASK, EGG_VIRTUAL_MOD5_MASK
+	      };
+
+	      len -= 6;
+	      accelerator += 4;
+	      mods |= mod_vals[*accelerator - '1'];
+	      accelerator += 2;
+	    }
+	  else if (len >= 5 && is_ctl (accelerator))
+	    {
+	      accelerator += 5;
+	      len -= 5;
+	      mods |= EGG_VIRTUAL_CONTROL_MASK;
+	    }
+	  else if (len >= 5 && is_alt (accelerator))
+	    {
+	      accelerator += 5;
+	      len -= 5;
+	      mods |= EGG_VIRTUAL_ALT_MASK;
+	    }
+          else if (len >= 6 && is_meta (accelerator))
+	    {
+	      accelerator += 6;
+	      len -= 6;
+	      mods |= EGG_VIRTUAL_META_MASK;
+	    }
+          else if (len >= 7 && is_hyper (accelerator))
+	    {
+	      accelerator += 7;
+	      len -= 7;
+	      mods |= EGG_VIRTUAL_HYPER_MASK;
+	    }
+          else if (len >= 7 && is_super (accelerator))
+	    {
+	      accelerator += 7;
+	      len -= 7;
+	      mods |= EGG_VIRTUAL_SUPER_MASK;
+	    }
+	  else
+	    {
+	      gchar last_ch;
+
+	      last_ch = *accelerator;
+	      while (last_ch && last_ch != '>')
+		{
+		  last_ch = *accelerator;
+		  accelerator += 1;
+		  len -= 1;
+		}
+	    }
+	}
+      else
+	{
+          keyval = gdk_keyval_from_name (accelerator);
+
+          if (keyval == 0)
+            bad_keyval = TRUE;
+
+          accelerator += len;
+          len -= len;
+	}
+    }
+
+  if (accelerator_key)
+    *accelerator_key = gdk_keyval_to_lower (keyval);
+  if (accelerator_mods)
+    *accelerator_mods = mods;
+
+  return !bad_keyval;
+}
+
+void
+egg_keymap_resolve_virtual_modifiers (GdkKeymap              *keymap,
+                                      EggVirtualModifierType  virtual_mods,
+                                      GdkModifierType        *concrete_mods)
+{
+  GdkModifierType concrete;
+  int i;
+  const EggModmap *modmap;
+
+  g_return_if_fail (GDK_IS_KEYMAP (keymap));
+  g_return_if_fail (concrete_mods != NULL);
+
+  modmap = egg_keymap_get_modmap (keymap);
+
+  /* Not so sure about this algorithm. */
+
+  concrete = 0;
+  i = 0;
+  while (i < EGG_MODMAP_ENTRY_LAST)
+    {
+      if (modmap->mapping[i] & virtual_mods)
+        concrete |= (1 << i);
+
+      ++i;
+    }
+
+  *concrete_mods = concrete;
+}
+
+void
+egg_keymap_virtualize_modifiers (GdkKeymap              *keymap,
+                                 GdkModifierType         concrete_mods,
+                                 EggVirtualModifierType *virtual_mods)
+{
+  GdkModifierType virtual;
+  int i;
+  const EggModmap *modmap;
+
+  g_return_if_fail (GDK_IS_KEYMAP (keymap));
+  g_return_if_fail (virtual_mods != NULL);
+
+  modmap = egg_keymap_get_modmap (keymap);
+
+  /* Not so sure about this algorithm. */
+
+  virtual = 0;
+  i = 0;
+  while (i < EGG_MODMAP_ENTRY_LAST)
+    {
+      if ((1 << i) & concrete_mods)
+        {
+          EggVirtualModifierType cleaned;
+
+          cleaned = modmap->mapping[i] & ~(EGG_VIRTUAL_MOD2_MASK |
+                                           EGG_VIRTUAL_MOD3_MASK |
+                                           EGG_VIRTUAL_MOD4_MASK |
+                                           EGG_VIRTUAL_MOD5_MASK);
+
+          if (cleaned != 0)
+            {
+              virtual |= cleaned;
+            }
+          else
+            {
+              /* Rather than dropping mod2->mod5 if not bound,
+               * go ahead and use the concrete names
+               */
+              virtual |= modmap->mapping[i];
+            }
+        }
+
+      ++i;
+    }
+
+  *virtual_mods = virtual;
+}
+
+static void
+reload_modmap (GdkKeymap *keymap,
+               EggModmap *modmap)
+{
+  XModifierKeymap *xmodmap;
+  int map_size;
+  int i;
+
+  /* FIXME multihead */
+  xmodmap = XGetModifierMapping (gdk_x11_get_default_xdisplay ());
+
+  memset (modmap->mapping, 0, sizeof (modmap->mapping));
+
+  /* there are 8 modifiers, and the first 3 are shift, shift lock,
+   * and control
+   */
+  map_size = 8 * xmodmap->max_keypermod;
+  i = 3 * xmodmap->max_keypermod;
+  while (i < map_size)
+    {
+      /* get the key code at this point in the map,
+       * see if its keysym is one we're interested in
+       */
+      int keycode = xmodmap->modifiermap[i];
+      GdkKeymapKey *keys;
+      guint *keyvals;
+      int n_entries;
+      int j;
+      EggVirtualModifierType mask;
+
+      keys = NULL;
+      keyvals = NULL;
+      n_entries = 0;
+
+      gdk_keymap_get_entries_for_keycode (keymap,
+                                          keycode,
+                                          &keys, &keyvals, &n_entries);
+
+      mask = 0;
+      j = 0;
+      while (j < n_entries)
+        {
+          if (keyvals[j] == GDK_KEY_Num_Lock)
+            mask |= EGG_VIRTUAL_NUM_LOCK_MASK;
+          else if (keyvals[j] == GDK_KEY_Scroll_Lock)
+            mask |= EGG_VIRTUAL_SCROLL_LOCK_MASK;
+          else if (keyvals[j] == GDK_KEY_Meta_L ||
+                   keyvals[j] == GDK_KEY_Meta_R)
+            mask |= EGG_VIRTUAL_META_MASK;
+          else if (keyvals[j] == GDK_KEY_Hyper_L ||
+                   keyvals[j] == GDK_KEY_Hyper_R)
+            mask |= EGG_VIRTUAL_HYPER_MASK;
+          else if (keyvals[j] == GDK_KEY_Super_L ||
+                   keyvals[j] == GDK_KEY_Super_R)
+            mask |= EGG_VIRTUAL_SUPER_MASK;
+          else if (keyvals[j] == GDK_KEY_Mode_switch)
+            mask |= EGG_VIRTUAL_MODE_SWITCH_MASK;
+
+          ++j;
+        }
+
+      /* Mod1Mask is 1 << 3 for example, i.e. the
+       * fourth modifier, i / keyspermod is the modifier
+       * index
+       */
+      modmap->mapping[i/xmodmap->max_keypermod] |= mask;
+
+      g_free (keyvals);
+      g_free (keys);
+
+      ++i;
+    }
+
+  /* Add in the not-really-virtual fixed entries */
+  modmap->mapping[EGG_MODMAP_ENTRY_SHIFT] |= EGG_VIRTUAL_SHIFT_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_CONTROL] |= EGG_VIRTUAL_CONTROL_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_LOCK] |= EGG_VIRTUAL_LOCK_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD1] |= EGG_VIRTUAL_ALT_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD2] |= EGG_VIRTUAL_MOD2_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD3] |= EGG_VIRTUAL_MOD3_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD4] |= EGG_VIRTUAL_MOD4_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD5] |= EGG_VIRTUAL_MOD5_MASK;
+
+  XFreeModifiermap (xmodmap);
+}
+
+const EggModmap*
+egg_keymap_get_modmap (GdkKeymap *keymap)
+{
+  EggModmap *modmap;
+
+  /* This is all a hack, much simpler when we can just
+   * modify GDK directly.
+   */
+
+  modmap = g_object_get_data (G_OBJECT (keymap),
+                              "egg-modmap");
+
+  if (modmap == NULL)
+    {
+      modmap = g_new0 (EggModmap, 1);
+
+      /* FIXME modify keymap change events with an event filter
+       * and force a reload if we get one
+       */
+
+      reload_modmap (keymap, modmap);
+
+      g_object_set_data_full (G_OBJECT (keymap),
+                              "egg-modmap",
+                              modmap,
+                              g_free);
+    }
+
+  g_assert (modmap != NULL);
+
+  return modmap;
+}
+
+
+
+ + + diff --git a/2020-04-15-000052-4762-cppcheck@60c698e3785f_master/index.html b/2020-04-15-000052-4762-cppcheck@60c698e3785f_master/index.html new file mode 100644 index 0000000..812f8b5 --- /dev/null +++ b/2020-04-15-000052-4762-cppcheck@60c698e3785f_master/index.html @@ -0,0 +1,101 @@ + + + + + + Cppcheck - HTML report - mate-indicator-applet + + + + + + + +
+ + + + + + + +
LineIdCWESeverityMessage
0missingIncludeSysteminformationCppcheck cannot find all the include files (use --check-config for details)
src/eggaccelerators.c
321duplicateExpression398styleSame expression on both sides of '-='.
+
+ + + diff --git a/2020-04-15-000052-4762-cppcheck@60c698e3785f_master/stats.html b/2020-04-15-000052-4762-cppcheck@60c698e3785f_master/stats.html new file mode 100644 index 0000000..14ae0d4 --- /dev/null +++ b/2020-04-15-000052-4762-cppcheck@60c698e3785f_master/stats.html @@ -0,0 +1,89 @@ + + + + + + Cppcheck - HTML report - mate-indicator-applet + + + + + + + +
+

Top 10 files for style severity, total findings: 1
+   1  src/eggaccelerators.c
+

+ +
+ + + diff --git a/2020-04-15-000052-4762-cppcheck@60c698e3785f_master/style.css b/2020-04-15-000052-4762-cppcheck@60c698e3785f_master/style.css new file mode 100644 index 0000000..c39571c --- /dev/null +++ b/2020-04-15-000052-4762-cppcheck@60c698e3785f_master/style.css @@ -0,0 +1,149 @@ + +body { + font: 13px Arial, Verdana, Sans-Serif; + margin: 0; + width: auto; +} + +h1 { + margin: 10px; +} + +#footer > p { + margin: 4px; +} + +.error { + background-color: #ffb7b7; +} + +.error2 { + background-color: #faa; + border: 1px dotted black; + display: inline-block; + margin-left: 4px; +} + +.inconclusive { + background-color: #B6B6B4; +} + +.inconclusive2 { + background-color: #B6B6B4; + border: 1px dotted black; + display: inline-block; + margin-left: 4px; +} + +div.verbose { + display: inline-block; + vertical-align: top; + cursor: help; +} + +div.verbose div.content { + display: none; + position: absolute; + padding: 10px; + margin: 4px; + max-width: 40%; + white-space: pre-wrap; + border: 1px solid black; + background-color: #FFFFCC; + cursor: auto; +} + +.highlight .hll { + padding: 1px; +} + +#header { + border-bottom: thin solid #aaa; +} + +#menu { + float: left; + margin-top: 5px; + text-align: left; + width: 150px; + /*height: 75%;*/ + position: fixed; + overflow: auto; + z-index: 1; +} + +#menu_index { + float: left; + margin-top: 5px; + padding-left: 5px; + text-align: left; + width: 300px; + /*height: 75%;*/ + position: fixed; + overflow: auto; + z-index: 1; +} + +#menu > a { + display: block; + margin-left: 10px; + font: 12px; + z-index: 1; +} + +#filename { + margin-left: 10px; + font: 12px; + z-index: 1; +} + +.highlighttable { + background-color:white; + z-index: 10; + position: relative; + margin: -10 px; +} + +#content { + background-color: white; + -webkit-box-sizing: content-box; + -moz-box-sizing: content-box; + box-sizing: content-box; + float: left; + margin: 5px; + margin-left: 10px; + padding: 0 10px 10px 10px; + width: 80%; + padding-left: 150px; +} + +#content_index { + background-color: white; + -webkit-box-sizing: content-box; + -moz-box-sizing: content-box; + box-sizing: content-box; + float: left; + margin: 5px; + margin-left: 10px; + padding: 0 10px 10px 10px; + width: 80%; + padding-left: 300px; +} + +.linenos { + border-right: thin solid #aaa; + color: lightgray; + padding-right: 6px; +} + +#footer { + border-top: thin solid #aaa; + clear: both; + font-size: 90%; + margin-top: 5px; +} + +#footer ul { + list-style-type: none; + padding-left: 0; +} diff --git a/2020-04-19-140522-4361-cppcheck@5fe75ca1e48e_master/0.html b/2020-04-19-140522-4361-cppcheck@5fe75ca1e48e_master/0.html new file mode 100644 index 0000000..dfb584a --- /dev/null +++ b/2020-04-19-140522-4361-cppcheck@5fe75ca1e48e_master/0.html @@ -0,0 +1,1208 @@ + + + + + + Cppcheck - HTML report - mate-indicator-applet + + + + + + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
/* eggaccelerators.c
+ * Copyright (C) 2002  Red Hat, Inc.; Copyright 1998, 2001 Tim Janik
+ * Developed by Havoc Pennington, Tim Janik
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
+ */
+
+#include "eggaccelerators.h"
+
+#include <string.h>
+#include <gdk/gdkx.h>
+#include <gdk/gdkkeysyms.h>
+
+enum
+{
+  EGG_MODMAP_ENTRY_SHIFT   = 0,
+  EGG_MODMAP_ENTRY_LOCK    = 1,
+  EGG_MODMAP_ENTRY_CONTROL = 2,
+  EGG_MODMAP_ENTRY_MOD1    = 3,
+  EGG_MODMAP_ENTRY_MOD2    = 4,
+  EGG_MODMAP_ENTRY_MOD3    = 5,
+  EGG_MODMAP_ENTRY_MOD4    = 6,
+  EGG_MODMAP_ENTRY_MOD5    = 7,
+  EGG_MODMAP_ENTRY_LAST    = 8
+};
+
+#define MODMAP_ENTRY_TO_MODIFIER(x) (1 << (x))
+
+typedef struct
+{
+  EggVirtualModifierType mapping[EGG_MODMAP_ENTRY_LAST];
+
+} EggModmap;
+
+const EggModmap* egg_keymap_get_modmap (GdkKeymap *keymap);
+
+static inline gboolean
+is_alt (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'a' || string[1] == 'A') &&
+	  (string[2] == 'l' || string[2] == 'L') &&
+	  (string[3] == 't' || string[3] == 'T') &&
+	  (string[4] == '>'));
+}
+
+static inline gboolean
+is_ctl (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'c' || string[1] == 'C') &&
+	  (string[2] == 't' || string[2] == 'T') &&
+	  (string[3] == 'l' || string[3] == 'L') &&
+	  (string[4] == '>'));
+}
+
+static inline gboolean
+is_modx (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'm' || string[1] == 'M') &&
+	  (string[2] == 'o' || string[2] == 'O') &&
+	  (string[3] == 'd' || string[3] == 'D') &&
+	  (string[4] >= '1' && string[4] <= '5') &&
+	  (string[5] == '>'));
+}
+
+static inline gboolean
+is_ctrl (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'c' || string[1] == 'C') &&
+	  (string[2] == 't' || string[2] == 'T') &&
+	  (string[3] == 'r' || string[3] == 'R') &&
+	  (string[4] == 'l' || string[4] == 'L') &&
+	  (string[5] == '>'));
+}
+
+static inline gboolean
+is_shft (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 's' || string[1] == 'S') &&
+	  (string[2] == 'h' || string[2] == 'H') &&
+	  (string[3] == 'f' || string[3] == 'F') &&
+	  (string[4] == 't' || string[4] == 'T') &&
+	  (string[5] == '>'));
+}
+
+static inline gboolean
+is_shift (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 's' || string[1] == 'S') &&
+	  (string[2] == 'h' || string[2] == 'H') &&
+	  (string[3] == 'i' || string[3] == 'I') &&
+	  (string[4] == 'f' || string[4] == 'F') &&
+	  (string[5] == 't' || string[5] == 'T') &&
+	  (string[6] == '>'));
+}
+
+static inline gboolean
+is_control (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'c' || string[1] == 'C') &&
+	  (string[2] == 'o' || string[2] == 'O') &&
+	  (string[3] == 'n' || string[3] == 'N') &&
+	  (string[4] == 't' || string[4] == 'T') &&
+	  (string[5] == 'r' || string[5] == 'R') &&
+	  (string[6] == 'o' || string[6] == 'O') &&
+	  (string[7] == 'l' || string[7] == 'L') &&
+	  (string[8] == '>'));
+}
+
+static inline gboolean
+is_release (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'r' || string[1] == 'R') &&
+	  (string[2] == 'e' || string[2] == 'E') &&
+	  (string[3] == 'l' || string[3] == 'L') &&
+	  (string[4] == 'e' || string[4] == 'E') &&
+	  (string[5] == 'a' || string[5] == 'A') &&
+	  (string[6] == 's' || string[6] == 'S') &&
+	  (string[7] == 'e' || string[7] == 'E') &&
+	  (string[8] == '>'));
+}
+
+static inline gboolean
+is_meta (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'm' || string[1] == 'M') &&
+	  (string[2] == 'e' || string[2] == 'E') &&
+	  (string[3] == 't' || string[3] == 'T') &&
+	  (string[4] == 'a' || string[4] == 'A') &&
+	  (string[5] == '>'));
+}
+
+static inline gboolean
+is_super (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 's' || string[1] == 'S') &&
+	  (string[2] == 'u' || string[2] == 'U') &&
+	  (string[3] == 'p' || string[3] == 'P') &&
+	  (string[4] == 'e' || string[4] == 'E') &&
+	  (string[5] == 'r' || string[5] == 'R') &&
+	  (string[6] == '>'));
+}
+
+static inline gboolean
+is_hyper (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'h' || string[1] == 'H') &&
+	  (string[2] == 'y' || string[2] == 'Y') &&
+	  (string[3] == 'p' || string[3] == 'P') &&
+	  (string[4] == 'e' || string[4] == 'E') &&
+	  (string[5] == 'r' || string[5] == 'R') &&
+	  (string[6] == '>'));
+}
+
+/**
+ * egg_accelerator_parse_virtual:
+ * @accelerator:      string representing an accelerator
+ * @accelerator_key:  return location for accelerator keyval
+ * @accelerator_mods: return location for accelerator modifier mask
+ *
+ * Parses a string representing a virtual accelerator. The format
+ * looks like "&lt;Control&gt;a" or "&lt;Shift&gt;&lt;Alt&gt;F1" or
+ * "&lt;Release&gt;z" (the last one is for key release).  The parser
+ * is fairly liberal and allows lower or upper case, and also
+ * abbreviations such as "&lt;Ctl&gt;" and "&lt;Ctrl&gt;".
+ *
+ * If the parse fails, @accelerator_key and @accelerator_mods will
+ * be set to 0 (zero) and %FALSE will be returned. If the string contains
+ * only modifiers, @accelerator_key will be set to 0 but %TRUE will be
+ * returned.
+ *
+ * The virtual vs. concrete accelerator distinction is a relic of
+ * how the X Window System works; there are modifiers Mod2-Mod5 that
+ * can represent various keyboard keys (numlock, meta, hyper, etc.),
+ * the virtual modifier represents the keyboard key, the concrete
+ * modifier the actual Mod2-Mod5 bits in the key press event.
+ *
+ * Returns: %TRUE on success.
+ */
+gboolean
+egg_accelerator_parse_virtual (const gchar            *accelerator,
+                               guint                  *accelerator_key,
+                               EggVirtualModifierType *accelerator_mods)
+{
+  guint keyval;
+  GdkModifierType mods;
+  gint len;
+  gboolean bad_keyval;
+
+  if (accelerator_key)
+    *accelerator_key = 0;
+  if (accelerator_mods)
+    *accelerator_mods = 0;
+
+  g_return_val_if_fail (accelerator != NULL, FALSE);
+
+  bad_keyval = FALSE;
+
+  keyval = 0;
+  mods = 0;
+  len = strlen (accelerator);
+  while (len)
+    {
+      if (*accelerator == '<')
+	{
+	  if (len >= 9 && is_release (accelerator))
+	    {
+	      accelerator += 9;
+	      len -= 9;
+	      mods |= EGG_VIRTUAL_RELEASE_MASK;
+	    }
+	  else if (len >= 9 && is_control (accelerator))
+	    {
+	      accelerator += 9;
+	      len -= 9;
+	      mods |= EGG_VIRTUAL_CONTROL_MASK;
+	    }
+	  else if (len >= 7 && is_shift (accelerator))
+	    {
+	      accelerator += 7;
+	      len -= 7;
+	      mods |= EGG_VIRTUAL_SHIFT_MASK;
+	    }
+	  else if (len >= 6 && is_shft (accelerator))
+	    {
+	      accelerator += 6;
+	      len -= 6;
+	      mods |= EGG_VIRTUAL_SHIFT_MASK;
+	    }
+	  else if (len >= 6 && is_ctrl (accelerator))
+	    {
+	      accelerator += 6;
+	      len -= 6;
+	      mods |= EGG_VIRTUAL_CONTROL_MASK;
+	    }
+	  else if (len >= 6 && is_modx (accelerator))
+	    {
+	      static const guint mod_vals[] = {
+		EGG_VIRTUAL_ALT_MASK, EGG_VIRTUAL_MOD2_MASK, EGG_VIRTUAL_MOD3_MASK,
+		EGG_VIRTUAL_MOD4_MASK, EGG_VIRTUAL_MOD5_MASK
+	      };
+
+	      len -= 6;
+	      accelerator += 4;
+	      mods |= mod_vals[*accelerator - '1'];
+	      accelerator += 2;
+	    }
+	  else if (len >= 5 && is_ctl (accelerator))
+	    {
+	      accelerator += 5;
+	      len -= 5;
+	      mods |= EGG_VIRTUAL_CONTROL_MASK;
+	    }
+	  else if (len >= 5 && is_alt (accelerator))
+	    {
+	      accelerator += 5;
+	      len -= 5;
+	      mods |= EGG_VIRTUAL_ALT_MASK;
+	    }
+          else if (len >= 6 && is_meta (accelerator))
+	    {
+	      accelerator += 6;
+	      len -= 6;
+	      mods |= EGG_VIRTUAL_META_MASK;
+	    }
+          else if (len >= 7 && is_hyper (accelerator))
+	    {
+	      accelerator += 7;
+	      len -= 7;
+	      mods |= EGG_VIRTUAL_HYPER_MASK;
+	    }
+          else if (len >= 7 && is_super (accelerator))
+	    {
+	      accelerator += 7;
+	      len -= 7;
+	      mods |= EGG_VIRTUAL_SUPER_MASK;
+	    }
+	  else
+	    {
+	      gchar last_ch;
+
+	      last_ch = *accelerator;
+	      while (last_ch && last_ch != '>')
+		{
+		  last_ch = *accelerator;
+		  accelerator += 1;
+		  len -= 1;
+		}
+	    }
+	}
+      else
+	{
+          keyval = gdk_keyval_from_name (accelerator);
+
+          if (keyval == 0)
+            bad_keyval = TRUE;
+
+          accelerator += len;
+          len -= len;
+	}
+    }
+
+  if (accelerator_key)
+    *accelerator_key = gdk_keyval_to_lower (keyval);
+  if (accelerator_mods)
+    *accelerator_mods = mods;
+
+  return !bad_keyval;
+}
+
+void
+egg_keymap_resolve_virtual_modifiers (GdkKeymap              *keymap,
+                                      EggVirtualModifierType  virtual_mods,
+                                      GdkModifierType        *concrete_mods)
+{
+  GdkModifierType concrete;
+  int i;
+  const EggModmap *modmap;
+
+  g_return_if_fail (GDK_IS_KEYMAP (keymap));
+  g_return_if_fail (concrete_mods != NULL);
+
+  modmap = egg_keymap_get_modmap (keymap);
+
+  /* Not so sure about this algorithm. */
+
+  concrete = 0;
+  i = 0;
+  while (i < EGG_MODMAP_ENTRY_LAST)
+    {
+      if (modmap->mapping[i] & virtual_mods)
+        concrete |= (1 << i);
+
+      ++i;
+    }
+
+  *concrete_mods = concrete;
+}
+
+void
+egg_keymap_virtualize_modifiers (GdkKeymap              *keymap,
+                                 GdkModifierType         concrete_mods,
+                                 EggVirtualModifierType *virtual_mods)
+{
+  GdkModifierType virtual;
+  int i;
+  const EggModmap *modmap;
+
+  g_return_if_fail (GDK_IS_KEYMAP (keymap));
+  g_return_if_fail (virtual_mods != NULL);
+
+  modmap = egg_keymap_get_modmap (keymap);
+
+  /* Not so sure about this algorithm. */
+
+  virtual = 0;
+  i = 0;
+  while (i < EGG_MODMAP_ENTRY_LAST)
+    {
+      if ((1 << i) & concrete_mods)
+        {
+          EggVirtualModifierType cleaned;
+
+          cleaned = modmap->mapping[i] & ~(EGG_VIRTUAL_MOD2_MASK |
+                                           EGG_VIRTUAL_MOD3_MASK |
+                                           EGG_VIRTUAL_MOD4_MASK |
+                                           EGG_VIRTUAL_MOD5_MASK);
+
+          if (cleaned != 0)
+            {
+              virtual |= cleaned;
+            }
+          else
+            {
+              /* Rather than dropping mod2->mod5 if not bound,
+               * go ahead and use the concrete names
+               */
+              virtual |= modmap->mapping[i];
+            }
+        }
+
+      ++i;
+    }
+
+  *virtual_mods = virtual;
+}
+
+static void
+reload_modmap (GdkKeymap *keymap,
+               EggModmap *modmap)
+{
+  XModifierKeymap *xmodmap;
+  int map_size;
+  int i;
+
+  /* FIXME multihead */
+  xmodmap = XGetModifierMapping (gdk_x11_get_default_xdisplay ());
+
+  memset (modmap->mapping, 0, sizeof (modmap->mapping));
+
+  /* there are 8 modifiers, and the first 3 are shift, shift lock,
+   * and control
+   */
+  map_size = 8 * xmodmap->max_keypermod;
+  i = 3 * xmodmap->max_keypermod;
+  while (i < map_size)
+    {
+      /* get the key code at this point in the map,
+       * see if its keysym is one we're interested in
+       */
+      int keycode = xmodmap->modifiermap[i];
+      GdkKeymapKey *keys;
+      guint *keyvals;
+      int n_entries;
+      int j;
+      EggVirtualModifierType mask;
+
+      keys = NULL;
+      keyvals = NULL;
+      n_entries = 0;
+
+      gdk_keymap_get_entries_for_keycode (keymap,
+                                          keycode,
+                                          &keys, &keyvals, &n_entries);
+
+      mask = 0;
+      j = 0;
+      while (j < n_entries)
+        {
+          if (keyvals[j] == GDK_KEY_Num_Lock)
+            mask |= EGG_VIRTUAL_NUM_LOCK_MASK;
+          else if (keyvals[j] == GDK_KEY_Scroll_Lock)
+            mask |= EGG_VIRTUAL_SCROLL_LOCK_MASK;
+          else if (keyvals[j] == GDK_KEY_Meta_L ||
+                   keyvals[j] == GDK_KEY_Meta_R)
+            mask |= EGG_VIRTUAL_META_MASK;
+          else if (keyvals[j] == GDK_KEY_Hyper_L ||
+                   keyvals[j] == GDK_KEY_Hyper_R)
+            mask |= EGG_VIRTUAL_HYPER_MASK;
+          else if (keyvals[j] == GDK_KEY_Super_L ||
+                   keyvals[j] == GDK_KEY_Super_R)
+            mask |= EGG_VIRTUAL_SUPER_MASK;
+          else if (keyvals[j] == GDK_KEY_Mode_switch)
+            mask |= EGG_VIRTUAL_MODE_SWITCH_MASK;
+
+          ++j;
+        }
+
+      /* Mod1Mask is 1 << 3 for example, i.e. the
+       * fourth modifier, i / keyspermod is the modifier
+       * index
+       */
+      modmap->mapping[i/xmodmap->max_keypermod] |= mask;
+
+      g_free (keyvals);
+      g_free (keys);
+
+      ++i;
+    }
+
+  /* Add in the not-really-virtual fixed entries */
+  modmap->mapping[EGG_MODMAP_ENTRY_SHIFT] |= EGG_VIRTUAL_SHIFT_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_CONTROL] |= EGG_VIRTUAL_CONTROL_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_LOCK] |= EGG_VIRTUAL_LOCK_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD1] |= EGG_VIRTUAL_ALT_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD2] |= EGG_VIRTUAL_MOD2_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD3] |= EGG_VIRTUAL_MOD3_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD4] |= EGG_VIRTUAL_MOD4_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD5] |= EGG_VIRTUAL_MOD5_MASK;
+
+  XFreeModifiermap (xmodmap);
+}
+
+const EggModmap*
+egg_keymap_get_modmap (GdkKeymap *keymap)
+{
+  EggModmap *modmap;
+
+  /* This is all a hack, much simpler when we can just
+   * modify GDK directly.
+   */
+
+  modmap = g_object_get_data (G_OBJECT (keymap),
+                              "egg-modmap");
+
+  if (modmap == NULL)
+    {
+      modmap = g_new0 (EggModmap, 1);
+
+      /* FIXME modify keymap change events with an event filter
+       * and force a reload if we get one
+       */
+
+      reload_modmap (keymap, modmap);
+
+      g_object_set_data_full (G_OBJECT (keymap),
+                              "egg-modmap",
+                              modmap,
+                              g_free);
+    }
+
+  g_assert (modmap != NULL);
+
+  return modmap;
+}
+
+
+
+ + + diff --git a/2020-04-19-140522-4361-cppcheck@5fe75ca1e48e_master/index.html b/2020-04-19-140522-4361-cppcheck@5fe75ca1e48e_master/index.html new file mode 100644 index 0000000..812f8b5 --- /dev/null +++ b/2020-04-19-140522-4361-cppcheck@5fe75ca1e48e_master/index.html @@ -0,0 +1,101 @@ + + + + + + Cppcheck - HTML report - mate-indicator-applet + + + + + + + +
+ + + + + + + +
LineIdCWESeverityMessage
0missingIncludeSysteminformationCppcheck cannot find all the include files (use --check-config for details)
src/eggaccelerators.c
321duplicateExpression398styleSame expression on both sides of '-='.
+
+ + + diff --git a/2020-04-19-140522-4361-cppcheck@5fe75ca1e48e_master/stats.html b/2020-04-19-140522-4361-cppcheck@5fe75ca1e48e_master/stats.html new file mode 100644 index 0000000..14ae0d4 --- /dev/null +++ b/2020-04-19-140522-4361-cppcheck@5fe75ca1e48e_master/stats.html @@ -0,0 +1,89 @@ + + + + + + Cppcheck - HTML report - mate-indicator-applet + + + + + + + +
+

Top 10 files for style severity, total findings: 1
+   1  src/eggaccelerators.c
+

+ +
+ + + diff --git a/2020-04-19-140522-4361-cppcheck@5fe75ca1e48e_master/style.css b/2020-04-19-140522-4361-cppcheck@5fe75ca1e48e_master/style.css new file mode 100644 index 0000000..c39571c --- /dev/null +++ b/2020-04-19-140522-4361-cppcheck@5fe75ca1e48e_master/style.css @@ -0,0 +1,149 @@ + +body { + font: 13px Arial, Verdana, Sans-Serif; + margin: 0; + width: auto; +} + +h1 { + margin: 10px; +} + +#footer > p { + margin: 4px; +} + +.error { + background-color: #ffb7b7; +} + +.error2 { + background-color: #faa; + border: 1px dotted black; + display: inline-block; + margin-left: 4px; +} + +.inconclusive { + background-color: #B6B6B4; +} + +.inconclusive2 { + background-color: #B6B6B4; + border: 1px dotted black; + display: inline-block; + margin-left: 4px; +} + +div.verbose { + display: inline-block; + vertical-align: top; + cursor: help; +} + +div.verbose div.content { + display: none; + position: absolute; + padding: 10px; + margin: 4px; + max-width: 40%; + white-space: pre-wrap; + border: 1px solid black; + background-color: #FFFFCC; + cursor: auto; +} + +.highlight .hll { + padding: 1px; +} + +#header { + border-bottom: thin solid #aaa; +} + +#menu { + float: left; + margin-top: 5px; + text-align: left; + width: 150px; + /*height: 75%;*/ + position: fixed; + overflow: auto; + z-index: 1; +} + +#menu_index { + float: left; + margin-top: 5px; + padding-left: 5px; + text-align: left; + width: 300px; + /*height: 75%;*/ + position: fixed; + overflow: auto; + z-index: 1; +} + +#menu > a { + display: block; + margin-left: 10px; + font: 12px; + z-index: 1; +} + +#filename { + margin-left: 10px; + font: 12px; + z-index: 1; +} + +.highlighttable { + background-color:white; + z-index: 10; + position: relative; + margin: -10 px; +} + +#content { + background-color: white; + -webkit-box-sizing: content-box; + -moz-box-sizing: content-box; + box-sizing: content-box; + float: left; + margin: 5px; + margin-left: 10px; + padding: 0 10px 10px 10px; + width: 80%; + padding-left: 150px; +} + +#content_index { + background-color: white; + -webkit-box-sizing: content-box; + -moz-box-sizing: content-box; + box-sizing: content-box; + float: left; + margin: 5px; + margin-left: 10px; + padding: 0 10px 10px 10px; + width: 80%; + padding-left: 300px; +} + +.linenos { + border-right: thin solid #aaa; + color: lightgray; + padding-right: 6px; +} + +#footer { + border-top: thin solid #aaa; + clear: both; + font-size: 90%; + margin-top: 5px; +} + +#footer ul { + list-style-type: none; + padding-left: 0; +} diff --git a/2020-04-20-002519-7043-cppcheck@228991434623_travis/0.html b/2020-04-20-002519-7043-cppcheck@228991434623_travis/0.html new file mode 100644 index 0000000..dfb584a --- /dev/null +++ b/2020-04-20-002519-7043-cppcheck@228991434623_travis/0.html @@ -0,0 +1,1208 @@ + + + + + + Cppcheck - HTML report - mate-indicator-applet + + + + + + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
/* eggaccelerators.c
+ * Copyright (C) 2002  Red Hat, Inc.; Copyright 1998, 2001 Tim Janik
+ * Developed by Havoc Pennington, Tim Janik
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
+ */
+
+#include "eggaccelerators.h"
+
+#include <string.h>
+#include <gdk/gdkx.h>
+#include <gdk/gdkkeysyms.h>
+
+enum
+{
+  EGG_MODMAP_ENTRY_SHIFT   = 0,
+  EGG_MODMAP_ENTRY_LOCK    = 1,
+  EGG_MODMAP_ENTRY_CONTROL = 2,
+  EGG_MODMAP_ENTRY_MOD1    = 3,
+  EGG_MODMAP_ENTRY_MOD2    = 4,
+  EGG_MODMAP_ENTRY_MOD3    = 5,
+  EGG_MODMAP_ENTRY_MOD4    = 6,
+  EGG_MODMAP_ENTRY_MOD5    = 7,
+  EGG_MODMAP_ENTRY_LAST    = 8
+};
+
+#define MODMAP_ENTRY_TO_MODIFIER(x) (1 << (x))
+
+typedef struct
+{
+  EggVirtualModifierType mapping[EGG_MODMAP_ENTRY_LAST];
+
+} EggModmap;
+
+const EggModmap* egg_keymap_get_modmap (GdkKeymap *keymap);
+
+static inline gboolean
+is_alt (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'a' || string[1] == 'A') &&
+	  (string[2] == 'l' || string[2] == 'L') &&
+	  (string[3] == 't' || string[3] == 'T') &&
+	  (string[4] == '>'));
+}
+
+static inline gboolean
+is_ctl (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'c' || string[1] == 'C') &&
+	  (string[2] == 't' || string[2] == 'T') &&
+	  (string[3] == 'l' || string[3] == 'L') &&
+	  (string[4] == '>'));
+}
+
+static inline gboolean
+is_modx (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'm' || string[1] == 'M') &&
+	  (string[2] == 'o' || string[2] == 'O') &&
+	  (string[3] == 'd' || string[3] == 'D') &&
+	  (string[4] >= '1' && string[4] <= '5') &&
+	  (string[5] == '>'));
+}
+
+static inline gboolean
+is_ctrl (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'c' || string[1] == 'C') &&
+	  (string[2] == 't' || string[2] == 'T') &&
+	  (string[3] == 'r' || string[3] == 'R') &&
+	  (string[4] == 'l' || string[4] == 'L') &&
+	  (string[5] == '>'));
+}
+
+static inline gboolean
+is_shft (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 's' || string[1] == 'S') &&
+	  (string[2] == 'h' || string[2] == 'H') &&
+	  (string[3] == 'f' || string[3] == 'F') &&
+	  (string[4] == 't' || string[4] == 'T') &&
+	  (string[5] == '>'));
+}
+
+static inline gboolean
+is_shift (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 's' || string[1] == 'S') &&
+	  (string[2] == 'h' || string[2] == 'H') &&
+	  (string[3] == 'i' || string[3] == 'I') &&
+	  (string[4] == 'f' || string[4] == 'F') &&
+	  (string[5] == 't' || string[5] == 'T') &&
+	  (string[6] == '>'));
+}
+
+static inline gboolean
+is_control (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'c' || string[1] == 'C') &&
+	  (string[2] == 'o' || string[2] == 'O') &&
+	  (string[3] == 'n' || string[3] == 'N') &&
+	  (string[4] == 't' || string[4] == 'T') &&
+	  (string[5] == 'r' || string[5] == 'R') &&
+	  (string[6] == 'o' || string[6] == 'O') &&
+	  (string[7] == 'l' || string[7] == 'L') &&
+	  (string[8] == '>'));
+}
+
+static inline gboolean
+is_release (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'r' || string[1] == 'R') &&
+	  (string[2] == 'e' || string[2] == 'E') &&
+	  (string[3] == 'l' || string[3] == 'L') &&
+	  (string[4] == 'e' || string[4] == 'E') &&
+	  (string[5] == 'a' || string[5] == 'A') &&
+	  (string[6] == 's' || string[6] == 'S') &&
+	  (string[7] == 'e' || string[7] == 'E') &&
+	  (string[8] == '>'));
+}
+
+static inline gboolean
+is_meta (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'm' || string[1] == 'M') &&
+	  (string[2] == 'e' || string[2] == 'E') &&
+	  (string[3] == 't' || string[3] == 'T') &&
+	  (string[4] == 'a' || string[4] == 'A') &&
+	  (string[5] == '>'));
+}
+
+static inline gboolean
+is_super (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 's' || string[1] == 'S') &&
+	  (string[2] == 'u' || string[2] == 'U') &&
+	  (string[3] == 'p' || string[3] == 'P') &&
+	  (string[4] == 'e' || string[4] == 'E') &&
+	  (string[5] == 'r' || string[5] == 'R') &&
+	  (string[6] == '>'));
+}
+
+static inline gboolean
+is_hyper (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'h' || string[1] == 'H') &&
+	  (string[2] == 'y' || string[2] == 'Y') &&
+	  (string[3] == 'p' || string[3] == 'P') &&
+	  (string[4] == 'e' || string[4] == 'E') &&
+	  (string[5] == 'r' || string[5] == 'R') &&
+	  (string[6] == '>'));
+}
+
+/**
+ * egg_accelerator_parse_virtual:
+ * @accelerator:      string representing an accelerator
+ * @accelerator_key:  return location for accelerator keyval
+ * @accelerator_mods: return location for accelerator modifier mask
+ *
+ * Parses a string representing a virtual accelerator. The format
+ * looks like "&lt;Control&gt;a" or "&lt;Shift&gt;&lt;Alt&gt;F1" or
+ * "&lt;Release&gt;z" (the last one is for key release).  The parser
+ * is fairly liberal and allows lower or upper case, and also
+ * abbreviations such as "&lt;Ctl&gt;" and "&lt;Ctrl&gt;".
+ *
+ * If the parse fails, @accelerator_key and @accelerator_mods will
+ * be set to 0 (zero) and %FALSE will be returned. If the string contains
+ * only modifiers, @accelerator_key will be set to 0 but %TRUE will be
+ * returned.
+ *
+ * The virtual vs. concrete accelerator distinction is a relic of
+ * how the X Window System works; there are modifiers Mod2-Mod5 that
+ * can represent various keyboard keys (numlock, meta, hyper, etc.),
+ * the virtual modifier represents the keyboard key, the concrete
+ * modifier the actual Mod2-Mod5 bits in the key press event.
+ *
+ * Returns: %TRUE on success.
+ */
+gboolean
+egg_accelerator_parse_virtual (const gchar            *accelerator,
+                               guint                  *accelerator_key,
+                               EggVirtualModifierType *accelerator_mods)
+{
+  guint keyval;
+  GdkModifierType mods;
+  gint len;
+  gboolean bad_keyval;
+
+  if (accelerator_key)
+    *accelerator_key = 0;
+  if (accelerator_mods)
+    *accelerator_mods = 0;
+
+  g_return_val_if_fail (accelerator != NULL, FALSE);
+
+  bad_keyval = FALSE;
+
+  keyval = 0;
+  mods = 0;
+  len = strlen (accelerator);
+  while (len)
+    {
+      if (*accelerator == '<')
+	{
+	  if (len >= 9 && is_release (accelerator))
+	    {
+	      accelerator += 9;
+	      len -= 9;
+	      mods |= EGG_VIRTUAL_RELEASE_MASK;
+	    }
+	  else if (len >= 9 && is_control (accelerator))
+	    {
+	      accelerator += 9;
+	      len -= 9;
+	      mods |= EGG_VIRTUAL_CONTROL_MASK;
+	    }
+	  else if (len >= 7 && is_shift (accelerator))
+	    {
+	      accelerator += 7;
+	      len -= 7;
+	      mods |= EGG_VIRTUAL_SHIFT_MASK;
+	    }
+	  else if (len >= 6 && is_shft (accelerator))
+	    {
+	      accelerator += 6;
+	      len -= 6;
+	      mods |= EGG_VIRTUAL_SHIFT_MASK;
+	    }
+	  else if (len >= 6 && is_ctrl (accelerator))
+	    {
+	      accelerator += 6;
+	      len -= 6;
+	      mods |= EGG_VIRTUAL_CONTROL_MASK;
+	    }
+	  else if (len >= 6 && is_modx (accelerator))
+	    {
+	      static const guint mod_vals[] = {
+		EGG_VIRTUAL_ALT_MASK, EGG_VIRTUAL_MOD2_MASK, EGG_VIRTUAL_MOD3_MASK,
+		EGG_VIRTUAL_MOD4_MASK, EGG_VIRTUAL_MOD5_MASK
+	      };
+
+	      len -= 6;
+	      accelerator += 4;
+	      mods |= mod_vals[*accelerator - '1'];
+	      accelerator += 2;
+	    }
+	  else if (len >= 5 && is_ctl (accelerator))
+	    {
+	      accelerator += 5;
+	      len -= 5;
+	      mods |= EGG_VIRTUAL_CONTROL_MASK;
+	    }
+	  else if (len >= 5 && is_alt (accelerator))
+	    {
+	      accelerator += 5;
+	      len -= 5;
+	      mods |= EGG_VIRTUAL_ALT_MASK;
+	    }
+          else if (len >= 6 && is_meta (accelerator))
+	    {
+	      accelerator += 6;
+	      len -= 6;
+	      mods |= EGG_VIRTUAL_META_MASK;
+	    }
+          else if (len >= 7 && is_hyper (accelerator))
+	    {
+	      accelerator += 7;
+	      len -= 7;
+	      mods |= EGG_VIRTUAL_HYPER_MASK;
+	    }
+          else if (len >= 7 && is_super (accelerator))
+	    {
+	      accelerator += 7;
+	      len -= 7;
+	      mods |= EGG_VIRTUAL_SUPER_MASK;
+	    }
+	  else
+	    {
+	      gchar last_ch;
+
+	      last_ch = *accelerator;
+	      while (last_ch && last_ch != '>')
+		{
+		  last_ch = *accelerator;
+		  accelerator += 1;
+		  len -= 1;
+		}
+	    }
+	}
+      else
+	{
+          keyval = gdk_keyval_from_name (accelerator);
+
+          if (keyval == 0)
+            bad_keyval = TRUE;
+
+          accelerator += len;
+          len -= len;
+	}
+    }
+
+  if (accelerator_key)
+    *accelerator_key = gdk_keyval_to_lower (keyval);
+  if (accelerator_mods)
+    *accelerator_mods = mods;
+
+  return !bad_keyval;
+}
+
+void
+egg_keymap_resolve_virtual_modifiers (GdkKeymap              *keymap,
+                                      EggVirtualModifierType  virtual_mods,
+                                      GdkModifierType        *concrete_mods)
+{
+  GdkModifierType concrete;
+  int i;
+  const EggModmap *modmap;
+
+  g_return_if_fail (GDK_IS_KEYMAP (keymap));
+  g_return_if_fail (concrete_mods != NULL);
+
+  modmap = egg_keymap_get_modmap (keymap);
+
+  /* Not so sure about this algorithm. */
+
+  concrete = 0;
+  i = 0;
+  while (i < EGG_MODMAP_ENTRY_LAST)
+    {
+      if (modmap->mapping[i] & virtual_mods)
+        concrete |= (1 << i);
+
+      ++i;
+    }
+
+  *concrete_mods = concrete;
+}
+
+void
+egg_keymap_virtualize_modifiers (GdkKeymap              *keymap,
+                                 GdkModifierType         concrete_mods,
+                                 EggVirtualModifierType *virtual_mods)
+{
+  GdkModifierType virtual;
+  int i;
+  const EggModmap *modmap;
+
+  g_return_if_fail (GDK_IS_KEYMAP (keymap));
+  g_return_if_fail (virtual_mods != NULL);
+
+  modmap = egg_keymap_get_modmap (keymap);
+
+  /* Not so sure about this algorithm. */
+
+  virtual = 0;
+  i = 0;
+  while (i < EGG_MODMAP_ENTRY_LAST)
+    {
+      if ((1 << i) & concrete_mods)
+        {
+          EggVirtualModifierType cleaned;
+
+          cleaned = modmap->mapping[i] & ~(EGG_VIRTUAL_MOD2_MASK |
+                                           EGG_VIRTUAL_MOD3_MASK |
+                                           EGG_VIRTUAL_MOD4_MASK |
+                                           EGG_VIRTUAL_MOD5_MASK);
+
+          if (cleaned != 0)
+            {
+              virtual |= cleaned;
+            }
+          else
+            {
+              /* Rather than dropping mod2->mod5 if not bound,
+               * go ahead and use the concrete names
+               */
+              virtual |= modmap->mapping[i];
+            }
+        }
+
+      ++i;
+    }
+
+  *virtual_mods = virtual;
+}
+
+static void
+reload_modmap (GdkKeymap *keymap,
+               EggModmap *modmap)
+{
+  XModifierKeymap *xmodmap;
+  int map_size;
+  int i;
+
+  /* FIXME multihead */
+  xmodmap = XGetModifierMapping (gdk_x11_get_default_xdisplay ());
+
+  memset (modmap->mapping, 0, sizeof (modmap->mapping));
+
+  /* there are 8 modifiers, and the first 3 are shift, shift lock,
+   * and control
+   */
+  map_size = 8 * xmodmap->max_keypermod;
+  i = 3 * xmodmap->max_keypermod;
+  while (i < map_size)
+    {
+      /* get the key code at this point in the map,
+       * see if its keysym is one we're interested in
+       */
+      int keycode = xmodmap->modifiermap[i];
+      GdkKeymapKey *keys;
+      guint *keyvals;
+      int n_entries;
+      int j;
+      EggVirtualModifierType mask;
+
+      keys = NULL;
+      keyvals = NULL;
+      n_entries = 0;
+
+      gdk_keymap_get_entries_for_keycode (keymap,
+                                          keycode,
+                                          &keys, &keyvals, &n_entries);
+
+      mask = 0;
+      j = 0;
+      while (j < n_entries)
+        {
+          if (keyvals[j] == GDK_KEY_Num_Lock)
+            mask |= EGG_VIRTUAL_NUM_LOCK_MASK;
+          else if (keyvals[j] == GDK_KEY_Scroll_Lock)
+            mask |= EGG_VIRTUAL_SCROLL_LOCK_MASK;
+          else if (keyvals[j] == GDK_KEY_Meta_L ||
+                   keyvals[j] == GDK_KEY_Meta_R)
+            mask |= EGG_VIRTUAL_META_MASK;
+          else if (keyvals[j] == GDK_KEY_Hyper_L ||
+                   keyvals[j] == GDK_KEY_Hyper_R)
+            mask |= EGG_VIRTUAL_HYPER_MASK;
+          else if (keyvals[j] == GDK_KEY_Super_L ||
+                   keyvals[j] == GDK_KEY_Super_R)
+            mask |= EGG_VIRTUAL_SUPER_MASK;
+          else if (keyvals[j] == GDK_KEY_Mode_switch)
+            mask |= EGG_VIRTUAL_MODE_SWITCH_MASK;
+
+          ++j;
+        }
+
+      /* Mod1Mask is 1 << 3 for example, i.e. the
+       * fourth modifier, i / keyspermod is the modifier
+       * index
+       */
+      modmap->mapping[i/xmodmap->max_keypermod] |= mask;
+
+      g_free (keyvals);
+      g_free (keys);
+
+      ++i;
+    }
+
+  /* Add in the not-really-virtual fixed entries */
+  modmap->mapping[EGG_MODMAP_ENTRY_SHIFT] |= EGG_VIRTUAL_SHIFT_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_CONTROL] |= EGG_VIRTUAL_CONTROL_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_LOCK] |= EGG_VIRTUAL_LOCK_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD1] |= EGG_VIRTUAL_ALT_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD2] |= EGG_VIRTUAL_MOD2_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD3] |= EGG_VIRTUAL_MOD3_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD4] |= EGG_VIRTUAL_MOD4_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD5] |= EGG_VIRTUAL_MOD5_MASK;
+
+  XFreeModifiermap (xmodmap);
+}
+
+const EggModmap*
+egg_keymap_get_modmap (GdkKeymap *keymap)
+{
+  EggModmap *modmap;
+
+  /* This is all a hack, much simpler when we can just
+   * modify GDK directly.
+   */
+
+  modmap = g_object_get_data (G_OBJECT (keymap),
+                              "egg-modmap");
+
+  if (modmap == NULL)
+    {
+      modmap = g_new0 (EggModmap, 1);
+
+      /* FIXME modify keymap change events with an event filter
+       * and force a reload if we get one
+       */
+
+      reload_modmap (keymap, modmap);
+
+      g_object_set_data_full (G_OBJECT (keymap),
+                              "egg-modmap",
+                              modmap,
+                              g_free);
+    }
+
+  g_assert (modmap != NULL);
+
+  return modmap;
+}
+
+
+
+ + + diff --git a/2020-04-20-002519-7043-cppcheck@228991434623_travis/index.html b/2020-04-20-002519-7043-cppcheck@228991434623_travis/index.html new file mode 100644 index 0000000..812f8b5 --- /dev/null +++ b/2020-04-20-002519-7043-cppcheck@228991434623_travis/index.html @@ -0,0 +1,101 @@ + + + + + + Cppcheck - HTML report - mate-indicator-applet + + + + + + + +
+ + + + + + + +
LineIdCWESeverityMessage
0missingIncludeSysteminformationCppcheck cannot find all the include files (use --check-config for details)
src/eggaccelerators.c
321duplicateExpression398styleSame expression on both sides of '-='.
+
+ + + diff --git a/2020-04-20-002519-7043-cppcheck@228991434623_travis/stats.html b/2020-04-20-002519-7043-cppcheck@228991434623_travis/stats.html new file mode 100644 index 0000000..14ae0d4 --- /dev/null +++ b/2020-04-20-002519-7043-cppcheck@228991434623_travis/stats.html @@ -0,0 +1,89 @@ + + + + + + Cppcheck - HTML report - mate-indicator-applet + + + + + + + +
+

Top 10 files for style severity, total findings: 1
+   1  src/eggaccelerators.c
+

+ +
+ + + diff --git a/2020-04-20-002519-7043-cppcheck@228991434623_travis/style.css b/2020-04-20-002519-7043-cppcheck@228991434623_travis/style.css new file mode 100644 index 0000000..c39571c --- /dev/null +++ b/2020-04-20-002519-7043-cppcheck@228991434623_travis/style.css @@ -0,0 +1,149 @@ + +body { + font: 13px Arial, Verdana, Sans-Serif; + margin: 0; + width: auto; +} + +h1 { + margin: 10px; +} + +#footer > p { + margin: 4px; +} + +.error { + background-color: #ffb7b7; +} + +.error2 { + background-color: #faa; + border: 1px dotted black; + display: inline-block; + margin-left: 4px; +} + +.inconclusive { + background-color: #B6B6B4; +} + +.inconclusive2 { + background-color: #B6B6B4; + border: 1px dotted black; + display: inline-block; + margin-left: 4px; +} + +div.verbose { + display: inline-block; + vertical-align: top; + cursor: help; +} + +div.verbose div.content { + display: none; + position: absolute; + padding: 10px; + margin: 4px; + max-width: 40%; + white-space: pre-wrap; + border: 1px solid black; + background-color: #FFFFCC; + cursor: auto; +} + +.highlight .hll { + padding: 1px; +} + +#header { + border-bottom: thin solid #aaa; +} + +#menu { + float: left; + margin-top: 5px; + text-align: left; + width: 150px; + /*height: 75%;*/ + position: fixed; + overflow: auto; + z-index: 1; +} + +#menu_index { + float: left; + margin-top: 5px; + padding-left: 5px; + text-align: left; + width: 300px; + /*height: 75%;*/ + position: fixed; + overflow: auto; + z-index: 1; +} + +#menu > a { + display: block; + margin-left: 10px; + font: 12px; + z-index: 1; +} + +#filename { + margin-left: 10px; + font: 12px; + z-index: 1; +} + +.highlighttable { + background-color:white; + z-index: 10; + position: relative; + margin: -10 px; +} + +#content { + background-color: white; + -webkit-box-sizing: content-box; + -moz-box-sizing: content-box; + box-sizing: content-box; + float: left; + margin: 5px; + margin-left: 10px; + padding: 0 10px 10px 10px; + width: 80%; + padding-left: 150px; +} + +#content_index { + background-color: white; + -webkit-box-sizing: content-box; + -moz-box-sizing: content-box; + box-sizing: content-box; + float: left; + margin: 5px; + margin-left: 10px; + padding: 0 10px 10px 10px; + width: 80%; + padding-left: 300px; +} + +.linenos { + border-right: thin solid #aaa; + color: lightgray; + padding-right: 6px; +} + +#footer { + border-top: thin solid #aaa; + clear: both; + font-size: 90%; + margin-top: 5px; +} + +#footer ul { + list-style-type: none; + padding-left: 0; +} diff --git a/2020-04-20-003354-2536-cppcheck@272fb9d24d93_travis/0.html b/2020-04-20-003354-2536-cppcheck@272fb9d24d93_travis/0.html new file mode 100644 index 0000000..dfb584a --- /dev/null +++ b/2020-04-20-003354-2536-cppcheck@272fb9d24d93_travis/0.html @@ -0,0 +1,1208 @@ + + + + + + Cppcheck - HTML report - mate-indicator-applet + + + + + + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
/* eggaccelerators.c
+ * Copyright (C) 2002  Red Hat, Inc.; Copyright 1998, 2001 Tim Janik
+ * Developed by Havoc Pennington, Tim Janik
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
+ */
+
+#include "eggaccelerators.h"
+
+#include <string.h>
+#include <gdk/gdkx.h>
+#include <gdk/gdkkeysyms.h>
+
+enum
+{
+  EGG_MODMAP_ENTRY_SHIFT   = 0,
+  EGG_MODMAP_ENTRY_LOCK    = 1,
+  EGG_MODMAP_ENTRY_CONTROL = 2,
+  EGG_MODMAP_ENTRY_MOD1    = 3,
+  EGG_MODMAP_ENTRY_MOD2    = 4,
+  EGG_MODMAP_ENTRY_MOD3    = 5,
+  EGG_MODMAP_ENTRY_MOD4    = 6,
+  EGG_MODMAP_ENTRY_MOD5    = 7,
+  EGG_MODMAP_ENTRY_LAST    = 8
+};
+
+#define MODMAP_ENTRY_TO_MODIFIER(x) (1 << (x))
+
+typedef struct
+{
+  EggVirtualModifierType mapping[EGG_MODMAP_ENTRY_LAST];
+
+} EggModmap;
+
+const EggModmap* egg_keymap_get_modmap (GdkKeymap *keymap);
+
+static inline gboolean
+is_alt (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'a' || string[1] == 'A') &&
+	  (string[2] == 'l' || string[2] == 'L') &&
+	  (string[3] == 't' || string[3] == 'T') &&
+	  (string[4] == '>'));
+}
+
+static inline gboolean
+is_ctl (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'c' || string[1] == 'C') &&
+	  (string[2] == 't' || string[2] == 'T') &&
+	  (string[3] == 'l' || string[3] == 'L') &&
+	  (string[4] == '>'));
+}
+
+static inline gboolean
+is_modx (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'm' || string[1] == 'M') &&
+	  (string[2] == 'o' || string[2] == 'O') &&
+	  (string[3] == 'd' || string[3] == 'D') &&
+	  (string[4] >= '1' && string[4] <= '5') &&
+	  (string[5] == '>'));
+}
+
+static inline gboolean
+is_ctrl (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'c' || string[1] == 'C') &&
+	  (string[2] == 't' || string[2] == 'T') &&
+	  (string[3] == 'r' || string[3] == 'R') &&
+	  (string[4] == 'l' || string[4] == 'L') &&
+	  (string[5] == '>'));
+}
+
+static inline gboolean
+is_shft (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 's' || string[1] == 'S') &&
+	  (string[2] == 'h' || string[2] == 'H') &&
+	  (string[3] == 'f' || string[3] == 'F') &&
+	  (string[4] == 't' || string[4] == 'T') &&
+	  (string[5] == '>'));
+}
+
+static inline gboolean
+is_shift (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 's' || string[1] == 'S') &&
+	  (string[2] == 'h' || string[2] == 'H') &&
+	  (string[3] == 'i' || string[3] == 'I') &&
+	  (string[4] == 'f' || string[4] == 'F') &&
+	  (string[5] == 't' || string[5] == 'T') &&
+	  (string[6] == '>'));
+}
+
+static inline gboolean
+is_control (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'c' || string[1] == 'C') &&
+	  (string[2] == 'o' || string[2] == 'O') &&
+	  (string[3] == 'n' || string[3] == 'N') &&
+	  (string[4] == 't' || string[4] == 'T') &&
+	  (string[5] == 'r' || string[5] == 'R') &&
+	  (string[6] == 'o' || string[6] == 'O') &&
+	  (string[7] == 'l' || string[7] == 'L') &&
+	  (string[8] == '>'));
+}
+
+static inline gboolean
+is_release (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'r' || string[1] == 'R') &&
+	  (string[2] == 'e' || string[2] == 'E') &&
+	  (string[3] == 'l' || string[3] == 'L') &&
+	  (string[4] == 'e' || string[4] == 'E') &&
+	  (string[5] == 'a' || string[5] == 'A') &&
+	  (string[6] == 's' || string[6] == 'S') &&
+	  (string[7] == 'e' || string[7] == 'E') &&
+	  (string[8] == '>'));
+}
+
+static inline gboolean
+is_meta (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'm' || string[1] == 'M') &&
+	  (string[2] == 'e' || string[2] == 'E') &&
+	  (string[3] == 't' || string[3] == 'T') &&
+	  (string[4] == 'a' || string[4] == 'A') &&
+	  (string[5] == '>'));
+}
+
+static inline gboolean
+is_super (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 's' || string[1] == 'S') &&
+	  (string[2] == 'u' || string[2] == 'U') &&
+	  (string[3] == 'p' || string[3] == 'P') &&
+	  (string[4] == 'e' || string[4] == 'E') &&
+	  (string[5] == 'r' || string[5] == 'R') &&
+	  (string[6] == '>'));
+}
+
+static inline gboolean
+is_hyper (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'h' || string[1] == 'H') &&
+	  (string[2] == 'y' || string[2] == 'Y') &&
+	  (string[3] == 'p' || string[3] == 'P') &&
+	  (string[4] == 'e' || string[4] == 'E') &&
+	  (string[5] == 'r' || string[5] == 'R') &&
+	  (string[6] == '>'));
+}
+
+/**
+ * egg_accelerator_parse_virtual:
+ * @accelerator:      string representing an accelerator
+ * @accelerator_key:  return location for accelerator keyval
+ * @accelerator_mods: return location for accelerator modifier mask
+ *
+ * Parses a string representing a virtual accelerator. The format
+ * looks like "&lt;Control&gt;a" or "&lt;Shift&gt;&lt;Alt&gt;F1" or
+ * "&lt;Release&gt;z" (the last one is for key release).  The parser
+ * is fairly liberal and allows lower or upper case, and also
+ * abbreviations such as "&lt;Ctl&gt;" and "&lt;Ctrl&gt;".
+ *
+ * If the parse fails, @accelerator_key and @accelerator_mods will
+ * be set to 0 (zero) and %FALSE will be returned. If the string contains
+ * only modifiers, @accelerator_key will be set to 0 but %TRUE will be
+ * returned.
+ *
+ * The virtual vs. concrete accelerator distinction is a relic of
+ * how the X Window System works; there are modifiers Mod2-Mod5 that
+ * can represent various keyboard keys (numlock, meta, hyper, etc.),
+ * the virtual modifier represents the keyboard key, the concrete
+ * modifier the actual Mod2-Mod5 bits in the key press event.
+ *
+ * Returns: %TRUE on success.
+ */
+gboolean
+egg_accelerator_parse_virtual (const gchar            *accelerator,
+                               guint                  *accelerator_key,
+                               EggVirtualModifierType *accelerator_mods)
+{
+  guint keyval;
+  GdkModifierType mods;
+  gint len;
+  gboolean bad_keyval;
+
+  if (accelerator_key)
+    *accelerator_key = 0;
+  if (accelerator_mods)
+    *accelerator_mods = 0;
+
+  g_return_val_if_fail (accelerator != NULL, FALSE);
+
+  bad_keyval = FALSE;
+
+  keyval = 0;
+  mods = 0;
+  len = strlen (accelerator);
+  while (len)
+    {
+      if (*accelerator == '<')
+	{
+	  if (len >= 9 && is_release (accelerator))
+	    {
+	      accelerator += 9;
+	      len -= 9;
+	      mods |= EGG_VIRTUAL_RELEASE_MASK;
+	    }
+	  else if (len >= 9 && is_control (accelerator))
+	    {
+	      accelerator += 9;
+	      len -= 9;
+	      mods |= EGG_VIRTUAL_CONTROL_MASK;
+	    }
+	  else if (len >= 7 && is_shift (accelerator))
+	    {
+	      accelerator += 7;
+	      len -= 7;
+	      mods |= EGG_VIRTUAL_SHIFT_MASK;
+	    }
+	  else if (len >= 6 && is_shft (accelerator))
+	    {
+	      accelerator += 6;
+	      len -= 6;
+	      mods |= EGG_VIRTUAL_SHIFT_MASK;
+	    }
+	  else if (len >= 6 && is_ctrl (accelerator))
+	    {
+	      accelerator += 6;
+	      len -= 6;
+	      mods |= EGG_VIRTUAL_CONTROL_MASK;
+	    }
+	  else if (len >= 6 && is_modx (accelerator))
+	    {
+	      static const guint mod_vals[] = {
+		EGG_VIRTUAL_ALT_MASK, EGG_VIRTUAL_MOD2_MASK, EGG_VIRTUAL_MOD3_MASK,
+		EGG_VIRTUAL_MOD4_MASK, EGG_VIRTUAL_MOD5_MASK
+	      };
+
+	      len -= 6;
+	      accelerator += 4;
+	      mods |= mod_vals[*accelerator - '1'];
+	      accelerator += 2;
+	    }
+	  else if (len >= 5 && is_ctl (accelerator))
+	    {
+	      accelerator += 5;
+	      len -= 5;
+	      mods |= EGG_VIRTUAL_CONTROL_MASK;
+	    }
+	  else if (len >= 5 && is_alt (accelerator))
+	    {
+	      accelerator += 5;
+	      len -= 5;
+	      mods |= EGG_VIRTUAL_ALT_MASK;
+	    }
+          else if (len >= 6 && is_meta (accelerator))
+	    {
+	      accelerator += 6;
+	      len -= 6;
+	      mods |= EGG_VIRTUAL_META_MASK;
+	    }
+          else if (len >= 7 && is_hyper (accelerator))
+	    {
+	      accelerator += 7;
+	      len -= 7;
+	      mods |= EGG_VIRTUAL_HYPER_MASK;
+	    }
+          else if (len >= 7 && is_super (accelerator))
+	    {
+	      accelerator += 7;
+	      len -= 7;
+	      mods |= EGG_VIRTUAL_SUPER_MASK;
+	    }
+	  else
+	    {
+	      gchar last_ch;
+
+	      last_ch = *accelerator;
+	      while (last_ch && last_ch != '>')
+		{
+		  last_ch = *accelerator;
+		  accelerator += 1;
+		  len -= 1;
+		}
+	    }
+	}
+      else
+	{
+          keyval = gdk_keyval_from_name (accelerator);
+
+          if (keyval == 0)
+            bad_keyval = TRUE;
+
+          accelerator += len;
+          len -= len;
+	}
+    }
+
+  if (accelerator_key)
+    *accelerator_key = gdk_keyval_to_lower (keyval);
+  if (accelerator_mods)
+    *accelerator_mods = mods;
+
+  return !bad_keyval;
+}
+
+void
+egg_keymap_resolve_virtual_modifiers (GdkKeymap              *keymap,
+                                      EggVirtualModifierType  virtual_mods,
+                                      GdkModifierType        *concrete_mods)
+{
+  GdkModifierType concrete;
+  int i;
+  const EggModmap *modmap;
+
+  g_return_if_fail (GDK_IS_KEYMAP (keymap));
+  g_return_if_fail (concrete_mods != NULL);
+
+  modmap = egg_keymap_get_modmap (keymap);
+
+  /* Not so sure about this algorithm. */
+
+  concrete = 0;
+  i = 0;
+  while (i < EGG_MODMAP_ENTRY_LAST)
+    {
+      if (modmap->mapping[i] & virtual_mods)
+        concrete |= (1 << i);
+
+      ++i;
+    }
+
+  *concrete_mods = concrete;
+}
+
+void
+egg_keymap_virtualize_modifiers (GdkKeymap              *keymap,
+                                 GdkModifierType         concrete_mods,
+                                 EggVirtualModifierType *virtual_mods)
+{
+  GdkModifierType virtual;
+  int i;
+  const EggModmap *modmap;
+
+  g_return_if_fail (GDK_IS_KEYMAP (keymap));
+  g_return_if_fail (virtual_mods != NULL);
+
+  modmap = egg_keymap_get_modmap (keymap);
+
+  /* Not so sure about this algorithm. */
+
+  virtual = 0;
+  i = 0;
+  while (i < EGG_MODMAP_ENTRY_LAST)
+    {
+      if ((1 << i) & concrete_mods)
+        {
+          EggVirtualModifierType cleaned;
+
+          cleaned = modmap->mapping[i] & ~(EGG_VIRTUAL_MOD2_MASK |
+                                           EGG_VIRTUAL_MOD3_MASK |
+                                           EGG_VIRTUAL_MOD4_MASK |
+                                           EGG_VIRTUAL_MOD5_MASK);
+
+          if (cleaned != 0)
+            {
+              virtual |= cleaned;
+            }
+          else
+            {
+              /* Rather than dropping mod2->mod5 if not bound,
+               * go ahead and use the concrete names
+               */
+              virtual |= modmap->mapping[i];
+            }
+        }
+
+      ++i;
+    }
+
+  *virtual_mods = virtual;
+}
+
+static void
+reload_modmap (GdkKeymap *keymap,
+               EggModmap *modmap)
+{
+  XModifierKeymap *xmodmap;
+  int map_size;
+  int i;
+
+  /* FIXME multihead */
+  xmodmap = XGetModifierMapping (gdk_x11_get_default_xdisplay ());
+
+  memset (modmap->mapping, 0, sizeof (modmap->mapping));
+
+  /* there are 8 modifiers, and the first 3 are shift, shift lock,
+   * and control
+   */
+  map_size = 8 * xmodmap->max_keypermod;
+  i = 3 * xmodmap->max_keypermod;
+  while (i < map_size)
+    {
+      /* get the key code at this point in the map,
+       * see if its keysym is one we're interested in
+       */
+      int keycode = xmodmap->modifiermap[i];
+      GdkKeymapKey *keys;
+      guint *keyvals;
+      int n_entries;
+      int j;
+      EggVirtualModifierType mask;
+
+      keys = NULL;
+      keyvals = NULL;
+      n_entries = 0;
+
+      gdk_keymap_get_entries_for_keycode (keymap,
+                                          keycode,
+                                          &keys, &keyvals, &n_entries);
+
+      mask = 0;
+      j = 0;
+      while (j < n_entries)
+        {
+          if (keyvals[j] == GDK_KEY_Num_Lock)
+            mask |= EGG_VIRTUAL_NUM_LOCK_MASK;
+          else if (keyvals[j] == GDK_KEY_Scroll_Lock)
+            mask |= EGG_VIRTUAL_SCROLL_LOCK_MASK;
+          else if (keyvals[j] == GDK_KEY_Meta_L ||
+                   keyvals[j] == GDK_KEY_Meta_R)
+            mask |= EGG_VIRTUAL_META_MASK;
+          else if (keyvals[j] == GDK_KEY_Hyper_L ||
+                   keyvals[j] == GDK_KEY_Hyper_R)
+            mask |= EGG_VIRTUAL_HYPER_MASK;
+          else if (keyvals[j] == GDK_KEY_Super_L ||
+                   keyvals[j] == GDK_KEY_Super_R)
+            mask |= EGG_VIRTUAL_SUPER_MASK;
+          else if (keyvals[j] == GDK_KEY_Mode_switch)
+            mask |= EGG_VIRTUAL_MODE_SWITCH_MASK;
+
+          ++j;
+        }
+
+      /* Mod1Mask is 1 << 3 for example, i.e. the
+       * fourth modifier, i / keyspermod is the modifier
+       * index
+       */
+      modmap->mapping[i/xmodmap->max_keypermod] |= mask;
+
+      g_free (keyvals);
+      g_free (keys);
+
+      ++i;
+    }
+
+  /* Add in the not-really-virtual fixed entries */
+  modmap->mapping[EGG_MODMAP_ENTRY_SHIFT] |= EGG_VIRTUAL_SHIFT_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_CONTROL] |= EGG_VIRTUAL_CONTROL_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_LOCK] |= EGG_VIRTUAL_LOCK_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD1] |= EGG_VIRTUAL_ALT_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD2] |= EGG_VIRTUAL_MOD2_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD3] |= EGG_VIRTUAL_MOD3_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD4] |= EGG_VIRTUAL_MOD4_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD5] |= EGG_VIRTUAL_MOD5_MASK;
+
+  XFreeModifiermap (xmodmap);
+}
+
+const EggModmap*
+egg_keymap_get_modmap (GdkKeymap *keymap)
+{
+  EggModmap *modmap;
+
+  /* This is all a hack, much simpler when we can just
+   * modify GDK directly.
+   */
+
+  modmap = g_object_get_data (G_OBJECT (keymap),
+                              "egg-modmap");
+
+  if (modmap == NULL)
+    {
+      modmap = g_new0 (EggModmap, 1);
+
+      /* FIXME modify keymap change events with an event filter
+       * and force a reload if we get one
+       */
+
+      reload_modmap (keymap, modmap);
+
+      g_object_set_data_full (G_OBJECT (keymap),
+                              "egg-modmap",
+                              modmap,
+                              g_free);
+    }
+
+  g_assert (modmap != NULL);
+
+  return modmap;
+}
+
+
+
+ + + diff --git a/2020-04-20-003354-2536-cppcheck@272fb9d24d93_travis/index.html b/2020-04-20-003354-2536-cppcheck@272fb9d24d93_travis/index.html new file mode 100644 index 0000000..812f8b5 --- /dev/null +++ b/2020-04-20-003354-2536-cppcheck@272fb9d24d93_travis/index.html @@ -0,0 +1,101 @@ + + + + + + Cppcheck - HTML report - mate-indicator-applet + + + + + + + +
+ + + + + + + +
LineIdCWESeverityMessage
0missingIncludeSysteminformationCppcheck cannot find all the include files (use --check-config for details)
src/eggaccelerators.c
321duplicateExpression398styleSame expression on both sides of '-='.
+
+ + + diff --git a/2020-04-20-003354-2536-cppcheck@272fb9d24d93_travis/stats.html b/2020-04-20-003354-2536-cppcheck@272fb9d24d93_travis/stats.html new file mode 100644 index 0000000..14ae0d4 --- /dev/null +++ b/2020-04-20-003354-2536-cppcheck@272fb9d24d93_travis/stats.html @@ -0,0 +1,89 @@ + + + + + + Cppcheck - HTML report - mate-indicator-applet + + + + + + + +
+

Top 10 files for style severity, total findings: 1
+   1  src/eggaccelerators.c
+

+ +
+ + + diff --git a/2020-04-20-003354-2536-cppcheck@272fb9d24d93_travis/style.css b/2020-04-20-003354-2536-cppcheck@272fb9d24d93_travis/style.css new file mode 100644 index 0000000..c39571c --- /dev/null +++ b/2020-04-20-003354-2536-cppcheck@272fb9d24d93_travis/style.css @@ -0,0 +1,149 @@ + +body { + font: 13px Arial, Verdana, Sans-Serif; + margin: 0; + width: auto; +} + +h1 { + margin: 10px; +} + +#footer > p { + margin: 4px; +} + +.error { + background-color: #ffb7b7; +} + +.error2 { + background-color: #faa; + border: 1px dotted black; + display: inline-block; + margin-left: 4px; +} + +.inconclusive { + background-color: #B6B6B4; +} + +.inconclusive2 { + background-color: #B6B6B4; + border: 1px dotted black; + display: inline-block; + margin-left: 4px; +} + +div.verbose { + display: inline-block; + vertical-align: top; + cursor: help; +} + +div.verbose div.content { + display: none; + position: absolute; + padding: 10px; + margin: 4px; + max-width: 40%; + white-space: pre-wrap; + border: 1px solid black; + background-color: #FFFFCC; + cursor: auto; +} + +.highlight .hll { + padding: 1px; +} + +#header { + border-bottom: thin solid #aaa; +} + +#menu { + float: left; + margin-top: 5px; + text-align: left; + width: 150px; + /*height: 75%;*/ + position: fixed; + overflow: auto; + z-index: 1; +} + +#menu_index { + float: left; + margin-top: 5px; + padding-left: 5px; + text-align: left; + width: 300px; + /*height: 75%;*/ + position: fixed; + overflow: auto; + z-index: 1; +} + +#menu > a { + display: block; + margin-left: 10px; + font: 12px; + z-index: 1; +} + +#filename { + margin-left: 10px; + font: 12px; + z-index: 1; +} + +.highlighttable { + background-color:white; + z-index: 10; + position: relative; + margin: -10 px; +} + +#content { + background-color: white; + -webkit-box-sizing: content-box; + -moz-box-sizing: content-box; + box-sizing: content-box; + float: left; + margin: 5px; + margin-left: 10px; + padding: 0 10px 10px 10px; + width: 80%; + padding-left: 150px; +} + +#content_index { + background-color: white; + -webkit-box-sizing: content-box; + -moz-box-sizing: content-box; + box-sizing: content-box; + float: left; + margin: 5px; + margin-left: 10px; + padding: 0 10px 10px 10px; + width: 80%; + padding-left: 300px; +} + +.linenos { + border-right: thin solid #aaa; + color: lightgray; + padding-right: 6px; +} + +#footer { + border-top: thin solid #aaa; + clear: both; + font-size: 90%; + margin-top: 5px; +} + +#footer ul { + list-style-type: none; + padding-left: 0; +} diff --git a/2020-04-20-005310-1134-cppcheck@c4c5242e5827_master/0.html b/2020-04-20-005310-1134-cppcheck@c4c5242e5827_master/0.html new file mode 100644 index 0000000..dfb584a --- /dev/null +++ b/2020-04-20-005310-1134-cppcheck@c4c5242e5827_master/0.html @@ -0,0 +1,1208 @@ + + + + + + Cppcheck - HTML report - mate-indicator-applet + + + + + + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
/* eggaccelerators.c
+ * Copyright (C) 2002  Red Hat, Inc.; Copyright 1998, 2001 Tim Janik
+ * Developed by Havoc Pennington, Tim Janik
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
+ */
+
+#include "eggaccelerators.h"
+
+#include <string.h>
+#include <gdk/gdkx.h>
+#include <gdk/gdkkeysyms.h>
+
+enum
+{
+  EGG_MODMAP_ENTRY_SHIFT   = 0,
+  EGG_MODMAP_ENTRY_LOCK    = 1,
+  EGG_MODMAP_ENTRY_CONTROL = 2,
+  EGG_MODMAP_ENTRY_MOD1    = 3,
+  EGG_MODMAP_ENTRY_MOD2    = 4,
+  EGG_MODMAP_ENTRY_MOD3    = 5,
+  EGG_MODMAP_ENTRY_MOD4    = 6,
+  EGG_MODMAP_ENTRY_MOD5    = 7,
+  EGG_MODMAP_ENTRY_LAST    = 8
+};
+
+#define MODMAP_ENTRY_TO_MODIFIER(x) (1 << (x))
+
+typedef struct
+{
+  EggVirtualModifierType mapping[EGG_MODMAP_ENTRY_LAST];
+
+} EggModmap;
+
+const EggModmap* egg_keymap_get_modmap (GdkKeymap *keymap);
+
+static inline gboolean
+is_alt (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'a' || string[1] == 'A') &&
+	  (string[2] == 'l' || string[2] == 'L') &&
+	  (string[3] == 't' || string[3] == 'T') &&
+	  (string[4] == '>'));
+}
+
+static inline gboolean
+is_ctl (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'c' || string[1] == 'C') &&
+	  (string[2] == 't' || string[2] == 'T') &&
+	  (string[3] == 'l' || string[3] == 'L') &&
+	  (string[4] == '>'));
+}
+
+static inline gboolean
+is_modx (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'm' || string[1] == 'M') &&
+	  (string[2] == 'o' || string[2] == 'O') &&
+	  (string[3] == 'd' || string[3] == 'D') &&
+	  (string[4] >= '1' && string[4] <= '5') &&
+	  (string[5] == '>'));
+}
+
+static inline gboolean
+is_ctrl (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'c' || string[1] == 'C') &&
+	  (string[2] == 't' || string[2] == 'T') &&
+	  (string[3] == 'r' || string[3] == 'R') &&
+	  (string[4] == 'l' || string[4] == 'L') &&
+	  (string[5] == '>'));
+}
+
+static inline gboolean
+is_shft (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 's' || string[1] == 'S') &&
+	  (string[2] == 'h' || string[2] == 'H') &&
+	  (string[3] == 'f' || string[3] == 'F') &&
+	  (string[4] == 't' || string[4] == 'T') &&
+	  (string[5] == '>'));
+}
+
+static inline gboolean
+is_shift (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 's' || string[1] == 'S') &&
+	  (string[2] == 'h' || string[2] == 'H') &&
+	  (string[3] == 'i' || string[3] == 'I') &&
+	  (string[4] == 'f' || string[4] == 'F') &&
+	  (string[5] == 't' || string[5] == 'T') &&
+	  (string[6] == '>'));
+}
+
+static inline gboolean
+is_control (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'c' || string[1] == 'C') &&
+	  (string[2] == 'o' || string[2] == 'O') &&
+	  (string[3] == 'n' || string[3] == 'N') &&
+	  (string[4] == 't' || string[4] == 'T') &&
+	  (string[5] == 'r' || string[5] == 'R') &&
+	  (string[6] == 'o' || string[6] == 'O') &&
+	  (string[7] == 'l' || string[7] == 'L') &&
+	  (string[8] == '>'));
+}
+
+static inline gboolean
+is_release (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'r' || string[1] == 'R') &&
+	  (string[2] == 'e' || string[2] == 'E') &&
+	  (string[3] == 'l' || string[3] == 'L') &&
+	  (string[4] == 'e' || string[4] == 'E') &&
+	  (string[5] == 'a' || string[5] == 'A') &&
+	  (string[6] == 's' || string[6] == 'S') &&
+	  (string[7] == 'e' || string[7] == 'E') &&
+	  (string[8] == '>'));
+}
+
+static inline gboolean
+is_meta (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'm' || string[1] == 'M') &&
+	  (string[2] == 'e' || string[2] == 'E') &&
+	  (string[3] == 't' || string[3] == 'T') &&
+	  (string[4] == 'a' || string[4] == 'A') &&
+	  (string[5] == '>'));
+}
+
+static inline gboolean
+is_super (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 's' || string[1] == 'S') &&
+	  (string[2] == 'u' || string[2] == 'U') &&
+	  (string[3] == 'p' || string[3] == 'P') &&
+	  (string[4] == 'e' || string[4] == 'E') &&
+	  (string[5] == 'r' || string[5] == 'R') &&
+	  (string[6] == '>'));
+}
+
+static inline gboolean
+is_hyper (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'h' || string[1] == 'H') &&
+	  (string[2] == 'y' || string[2] == 'Y') &&
+	  (string[3] == 'p' || string[3] == 'P') &&
+	  (string[4] == 'e' || string[4] == 'E') &&
+	  (string[5] == 'r' || string[5] == 'R') &&
+	  (string[6] == '>'));
+}
+
+/**
+ * egg_accelerator_parse_virtual:
+ * @accelerator:      string representing an accelerator
+ * @accelerator_key:  return location for accelerator keyval
+ * @accelerator_mods: return location for accelerator modifier mask
+ *
+ * Parses a string representing a virtual accelerator. The format
+ * looks like "&lt;Control&gt;a" or "&lt;Shift&gt;&lt;Alt&gt;F1" or
+ * "&lt;Release&gt;z" (the last one is for key release).  The parser
+ * is fairly liberal and allows lower or upper case, and also
+ * abbreviations such as "&lt;Ctl&gt;" and "&lt;Ctrl&gt;".
+ *
+ * If the parse fails, @accelerator_key and @accelerator_mods will
+ * be set to 0 (zero) and %FALSE will be returned. If the string contains
+ * only modifiers, @accelerator_key will be set to 0 but %TRUE will be
+ * returned.
+ *
+ * The virtual vs. concrete accelerator distinction is a relic of
+ * how the X Window System works; there are modifiers Mod2-Mod5 that
+ * can represent various keyboard keys (numlock, meta, hyper, etc.),
+ * the virtual modifier represents the keyboard key, the concrete
+ * modifier the actual Mod2-Mod5 bits in the key press event.
+ *
+ * Returns: %TRUE on success.
+ */
+gboolean
+egg_accelerator_parse_virtual (const gchar            *accelerator,
+                               guint                  *accelerator_key,
+                               EggVirtualModifierType *accelerator_mods)
+{
+  guint keyval;
+  GdkModifierType mods;
+  gint len;
+  gboolean bad_keyval;
+
+  if (accelerator_key)
+    *accelerator_key = 0;
+  if (accelerator_mods)
+    *accelerator_mods = 0;
+
+  g_return_val_if_fail (accelerator != NULL, FALSE);
+
+  bad_keyval = FALSE;
+
+  keyval = 0;
+  mods = 0;
+  len = strlen (accelerator);
+  while (len)
+    {
+      if (*accelerator == '<')
+	{
+	  if (len >= 9 && is_release (accelerator))
+	    {
+	      accelerator += 9;
+	      len -= 9;
+	      mods |= EGG_VIRTUAL_RELEASE_MASK;
+	    }
+	  else if (len >= 9 && is_control (accelerator))
+	    {
+	      accelerator += 9;
+	      len -= 9;
+	      mods |= EGG_VIRTUAL_CONTROL_MASK;
+	    }
+	  else if (len >= 7 && is_shift (accelerator))
+	    {
+	      accelerator += 7;
+	      len -= 7;
+	      mods |= EGG_VIRTUAL_SHIFT_MASK;
+	    }
+	  else if (len >= 6 && is_shft (accelerator))
+	    {
+	      accelerator += 6;
+	      len -= 6;
+	      mods |= EGG_VIRTUAL_SHIFT_MASK;
+	    }
+	  else if (len >= 6 && is_ctrl (accelerator))
+	    {
+	      accelerator += 6;
+	      len -= 6;
+	      mods |= EGG_VIRTUAL_CONTROL_MASK;
+	    }
+	  else if (len >= 6 && is_modx (accelerator))
+	    {
+	      static const guint mod_vals[] = {
+		EGG_VIRTUAL_ALT_MASK, EGG_VIRTUAL_MOD2_MASK, EGG_VIRTUAL_MOD3_MASK,
+		EGG_VIRTUAL_MOD4_MASK, EGG_VIRTUAL_MOD5_MASK
+	      };
+
+	      len -= 6;
+	      accelerator += 4;
+	      mods |= mod_vals[*accelerator - '1'];
+	      accelerator += 2;
+	    }
+	  else if (len >= 5 && is_ctl (accelerator))
+	    {
+	      accelerator += 5;
+	      len -= 5;
+	      mods |= EGG_VIRTUAL_CONTROL_MASK;
+	    }
+	  else if (len >= 5 && is_alt (accelerator))
+	    {
+	      accelerator += 5;
+	      len -= 5;
+	      mods |= EGG_VIRTUAL_ALT_MASK;
+	    }
+          else if (len >= 6 && is_meta (accelerator))
+	    {
+	      accelerator += 6;
+	      len -= 6;
+	      mods |= EGG_VIRTUAL_META_MASK;
+	    }
+          else if (len >= 7 && is_hyper (accelerator))
+	    {
+	      accelerator += 7;
+	      len -= 7;
+	      mods |= EGG_VIRTUAL_HYPER_MASK;
+	    }
+          else if (len >= 7 && is_super (accelerator))
+	    {
+	      accelerator += 7;
+	      len -= 7;
+	      mods |= EGG_VIRTUAL_SUPER_MASK;
+	    }
+	  else
+	    {
+	      gchar last_ch;
+
+	      last_ch = *accelerator;
+	      while (last_ch && last_ch != '>')
+		{
+		  last_ch = *accelerator;
+		  accelerator += 1;
+		  len -= 1;
+		}
+	    }
+	}
+      else
+	{
+          keyval = gdk_keyval_from_name (accelerator);
+
+          if (keyval == 0)
+            bad_keyval = TRUE;
+
+          accelerator += len;
+          len -= len;
+	}
+    }
+
+  if (accelerator_key)
+    *accelerator_key = gdk_keyval_to_lower (keyval);
+  if (accelerator_mods)
+    *accelerator_mods = mods;
+
+  return !bad_keyval;
+}
+
+void
+egg_keymap_resolve_virtual_modifiers (GdkKeymap              *keymap,
+                                      EggVirtualModifierType  virtual_mods,
+                                      GdkModifierType        *concrete_mods)
+{
+  GdkModifierType concrete;
+  int i;
+  const EggModmap *modmap;
+
+  g_return_if_fail (GDK_IS_KEYMAP (keymap));
+  g_return_if_fail (concrete_mods != NULL);
+
+  modmap = egg_keymap_get_modmap (keymap);
+
+  /* Not so sure about this algorithm. */
+
+  concrete = 0;
+  i = 0;
+  while (i < EGG_MODMAP_ENTRY_LAST)
+    {
+      if (modmap->mapping[i] & virtual_mods)
+        concrete |= (1 << i);
+
+      ++i;
+    }
+
+  *concrete_mods = concrete;
+}
+
+void
+egg_keymap_virtualize_modifiers (GdkKeymap              *keymap,
+                                 GdkModifierType         concrete_mods,
+                                 EggVirtualModifierType *virtual_mods)
+{
+  GdkModifierType virtual;
+  int i;
+  const EggModmap *modmap;
+
+  g_return_if_fail (GDK_IS_KEYMAP (keymap));
+  g_return_if_fail (virtual_mods != NULL);
+
+  modmap = egg_keymap_get_modmap (keymap);
+
+  /* Not so sure about this algorithm. */
+
+  virtual = 0;
+  i = 0;
+  while (i < EGG_MODMAP_ENTRY_LAST)
+    {
+      if ((1 << i) & concrete_mods)
+        {
+          EggVirtualModifierType cleaned;
+
+          cleaned = modmap->mapping[i] & ~(EGG_VIRTUAL_MOD2_MASK |
+                                           EGG_VIRTUAL_MOD3_MASK |
+                                           EGG_VIRTUAL_MOD4_MASK |
+                                           EGG_VIRTUAL_MOD5_MASK);
+
+          if (cleaned != 0)
+            {
+              virtual |= cleaned;
+            }
+          else
+            {
+              /* Rather than dropping mod2->mod5 if not bound,
+               * go ahead and use the concrete names
+               */
+              virtual |= modmap->mapping[i];
+            }
+        }
+
+      ++i;
+    }
+
+  *virtual_mods = virtual;
+}
+
+static void
+reload_modmap (GdkKeymap *keymap,
+               EggModmap *modmap)
+{
+  XModifierKeymap *xmodmap;
+  int map_size;
+  int i;
+
+  /* FIXME multihead */
+  xmodmap = XGetModifierMapping (gdk_x11_get_default_xdisplay ());
+
+  memset (modmap->mapping, 0, sizeof (modmap->mapping));
+
+  /* there are 8 modifiers, and the first 3 are shift, shift lock,
+   * and control
+   */
+  map_size = 8 * xmodmap->max_keypermod;
+  i = 3 * xmodmap->max_keypermod;
+  while (i < map_size)
+    {
+      /* get the key code at this point in the map,
+       * see if its keysym is one we're interested in
+       */
+      int keycode = xmodmap->modifiermap[i];
+      GdkKeymapKey *keys;
+      guint *keyvals;
+      int n_entries;
+      int j;
+      EggVirtualModifierType mask;
+
+      keys = NULL;
+      keyvals = NULL;
+      n_entries = 0;
+
+      gdk_keymap_get_entries_for_keycode (keymap,
+                                          keycode,
+                                          &keys, &keyvals, &n_entries);
+
+      mask = 0;
+      j = 0;
+      while (j < n_entries)
+        {
+          if (keyvals[j] == GDK_KEY_Num_Lock)
+            mask |= EGG_VIRTUAL_NUM_LOCK_MASK;
+          else if (keyvals[j] == GDK_KEY_Scroll_Lock)
+            mask |= EGG_VIRTUAL_SCROLL_LOCK_MASK;
+          else if (keyvals[j] == GDK_KEY_Meta_L ||
+                   keyvals[j] == GDK_KEY_Meta_R)
+            mask |= EGG_VIRTUAL_META_MASK;
+          else if (keyvals[j] == GDK_KEY_Hyper_L ||
+                   keyvals[j] == GDK_KEY_Hyper_R)
+            mask |= EGG_VIRTUAL_HYPER_MASK;
+          else if (keyvals[j] == GDK_KEY_Super_L ||
+                   keyvals[j] == GDK_KEY_Super_R)
+            mask |= EGG_VIRTUAL_SUPER_MASK;
+          else if (keyvals[j] == GDK_KEY_Mode_switch)
+            mask |= EGG_VIRTUAL_MODE_SWITCH_MASK;
+
+          ++j;
+        }
+
+      /* Mod1Mask is 1 << 3 for example, i.e. the
+       * fourth modifier, i / keyspermod is the modifier
+       * index
+       */
+      modmap->mapping[i/xmodmap->max_keypermod] |= mask;
+
+      g_free (keyvals);
+      g_free (keys);
+
+      ++i;
+    }
+
+  /* Add in the not-really-virtual fixed entries */
+  modmap->mapping[EGG_MODMAP_ENTRY_SHIFT] |= EGG_VIRTUAL_SHIFT_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_CONTROL] |= EGG_VIRTUAL_CONTROL_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_LOCK] |= EGG_VIRTUAL_LOCK_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD1] |= EGG_VIRTUAL_ALT_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD2] |= EGG_VIRTUAL_MOD2_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD3] |= EGG_VIRTUAL_MOD3_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD4] |= EGG_VIRTUAL_MOD4_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD5] |= EGG_VIRTUAL_MOD5_MASK;
+
+  XFreeModifiermap (xmodmap);
+}
+
+const EggModmap*
+egg_keymap_get_modmap (GdkKeymap *keymap)
+{
+  EggModmap *modmap;
+
+  /* This is all a hack, much simpler when we can just
+   * modify GDK directly.
+   */
+
+  modmap = g_object_get_data (G_OBJECT (keymap),
+                              "egg-modmap");
+
+  if (modmap == NULL)
+    {
+      modmap = g_new0 (EggModmap, 1);
+
+      /* FIXME modify keymap change events with an event filter
+       * and force a reload if we get one
+       */
+
+      reload_modmap (keymap, modmap);
+
+      g_object_set_data_full (G_OBJECT (keymap),
+                              "egg-modmap",
+                              modmap,
+                              g_free);
+    }
+
+  g_assert (modmap != NULL);
+
+  return modmap;
+}
+
+
+
+ + + diff --git a/2020-04-20-005310-1134-cppcheck@c4c5242e5827_master/index.html b/2020-04-20-005310-1134-cppcheck@c4c5242e5827_master/index.html new file mode 100644 index 0000000..812f8b5 --- /dev/null +++ b/2020-04-20-005310-1134-cppcheck@c4c5242e5827_master/index.html @@ -0,0 +1,101 @@ + + + + + + Cppcheck - HTML report - mate-indicator-applet + + + + + + + +
+ + + + + + + +
LineIdCWESeverityMessage
0missingIncludeSysteminformationCppcheck cannot find all the include files (use --check-config for details)
src/eggaccelerators.c
321duplicateExpression398styleSame expression on both sides of '-='.
+
+ + + diff --git a/2020-04-20-005310-1134-cppcheck@c4c5242e5827_master/stats.html b/2020-04-20-005310-1134-cppcheck@c4c5242e5827_master/stats.html new file mode 100644 index 0000000..14ae0d4 --- /dev/null +++ b/2020-04-20-005310-1134-cppcheck@c4c5242e5827_master/stats.html @@ -0,0 +1,89 @@ + + + + + + Cppcheck - HTML report - mate-indicator-applet + + + + + + + +
+

Top 10 files for style severity, total findings: 1
+   1  src/eggaccelerators.c
+

+ +
+ + + diff --git a/2020-04-20-005310-1134-cppcheck@c4c5242e5827_master/style.css b/2020-04-20-005310-1134-cppcheck@c4c5242e5827_master/style.css new file mode 100644 index 0000000..c39571c --- /dev/null +++ b/2020-04-20-005310-1134-cppcheck@c4c5242e5827_master/style.css @@ -0,0 +1,149 @@ + +body { + font: 13px Arial, Verdana, Sans-Serif; + margin: 0; + width: auto; +} + +h1 { + margin: 10px; +} + +#footer > p { + margin: 4px; +} + +.error { + background-color: #ffb7b7; +} + +.error2 { + background-color: #faa; + border: 1px dotted black; + display: inline-block; + margin-left: 4px; +} + +.inconclusive { + background-color: #B6B6B4; +} + +.inconclusive2 { + background-color: #B6B6B4; + border: 1px dotted black; + display: inline-block; + margin-left: 4px; +} + +div.verbose { + display: inline-block; + vertical-align: top; + cursor: help; +} + +div.verbose div.content { + display: none; + position: absolute; + padding: 10px; + margin: 4px; + max-width: 40%; + white-space: pre-wrap; + border: 1px solid black; + background-color: #FFFFCC; + cursor: auto; +} + +.highlight .hll { + padding: 1px; +} + +#header { + border-bottom: thin solid #aaa; +} + +#menu { + float: left; + margin-top: 5px; + text-align: left; + width: 150px; + /*height: 75%;*/ + position: fixed; + overflow: auto; + z-index: 1; +} + +#menu_index { + float: left; + margin-top: 5px; + padding-left: 5px; + text-align: left; + width: 300px; + /*height: 75%;*/ + position: fixed; + overflow: auto; + z-index: 1; +} + +#menu > a { + display: block; + margin-left: 10px; + font: 12px; + z-index: 1; +} + +#filename { + margin-left: 10px; + font: 12px; + z-index: 1; +} + +.highlighttable { + background-color:white; + z-index: 10; + position: relative; + margin: -10 px; +} + +#content { + background-color: white; + -webkit-box-sizing: content-box; + -moz-box-sizing: content-box; + box-sizing: content-box; + float: left; + margin: 5px; + margin-left: 10px; + padding: 0 10px 10px 10px; + width: 80%; + padding-left: 150px; +} + +#content_index { + background-color: white; + -webkit-box-sizing: content-box; + -moz-box-sizing: content-box; + box-sizing: content-box; + float: left; + margin: 5px; + margin-left: 10px; + padding: 0 10px 10px 10px; + width: 80%; + padding-left: 300px; +} + +.linenos { + border-right: thin solid #aaa; + color: lightgray; + padding-right: 6px; +} + +#footer { + border-top: thin solid #aaa; + clear: both; + font-size: 90%; + margin-top: 5px; +} + +#footer ul { + list-style-type: none; + padding-left: 0; +} diff --git a/2020-04-20-194804-0062-cppcheck@fd5ae00d8191_travis/0.html b/2020-04-20-194804-0062-cppcheck@fd5ae00d8191_travis/0.html new file mode 100644 index 0000000..dfb584a --- /dev/null +++ b/2020-04-20-194804-0062-cppcheck@fd5ae00d8191_travis/0.html @@ -0,0 +1,1208 @@ + + + + + + Cppcheck - HTML report - mate-indicator-applet + + + + + + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
/* eggaccelerators.c
+ * Copyright (C) 2002  Red Hat, Inc.; Copyright 1998, 2001 Tim Janik
+ * Developed by Havoc Pennington, Tim Janik
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
+ */
+
+#include "eggaccelerators.h"
+
+#include <string.h>
+#include <gdk/gdkx.h>
+#include <gdk/gdkkeysyms.h>
+
+enum
+{
+  EGG_MODMAP_ENTRY_SHIFT   = 0,
+  EGG_MODMAP_ENTRY_LOCK    = 1,
+  EGG_MODMAP_ENTRY_CONTROL = 2,
+  EGG_MODMAP_ENTRY_MOD1    = 3,
+  EGG_MODMAP_ENTRY_MOD2    = 4,
+  EGG_MODMAP_ENTRY_MOD3    = 5,
+  EGG_MODMAP_ENTRY_MOD4    = 6,
+  EGG_MODMAP_ENTRY_MOD5    = 7,
+  EGG_MODMAP_ENTRY_LAST    = 8
+};
+
+#define MODMAP_ENTRY_TO_MODIFIER(x) (1 << (x))
+
+typedef struct
+{
+  EggVirtualModifierType mapping[EGG_MODMAP_ENTRY_LAST];
+
+} EggModmap;
+
+const EggModmap* egg_keymap_get_modmap (GdkKeymap *keymap);
+
+static inline gboolean
+is_alt (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'a' || string[1] == 'A') &&
+	  (string[2] == 'l' || string[2] == 'L') &&
+	  (string[3] == 't' || string[3] == 'T') &&
+	  (string[4] == '>'));
+}
+
+static inline gboolean
+is_ctl (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'c' || string[1] == 'C') &&
+	  (string[2] == 't' || string[2] == 'T') &&
+	  (string[3] == 'l' || string[3] == 'L') &&
+	  (string[4] == '>'));
+}
+
+static inline gboolean
+is_modx (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'm' || string[1] == 'M') &&
+	  (string[2] == 'o' || string[2] == 'O') &&
+	  (string[3] == 'd' || string[3] == 'D') &&
+	  (string[4] >= '1' && string[4] <= '5') &&
+	  (string[5] == '>'));
+}
+
+static inline gboolean
+is_ctrl (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'c' || string[1] == 'C') &&
+	  (string[2] == 't' || string[2] == 'T') &&
+	  (string[3] == 'r' || string[3] == 'R') &&
+	  (string[4] == 'l' || string[4] == 'L') &&
+	  (string[5] == '>'));
+}
+
+static inline gboolean
+is_shft (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 's' || string[1] == 'S') &&
+	  (string[2] == 'h' || string[2] == 'H') &&
+	  (string[3] == 'f' || string[3] == 'F') &&
+	  (string[4] == 't' || string[4] == 'T') &&
+	  (string[5] == '>'));
+}
+
+static inline gboolean
+is_shift (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 's' || string[1] == 'S') &&
+	  (string[2] == 'h' || string[2] == 'H') &&
+	  (string[3] == 'i' || string[3] == 'I') &&
+	  (string[4] == 'f' || string[4] == 'F') &&
+	  (string[5] == 't' || string[5] == 'T') &&
+	  (string[6] == '>'));
+}
+
+static inline gboolean
+is_control (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'c' || string[1] == 'C') &&
+	  (string[2] == 'o' || string[2] == 'O') &&
+	  (string[3] == 'n' || string[3] == 'N') &&
+	  (string[4] == 't' || string[4] == 'T') &&
+	  (string[5] == 'r' || string[5] == 'R') &&
+	  (string[6] == 'o' || string[6] == 'O') &&
+	  (string[7] == 'l' || string[7] == 'L') &&
+	  (string[8] == '>'));
+}
+
+static inline gboolean
+is_release (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'r' || string[1] == 'R') &&
+	  (string[2] == 'e' || string[2] == 'E') &&
+	  (string[3] == 'l' || string[3] == 'L') &&
+	  (string[4] == 'e' || string[4] == 'E') &&
+	  (string[5] == 'a' || string[5] == 'A') &&
+	  (string[6] == 's' || string[6] == 'S') &&
+	  (string[7] == 'e' || string[7] == 'E') &&
+	  (string[8] == '>'));
+}
+
+static inline gboolean
+is_meta (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'm' || string[1] == 'M') &&
+	  (string[2] == 'e' || string[2] == 'E') &&
+	  (string[3] == 't' || string[3] == 'T') &&
+	  (string[4] == 'a' || string[4] == 'A') &&
+	  (string[5] == '>'));
+}
+
+static inline gboolean
+is_super (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 's' || string[1] == 'S') &&
+	  (string[2] == 'u' || string[2] == 'U') &&
+	  (string[3] == 'p' || string[3] == 'P') &&
+	  (string[4] == 'e' || string[4] == 'E') &&
+	  (string[5] == 'r' || string[5] == 'R') &&
+	  (string[6] == '>'));
+}
+
+static inline gboolean
+is_hyper (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'h' || string[1] == 'H') &&
+	  (string[2] == 'y' || string[2] == 'Y') &&
+	  (string[3] == 'p' || string[3] == 'P') &&
+	  (string[4] == 'e' || string[4] == 'E') &&
+	  (string[5] == 'r' || string[5] == 'R') &&
+	  (string[6] == '>'));
+}
+
+/**
+ * egg_accelerator_parse_virtual:
+ * @accelerator:      string representing an accelerator
+ * @accelerator_key:  return location for accelerator keyval
+ * @accelerator_mods: return location for accelerator modifier mask
+ *
+ * Parses a string representing a virtual accelerator. The format
+ * looks like "&lt;Control&gt;a" or "&lt;Shift&gt;&lt;Alt&gt;F1" or
+ * "&lt;Release&gt;z" (the last one is for key release).  The parser
+ * is fairly liberal and allows lower or upper case, and also
+ * abbreviations such as "&lt;Ctl&gt;" and "&lt;Ctrl&gt;".
+ *
+ * If the parse fails, @accelerator_key and @accelerator_mods will
+ * be set to 0 (zero) and %FALSE will be returned. If the string contains
+ * only modifiers, @accelerator_key will be set to 0 but %TRUE will be
+ * returned.
+ *
+ * The virtual vs. concrete accelerator distinction is a relic of
+ * how the X Window System works; there are modifiers Mod2-Mod5 that
+ * can represent various keyboard keys (numlock, meta, hyper, etc.),
+ * the virtual modifier represents the keyboard key, the concrete
+ * modifier the actual Mod2-Mod5 bits in the key press event.
+ *
+ * Returns: %TRUE on success.
+ */
+gboolean
+egg_accelerator_parse_virtual (const gchar            *accelerator,
+                               guint                  *accelerator_key,
+                               EggVirtualModifierType *accelerator_mods)
+{
+  guint keyval;
+  GdkModifierType mods;
+  gint len;
+  gboolean bad_keyval;
+
+  if (accelerator_key)
+    *accelerator_key = 0;
+  if (accelerator_mods)
+    *accelerator_mods = 0;
+
+  g_return_val_if_fail (accelerator != NULL, FALSE);
+
+  bad_keyval = FALSE;
+
+  keyval = 0;
+  mods = 0;
+  len = strlen (accelerator);
+  while (len)
+    {
+      if (*accelerator == '<')
+	{
+	  if (len >= 9 && is_release (accelerator))
+	    {
+	      accelerator += 9;
+	      len -= 9;
+	      mods |= EGG_VIRTUAL_RELEASE_MASK;
+	    }
+	  else if (len >= 9 && is_control (accelerator))
+	    {
+	      accelerator += 9;
+	      len -= 9;
+	      mods |= EGG_VIRTUAL_CONTROL_MASK;
+	    }
+	  else if (len >= 7 && is_shift (accelerator))
+	    {
+	      accelerator += 7;
+	      len -= 7;
+	      mods |= EGG_VIRTUAL_SHIFT_MASK;
+	    }
+	  else if (len >= 6 && is_shft (accelerator))
+	    {
+	      accelerator += 6;
+	      len -= 6;
+	      mods |= EGG_VIRTUAL_SHIFT_MASK;
+	    }
+	  else if (len >= 6 && is_ctrl (accelerator))
+	    {
+	      accelerator += 6;
+	      len -= 6;
+	      mods |= EGG_VIRTUAL_CONTROL_MASK;
+	    }
+	  else if (len >= 6 && is_modx (accelerator))
+	    {
+	      static const guint mod_vals[] = {
+		EGG_VIRTUAL_ALT_MASK, EGG_VIRTUAL_MOD2_MASK, EGG_VIRTUAL_MOD3_MASK,
+		EGG_VIRTUAL_MOD4_MASK, EGG_VIRTUAL_MOD5_MASK
+	      };
+
+	      len -= 6;
+	      accelerator += 4;
+	      mods |= mod_vals[*accelerator - '1'];
+	      accelerator += 2;
+	    }
+	  else if (len >= 5 && is_ctl (accelerator))
+	    {
+	      accelerator += 5;
+	      len -= 5;
+	      mods |= EGG_VIRTUAL_CONTROL_MASK;
+	    }
+	  else if (len >= 5 && is_alt (accelerator))
+	    {
+	      accelerator += 5;
+	      len -= 5;
+	      mods |= EGG_VIRTUAL_ALT_MASK;
+	    }
+          else if (len >= 6 && is_meta (accelerator))
+	    {
+	      accelerator += 6;
+	      len -= 6;
+	      mods |= EGG_VIRTUAL_META_MASK;
+	    }
+          else if (len >= 7 && is_hyper (accelerator))
+	    {
+	      accelerator += 7;
+	      len -= 7;
+	      mods |= EGG_VIRTUAL_HYPER_MASK;
+	    }
+          else if (len >= 7 && is_super (accelerator))
+	    {
+	      accelerator += 7;
+	      len -= 7;
+	      mods |= EGG_VIRTUAL_SUPER_MASK;
+	    }
+	  else
+	    {
+	      gchar last_ch;
+
+	      last_ch = *accelerator;
+	      while (last_ch && last_ch != '>')
+		{
+		  last_ch = *accelerator;
+		  accelerator += 1;
+		  len -= 1;
+		}
+	    }
+	}
+      else
+	{
+          keyval = gdk_keyval_from_name (accelerator);
+
+          if (keyval == 0)
+            bad_keyval = TRUE;
+
+          accelerator += len;
+          len -= len;
+	}
+    }
+
+  if (accelerator_key)
+    *accelerator_key = gdk_keyval_to_lower (keyval);
+  if (accelerator_mods)
+    *accelerator_mods = mods;
+
+  return !bad_keyval;
+}
+
+void
+egg_keymap_resolve_virtual_modifiers (GdkKeymap              *keymap,
+                                      EggVirtualModifierType  virtual_mods,
+                                      GdkModifierType        *concrete_mods)
+{
+  GdkModifierType concrete;
+  int i;
+  const EggModmap *modmap;
+
+  g_return_if_fail (GDK_IS_KEYMAP (keymap));
+  g_return_if_fail (concrete_mods != NULL);
+
+  modmap = egg_keymap_get_modmap (keymap);
+
+  /* Not so sure about this algorithm. */
+
+  concrete = 0;
+  i = 0;
+  while (i < EGG_MODMAP_ENTRY_LAST)
+    {
+      if (modmap->mapping[i] & virtual_mods)
+        concrete |= (1 << i);
+
+      ++i;
+    }
+
+  *concrete_mods = concrete;
+}
+
+void
+egg_keymap_virtualize_modifiers (GdkKeymap              *keymap,
+                                 GdkModifierType         concrete_mods,
+                                 EggVirtualModifierType *virtual_mods)
+{
+  GdkModifierType virtual;
+  int i;
+  const EggModmap *modmap;
+
+  g_return_if_fail (GDK_IS_KEYMAP (keymap));
+  g_return_if_fail (virtual_mods != NULL);
+
+  modmap = egg_keymap_get_modmap (keymap);
+
+  /* Not so sure about this algorithm. */
+
+  virtual = 0;
+  i = 0;
+  while (i < EGG_MODMAP_ENTRY_LAST)
+    {
+      if ((1 << i) & concrete_mods)
+        {
+          EggVirtualModifierType cleaned;
+
+          cleaned = modmap->mapping[i] & ~(EGG_VIRTUAL_MOD2_MASK |
+                                           EGG_VIRTUAL_MOD3_MASK |
+                                           EGG_VIRTUAL_MOD4_MASK |
+                                           EGG_VIRTUAL_MOD5_MASK);
+
+          if (cleaned != 0)
+            {
+              virtual |= cleaned;
+            }
+          else
+            {
+              /* Rather than dropping mod2->mod5 if not bound,
+               * go ahead and use the concrete names
+               */
+              virtual |= modmap->mapping[i];
+            }
+        }
+
+      ++i;
+    }
+
+  *virtual_mods = virtual;
+}
+
+static void
+reload_modmap (GdkKeymap *keymap,
+               EggModmap *modmap)
+{
+  XModifierKeymap *xmodmap;
+  int map_size;
+  int i;
+
+  /* FIXME multihead */
+  xmodmap = XGetModifierMapping (gdk_x11_get_default_xdisplay ());
+
+  memset (modmap->mapping, 0, sizeof (modmap->mapping));
+
+  /* there are 8 modifiers, and the first 3 are shift, shift lock,
+   * and control
+   */
+  map_size = 8 * xmodmap->max_keypermod;
+  i = 3 * xmodmap->max_keypermod;
+  while (i < map_size)
+    {
+      /* get the key code at this point in the map,
+       * see if its keysym is one we're interested in
+       */
+      int keycode = xmodmap->modifiermap[i];
+      GdkKeymapKey *keys;
+      guint *keyvals;
+      int n_entries;
+      int j;
+      EggVirtualModifierType mask;
+
+      keys = NULL;
+      keyvals = NULL;
+      n_entries = 0;
+
+      gdk_keymap_get_entries_for_keycode (keymap,
+                                          keycode,
+                                          &keys, &keyvals, &n_entries);
+
+      mask = 0;
+      j = 0;
+      while (j < n_entries)
+        {
+          if (keyvals[j] == GDK_KEY_Num_Lock)
+            mask |= EGG_VIRTUAL_NUM_LOCK_MASK;
+          else if (keyvals[j] == GDK_KEY_Scroll_Lock)
+            mask |= EGG_VIRTUAL_SCROLL_LOCK_MASK;
+          else if (keyvals[j] == GDK_KEY_Meta_L ||
+                   keyvals[j] == GDK_KEY_Meta_R)
+            mask |= EGG_VIRTUAL_META_MASK;
+          else if (keyvals[j] == GDK_KEY_Hyper_L ||
+                   keyvals[j] == GDK_KEY_Hyper_R)
+            mask |= EGG_VIRTUAL_HYPER_MASK;
+          else if (keyvals[j] == GDK_KEY_Super_L ||
+                   keyvals[j] == GDK_KEY_Super_R)
+            mask |= EGG_VIRTUAL_SUPER_MASK;
+          else if (keyvals[j] == GDK_KEY_Mode_switch)
+            mask |= EGG_VIRTUAL_MODE_SWITCH_MASK;
+
+          ++j;
+        }
+
+      /* Mod1Mask is 1 << 3 for example, i.e. the
+       * fourth modifier, i / keyspermod is the modifier
+       * index
+       */
+      modmap->mapping[i/xmodmap->max_keypermod] |= mask;
+
+      g_free (keyvals);
+      g_free (keys);
+
+      ++i;
+    }
+
+  /* Add in the not-really-virtual fixed entries */
+  modmap->mapping[EGG_MODMAP_ENTRY_SHIFT] |= EGG_VIRTUAL_SHIFT_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_CONTROL] |= EGG_VIRTUAL_CONTROL_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_LOCK] |= EGG_VIRTUAL_LOCK_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD1] |= EGG_VIRTUAL_ALT_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD2] |= EGG_VIRTUAL_MOD2_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD3] |= EGG_VIRTUAL_MOD3_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD4] |= EGG_VIRTUAL_MOD4_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD5] |= EGG_VIRTUAL_MOD5_MASK;
+
+  XFreeModifiermap (xmodmap);
+}
+
+const EggModmap*
+egg_keymap_get_modmap (GdkKeymap *keymap)
+{
+  EggModmap *modmap;
+
+  /* This is all a hack, much simpler when we can just
+   * modify GDK directly.
+   */
+
+  modmap = g_object_get_data (G_OBJECT (keymap),
+                              "egg-modmap");
+
+  if (modmap == NULL)
+    {
+      modmap = g_new0 (EggModmap, 1);
+
+      /* FIXME modify keymap change events with an event filter
+       * and force a reload if we get one
+       */
+
+      reload_modmap (keymap, modmap);
+
+      g_object_set_data_full (G_OBJECT (keymap),
+                              "egg-modmap",
+                              modmap,
+                              g_free);
+    }
+
+  g_assert (modmap != NULL);
+
+  return modmap;
+}
+
+
+
+ + + diff --git a/2020-04-20-194804-0062-cppcheck@fd5ae00d8191_travis/index.html b/2020-04-20-194804-0062-cppcheck@fd5ae00d8191_travis/index.html new file mode 100644 index 0000000..812f8b5 --- /dev/null +++ b/2020-04-20-194804-0062-cppcheck@fd5ae00d8191_travis/index.html @@ -0,0 +1,101 @@ + + + + + + Cppcheck - HTML report - mate-indicator-applet + + + + + + + +
+ + + + + + + +
LineIdCWESeverityMessage
0missingIncludeSysteminformationCppcheck cannot find all the include files (use --check-config for details)
src/eggaccelerators.c
321duplicateExpression398styleSame expression on both sides of '-='.
+
+ + + diff --git a/2020-04-20-194804-0062-cppcheck@fd5ae00d8191_travis/stats.html b/2020-04-20-194804-0062-cppcheck@fd5ae00d8191_travis/stats.html new file mode 100644 index 0000000..14ae0d4 --- /dev/null +++ b/2020-04-20-194804-0062-cppcheck@fd5ae00d8191_travis/stats.html @@ -0,0 +1,89 @@ + + + + + + Cppcheck - HTML report - mate-indicator-applet + + + + + + + +
+

Top 10 files for style severity, total findings: 1
+   1  src/eggaccelerators.c
+

+ +
+ + + diff --git a/2020-04-20-194804-0062-cppcheck@fd5ae00d8191_travis/style.css b/2020-04-20-194804-0062-cppcheck@fd5ae00d8191_travis/style.css new file mode 100644 index 0000000..c39571c --- /dev/null +++ b/2020-04-20-194804-0062-cppcheck@fd5ae00d8191_travis/style.css @@ -0,0 +1,149 @@ + +body { + font: 13px Arial, Verdana, Sans-Serif; + margin: 0; + width: auto; +} + +h1 { + margin: 10px; +} + +#footer > p { + margin: 4px; +} + +.error { + background-color: #ffb7b7; +} + +.error2 { + background-color: #faa; + border: 1px dotted black; + display: inline-block; + margin-left: 4px; +} + +.inconclusive { + background-color: #B6B6B4; +} + +.inconclusive2 { + background-color: #B6B6B4; + border: 1px dotted black; + display: inline-block; + margin-left: 4px; +} + +div.verbose { + display: inline-block; + vertical-align: top; + cursor: help; +} + +div.verbose div.content { + display: none; + position: absolute; + padding: 10px; + margin: 4px; + max-width: 40%; + white-space: pre-wrap; + border: 1px solid black; + background-color: #FFFFCC; + cursor: auto; +} + +.highlight .hll { + padding: 1px; +} + +#header { + border-bottom: thin solid #aaa; +} + +#menu { + float: left; + margin-top: 5px; + text-align: left; + width: 150px; + /*height: 75%;*/ + position: fixed; + overflow: auto; + z-index: 1; +} + +#menu_index { + float: left; + margin-top: 5px; + padding-left: 5px; + text-align: left; + width: 300px; + /*height: 75%;*/ + position: fixed; + overflow: auto; + z-index: 1; +} + +#menu > a { + display: block; + margin-left: 10px; + font: 12px; + z-index: 1; +} + +#filename { + margin-left: 10px; + font: 12px; + z-index: 1; +} + +.highlighttable { + background-color:white; + z-index: 10; + position: relative; + margin: -10 px; +} + +#content { + background-color: white; + -webkit-box-sizing: content-box; + -moz-box-sizing: content-box; + box-sizing: content-box; + float: left; + margin: 5px; + margin-left: 10px; + padding: 0 10px 10px 10px; + width: 80%; + padding-left: 150px; +} + +#content_index { + background-color: white; + -webkit-box-sizing: content-box; + -moz-box-sizing: content-box; + box-sizing: content-box; + float: left; + margin: 5px; + margin-left: 10px; + padding: 0 10px 10px 10px; + width: 80%; + padding-left: 300px; +} + +.linenos { + border-right: thin solid #aaa; + color: lightgray; + padding-right: 6px; +} + +#footer { + border-top: thin solid #aaa; + clear: both; + font-size: 90%; + margin-top: 5px; +} + +#footer ul { + list-style-type: none; + padding-left: 0; +} diff --git a/2020-04-20-204711-9247-cppcheck@5155c763c825_master/0.html b/2020-04-20-204711-9247-cppcheck@5155c763c825_master/0.html new file mode 100644 index 0000000..dfb584a --- /dev/null +++ b/2020-04-20-204711-9247-cppcheck@5155c763c825_master/0.html @@ -0,0 +1,1208 @@ + + + + + + Cppcheck - HTML report - mate-indicator-applet + + + + + + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
/* eggaccelerators.c
+ * Copyright (C) 2002  Red Hat, Inc.; Copyright 1998, 2001 Tim Janik
+ * Developed by Havoc Pennington, Tim Janik
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
+ */
+
+#include "eggaccelerators.h"
+
+#include <string.h>
+#include <gdk/gdkx.h>
+#include <gdk/gdkkeysyms.h>
+
+enum
+{
+  EGG_MODMAP_ENTRY_SHIFT   = 0,
+  EGG_MODMAP_ENTRY_LOCK    = 1,
+  EGG_MODMAP_ENTRY_CONTROL = 2,
+  EGG_MODMAP_ENTRY_MOD1    = 3,
+  EGG_MODMAP_ENTRY_MOD2    = 4,
+  EGG_MODMAP_ENTRY_MOD3    = 5,
+  EGG_MODMAP_ENTRY_MOD4    = 6,
+  EGG_MODMAP_ENTRY_MOD5    = 7,
+  EGG_MODMAP_ENTRY_LAST    = 8
+};
+
+#define MODMAP_ENTRY_TO_MODIFIER(x) (1 << (x))
+
+typedef struct
+{
+  EggVirtualModifierType mapping[EGG_MODMAP_ENTRY_LAST];
+
+} EggModmap;
+
+const EggModmap* egg_keymap_get_modmap (GdkKeymap *keymap);
+
+static inline gboolean
+is_alt (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'a' || string[1] == 'A') &&
+	  (string[2] == 'l' || string[2] == 'L') &&
+	  (string[3] == 't' || string[3] == 'T') &&
+	  (string[4] == '>'));
+}
+
+static inline gboolean
+is_ctl (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'c' || string[1] == 'C') &&
+	  (string[2] == 't' || string[2] == 'T') &&
+	  (string[3] == 'l' || string[3] == 'L') &&
+	  (string[4] == '>'));
+}
+
+static inline gboolean
+is_modx (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'm' || string[1] == 'M') &&
+	  (string[2] == 'o' || string[2] == 'O') &&
+	  (string[3] == 'd' || string[3] == 'D') &&
+	  (string[4] >= '1' && string[4] <= '5') &&
+	  (string[5] == '>'));
+}
+
+static inline gboolean
+is_ctrl (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'c' || string[1] == 'C') &&
+	  (string[2] == 't' || string[2] == 'T') &&
+	  (string[3] == 'r' || string[3] == 'R') &&
+	  (string[4] == 'l' || string[4] == 'L') &&
+	  (string[5] == '>'));
+}
+
+static inline gboolean
+is_shft (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 's' || string[1] == 'S') &&
+	  (string[2] == 'h' || string[2] == 'H') &&
+	  (string[3] == 'f' || string[3] == 'F') &&
+	  (string[4] == 't' || string[4] == 'T') &&
+	  (string[5] == '>'));
+}
+
+static inline gboolean
+is_shift (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 's' || string[1] == 'S') &&
+	  (string[2] == 'h' || string[2] == 'H') &&
+	  (string[3] == 'i' || string[3] == 'I') &&
+	  (string[4] == 'f' || string[4] == 'F') &&
+	  (string[5] == 't' || string[5] == 'T') &&
+	  (string[6] == '>'));
+}
+
+static inline gboolean
+is_control (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'c' || string[1] == 'C') &&
+	  (string[2] == 'o' || string[2] == 'O') &&
+	  (string[3] == 'n' || string[3] == 'N') &&
+	  (string[4] == 't' || string[4] == 'T') &&
+	  (string[5] == 'r' || string[5] == 'R') &&
+	  (string[6] == 'o' || string[6] == 'O') &&
+	  (string[7] == 'l' || string[7] == 'L') &&
+	  (string[8] == '>'));
+}
+
+static inline gboolean
+is_release (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'r' || string[1] == 'R') &&
+	  (string[2] == 'e' || string[2] == 'E') &&
+	  (string[3] == 'l' || string[3] == 'L') &&
+	  (string[4] == 'e' || string[4] == 'E') &&
+	  (string[5] == 'a' || string[5] == 'A') &&
+	  (string[6] == 's' || string[6] == 'S') &&
+	  (string[7] == 'e' || string[7] == 'E') &&
+	  (string[8] == '>'));
+}
+
+static inline gboolean
+is_meta (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'm' || string[1] == 'M') &&
+	  (string[2] == 'e' || string[2] == 'E') &&
+	  (string[3] == 't' || string[3] == 'T') &&
+	  (string[4] == 'a' || string[4] == 'A') &&
+	  (string[5] == '>'));
+}
+
+static inline gboolean
+is_super (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 's' || string[1] == 'S') &&
+	  (string[2] == 'u' || string[2] == 'U') &&
+	  (string[3] == 'p' || string[3] == 'P') &&
+	  (string[4] == 'e' || string[4] == 'E') &&
+	  (string[5] == 'r' || string[5] == 'R') &&
+	  (string[6] == '>'));
+}
+
+static inline gboolean
+is_hyper (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'h' || string[1] == 'H') &&
+	  (string[2] == 'y' || string[2] == 'Y') &&
+	  (string[3] == 'p' || string[3] == 'P') &&
+	  (string[4] == 'e' || string[4] == 'E') &&
+	  (string[5] == 'r' || string[5] == 'R') &&
+	  (string[6] == '>'));
+}
+
+/**
+ * egg_accelerator_parse_virtual:
+ * @accelerator:      string representing an accelerator
+ * @accelerator_key:  return location for accelerator keyval
+ * @accelerator_mods: return location for accelerator modifier mask
+ *
+ * Parses a string representing a virtual accelerator. The format
+ * looks like "&lt;Control&gt;a" or "&lt;Shift&gt;&lt;Alt&gt;F1" or
+ * "&lt;Release&gt;z" (the last one is for key release).  The parser
+ * is fairly liberal and allows lower or upper case, and also
+ * abbreviations such as "&lt;Ctl&gt;" and "&lt;Ctrl&gt;".
+ *
+ * If the parse fails, @accelerator_key and @accelerator_mods will
+ * be set to 0 (zero) and %FALSE will be returned. If the string contains
+ * only modifiers, @accelerator_key will be set to 0 but %TRUE will be
+ * returned.
+ *
+ * The virtual vs. concrete accelerator distinction is a relic of
+ * how the X Window System works; there are modifiers Mod2-Mod5 that
+ * can represent various keyboard keys (numlock, meta, hyper, etc.),
+ * the virtual modifier represents the keyboard key, the concrete
+ * modifier the actual Mod2-Mod5 bits in the key press event.
+ *
+ * Returns: %TRUE on success.
+ */
+gboolean
+egg_accelerator_parse_virtual (const gchar            *accelerator,
+                               guint                  *accelerator_key,
+                               EggVirtualModifierType *accelerator_mods)
+{
+  guint keyval;
+  GdkModifierType mods;
+  gint len;
+  gboolean bad_keyval;
+
+  if (accelerator_key)
+    *accelerator_key = 0;
+  if (accelerator_mods)
+    *accelerator_mods = 0;
+
+  g_return_val_if_fail (accelerator != NULL, FALSE);
+
+  bad_keyval = FALSE;
+
+  keyval = 0;
+  mods = 0;
+  len = strlen (accelerator);
+  while (len)
+    {
+      if (*accelerator == '<')
+	{
+	  if (len >= 9 && is_release (accelerator))
+	    {
+	      accelerator += 9;
+	      len -= 9;
+	      mods |= EGG_VIRTUAL_RELEASE_MASK;
+	    }
+	  else if (len >= 9 && is_control (accelerator))
+	    {
+	      accelerator += 9;
+	      len -= 9;
+	      mods |= EGG_VIRTUAL_CONTROL_MASK;
+	    }
+	  else if (len >= 7 && is_shift (accelerator))
+	    {
+	      accelerator += 7;
+	      len -= 7;
+	      mods |= EGG_VIRTUAL_SHIFT_MASK;
+	    }
+	  else if (len >= 6 && is_shft (accelerator))
+	    {
+	      accelerator += 6;
+	      len -= 6;
+	      mods |= EGG_VIRTUAL_SHIFT_MASK;
+	    }
+	  else if (len >= 6 && is_ctrl (accelerator))
+	    {
+	      accelerator += 6;
+	      len -= 6;
+	      mods |= EGG_VIRTUAL_CONTROL_MASK;
+	    }
+	  else if (len >= 6 && is_modx (accelerator))
+	    {
+	      static const guint mod_vals[] = {
+		EGG_VIRTUAL_ALT_MASK, EGG_VIRTUAL_MOD2_MASK, EGG_VIRTUAL_MOD3_MASK,
+		EGG_VIRTUAL_MOD4_MASK, EGG_VIRTUAL_MOD5_MASK
+	      };
+
+	      len -= 6;
+	      accelerator += 4;
+	      mods |= mod_vals[*accelerator - '1'];
+	      accelerator += 2;
+	    }
+	  else if (len >= 5 && is_ctl (accelerator))
+	    {
+	      accelerator += 5;
+	      len -= 5;
+	      mods |= EGG_VIRTUAL_CONTROL_MASK;
+	    }
+	  else if (len >= 5 && is_alt (accelerator))
+	    {
+	      accelerator += 5;
+	      len -= 5;
+	      mods |= EGG_VIRTUAL_ALT_MASK;
+	    }
+          else if (len >= 6 && is_meta (accelerator))
+	    {
+	      accelerator += 6;
+	      len -= 6;
+	      mods |= EGG_VIRTUAL_META_MASK;
+	    }
+          else if (len >= 7 && is_hyper (accelerator))
+	    {
+	      accelerator += 7;
+	      len -= 7;
+	      mods |= EGG_VIRTUAL_HYPER_MASK;
+	    }
+          else if (len >= 7 && is_super (accelerator))
+	    {
+	      accelerator += 7;
+	      len -= 7;
+	      mods |= EGG_VIRTUAL_SUPER_MASK;
+	    }
+	  else
+	    {
+	      gchar last_ch;
+
+	      last_ch = *accelerator;
+	      while (last_ch && last_ch != '>')
+		{
+		  last_ch = *accelerator;
+		  accelerator += 1;
+		  len -= 1;
+		}
+	    }
+	}
+      else
+	{
+          keyval = gdk_keyval_from_name (accelerator);
+
+          if (keyval == 0)
+            bad_keyval = TRUE;
+
+          accelerator += len;
+          len -= len;
+	}
+    }
+
+  if (accelerator_key)
+    *accelerator_key = gdk_keyval_to_lower (keyval);
+  if (accelerator_mods)
+    *accelerator_mods = mods;
+
+  return !bad_keyval;
+}
+
+void
+egg_keymap_resolve_virtual_modifiers (GdkKeymap              *keymap,
+                                      EggVirtualModifierType  virtual_mods,
+                                      GdkModifierType        *concrete_mods)
+{
+  GdkModifierType concrete;
+  int i;
+  const EggModmap *modmap;
+
+  g_return_if_fail (GDK_IS_KEYMAP (keymap));
+  g_return_if_fail (concrete_mods != NULL);
+
+  modmap = egg_keymap_get_modmap (keymap);
+
+  /* Not so sure about this algorithm. */
+
+  concrete = 0;
+  i = 0;
+  while (i < EGG_MODMAP_ENTRY_LAST)
+    {
+      if (modmap->mapping[i] & virtual_mods)
+        concrete |= (1 << i);
+
+      ++i;
+    }
+
+  *concrete_mods = concrete;
+}
+
+void
+egg_keymap_virtualize_modifiers (GdkKeymap              *keymap,
+                                 GdkModifierType         concrete_mods,
+                                 EggVirtualModifierType *virtual_mods)
+{
+  GdkModifierType virtual;
+  int i;
+  const EggModmap *modmap;
+
+  g_return_if_fail (GDK_IS_KEYMAP (keymap));
+  g_return_if_fail (virtual_mods != NULL);
+
+  modmap = egg_keymap_get_modmap (keymap);
+
+  /* Not so sure about this algorithm. */
+
+  virtual = 0;
+  i = 0;
+  while (i < EGG_MODMAP_ENTRY_LAST)
+    {
+      if ((1 << i) & concrete_mods)
+        {
+          EggVirtualModifierType cleaned;
+
+          cleaned = modmap->mapping[i] & ~(EGG_VIRTUAL_MOD2_MASK |
+                                           EGG_VIRTUAL_MOD3_MASK |
+                                           EGG_VIRTUAL_MOD4_MASK |
+                                           EGG_VIRTUAL_MOD5_MASK);
+
+          if (cleaned != 0)
+            {
+              virtual |= cleaned;
+            }
+          else
+            {
+              /* Rather than dropping mod2->mod5 if not bound,
+               * go ahead and use the concrete names
+               */
+              virtual |= modmap->mapping[i];
+            }
+        }
+
+      ++i;
+    }
+
+  *virtual_mods = virtual;
+}
+
+static void
+reload_modmap (GdkKeymap *keymap,
+               EggModmap *modmap)
+{
+  XModifierKeymap *xmodmap;
+  int map_size;
+  int i;
+
+  /* FIXME multihead */
+  xmodmap = XGetModifierMapping (gdk_x11_get_default_xdisplay ());
+
+  memset (modmap->mapping, 0, sizeof (modmap->mapping));
+
+  /* there are 8 modifiers, and the first 3 are shift, shift lock,
+   * and control
+   */
+  map_size = 8 * xmodmap->max_keypermod;
+  i = 3 * xmodmap->max_keypermod;
+  while (i < map_size)
+    {
+      /* get the key code at this point in the map,
+       * see if its keysym is one we're interested in
+       */
+      int keycode = xmodmap->modifiermap[i];
+      GdkKeymapKey *keys;
+      guint *keyvals;
+      int n_entries;
+      int j;
+      EggVirtualModifierType mask;
+
+      keys = NULL;
+      keyvals = NULL;
+      n_entries = 0;
+
+      gdk_keymap_get_entries_for_keycode (keymap,
+                                          keycode,
+                                          &keys, &keyvals, &n_entries);
+
+      mask = 0;
+      j = 0;
+      while (j < n_entries)
+        {
+          if (keyvals[j] == GDK_KEY_Num_Lock)
+            mask |= EGG_VIRTUAL_NUM_LOCK_MASK;
+          else if (keyvals[j] == GDK_KEY_Scroll_Lock)
+            mask |= EGG_VIRTUAL_SCROLL_LOCK_MASK;
+          else if (keyvals[j] == GDK_KEY_Meta_L ||
+                   keyvals[j] == GDK_KEY_Meta_R)
+            mask |= EGG_VIRTUAL_META_MASK;
+          else if (keyvals[j] == GDK_KEY_Hyper_L ||
+                   keyvals[j] == GDK_KEY_Hyper_R)
+            mask |= EGG_VIRTUAL_HYPER_MASK;
+          else if (keyvals[j] == GDK_KEY_Super_L ||
+                   keyvals[j] == GDK_KEY_Super_R)
+            mask |= EGG_VIRTUAL_SUPER_MASK;
+          else if (keyvals[j] == GDK_KEY_Mode_switch)
+            mask |= EGG_VIRTUAL_MODE_SWITCH_MASK;
+
+          ++j;
+        }
+
+      /* Mod1Mask is 1 << 3 for example, i.e. the
+       * fourth modifier, i / keyspermod is the modifier
+       * index
+       */
+      modmap->mapping[i/xmodmap->max_keypermod] |= mask;
+
+      g_free (keyvals);
+      g_free (keys);
+
+      ++i;
+    }
+
+  /* Add in the not-really-virtual fixed entries */
+  modmap->mapping[EGG_MODMAP_ENTRY_SHIFT] |= EGG_VIRTUAL_SHIFT_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_CONTROL] |= EGG_VIRTUAL_CONTROL_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_LOCK] |= EGG_VIRTUAL_LOCK_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD1] |= EGG_VIRTUAL_ALT_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD2] |= EGG_VIRTUAL_MOD2_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD3] |= EGG_VIRTUAL_MOD3_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD4] |= EGG_VIRTUAL_MOD4_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD5] |= EGG_VIRTUAL_MOD5_MASK;
+
+  XFreeModifiermap (xmodmap);
+}
+
+const EggModmap*
+egg_keymap_get_modmap (GdkKeymap *keymap)
+{
+  EggModmap *modmap;
+
+  /* This is all a hack, much simpler when we can just
+   * modify GDK directly.
+   */
+
+  modmap = g_object_get_data (G_OBJECT (keymap),
+                              "egg-modmap");
+
+  if (modmap == NULL)
+    {
+      modmap = g_new0 (EggModmap, 1);
+
+      /* FIXME modify keymap change events with an event filter
+       * and force a reload if we get one
+       */
+
+      reload_modmap (keymap, modmap);
+
+      g_object_set_data_full (G_OBJECT (keymap),
+                              "egg-modmap",
+                              modmap,
+                              g_free);
+    }
+
+  g_assert (modmap != NULL);
+
+  return modmap;
+}
+
+
+
+ + + diff --git a/2020-04-20-204711-9247-cppcheck@5155c763c825_master/index.html b/2020-04-20-204711-9247-cppcheck@5155c763c825_master/index.html new file mode 100644 index 0000000..812f8b5 --- /dev/null +++ b/2020-04-20-204711-9247-cppcheck@5155c763c825_master/index.html @@ -0,0 +1,101 @@ + + + + + + Cppcheck - HTML report - mate-indicator-applet + + + + + + + +
+ + + + + + + +
LineIdCWESeverityMessage
0missingIncludeSysteminformationCppcheck cannot find all the include files (use --check-config for details)
src/eggaccelerators.c
321duplicateExpression398styleSame expression on both sides of '-='.
+
+ + + diff --git a/2020-04-20-204711-9247-cppcheck@5155c763c825_master/stats.html b/2020-04-20-204711-9247-cppcheck@5155c763c825_master/stats.html new file mode 100644 index 0000000..14ae0d4 --- /dev/null +++ b/2020-04-20-204711-9247-cppcheck@5155c763c825_master/stats.html @@ -0,0 +1,89 @@ + + + + + + Cppcheck - HTML report - mate-indicator-applet + + + + + + + +
+

Top 10 files for style severity, total findings: 1
+   1  src/eggaccelerators.c
+

+ +
+ + + diff --git a/2020-04-20-204711-9247-cppcheck@5155c763c825_master/style.css b/2020-04-20-204711-9247-cppcheck@5155c763c825_master/style.css new file mode 100644 index 0000000..c39571c --- /dev/null +++ b/2020-04-20-204711-9247-cppcheck@5155c763c825_master/style.css @@ -0,0 +1,149 @@ + +body { + font: 13px Arial, Verdana, Sans-Serif; + margin: 0; + width: auto; +} + +h1 { + margin: 10px; +} + +#footer > p { + margin: 4px; +} + +.error { + background-color: #ffb7b7; +} + +.error2 { + background-color: #faa; + border: 1px dotted black; + display: inline-block; + margin-left: 4px; +} + +.inconclusive { + background-color: #B6B6B4; +} + +.inconclusive2 { + background-color: #B6B6B4; + border: 1px dotted black; + display: inline-block; + margin-left: 4px; +} + +div.verbose { + display: inline-block; + vertical-align: top; + cursor: help; +} + +div.verbose div.content { + display: none; + position: absolute; + padding: 10px; + margin: 4px; + max-width: 40%; + white-space: pre-wrap; + border: 1px solid black; + background-color: #FFFFCC; + cursor: auto; +} + +.highlight .hll { + padding: 1px; +} + +#header { + border-bottom: thin solid #aaa; +} + +#menu { + float: left; + margin-top: 5px; + text-align: left; + width: 150px; + /*height: 75%;*/ + position: fixed; + overflow: auto; + z-index: 1; +} + +#menu_index { + float: left; + margin-top: 5px; + padding-left: 5px; + text-align: left; + width: 300px; + /*height: 75%;*/ + position: fixed; + overflow: auto; + z-index: 1; +} + +#menu > a { + display: block; + margin-left: 10px; + font: 12px; + z-index: 1; +} + +#filename { + margin-left: 10px; + font: 12px; + z-index: 1; +} + +.highlighttable { + background-color:white; + z-index: 10; + position: relative; + margin: -10 px; +} + +#content { + background-color: white; + -webkit-box-sizing: content-box; + -moz-box-sizing: content-box; + box-sizing: content-box; + float: left; + margin: 5px; + margin-left: 10px; + padding: 0 10px 10px 10px; + width: 80%; + padding-left: 150px; +} + +#content_index { + background-color: white; + -webkit-box-sizing: content-box; + -moz-box-sizing: content-box; + box-sizing: content-box; + float: left; + margin: 5px; + margin-left: 10px; + padding: 0 10px 10px 10px; + width: 80%; + padding-left: 300px; +} + +.linenos { + border-right: thin solid #aaa; + color: lightgray; + padding-right: 6px; +} + +#footer { + border-top: thin solid #aaa; + clear: both; + font-size: 90%; + margin-top: 5px; +} + +#footer ul { + list-style-type: none; + padding-left: 0; +} diff --git a/2020-06-22-162728-2181-cppcheck@9e512823070d_travis-ci/0.html b/2020-06-22-162728-2181-cppcheck@9e512823070d_travis-ci/0.html new file mode 100644 index 0000000..dfb584a --- /dev/null +++ b/2020-06-22-162728-2181-cppcheck@9e512823070d_travis-ci/0.html @@ -0,0 +1,1208 @@ + + + + + + Cppcheck - HTML report - mate-indicator-applet + + + + + + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
/* eggaccelerators.c
+ * Copyright (C) 2002  Red Hat, Inc.; Copyright 1998, 2001 Tim Janik
+ * Developed by Havoc Pennington, Tim Janik
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
+ */
+
+#include "eggaccelerators.h"
+
+#include <string.h>
+#include <gdk/gdkx.h>
+#include <gdk/gdkkeysyms.h>
+
+enum
+{
+  EGG_MODMAP_ENTRY_SHIFT   = 0,
+  EGG_MODMAP_ENTRY_LOCK    = 1,
+  EGG_MODMAP_ENTRY_CONTROL = 2,
+  EGG_MODMAP_ENTRY_MOD1    = 3,
+  EGG_MODMAP_ENTRY_MOD2    = 4,
+  EGG_MODMAP_ENTRY_MOD3    = 5,
+  EGG_MODMAP_ENTRY_MOD4    = 6,
+  EGG_MODMAP_ENTRY_MOD5    = 7,
+  EGG_MODMAP_ENTRY_LAST    = 8
+};
+
+#define MODMAP_ENTRY_TO_MODIFIER(x) (1 << (x))
+
+typedef struct
+{
+  EggVirtualModifierType mapping[EGG_MODMAP_ENTRY_LAST];
+
+} EggModmap;
+
+const EggModmap* egg_keymap_get_modmap (GdkKeymap *keymap);
+
+static inline gboolean
+is_alt (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'a' || string[1] == 'A') &&
+	  (string[2] == 'l' || string[2] == 'L') &&
+	  (string[3] == 't' || string[3] == 'T') &&
+	  (string[4] == '>'));
+}
+
+static inline gboolean
+is_ctl (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'c' || string[1] == 'C') &&
+	  (string[2] == 't' || string[2] == 'T') &&
+	  (string[3] == 'l' || string[3] == 'L') &&
+	  (string[4] == '>'));
+}
+
+static inline gboolean
+is_modx (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'm' || string[1] == 'M') &&
+	  (string[2] == 'o' || string[2] == 'O') &&
+	  (string[3] == 'd' || string[3] == 'D') &&
+	  (string[4] >= '1' && string[4] <= '5') &&
+	  (string[5] == '>'));
+}
+
+static inline gboolean
+is_ctrl (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'c' || string[1] == 'C') &&
+	  (string[2] == 't' || string[2] == 'T') &&
+	  (string[3] == 'r' || string[3] == 'R') &&
+	  (string[4] == 'l' || string[4] == 'L') &&
+	  (string[5] == '>'));
+}
+
+static inline gboolean
+is_shft (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 's' || string[1] == 'S') &&
+	  (string[2] == 'h' || string[2] == 'H') &&
+	  (string[3] == 'f' || string[3] == 'F') &&
+	  (string[4] == 't' || string[4] == 'T') &&
+	  (string[5] == '>'));
+}
+
+static inline gboolean
+is_shift (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 's' || string[1] == 'S') &&
+	  (string[2] == 'h' || string[2] == 'H') &&
+	  (string[3] == 'i' || string[3] == 'I') &&
+	  (string[4] == 'f' || string[4] == 'F') &&
+	  (string[5] == 't' || string[5] == 'T') &&
+	  (string[6] == '>'));
+}
+
+static inline gboolean
+is_control (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'c' || string[1] == 'C') &&
+	  (string[2] == 'o' || string[2] == 'O') &&
+	  (string[3] == 'n' || string[3] == 'N') &&
+	  (string[4] == 't' || string[4] == 'T') &&
+	  (string[5] == 'r' || string[5] == 'R') &&
+	  (string[6] == 'o' || string[6] == 'O') &&
+	  (string[7] == 'l' || string[7] == 'L') &&
+	  (string[8] == '>'));
+}
+
+static inline gboolean
+is_release (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'r' || string[1] == 'R') &&
+	  (string[2] == 'e' || string[2] == 'E') &&
+	  (string[3] == 'l' || string[3] == 'L') &&
+	  (string[4] == 'e' || string[4] == 'E') &&
+	  (string[5] == 'a' || string[5] == 'A') &&
+	  (string[6] == 's' || string[6] == 'S') &&
+	  (string[7] == 'e' || string[7] == 'E') &&
+	  (string[8] == '>'));
+}
+
+static inline gboolean
+is_meta (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'm' || string[1] == 'M') &&
+	  (string[2] == 'e' || string[2] == 'E') &&
+	  (string[3] == 't' || string[3] == 'T') &&
+	  (string[4] == 'a' || string[4] == 'A') &&
+	  (string[5] == '>'));
+}
+
+static inline gboolean
+is_super (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 's' || string[1] == 'S') &&
+	  (string[2] == 'u' || string[2] == 'U') &&
+	  (string[3] == 'p' || string[3] == 'P') &&
+	  (string[4] == 'e' || string[4] == 'E') &&
+	  (string[5] == 'r' || string[5] == 'R') &&
+	  (string[6] == '>'));
+}
+
+static inline gboolean
+is_hyper (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'h' || string[1] == 'H') &&
+	  (string[2] == 'y' || string[2] == 'Y') &&
+	  (string[3] == 'p' || string[3] == 'P') &&
+	  (string[4] == 'e' || string[4] == 'E') &&
+	  (string[5] == 'r' || string[5] == 'R') &&
+	  (string[6] == '>'));
+}
+
+/**
+ * egg_accelerator_parse_virtual:
+ * @accelerator:      string representing an accelerator
+ * @accelerator_key:  return location for accelerator keyval
+ * @accelerator_mods: return location for accelerator modifier mask
+ *
+ * Parses a string representing a virtual accelerator. The format
+ * looks like "&lt;Control&gt;a" or "&lt;Shift&gt;&lt;Alt&gt;F1" or
+ * "&lt;Release&gt;z" (the last one is for key release).  The parser
+ * is fairly liberal and allows lower or upper case, and also
+ * abbreviations such as "&lt;Ctl&gt;" and "&lt;Ctrl&gt;".
+ *
+ * If the parse fails, @accelerator_key and @accelerator_mods will
+ * be set to 0 (zero) and %FALSE will be returned. If the string contains
+ * only modifiers, @accelerator_key will be set to 0 but %TRUE will be
+ * returned.
+ *
+ * The virtual vs. concrete accelerator distinction is a relic of
+ * how the X Window System works; there are modifiers Mod2-Mod5 that
+ * can represent various keyboard keys (numlock, meta, hyper, etc.),
+ * the virtual modifier represents the keyboard key, the concrete
+ * modifier the actual Mod2-Mod5 bits in the key press event.
+ *
+ * Returns: %TRUE on success.
+ */
+gboolean
+egg_accelerator_parse_virtual (const gchar            *accelerator,
+                               guint                  *accelerator_key,
+                               EggVirtualModifierType *accelerator_mods)
+{
+  guint keyval;
+  GdkModifierType mods;
+  gint len;
+  gboolean bad_keyval;
+
+  if (accelerator_key)
+    *accelerator_key = 0;
+  if (accelerator_mods)
+    *accelerator_mods = 0;
+
+  g_return_val_if_fail (accelerator != NULL, FALSE);
+
+  bad_keyval = FALSE;
+
+  keyval = 0;
+  mods = 0;
+  len = strlen (accelerator);
+  while (len)
+    {
+      if (*accelerator == '<')
+	{
+	  if (len >= 9 && is_release (accelerator))
+	    {
+	      accelerator += 9;
+	      len -= 9;
+	      mods |= EGG_VIRTUAL_RELEASE_MASK;
+	    }
+	  else if (len >= 9 && is_control (accelerator))
+	    {
+	      accelerator += 9;
+	      len -= 9;
+	      mods |= EGG_VIRTUAL_CONTROL_MASK;
+	    }
+	  else if (len >= 7 && is_shift (accelerator))
+	    {
+	      accelerator += 7;
+	      len -= 7;
+	      mods |= EGG_VIRTUAL_SHIFT_MASK;
+	    }
+	  else if (len >= 6 && is_shft (accelerator))
+	    {
+	      accelerator += 6;
+	      len -= 6;
+	      mods |= EGG_VIRTUAL_SHIFT_MASK;
+	    }
+	  else if (len >= 6 && is_ctrl (accelerator))
+	    {
+	      accelerator += 6;
+	      len -= 6;
+	      mods |= EGG_VIRTUAL_CONTROL_MASK;
+	    }
+	  else if (len >= 6 && is_modx (accelerator))
+	    {
+	      static const guint mod_vals[] = {
+		EGG_VIRTUAL_ALT_MASK, EGG_VIRTUAL_MOD2_MASK, EGG_VIRTUAL_MOD3_MASK,
+		EGG_VIRTUAL_MOD4_MASK, EGG_VIRTUAL_MOD5_MASK
+	      };
+
+	      len -= 6;
+	      accelerator += 4;
+	      mods |= mod_vals[*accelerator - '1'];
+	      accelerator += 2;
+	    }
+	  else if (len >= 5 && is_ctl (accelerator))
+	    {
+	      accelerator += 5;
+	      len -= 5;
+	      mods |= EGG_VIRTUAL_CONTROL_MASK;
+	    }
+	  else if (len >= 5 && is_alt (accelerator))
+	    {
+	      accelerator += 5;
+	      len -= 5;
+	      mods |= EGG_VIRTUAL_ALT_MASK;
+	    }
+          else if (len >= 6 && is_meta (accelerator))
+	    {
+	      accelerator += 6;
+	      len -= 6;
+	      mods |= EGG_VIRTUAL_META_MASK;
+	    }
+          else if (len >= 7 && is_hyper (accelerator))
+	    {
+	      accelerator += 7;
+	      len -= 7;
+	      mods |= EGG_VIRTUAL_HYPER_MASK;
+	    }
+          else if (len >= 7 && is_super (accelerator))
+	    {
+	      accelerator += 7;
+	      len -= 7;
+	      mods |= EGG_VIRTUAL_SUPER_MASK;
+	    }
+	  else
+	    {
+	      gchar last_ch;
+
+	      last_ch = *accelerator;
+	      while (last_ch && last_ch != '>')
+		{
+		  last_ch = *accelerator;
+		  accelerator += 1;
+		  len -= 1;
+		}
+	    }
+	}
+      else
+	{
+          keyval = gdk_keyval_from_name (accelerator);
+
+          if (keyval == 0)
+            bad_keyval = TRUE;
+
+          accelerator += len;
+          len -= len;
+	}
+    }
+
+  if (accelerator_key)
+    *accelerator_key = gdk_keyval_to_lower (keyval);
+  if (accelerator_mods)
+    *accelerator_mods = mods;
+
+  return !bad_keyval;
+}
+
+void
+egg_keymap_resolve_virtual_modifiers (GdkKeymap              *keymap,
+                                      EggVirtualModifierType  virtual_mods,
+                                      GdkModifierType        *concrete_mods)
+{
+  GdkModifierType concrete;
+  int i;
+  const EggModmap *modmap;
+
+  g_return_if_fail (GDK_IS_KEYMAP (keymap));
+  g_return_if_fail (concrete_mods != NULL);
+
+  modmap = egg_keymap_get_modmap (keymap);
+
+  /* Not so sure about this algorithm. */
+
+  concrete = 0;
+  i = 0;
+  while (i < EGG_MODMAP_ENTRY_LAST)
+    {
+      if (modmap->mapping[i] & virtual_mods)
+        concrete |= (1 << i);
+
+      ++i;
+    }
+
+  *concrete_mods = concrete;
+}
+
+void
+egg_keymap_virtualize_modifiers (GdkKeymap              *keymap,
+                                 GdkModifierType         concrete_mods,
+                                 EggVirtualModifierType *virtual_mods)
+{
+  GdkModifierType virtual;
+  int i;
+  const EggModmap *modmap;
+
+  g_return_if_fail (GDK_IS_KEYMAP (keymap));
+  g_return_if_fail (virtual_mods != NULL);
+
+  modmap = egg_keymap_get_modmap (keymap);
+
+  /* Not so sure about this algorithm. */
+
+  virtual = 0;
+  i = 0;
+  while (i < EGG_MODMAP_ENTRY_LAST)
+    {
+      if ((1 << i) & concrete_mods)
+        {
+          EggVirtualModifierType cleaned;
+
+          cleaned = modmap->mapping[i] & ~(EGG_VIRTUAL_MOD2_MASK |
+                                           EGG_VIRTUAL_MOD3_MASK |
+                                           EGG_VIRTUAL_MOD4_MASK |
+                                           EGG_VIRTUAL_MOD5_MASK);
+
+          if (cleaned != 0)
+            {
+              virtual |= cleaned;
+            }
+          else
+            {
+              /* Rather than dropping mod2->mod5 if not bound,
+               * go ahead and use the concrete names
+               */
+              virtual |= modmap->mapping[i];
+            }
+        }
+
+      ++i;
+    }
+
+  *virtual_mods = virtual;
+}
+
+static void
+reload_modmap (GdkKeymap *keymap,
+               EggModmap *modmap)
+{
+  XModifierKeymap *xmodmap;
+  int map_size;
+  int i;
+
+  /* FIXME multihead */
+  xmodmap = XGetModifierMapping (gdk_x11_get_default_xdisplay ());
+
+  memset (modmap->mapping, 0, sizeof (modmap->mapping));
+
+  /* there are 8 modifiers, and the first 3 are shift, shift lock,
+   * and control
+   */
+  map_size = 8 * xmodmap->max_keypermod;
+  i = 3 * xmodmap->max_keypermod;
+  while (i < map_size)
+    {
+      /* get the key code at this point in the map,
+       * see if its keysym is one we're interested in
+       */
+      int keycode = xmodmap->modifiermap[i];
+      GdkKeymapKey *keys;
+      guint *keyvals;
+      int n_entries;
+      int j;
+      EggVirtualModifierType mask;
+
+      keys = NULL;
+      keyvals = NULL;
+      n_entries = 0;
+
+      gdk_keymap_get_entries_for_keycode (keymap,
+                                          keycode,
+                                          &keys, &keyvals, &n_entries);
+
+      mask = 0;
+      j = 0;
+      while (j < n_entries)
+        {
+          if (keyvals[j] == GDK_KEY_Num_Lock)
+            mask |= EGG_VIRTUAL_NUM_LOCK_MASK;
+          else if (keyvals[j] == GDK_KEY_Scroll_Lock)
+            mask |= EGG_VIRTUAL_SCROLL_LOCK_MASK;
+          else if (keyvals[j] == GDK_KEY_Meta_L ||
+                   keyvals[j] == GDK_KEY_Meta_R)
+            mask |= EGG_VIRTUAL_META_MASK;
+          else if (keyvals[j] == GDK_KEY_Hyper_L ||
+                   keyvals[j] == GDK_KEY_Hyper_R)
+            mask |= EGG_VIRTUAL_HYPER_MASK;
+          else if (keyvals[j] == GDK_KEY_Super_L ||
+                   keyvals[j] == GDK_KEY_Super_R)
+            mask |= EGG_VIRTUAL_SUPER_MASK;
+          else if (keyvals[j] == GDK_KEY_Mode_switch)
+            mask |= EGG_VIRTUAL_MODE_SWITCH_MASK;
+
+          ++j;
+        }
+
+      /* Mod1Mask is 1 << 3 for example, i.e. the
+       * fourth modifier, i / keyspermod is the modifier
+       * index
+       */
+      modmap->mapping[i/xmodmap->max_keypermod] |= mask;
+
+      g_free (keyvals);
+      g_free (keys);
+
+      ++i;
+    }
+
+  /* Add in the not-really-virtual fixed entries */
+  modmap->mapping[EGG_MODMAP_ENTRY_SHIFT] |= EGG_VIRTUAL_SHIFT_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_CONTROL] |= EGG_VIRTUAL_CONTROL_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_LOCK] |= EGG_VIRTUAL_LOCK_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD1] |= EGG_VIRTUAL_ALT_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD2] |= EGG_VIRTUAL_MOD2_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD3] |= EGG_VIRTUAL_MOD3_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD4] |= EGG_VIRTUAL_MOD4_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD5] |= EGG_VIRTUAL_MOD5_MASK;
+
+  XFreeModifiermap (xmodmap);
+}
+
+const EggModmap*
+egg_keymap_get_modmap (GdkKeymap *keymap)
+{
+  EggModmap *modmap;
+
+  /* This is all a hack, much simpler when we can just
+   * modify GDK directly.
+   */
+
+  modmap = g_object_get_data (G_OBJECT (keymap),
+                              "egg-modmap");
+
+  if (modmap == NULL)
+    {
+      modmap = g_new0 (EggModmap, 1);
+
+      /* FIXME modify keymap change events with an event filter
+       * and force a reload if we get one
+       */
+
+      reload_modmap (keymap, modmap);
+
+      g_object_set_data_full (G_OBJECT (keymap),
+                              "egg-modmap",
+                              modmap,
+                              g_free);
+    }
+
+  g_assert (modmap != NULL);
+
+  return modmap;
+}
+
+
+
+ + + diff --git a/2020-06-22-162728-2181-cppcheck@9e512823070d_travis-ci/index.html b/2020-06-22-162728-2181-cppcheck@9e512823070d_travis-ci/index.html new file mode 100644 index 0000000..812f8b5 --- /dev/null +++ b/2020-06-22-162728-2181-cppcheck@9e512823070d_travis-ci/index.html @@ -0,0 +1,101 @@ + + + + + + Cppcheck - HTML report - mate-indicator-applet + + + + + + + +
+ + + + + + + +
LineIdCWESeverityMessage
0missingIncludeSysteminformationCppcheck cannot find all the include files (use --check-config for details)
src/eggaccelerators.c
321duplicateExpression398styleSame expression on both sides of '-='.
+
+ + + diff --git a/2020-06-22-162728-2181-cppcheck@9e512823070d_travis-ci/stats.html b/2020-06-22-162728-2181-cppcheck@9e512823070d_travis-ci/stats.html new file mode 100644 index 0000000..14ae0d4 --- /dev/null +++ b/2020-06-22-162728-2181-cppcheck@9e512823070d_travis-ci/stats.html @@ -0,0 +1,89 @@ + + + + + + Cppcheck - HTML report - mate-indicator-applet + + + + + + + +
+

Top 10 files for style severity, total findings: 1
+   1  src/eggaccelerators.c
+

+ +
+ + + diff --git a/2020-06-22-162728-2181-cppcheck@9e512823070d_travis-ci/style.css b/2020-06-22-162728-2181-cppcheck@9e512823070d_travis-ci/style.css new file mode 100644 index 0000000..c39571c --- /dev/null +++ b/2020-06-22-162728-2181-cppcheck@9e512823070d_travis-ci/style.css @@ -0,0 +1,149 @@ + +body { + font: 13px Arial, Verdana, Sans-Serif; + margin: 0; + width: auto; +} + +h1 { + margin: 10px; +} + +#footer > p { + margin: 4px; +} + +.error { + background-color: #ffb7b7; +} + +.error2 { + background-color: #faa; + border: 1px dotted black; + display: inline-block; + margin-left: 4px; +} + +.inconclusive { + background-color: #B6B6B4; +} + +.inconclusive2 { + background-color: #B6B6B4; + border: 1px dotted black; + display: inline-block; + margin-left: 4px; +} + +div.verbose { + display: inline-block; + vertical-align: top; + cursor: help; +} + +div.verbose div.content { + display: none; + position: absolute; + padding: 10px; + margin: 4px; + max-width: 40%; + white-space: pre-wrap; + border: 1px solid black; + background-color: #FFFFCC; + cursor: auto; +} + +.highlight .hll { + padding: 1px; +} + +#header { + border-bottom: thin solid #aaa; +} + +#menu { + float: left; + margin-top: 5px; + text-align: left; + width: 150px; + /*height: 75%;*/ + position: fixed; + overflow: auto; + z-index: 1; +} + +#menu_index { + float: left; + margin-top: 5px; + padding-left: 5px; + text-align: left; + width: 300px; + /*height: 75%;*/ + position: fixed; + overflow: auto; + z-index: 1; +} + +#menu > a { + display: block; + margin-left: 10px; + font: 12px; + z-index: 1; +} + +#filename { + margin-left: 10px; + font: 12px; + z-index: 1; +} + +.highlighttable { + background-color:white; + z-index: 10; + position: relative; + margin: -10 px; +} + +#content { + background-color: white; + -webkit-box-sizing: content-box; + -moz-box-sizing: content-box; + box-sizing: content-box; + float: left; + margin: 5px; + margin-left: 10px; + padding: 0 10px 10px 10px; + width: 80%; + padding-left: 150px; +} + +#content_index { + background-color: white; + -webkit-box-sizing: content-box; + -moz-box-sizing: content-box; + box-sizing: content-box; + float: left; + margin: 5px; + margin-left: 10px; + padding: 0 10px 10px 10px; + width: 80%; + padding-left: 300px; +} + +.linenos { + border-right: thin solid #aaa; + color: lightgray; + padding-right: 6px; +} + +#footer { + border-top: thin solid #aaa; + clear: both; + font-size: 90%; + margin-top: 5px; +} + +#footer ul { + list-style-type: none; + padding-left: 0; +} diff --git a/2020-06-26-094257-4646-cppcheck@741c50ee9687_master/0.html b/2020-06-26-094257-4646-cppcheck@741c50ee9687_master/0.html new file mode 100644 index 0000000..dfb584a --- /dev/null +++ b/2020-06-26-094257-4646-cppcheck@741c50ee9687_master/0.html @@ -0,0 +1,1208 @@ + + + + + + Cppcheck - HTML report - mate-indicator-applet + + + + + + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
/* eggaccelerators.c
+ * Copyright (C) 2002  Red Hat, Inc.; Copyright 1998, 2001 Tim Janik
+ * Developed by Havoc Pennington, Tim Janik
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
+ */
+
+#include "eggaccelerators.h"
+
+#include <string.h>
+#include <gdk/gdkx.h>
+#include <gdk/gdkkeysyms.h>
+
+enum
+{
+  EGG_MODMAP_ENTRY_SHIFT   = 0,
+  EGG_MODMAP_ENTRY_LOCK    = 1,
+  EGG_MODMAP_ENTRY_CONTROL = 2,
+  EGG_MODMAP_ENTRY_MOD1    = 3,
+  EGG_MODMAP_ENTRY_MOD2    = 4,
+  EGG_MODMAP_ENTRY_MOD3    = 5,
+  EGG_MODMAP_ENTRY_MOD4    = 6,
+  EGG_MODMAP_ENTRY_MOD5    = 7,
+  EGG_MODMAP_ENTRY_LAST    = 8
+};
+
+#define MODMAP_ENTRY_TO_MODIFIER(x) (1 << (x))
+
+typedef struct
+{
+  EggVirtualModifierType mapping[EGG_MODMAP_ENTRY_LAST];
+
+} EggModmap;
+
+const EggModmap* egg_keymap_get_modmap (GdkKeymap *keymap);
+
+static inline gboolean
+is_alt (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'a' || string[1] == 'A') &&
+	  (string[2] == 'l' || string[2] == 'L') &&
+	  (string[3] == 't' || string[3] == 'T') &&
+	  (string[4] == '>'));
+}
+
+static inline gboolean
+is_ctl (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'c' || string[1] == 'C') &&
+	  (string[2] == 't' || string[2] == 'T') &&
+	  (string[3] == 'l' || string[3] == 'L') &&
+	  (string[4] == '>'));
+}
+
+static inline gboolean
+is_modx (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'm' || string[1] == 'M') &&
+	  (string[2] == 'o' || string[2] == 'O') &&
+	  (string[3] == 'd' || string[3] == 'D') &&
+	  (string[4] >= '1' && string[4] <= '5') &&
+	  (string[5] == '>'));
+}
+
+static inline gboolean
+is_ctrl (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'c' || string[1] == 'C') &&
+	  (string[2] == 't' || string[2] == 'T') &&
+	  (string[3] == 'r' || string[3] == 'R') &&
+	  (string[4] == 'l' || string[4] == 'L') &&
+	  (string[5] == '>'));
+}
+
+static inline gboolean
+is_shft (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 's' || string[1] == 'S') &&
+	  (string[2] == 'h' || string[2] == 'H') &&
+	  (string[3] == 'f' || string[3] == 'F') &&
+	  (string[4] == 't' || string[4] == 'T') &&
+	  (string[5] == '>'));
+}
+
+static inline gboolean
+is_shift (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 's' || string[1] == 'S') &&
+	  (string[2] == 'h' || string[2] == 'H') &&
+	  (string[3] == 'i' || string[3] == 'I') &&
+	  (string[4] == 'f' || string[4] == 'F') &&
+	  (string[5] == 't' || string[5] == 'T') &&
+	  (string[6] == '>'));
+}
+
+static inline gboolean
+is_control (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'c' || string[1] == 'C') &&
+	  (string[2] == 'o' || string[2] == 'O') &&
+	  (string[3] == 'n' || string[3] == 'N') &&
+	  (string[4] == 't' || string[4] == 'T') &&
+	  (string[5] == 'r' || string[5] == 'R') &&
+	  (string[6] == 'o' || string[6] == 'O') &&
+	  (string[7] == 'l' || string[7] == 'L') &&
+	  (string[8] == '>'));
+}
+
+static inline gboolean
+is_release (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'r' || string[1] == 'R') &&
+	  (string[2] == 'e' || string[2] == 'E') &&
+	  (string[3] == 'l' || string[3] == 'L') &&
+	  (string[4] == 'e' || string[4] == 'E') &&
+	  (string[5] == 'a' || string[5] == 'A') &&
+	  (string[6] == 's' || string[6] == 'S') &&
+	  (string[7] == 'e' || string[7] == 'E') &&
+	  (string[8] == '>'));
+}
+
+static inline gboolean
+is_meta (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'm' || string[1] == 'M') &&
+	  (string[2] == 'e' || string[2] == 'E') &&
+	  (string[3] == 't' || string[3] == 'T') &&
+	  (string[4] == 'a' || string[4] == 'A') &&
+	  (string[5] == '>'));
+}
+
+static inline gboolean
+is_super (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 's' || string[1] == 'S') &&
+	  (string[2] == 'u' || string[2] == 'U') &&
+	  (string[3] == 'p' || string[3] == 'P') &&
+	  (string[4] == 'e' || string[4] == 'E') &&
+	  (string[5] == 'r' || string[5] == 'R') &&
+	  (string[6] == '>'));
+}
+
+static inline gboolean
+is_hyper (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'h' || string[1] == 'H') &&
+	  (string[2] == 'y' || string[2] == 'Y') &&
+	  (string[3] == 'p' || string[3] == 'P') &&
+	  (string[4] == 'e' || string[4] == 'E') &&
+	  (string[5] == 'r' || string[5] == 'R') &&
+	  (string[6] == '>'));
+}
+
+/**
+ * egg_accelerator_parse_virtual:
+ * @accelerator:      string representing an accelerator
+ * @accelerator_key:  return location for accelerator keyval
+ * @accelerator_mods: return location for accelerator modifier mask
+ *
+ * Parses a string representing a virtual accelerator. The format
+ * looks like "&lt;Control&gt;a" or "&lt;Shift&gt;&lt;Alt&gt;F1" or
+ * "&lt;Release&gt;z" (the last one is for key release).  The parser
+ * is fairly liberal and allows lower or upper case, and also
+ * abbreviations such as "&lt;Ctl&gt;" and "&lt;Ctrl&gt;".
+ *
+ * If the parse fails, @accelerator_key and @accelerator_mods will
+ * be set to 0 (zero) and %FALSE will be returned. If the string contains
+ * only modifiers, @accelerator_key will be set to 0 but %TRUE will be
+ * returned.
+ *
+ * The virtual vs. concrete accelerator distinction is a relic of
+ * how the X Window System works; there are modifiers Mod2-Mod5 that
+ * can represent various keyboard keys (numlock, meta, hyper, etc.),
+ * the virtual modifier represents the keyboard key, the concrete
+ * modifier the actual Mod2-Mod5 bits in the key press event.
+ *
+ * Returns: %TRUE on success.
+ */
+gboolean
+egg_accelerator_parse_virtual (const gchar            *accelerator,
+                               guint                  *accelerator_key,
+                               EggVirtualModifierType *accelerator_mods)
+{
+  guint keyval;
+  GdkModifierType mods;
+  gint len;
+  gboolean bad_keyval;
+
+  if (accelerator_key)
+    *accelerator_key = 0;
+  if (accelerator_mods)
+    *accelerator_mods = 0;
+
+  g_return_val_if_fail (accelerator != NULL, FALSE);
+
+  bad_keyval = FALSE;
+
+  keyval = 0;
+  mods = 0;
+  len = strlen (accelerator);
+  while (len)
+    {
+      if (*accelerator == '<')
+	{
+	  if (len >= 9 && is_release (accelerator))
+	    {
+	      accelerator += 9;
+	      len -= 9;
+	      mods |= EGG_VIRTUAL_RELEASE_MASK;
+	    }
+	  else if (len >= 9 && is_control (accelerator))
+	    {
+	      accelerator += 9;
+	      len -= 9;
+	      mods |= EGG_VIRTUAL_CONTROL_MASK;
+	    }
+	  else if (len >= 7 && is_shift (accelerator))
+	    {
+	      accelerator += 7;
+	      len -= 7;
+	      mods |= EGG_VIRTUAL_SHIFT_MASK;
+	    }
+	  else if (len >= 6 && is_shft (accelerator))
+	    {
+	      accelerator += 6;
+	      len -= 6;
+	      mods |= EGG_VIRTUAL_SHIFT_MASK;
+	    }
+	  else if (len >= 6 && is_ctrl (accelerator))
+	    {
+	      accelerator += 6;
+	      len -= 6;
+	      mods |= EGG_VIRTUAL_CONTROL_MASK;
+	    }
+	  else if (len >= 6 && is_modx (accelerator))
+	    {
+	      static const guint mod_vals[] = {
+		EGG_VIRTUAL_ALT_MASK, EGG_VIRTUAL_MOD2_MASK, EGG_VIRTUAL_MOD3_MASK,
+		EGG_VIRTUAL_MOD4_MASK, EGG_VIRTUAL_MOD5_MASK
+	      };
+
+	      len -= 6;
+	      accelerator += 4;
+	      mods |= mod_vals[*accelerator - '1'];
+	      accelerator += 2;
+	    }
+	  else if (len >= 5 && is_ctl (accelerator))
+	    {
+	      accelerator += 5;
+	      len -= 5;
+	      mods |= EGG_VIRTUAL_CONTROL_MASK;
+	    }
+	  else if (len >= 5 && is_alt (accelerator))
+	    {
+	      accelerator += 5;
+	      len -= 5;
+	      mods |= EGG_VIRTUAL_ALT_MASK;
+	    }
+          else if (len >= 6 && is_meta (accelerator))
+	    {
+	      accelerator += 6;
+	      len -= 6;
+	      mods |= EGG_VIRTUAL_META_MASK;
+	    }
+          else if (len >= 7 && is_hyper (accelerator))
+	    {
+	      accelerator += 7;
+	      len -= 7;
+	      mods |= EGG_VIRTUAL_HYPER_MASK;
+	    }
+          else if (len >= 7 && is_super (accelerator))
+	    {
+	      accelerator += 7;
+	      len -= 7;
+	      mods |= EGG_VIRTUAL_SUPER_MASK;
+	    }
+	  else
+	    {
+	      gchar last_ch;
+
+	      last_ch = *accelerator;
+	      while (last_ch && last_ch != '>')
+		{
+		  last_ch = *accelerator;
+		  accelerator += 1;
+		  len -= 1;
+		}
+	    }
+	}
+      else
+	{
+          keyval = gdk_keyval_from_name (accelerator);
+
+          if (keyval == 0)
+            bad_keyval = TRUE;
+
+          accelerator += len;
+          len -= len;
+	}
+    }
+
+  if (accelerator_key)
+    *accelerator_key = gdk_keyval_to_lower (keyval);
+  if (accelerator_mods)
+    *accelerator_mods = mods;
+
+  return !bad_keyval;
+}
+
+void
+egg_keymap_resolve_virtual_modifiers (GdkKeymap              *keymap,
+                                      EggVirtualModifierType  virtual_mods,
+                                      GdkModifierType        *concrete_mods)
+{
+  GdkModifierType concrete;
+  int i;
+  const EggModmap *modmap;
+
+  g_return_if_fail (GDK_IS_KEYMAP (keymap));
+  g_return_if_fail (concrete_mods != NULL);
+
+  modmap = egg_keymap_get_modmap (keymap);
+
+  /* Not so sure about this algorithm. */
+
+  concrete = 0;
+  i = 0;
+  while (i < EGG_MODMAP_ENTRY_LAST)
+    {
+      if (modmap->mapping[i] & virtual_mods)
+        concrete |= (1 << i);
+
+      ++i;
+    }
+
+  *concrete_mods = concrete;
+}
+
+void
+egg_keymap_virtualize_modifiers (GdkKeymap              *keymap,
+                                 GdkModifierType         concrete_mods,
+                                 EggVirtualModifierType *virtual_mods)
+{
+  GdkModifierType virtual;
+  int i;
+  const EggModmap *modmap;
+
+  g_return_if_fail (GDK_IS_KEYMAP (keymap));
+  g_return_if_fail (virtual_mods != NULL);
+
+  modmap = egg_keymap_get_modmap (keymap);
+
+  /* Not so sure about this algorithm. */
+
+  virtual = 0;
+  i = 0;
+  while (i < EGG_MODMAP_ENTRY_LAST)
+    {
+      if ((1 << i) & concrete_mods)
+        {
+          EggVirtualModifierType cleaned;
+
+          cleaned = modmap->mapping[i] & ~(EGG_VIRTUAL_MOD2_MASK |
+                                           EGG_VIRTUAL_MOD3_MASK |
+                                           EGG_VIRTUAL_MOD4_MASK |
+                                           EGG_VIRTUAL_MOD5_MASK);
+
+          if (cleaned != 0)
+            {
+              virtual |= cleaned;
+            }
+          else
+            {
+              /* Rather than dropping mod2->mod5 if not bound,
+               * go ahead and use the concrete names
+               */
+              virtual |= modmap->mapping[i];
+            }
+        }
+
+      ++i;
+    }
+
+  *virtual_mods = virtual;
+}
+
+static void
+reload_modmap (GdkKeymap *keymap,
+               EggModmap *modmap)
+{
+  XModifierKeymap *xmodmap;
+  int map_size;
+  int i;
+
+  /* FIXME multihead */
+  xmodmap = XGetModifierMapping (gdk_x11_get_default_xdisplay ());
+
+  memset (modmap->mapping, 0, sizeof (modmap->mapping));
+
+  /* there are 8 modifiers, and the first 3 are shift, shift lock,
+   * and control
+   */
+  map_size = 8 * xmodmap->max_keypermod;
+  i = 3 * xmodmap->max_keypermod;
+  while (i < map_size)
+    {
+      /* get the key code at this point in the map,
+       * see if its keysym is one we're interested in
+       */
+      int keycode = xmodmap->modifiermap[i];
+      GdkKeymapKey *keys;
+      guint *keyvals;
+      int n_entries;
+      int j;
+      EggVirtualModifierType mask;
+
+      keys = NULL;
+      keyvals = NULL;
+      n_entries = 0;
+
+      gdk_keymap_get_entries_for_keycode (keymap,
+                                          keycode,
+                                          &keys, &keyvals, &n_entries);
+
+      mask = 0;
+      j = 0;
+      while (j < n_entries)
+        {
+          if (keyvals[j] == GDK_KEY_Num_Lock)
+            mask |= EGG_VIRTUAL_NUM_LOCK_MASK;
+          else if (keyvals[j] == GDK_KEY_Scroll_Lock)
+            mask |= EGG_VIRTUAL_SCROLL_LOCK_MASK;
+          else if (keyvals[j] == GDK_KEY_Meta_L ||
+                   keyvals[j] == GDK_KEY_Meta_R)
+            mask |= EGG_VIRTUAL_META_MASK;
+          else if (keyvals[j] == GDK_KEY_Hyper_L ||
+                   keyvals[j] == GDK_KEY_Hyper_R)
+            mask |= EGG_VIRTUAL_HYPER_MASK;
+          else if (keyvals[j] == GDK_KEY_Super_L ||
+                   keyvals[j] == GDK_KEY_Super_R)
+            mask |= EGG_VIRTUAL_SUPER_MASK;
+          else if (keyvals[j] == GDK_KEY_Mode_switch)
+            mask |= EGG_VIRTUAL_MODE_SWITCH_MASK;
+
+          ++j;
+        }
+
+      /* Mod1Mask is 1 << 3 for example, i.e. the
+       * fourth modifier, i / keyspermod is the modifier
+       * index
+       */
+      modmap->mapping[i/xmodmap->max_keypermod] |= mask;
+
+      g_free (keyvals);
+      g_free (keys);
+
+      ++i;
+    }
+
+  /* Add in the not-really-virtual fixed entries */
+  modmap->mapping[EGG_MODMAP_ENTRY_SHIFT] |= EGG_VIRTUAL_SHIFT_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_CONTROL] |= EGG_VIRTUAL_CONTROL_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_LOCK] |= EGG_VIRTUAL_LOCK_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD1] |= EGG_VIRTUAL_ALT_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD2] |= EGG_VIRTUAL_MOD2_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD3] |= EGG_VIRTUAL_MOD3_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD4] |= EGG_VIRTUAL_MOD4_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD5] |= EGG_VIRTUAL_MOD5_MASK;
+
+  XFreeModifiermap (xmodmap);
+}
+
+const EggModmap*
+egg_keymap_get_modmap (GdkKeymap *keymap)
+{
+  EggModmap *modmap;
+
+  /* This is all a hack, much simpler when we can just
+   * modify GDK directly.
+   */
+
+  modmap = g_object_get_data (G_OBJECT (keymap),
+                              "egg-modmap");
+
+  if (modmap == NULL)
+    {
+      modmap = g_new0 (EggModmap, 1);
+
+      /* FIXME modify keymap change events with an event filter
+       * and force a reload if we get one
+       */
+
+      reload_modmap (keymap, modmap);
+
+      g_object_set_data_full (G_OBJECT (keymap),
+                              "egg-modmap",
+                              modmap,
+                              g_free);
+    }
+
+  g_assert (modmap != NULL);
+
+  return modmap;
+}
+
+
+
+ + + diff --git a/2020-06-26-094257-4646-cppcheck@741c50ee9687_master/index.html b/2020-06-26-094257-4646-cppcheck@741c50ee9687_master/index.html new file mode 100644 index 0000000..812f8b5 --- /dev/null +++ b/2020-06-26-094257-4646-cppcheck@741c50ee9687_master/index.html @@ -0,0 +1,101 @@ + + + + + + Cppcheck - HTML report - mate-indicator-applet + + + + + + + +
+ + + + + + + +
LineIdCWESeverityMessage
0missingIncludeSysteminformationCppcheck cannot find all the include files (use --check-config for details)
src/eggaccelerators.c
321duplicateExpression398styleSame expression on both sides of '-='.
+
+ + + diff --git a/2020-06-26-094257-4646-cppcheck@741c50ee9687_master/stats.html b/2020-06-26-094257-4646-cppcheck@741c50ee9687_master/stats.html new file mode 100644 index 0000000..14ae0d4 --- /dev/null +++ b/2020-06-26-094257-4646-cppcheck@741c50ee9687_master/stats.html @@ -0,0 +1,89 @@ + + + + + + Cppcheck - HTML report - mate-indicator-applet + + + + + + + +
+

Top 10 files for style severity, total findings: 1
+   1  src/eggaccelerators.c
+

+ +
+ + + diff --git a/2020-06-26-094257-4646-cppcheck@741c50ee9687_master/style.css b/2020-06-26-094257-4646-cppcheck@741c50ee9687_master/style.css new file mode 100644 index 0000000..c39571c --- /dev/null +++ b/2020-06-26-094257-4646-cppcheck@741c50ee9687_master/style.css @@ -0,0 +1,149 @@ + +body { + font: 13px Arial, Verdana, Sans-Serif; + margin: 0; + width: auto; +} + +h1 { + margin: 10px; +} + +#footer > p { + margin: 4px; +} + +.error { + background-color: #ffb7b7; +} + +.error2 { + background-color: #faa; + border: 1px dotted black; + display: inline-block; + margin-left: 4px; +} + +.inconclusive { + background-color: #B6B6B4; +} + +.inconclusive2 { + background-color: #B6B6B4; + border: 1px dotted black; + display: inline-block; + margin-left: 4px; +} + +div.verbose { + display: inline-block; + vertical-align: top; + cursor: help; +} + +div.verbose div.content { + display: none; + position: absolute; + padding: 10px; + margin: 4px; + max-width: 40%; + white-space: pre-wrap; + border: 1px solid black; + background-color: #FFFFCC; + cursor: auto; +} + +.highlight .hll { + padding: 1px; +} + +#header { + border-bottom: thin solid #aaa; +} + +#menu { + float: left; + margin-top: 5px; + text-align: left; + width: 150px; + /*height: 75%;*/ + position: fixed; + overflow: auto; + z-index: 1; +} + +#menu_index { + float: left; + margin-top: 5px; + padding-left: 5px; + text-align: left; + width: 300px; + /*height: 75%;*/ + position: fixed; + overflow: auto; + z-index: 1; +} + +#menu > a { + display: block; + margin-left: 10px; + font: 12px; + z-index: 1; +} + +#filename { + margin-left: 10px; + font: 12px; + z-index: 1; +} + +.highlighttable { + background-color:white; + z-index: 10; + position: relative; + margin: -10 px; +} + +#content { + background-color: white; + -webkit-box-sizing: content-box; + -moz-box-sizing: content-box; + box-sizing: content-box; + float: left; + margin: 5px; + margin-left: 10px; + padding: 0 10px 10px 10px; + width: 80%; + padding-left: 150px; +} + +#content_index { + background-color: white; + -webkit-box-sizing: content-box; + -moz-box-sizing: content-box; + box-sizing: content-box; + float: left; + margin: 5px; + margin-left: 10px; + padding: 0 10px 10px 10px; + width: 80%; + padding-left: 300px; +} + +.linenos { + border-right: thin solid #aaa; + color: lightgray; + padding-right: 6px; +} + +#footer { + border-top: thin solid #aaa; + clear: both; + font-size: 90%; + margin-top: 5px; +} + +#footer ul { + list-style-type: none; + padding-left: 0; +} diff --git a/2020-07-06-000331-2607-cppcheck@418dae76ea9e_master/0.html b/2020-07-06-000331-2607-cppcheck@418dae76ea9e_master/0.html new file mode 100644 index 0000000..dfb584a --- /dev/null +++ b/2020-07-06-000331-2607-cppcheck@418dae76ea9e_master/0.html @@ -0,0 +1,1208 @@ + + + + + + Cppcheck - HTML report - mate-indicator-applet + + + + + + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
/* eggaccelerators.c
+ * Copyright (C) 2002  Red Hat, Inc.; Copyright 1998, 2001 Tim Janik
+ * Developed by Havoc Pennington, Tim Janik
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
+ */
+
+#include "eggaccelerators.h"
+
+#include <string.h>
+#include <gdk/gdkx.h>
+#include <gdk/gdkkeysyms.h>
+
+enum
+{
+  EGG_MODMAP_ENTRY_SHIFT   = 0,
+  EGG_MODMAP_ENTRY_LOCK    = 1,
+  EGG_MODMAP_ENTRY_CONTROL = 2,
+  EGG_MODMAP_ENTRY_MOD1    = 3,
+  EGG_MODMAP_ENTRY_MOD2    = 4,
+  EGG_MODMAP_ENTRY_MOD3    = 5,
+  EGG_MODMAP_ENTRY_MOD4    = 6,
+  EGG_MODMAP_ENTRY_MOD5    = 7,
+  EGG_MODMAP_ENTRY_LAST    = 8
+};
+
+#define MODMAP_ENTRY_TO_MODIFIER(x) (1 << (x))
+
+typedef struct
+{
+  EggVirtualModifierType mapping[EGG_MODMAP_ENTRY_LAST];
+
+} EggModmap;
+
+const EggModmap* egg_keymap_get_modmap (GdkKeymap *keymap);
+
+static inline gboolean
+is_alt (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'a' || string[1] == 'A') &&
+	  (string[2] == 'l' || string[2] == 'L') &&
+	  (string[3] == 't' || string[3] == 'T') &&
+	  (string[4] == '>'));
+}
+
+static inline gboolean
+is_ctl (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'c' || string[1] == 'C') &&
+	  (string[2] == 't' || string[2] == 'T') &&
+	  (string[3] == 'l' || string[3] == 'L') &&
+	  (string[4] == '>'));
+}
+
+static inline gboolean
+is_modx (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'm' || string[1] == 'M') &&
+	  (string[2] == 'o' || string[2] == 'O') &&
+	  (string[3] == 'd' || string[3] == 'D') &&
+	  (string[4] >= '1' && string[4] <= '5') &&
+	  (string[5] == '>'));
+}
+
+static inline gboolean
+is_ctrl (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'c' || string[1] == 'C') &&
+	  (string[2] == 't' || string[2] == 'T') &&
+	  (string[3] == 'r' || string[3] == 'R') &&
+	  (string[4] == 'l' || string[4] == 'L') &&
+	  (string[5] == '>'));
+}
+
+static inline gboolean
+is_shft (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 's' || string[1] == 'S') &&
+	  (string[2] == 'h' || string[2] == 'H') &&
+	  (string[3] == 'f' || string[3] == 'F') &&
+	  (string[4] == 't' || string[4] == 'T') &&
+	  (string[5] == '>'));
+}
+
+static inline gboolean
+is_shift (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 's' || string[1] == 'S') &&
+	  (string[2] == 'h' || string[2] == 'H') &&
+	  (string[3] == 'i' || string[3] == 'I') &&
+	  (string[4] == 'f' || string[4] == 'F') &&
+	  (string[5] == 't' || string[5] == 'T') &&
+	  (string[6] == '>'));
+}
+
+static inline gboolean
+is_control (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'c' || string[1] == 'C') &&
+	  (string[2] == 'o' || string[2] == 'O') &&
+	  (string[3] == 'n' || string[3] == 'N') &&
+	  (string[4] == 't' || string[4] == 'T') &&
+	  (string[5] == 'r' || string[5] == 'R') &&
+	  (string[6] == 'o' || string[6] == 'O') &&
+	  (string[7] == 'l' || string[7] == 'L') &&
+	  (string[8] == '>'));
+}
+
+static inline gboolean
+is_release (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'r' || string[1] == 'R') &&
+	  (string[2] == 'e' || string[2] == 'E') &&
+	  (string[3] == 'l' || string[3] == 'L') &&
+	  (string[4] == 'e' || string[4] == 'E') &&
+	  (string[5] == 'a' || string[5] == 'A') &&
+	  (string[6] == 's' || string[6] == 'S') &&
+	  (string[7] == 'e' || string[7] == 'E') &&
+	  (string[8] == '>'));
+}
+
+static inline gboolean
+is_meta (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'm' || string[1] == 'M') &&
+	  (string[2] == 'e' || string[2] == 'E') &&
+	  (string[3] == 't' || string[3] == 'T') &&
+	  (string[4] == 'a' || string[4] == 'A') &&
+	  (string[5] == '>'));
+}
+
+static inline gboolean
+is_super (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 's' || string[1] == 'S') &&
+	  (string[2] == 'u' || string[2] == 'U') &&
+	  (string[3] == 'p' || string[3] == 'P') &&
+	  (string[4] == 'e' || string[4] == 'E') &&
+	  (string[5] == 'r' || string[5] == 'R') &&
+	  (string[6] == '>'));
+}
+
+static inline gboolean
+is_hyper (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'h' || string[1] == 'H') &&
+	  (string[2] == 'y' || string[2] == 'Y') &&
+	  (string[3] == 'p' || string[3] == 'P') &&
+	  (string[4] == 'e' || string[4] == 'E') &&
+	  (string[5] == 'r' || string[5] == 'R') &&
+	  (string[6] == '>'));
+}
+
+/**
+ * egg_accelerator_parse_virtual:
+ * @accelerator:      string representing an accelerator
+ * @accelerator_key:  return location for accelerator keyval
+ * @accelerator_mods: return location for accelerator modifier mask
+ *
+ * Parses a string representing a virtual accelerator. The format
+ * looks like "&lt;Control&gt;a" or "&lt;Shift&gt;&lt;Alt&gt;F1" or
+ * "&lt;Release&gt;z" (the last one is for key release).  The parser
+ * is fairly liberal and allows lower or upper case, and also
+ * abbreviations such as "&lt;Ctl&gt;" and "&lt;Ctrl&gt;".
+ *
+ * If the parse fails, @accelerator_key and @accelerator_mods will
+ * be set to 0 (zero) and %FALSE will be returned. If the string contains
+ * only modifiers, @accelerator_key will be set to 0 but %TRUE will be
+ * returned.
+ *
+ * The virtual vs. concrete accelerator distinction is a relic of
+ * how the X Window System works; there are modifiers Mod2-Mod5 that
+ * can represent various keyboard keys (numlock, meta, hyper, etc.),
+ * the virtual modifier represents the keyboard key, the concrete
+ * modifier the actual Mod2-Mod5 bits in the key press event.
+ *
+ * Returns: %TRUE on success.
+ */
+gboolean
+egg_accelerator_parse_virtual (const gchar            *accelerator,
+                               guint                  *accelerator_key,
+                               EggVirtualModifierType *accelerator_mods)
+{
+  guint keyval;
+  GdkModifierType mods;
+  gint len;
+  gboolean bad_keyval;
+
+  if (accelerator_key)
+    *accelerator_key = 0;
+  if (accelerator_mods)
+    *accelerator_mods = 0;
+
+  g_return_val_if_fail (accelerator != NULL, FALSE);
+
+  bad_keyval = FALSE;
+
+  keyval = 0;
+  mods = 0;
+  len = strlen (accelerator);
+  while (len)
+    {
+      if (*accelerator == '<')
+	{
+	  if (len >= 9 && is_release (accelerator))
+	    {
+	      accelerator += 9;
+	      len -= 9;
+	      mods |= EGG_VIRTUAL_RELEASE_MASK;
+	    }
+	  else if (len >= 9 && is_control (accelerator))
+	    {
+	      accelerator += 9;
+	      len -= 9;
+	      mods |= EGG_VIRTUAL_CONTROL_MASK;
+	    }
+	  else if (len >= 7 && is_shift (accelerator))
+	    {
+	      accelerator += 7;
+	      len -= 7;
+	      mods |= EGG_VIRTUAL_SHIFT_MASK;
+	    }
+	  else if (len >= 6 && is_shft (accelerator))
+	    {
+	      accelerator += 6;
+	      len -= 6;
+	      mods |= EGG_VIRTUAL_SHIFT_MASK;
+	    }
+	  else if (len >= 6 && is_ctrl (accelerator))
+	    {
+	      accelerator += 6;
+	      len -= 6;
+	      mods |= EGG_VIRTUAL_CONTROL_MASK;
+	    }
+	  else if (len >= 6 && is_modx (accelerator))
+	    {
+	      static const guint mod_vals[] = {
+		EGG_VIRTUAL_ALT_MASK, EGG_VIRTUAL_MOD2_MASK, EGG_VIRTUAL_MOD3_MASK,
+		EGG_VIRTUAL_MOD4_MASK, EGG_VIRTUAL_MOD5_MASK
+	      };
+
+	      len -= 6;
+	      accelerator += 4;
+	      mods |= mod_vals[*accelerator - '1'];
+	      accelerator += 2;
+	    }
+	  else if (len >= 5 && is_ctl (accelerator))
+	    {
+	      accelerator += 5;
+	      len -= 5;
+	      mods |= EGG_VIRTUAL_CONTROL_MASK;
+	    }
+	  else if (len >= 5 && is_alt (accelerator))
+	    {
+	      accelerator += 5;
+	      len -= 5;
+	      mods |= EGG_VIRTUAL_ALT_MASK;
+	    }
+          else if (len >= 6 && is_meta (accelerator))
+	    {
+	      accelerator += 6;
+	      len -= 6;
+	      mods |= EGG_VIRTUAL_META_MASK;
+	    }
+          else if (len >= 7 && is_hyper (accelerator))
+	    {
+	      accelerator += 7;
+	      len -= 7;
+	      mods |= EGG_VIRTUAL_HYPER_MASK;
+	    }
+          else if (len >= 7 && is_super (accelerator))
+	    {
+	      accelerator += 7;
+	      len -= 7;
+	      mods |= EGG_VIRTUAL_SUPER_MASK;
+	    }
+	  else
+	    {
+	      gchar last_ch;
+
+	      last_ch = *accelerator;
+	      while (last_ch && last_ch != '>')
+		{
+		  last_ch = *accelerator;
+		  accelerator += 1;
+		  len -= 1;
+		}
+	    }
+	}
+      else
+	{
+          keyval = gdk_keyval_from_name (accelerator);
+
+          if (keyval == 0)
+            bad_keyval = TRUE;
+
+          accelerator += len;
+          len -= len;
+	}
+    }
+
+  if (accelerator_key)
+    *accelerator_key = gdk_keyval_to_lower (keyval);
+  if (accelerator_mods)
+    *accelerator_mods = mods;
+
+  return !bad_keyval;
+}
+
+void
+egg_keymap_resolve_virtual_modifiers (GdkKeymap              *keymap,
+                                      EggVirtualModifierType  virtual_mods,
+                                      GdkModifierType        *concrete_mods)
+{
+  GdkModifierType concrete;
+  int i;
+  const EggModmap *modmap;
+
+  g_return_if_fail (GDK_IS_KEYMAP (keymap));
+  g_return_if_fail (concrete_mods != NULL);
+
+  modmap = egg_keymap_get_modmap (keymap);
+
+  /* Not so sure about this algorithm. */
+
+  concrete = 0;
+  i = 0;
+  while (i < EGG_MODMAP_ENTRY_LAST)
+    {
+      if (modmap->mapping[i] & virtual_mods)
+        concrete |= (1 << i);
+
+      ++i;
+    }
+
+  *concrete_mods = concrete;
+}
+
+void
+egg_keymap_virtualize_modifiers (GdkKeymap              *keymap,
+                                 GdkModifierType         concrete_mods,
+                                 EggVirtualModifierType *virtual_mods)
+{
+  GdkModifierType virtual;
+  int i;
+  const EggModmap *modmap;
+
+  g_return_if_fail (GDK_IS_KEYMAP (keymap));
+  g_return_if_fail (virtual_mods != NULL);
+
+  modmap = egg_keymap_get_modmap (keymap);
+
+  /* Not so sure about this algorithm. */
+
+  virtual = 0;
+  i = 0;
+  while (i < EGG_MODMAP_ENTRY_LAST)
+    {
+      if ((1 << i) & concrete_mods)
+        {
+          EggVirtualModifierType cleaned;
+
+          cleaned = modmap->mapping[i] & ~(EGG_VIRTUAL_MOD2_MASK |
+                                           EGG_VIRTUAL_MOD3_MASK |
+                                           EGG_VIRTUAL_MOD4_MASK |
+                                           EGG_VIRTUAL_MOD5_MASK);
+
+          if (cleaned != 0)
+            {
+              virtual |= cleaned;
+            }
+          else
+            {
+              /* Rather than dropping mod2->mod5 if not bound,
+               * go ahead and use the concrete names
+               */
+              virtual |= modmap->mapping[i];
+            }
+        }
+
+      ++i;
+    }
+
+  *virtual_mods = virtual;
+}
+
+static void
+reload_modmap (GdkKeymap *keymap,
+               EggModmap *modmap)
+{
+  XModifierKeymap *xmodmap;
+  int map_size;
+  int i;
+
+  /* FIXME multihead */
+  xmodmap = XGetModifierMapping (gdk_x11_get_default_xdisplay ());
+
+  memset (modmap->mapping, 0, sizeof (modmap->mapping));
+
+  /* there are 8 modifiers, and the first 3 are shift, shift lock,
+   * and control
+   */
+  map_size = 8 * xmodmap->max_keypermod;
+  i = 3 * xmodmap->max_keypermod;
+  while (i < map_size)
+    {
+      /* get the key code at this point in the map,
+       * see if its keysym is one we're interested in
+       */
+      int keycode = xmodmap->modifiermap[i];
+      GdkKeymapKey *keys;
+      guint *keyvals;
+      int n_entries;
+      int j;
+      EggVirtualModifierType mask;
+
+      keys = NULL;
+      keyvals = NULL;
+      n_entries = 0;
+
+      gdk_keymap_get_entries_for_keycode (keymap,
+                                          keycode,
+                                          &keys, &keyvals, &n_entries);
+
+      mask = 0;
+      j = 0;
+      while (j < n_entries)
+        {
+          if (keyvals[j] == GDK_KEY_Num_Lock)
+            mask |= EGG_VIRTUAL_NUM_LOCK_MASK;
+          else if (keyvals[j] == GDK_KEY_Scroll_Lock)
+            mask |= EGG_VIRTUAL_SCROLL_LOCK_MASK;
+          else if (keyvals[j] == GDK_KEY_Meta_L ||
+                   keyvals[j] == GDK_KEY_Meta_R)
+            mask |= EGG_VIRTUAL_META_MASK;
+          else if (keyvals[j] == GDK_KEY_Hyper_L ||
+                   keyvals[j] == GDK_KEY_Hyper_R)
+            mask |= EGG_VIRTUAL_HYPER_MASK;
+          else if (keyvals[j] == GDK_KEY_Super_L ||
+                   keyvals[j] == GDK_KEY_Super_R)
+            mask |= EGG_VIRTUAL_SUPER_MASK;
+          else if (keyvals[j] == GDK_KEY_Mode_switch)
+            mask |= EGG_VIRTUAL_MODE_SWITCH_MASK;
+
+          ++j;
+        }
+
+      /* Mod1Mask is 1 << 3 for example, i.e. the
+       * fourth modifier, i / keyspermod is the modifier
+       * index
+       */
+      modmap->mapping[i/xmodmap->max_keypermod] |= mask;
+
+      g_free (keyvals);
+      g_free (keys);
+
+      ++i;
+    }
+
+  /* Add in the not-really-virtual fixed entries */
+  modmap->mapping[EGG_MODMAP_ENTRY_SHIFT] |= EGG_VIRTUAL_SHIFT_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_CONTROL] |= EGG_VIRTUAL_CONTROL_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_LOCK] |= EGG_VIRTUAL_LOCK_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD1] |= EGG_VIRTUAL_ALT_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD2] |= EGG_VIRTUAL_MOD2_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD3] |= EGG_VIRTUAL_MOD3_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD4] |= EGG_VIRTUAL_MOD4_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD5] |= EGG_VIRTUAL_MOD5_MASK;
+
+  XFreeModifiermap (xmodmap);
+}
+
+const EggModmap*
+egg_keymap_get_modmap (GdkKeymap *keymap)
+{
+  EggModmap *modmap;
+
+  /* This is all a hack, much simpler when we can just
+   * modify GDK directly.
+   */
+
+  modmap = g_object_get_data (G_OBJECT (keymap),
+                              "egg-modmap");
+
+  if (modmap == NULL)
+    {
+      modmap = g_new0 (EggModmap, 1);
+
+      /* FIXME modify keymap change events with an event filter
+       * and force a reload if we get one
+       */
+
+      reload_modmap (keymap, modmap);
+
+      g_object_set_data_full (G_OBJECT (keymap),
+                              "egg-modmap",
+                              modmap,
+                              g_free);
+    }
+
+  g_assert (modmap != NULL);
+
+  return modmap;
+}
+
+
+
+ + + diff --git a/2020-07-06-000331-2607-cppcheck@418dae76ea9e_master/index.html b/2020-07-06-000331-2607-cppcheck@418dae76ea9e_master/index.html new file mode 100644 index 0000000..812f8b5 --- /dev/null +++ b/2020-07-06-000331-2607-cppcheck@418dae76ea9e_master/index.html @@ -0,0 +1,101 @@ + + + + + + Cppcheck - HTML report - mate-indicator-applet + + + + + + + +
+ + + + + + + +
LineIdCWESeverityMessage
0missingIncludeSysteminformationCppcheck cannot find all the include files (use --check-config for details)
src/eggaccelerators.c
321duplicateExpression398styleSame expression on both sides of '-='.
+
+ + + diff --git a/2020-07-06-000331-2607-cppcheck@418dae76ea9e_master/stats.html b/2020-07-06-000331-2607-cppcheck@418dae76ea9e_master/stats.html new file mode 100644 index 0000000..14ae0d4 --- /dev/null +++ b/2020-07-06-000331-2607-cppcheck@418dae76ea9e_master/stats.html @@ -0,0 +1,89 @@ + + + + + + Cppcheck - HTML report - mate-indicator-applet + + + + + + + +
+

Top 10 files for style severity, total findings: 1
+   1  src/eggaccelerators.c
+

+ +
+ + + diff --git a/2020-07-06-000331-2607-cppcheck@418dae76ea9e_master/style.css b/2020-07-06-000331-2607-cppcheck@418dae76ea9e_master/style.css new file mode 100644 index 0000000..c39571c --- /dev/null +++ b/2020-07-06-000331-2607-cppcheck@418dae76ea9e_master/style.css @@ -0,0 +1,149 @@ + +body { + font: 13px Arial, Verdana, Sans-Serif; + margin: 0; + width: auto; +} + +h1 { + margin: 10px; +} + +#footer > p { + margin: 4px; +} + +.error { + background-color: #ffb7b7; +} + +.error2 { + background-color: #faa; + border: 1px dotted black; + display: inline-block; + margin-left: 4px; +} + +.inconclusive { + background-color: #B6B6B4; +} + +.inconclusive2 { + background-color: #B6B6B4; + border: 1px dotted black; + display: inline-block; + margin-left: 4px; +} + +div.verbose { + display: inline-block; + vertical-align: top; + cursor: help; +} + +div.verbose div.content { + display: none; + position: absolute; + padding: 10px; + margin: 4px; + max-width: 40%; + white-space: pre-wrap; + border: 1px solid black; + background-color: #FFFFCC; + cursor: auto; +} + +.highlight .hll { + padding: 1px; +} + +#header { + border-bottom: thin solid #aaa; +} + +#menu { + float: left; + margin-top: 5px; + text-align: left; + width: 150px; + /*height: 75%;*/ + position: fixed; + overflow: auto; + z-index: 1; +} + +#menu_index { + float: left; + margin-top: 5px; + padding-left: 5px; + text-align: left; + width: 300px; + /*height: 75%;*/ + position: fixed; + overflow: auto; + z-index: 1; +} + +#menu > a { + display: block; + margin-left: 10px; + font: 12px; + z-index: 1; +} + +#filename { + margin-left: 10px; + font: 12px; + z-index: 1; +} + +.highlighttable { + background-color:white; + z-index: 10; + position: relative; + margin: -10 px; +} + +#content { + background-color: white; + -webkit-box-sizing: content-box; + -moz-box-sizing: content-box; + box-sizing: content-box; + float: left; + margin: 5px; + margin-left: 10px; + padding: 0 10px 10px 10px; + width: 80%; + padding-left: 150px; +} + +#content_index { + background-color: white; + -webkit-box-sizing: content-box; + -moz-box-sizing: content-box; + box-sizing: content-box; + float: left; + margin: 5px; + margin-left: 10px; + padding: 0 10px 10px 10px; + width: 80%; + padding-left: 300px; +} + +.linenos { + border-right: thin solid #aaa; + color: lightgray; + padding-right: 6px; +} + +#footer { + border-top: thin solid #aaa; + clear: both; + font-size: 90%; + margin-top: 5px; +} + +#footer ul { + list-style-type: none; + padding-left: 0; +} diff --git a/2020-08-20-160620-0353-cppcheck@fb7b816f4a78_master/0.html b/2020-08-20-160620-0353-cppcheck@fb7b816f4a78_master/0.html new file mode 100644 index 0000000..501a2f5 --- /dev/null +++ b/2020-08-20-160620-0353-cppcheck@fb7b816f4a78_master/0.html @@ -0,0 +1,1224 @@ + + + + + + Cppcheck - HTML report - mate-indicator-applet + + + + + + +
+ +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
/* eggaccelerators.c
+ * Copyright (C) 2002  Red Hat, Inc.; Copyright 1998, 2001 Tim Janik
+ * Developed by Havoc Pennington, Tim Janik
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
+ */
+
+#include "eggaccelerators.h"
+
+#include <string.h>
+#include <gdk/gdkx.h>
+#include <gdk/gdkkeysyms.h>
+
+enum
+{
+  EGG_MODMAP_ENTRY_SHIFT   = 0,
+  EGG_MODMAP_ENTRY_LOCK    = 1,
+  EGG_MODMAP_ENTRY_CONTROL = 2,
+  EGG_MODMAP_ENTRY_MOD1    = 3,
+  EGG_MODMAP_ENTRY_MOD2    = 4,
+  EGG_MODMAP_ENTRY_MOD3    = 5,
+  EGG_MODMAP_ENTRY_MOD4    = 6,
+  EGG_MODMAP_ENTRY_MOD5    = 7,
+  EGG_MODMAP_ENTRY_LAST    = 8
+};
+
+#define MODMAP_ENTRY_TO_MODIFIER(x) (1 << (x))
+
+typedef struct
+{
+  EggVirtualModifierType mapping[EGG_MODMAP_ENTRY_LAST];
+
+} EggModmap;
+
+const EggModmap* egg_keymap_get_modmap (GdkKeymap *keymap);
+
+static inline gboolean
+is_alt (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'a' || string[1] == 'A') &&
+	  (string[2] == 'l' || string[2] == 'L') &&
+	  (string[3] == 't' || string[3] == 'T') &&
+	  (string[4] == '>'));
+}
+
+static inline gboolean
+is_ctl (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'c' || string[1] == 'C') &&
+	  (string[2] == 't' || string[2] == 'T') &&
+	  (string[3] == 'l' || string[3] == 'L') &&
+	  (string[4] == '>'));
+}
+
+static inline gboolean
+is_modx (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'm' || string[1] == 'M') &&
+	  (string[2] == 'o' || string[2] == 'O') &&
+	  (string[3] == 'd' || string[3] == 'D') &&
+	  (string[4] >= '1' && string[4] <= '5') &&
+	  (string[5] == '>'));
+}
+
+static inline gboolean
+is_ctrl (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'c' || string[1] == 'C') &&
+	  (string[2] == 't' || string[2] == 'T') &&
+	  (string[3] == 'r' || string[3] == 'R') &&
+	  (string[4] == 'l' || string[4] == 'L') &&
+	  (string[5] == '>'));
+}
+
+static inline gboolean
+is_shft (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 's' || string[1] == 'S') &&
+	  (string[2] == 'h' || string[2] == 'H') &&
+	  (string[3] == 'f' || string[3] == 'F') &&
+	  (string[4] == 't' || string[4] == 'T') &&
+	  (string[5] == '>'));
+}
+
+static inline gboolean
+is_shift (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 's' || string[1] == 'S') &&
+	  (string[2] == 'h' || string[2] == 'H') &&
+	  (string[3] == 'i' || string[3] == 'I') &&
+	  (string[4] == 'f' || string[4] == 'F') &&
+	  (string[5] == 't' || string[5] == 'T') &&
+	  (string[6] == '>'));
+}
+
+static inline gboolean
+is_control (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'c' || string[1] == 'C') &&
+	  (string[2] == 'o' || string[2] == 'O') &&
+	  (string[3] == 'n' || string[3] == 'N') &&
+	  (string[4] == 't' || string[4] == 'T') &&
+	  (string[5] == 'r' || string[5] == 'R') &&
+	  (string[6] == 'o' || string[6] == 'O') &&
+	  (string[7] == 'l' || string[7] == 'L') &&
+	  (string[8] == '>'));
+}
+
+static inline gboolean
+is_release (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'r' || string[1] == 'R') &&
+	  (string[2] == 'e' || string[2] == 'E') &&
+	  (string[3] == 'l' || string[3] == 'L') &&
+	  (string[4] == 'e' || string[4] == 'E') &&
+	  (string[5] == 'a' || string[5] == 'A') &&
+	  (string[6] == 's' || string[6] == 'S') &&
+	  (string[7] == 'e' || string[7] == 'E') &&
+	  (string[8] == '>'));
+}
+
+static inline gboolean
+is_meta (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'm' || string[1] == 'M') &&
+	  (string[2] == 'e' || string[2] == 'E') &&
+	  (string[3] == 't' || string[3] == 'T') &&
+	  (string[4] == 'a' || string[4] == 'A') &&
+	  (string[5] == '>'));
+}
+
+static inline gboolean
+is_super (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 's' || string[1] == 'S') &&
+	  (string[2] == 'u' || string[2] == 'U') &&
+	  (string[3] == 'p' || string[3] == 'P') &&
+	  (string[4] == 'e' || string[4] == 'E') &&
+	  (string[5] == 'r' || string[5] == 'R') &&
+	  (string[6] == '>'));
+}
+
+static inline gboolean
+is_hyper (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'h' || string[1] == 'H') &&
+	  (string[2] == 'y' || string[2] == 'Y') &&
+	  (string[3] == 'p' || string[3] == 'P') &&
+	  (string[4] == 'e' || string[4] == 'E') &&
+	  (string[5] == 'r' || string[5] == 'R') &&
+	  (string[6] == '>'));
+}
+
+/**
+ * egg_accelerator_parse_virtual:
+ * @accelerator:      string representing an accelerator
+ * @accelerator_key:  return location for accelerator keyval
+ * @accelerator_mods: return location for accelerator modifier mask
+ *
+ * Parses a string representing a virtual accelerator. The format
+ * looks like "&lt;Control&gt;a" or "&lt;Shift&gt;&lt;Alt&gt;F1" or
+ * "&lt;Release&gt;z" (the last one is for key release).  The parser
+ * is fairly liberal and allows lower or upper case, and also
+ * abbreviations such as "&lt;Ctl&gt;" and "&lt;Ctrl&gt;".
+ *
+ * If the parse fails, @accelerator_key and @accelerator_mods will
+ * be set to 0 (zero) and %FALSE will be returned. If the string contains
+ * only modifiers, @accelerator_key will be set to 0 but %TRUE will be
+ * returned.
+ *
+ * The virtual vs. concrete accelerator distinction is a relic of
+ * how the X Window System works; there are modifiers Mod2-Mod5 that
+ * can represent various keyboard keys (numlock, meta, hyper, etc.),
+ * the virtual modifier represents the keyboard key, the concrete
+ * modifier the actual Mod2-Mod5 bits in the key press event.
+ *
+ * Returns: %TRUE on success.
+ */
+gboolean
+egg_accelerator_parse_virtual (const gchar            *accelerator,
+                               guint                  *accelerator_key,
+                               EggVirtualModifierType *accelerator_mods)
+{
+  guint keyval;
+  GdkModifierType mods;
+  gint len;
+  gboolean bad_keyval;
+
+  if (accelerator_key)
+    *accelerator_key = 0;
+  if (accelerator_mods)
+    *accelerator_mods = 0;
+
+  g_return_val_if_fail (accelerator != NULL, FALSE);
+
+  bad_keyval = FALSE;
+
+  keyval = 0;
+  mods = 0;
+  len = strlen (accelerator);
+  while (len)
+    {
+      if (*accelerator == '<')
+	{
+	  if (len >= 9 && is_release (accelerator))
+	    {
+	      accelerator += 9;
+	      len -= 9;
+	      mods |= EGG_VIRTUAL_RELEASE_MASK;
+	    }
+	  else if (len >= 9 && is_control (accelerator))
+	    {
+	      accelerator += 9;
+	      len -= 9;
+	      mods |= EGG_VIRTUAL_CONTROL_MASK;
+	    }
+	  else if (len >= 7 && is_shift (accelerator))
+	    {
+	      accelerator += 7;
+	      len -= 7;
+	      mods |= EGG_VIRTUAL_SHIFT_MASK;
+	    }
+	  else if (len >= 6 && is_shft (accelerator))
+	    {
+	      accelerator += 6;
+	      len -= 6;
+	      mods |= EGG_VIRTUAL_SHIFT_MASK;
+	    }
+	  else if (len >= 6 && is_ctrl (accelerator))
+	    {
+	      accelerator += 6;
+	      len -= 6;
+	      mods |= EGG_VIRTUAL_CONTROL_MASK;
+	    }
+	  else if (len >= 6 && is_modx (accelerator))
+	    {
+	      static const guint mod_vals[] = {
+		EGG_VIRTUAL_ALT_MASK, EGG_VIRTUAL_MOD2_MASK, EGG_VIRTUAL_MOD3_MASK,
+		EGG_VIRTUAL_MOD4_MASK, EGG_VIRTUAL_MOD5_MASK
+	      };
+
+	      len -= 6;
+	      accelerator += 4;
+	      mods |= mod_vals[*accelerator - '1'];
+	      accelerator += 2;
+	    }
+	  else if (len >= 5 && is_ctl (accelerator))
+	    {
+	      accelerator += 5;
+	      len -= 5;
+	      mods |= EGG_VIRTUAL_CONTROL_MASK;
+	    }
+	  else if (len >= 5 && is_alt (accelerator))
+	    {
+	      accelerator += 5;
+	      len -= 5;
+	      mods |= EGG_VIRTUAL_ALT_MASK;
+	    }
+          else if (len >= 6 && is_meta (accelerator))
+	    {
+	      accelerator += 6;
+	      len -= 6;
+	      mods |= EGG_VIRTUAL_META_MASK;
+	    }
+          else if (len >= 7 && is_hyper (accelerator))
+	    {
+	      accelerator += 7;
+	      len -= 7;
+	      mods |= EGG_VIRTUAL_HYPER_MASK;
+	    }
+          else if (len >= 7 && is_super (accelerator))
+	    {
+	      accelerator += 7;
+	      len -= 7;
+	      mods |= EGG_VIRTUAL_SUPER_MASK;
+	    }
+	  else
+	    {
+	      gchar last_ch;
+
+	      last_ch = *accelerator;
+	      while (last_ch && last_ch != '>')
+		{
+		  last_ch = *accelerator;
+		  accelerator += 1;
+		  len -= 1;
+		}
+	    }
+	}
+      else
+	{
+          keyval = gdk_keyval_from_name (accelerator);
+
+          if (keyval == 0)
+            bad_keyval = TRUE;
+
+          accelerator += len;
+          len -= len;
+	}
+    }
+
+  if (accelerator_key)
+    *accelerator_key = gdk_keyval_to_lower (keyval);
+  if (accelerator_mods)
+    *accelerator_mods = mods;
+
+  return !bad_keyval;
+}
+
+void
+egg_keymap_resolve_virtual_modifiers (GdkKeymap              *keymap,
+                                      EggVirtualModifierType  virtual_mods,
+                                      GdkModifierType        *concrete_mods)
+{
+  GdkModifierType concrete;
+  int i;
+  const EggModmap *modmap;
+
+  g_return_if_fail (GDK_IS_KEYMAP (keymap));
+  g_return_if_fail (concrete_mods != NULL);
+
+  modmap = egg_keymap_get_modmap (keymap);
+
+  /* Not so sure about this algorithm. */
+
+  concrete = 0;
+  i = 0;
+  while (i < EGG_MODMAP_ENTRY_LAST)
+    {
+      if (modmap->mapping[i] & virtual_mods)
+        concrete |= (1 << i);
+
+      ++i;
+    }
+
+  *concrete_mods = concrete;
+}
+
+void
+egg_keymap_virtualize_modifiers (GdkKeymap              *keymap,
+                                 GdkModifierType         concrete_mods,
+                                 EggVirtualModifierType *virtual_mods)
+{
+  GdkModifierType virtual;
+  int i;
+  const EggModmap *modmap;
+
+  g_return_if_fail (GDK_IS_KEYMAP (keymap));
+  g_return_if_fail (virtual_mods != NULL);
+
+  modmap = egg_keymap_get_modmap (keymap);
+
+  /* Not so sure about this algorithm. */
+
+  virtual = 0;
+  i = 0;
+  while (i < EGG_MODMAP_ENTRY_LAST)
+    {
+      if ((1 << i) & concrete_mods)
+        {
+          EggVirtualModifierType cleaned;
+
+          cleaned = modmap->mapping[i] & ~(EGG_VIRTUAL_MOD2_MASK |
+                                           EGG_VIRTUAL_MOD3_MASK |
+                                           EGG_VIRTUAL_MOD4_MASK |
+                                           EGG_VIRTUAL_MOD5_MASK);
+
+          if (cleaned != 0)
+            {
+              virtual |= cleaned;
+            }
+          else
+            {
+              /* Rather than dropping mod2->mod5 if not bound,
+               * go ahead and use the concrete names
+               */
+              virtual |= modmap->mapping[i];
+            }
+        }
+
+      ++i;
+    }
+
+  *virtual_mods = virtual;
+}
+
+static void
+reload_modmap (GdkKeymap *keymap,
+               EggModmap *modmap)
+{
+  XModifierKeymap *xmodmap;
+  int map_size;
+  int i;
+
+  /* FIXME multihead */
+  xmodmap = XGetModifierMapping (gdk_x11_get_default_xdisplay ());
+
+  memset (modmap->mapping, 0, sizeof (modmap->mapping));
+
+  /* there are 8 modifiers, and the first 3 are shift, shift lock,
+   * and control
+   */
+  map_size = 8 * xmodmap->max_keypermod;
+  i = 3 * xmodmap->max_keypermod;
+  while (i < map_size)
+    {
+      /* get the key code at this point in the map,
+       * see if its keysym is one we're interested in
+       */
+      int keycode = xmodmap->modifiermap[i];
+      GdkKeymapKey *keys;
+      guint *keyvals;
+      int n_entries;
+      int j;
+      EggVirtualModifierType mask;
+
+      keys = NULL;
+      keyvals = NULL;
+      n_entries = 0;
+
+      gdk_keymap_get_entries_for_keycode (keymap,
+                                          keycode,
+                                          &keys, &keyvals, &n_entries);
+
+      mask = 0;
+      j = 0;
+      while (j < n_entries)
+        {
+          if (keyvals[j] == GDK_KEY_Num_Lock)
+            mask |= EGG_VIRTUAL_NUM_LOCK_MASK;
+          else if (keyvals[j] == GDK_KEY_Scroll_Lock)
+            mask |= EGG_VIRTUAL_SCROLL_LOCK_MASK;
+          else if (keyvals[j] == GDK_KEY_Meta_L ||
+                   keyvals[j] == GDK_KEY_Meta_R)
+            mask |= EGG_VIRTUAL_META_MASK;
+          else if (keyvals[j] == GDK_KEY_Hyper_L ||
+                   keyvals[j] == GDK_KEY_Hyper_R)
+            mask |= EGG_VIRTUAL_HYPER_MASK;
+          else if (keyvals[j] == GDK_KEY_Super_L ||
+                   keyvals[j] == GDK_KEY_Super_R)
+            mask |= EGG_VIRTUAL_SUPER_MASK;
+          else if (keyvals[j] == GDK_KEY_Mode_switch)
+            mask |= EGG_VIRTUAL_MODE_SWITCH_MASK;
+
+          ++j;
+        }
+
+      /* Mod1Mask is 1 << 3 for example, i.e. the
+       * fourth modifier, i / keyspermod is the modifier
+       * index
+       */
+      modmap->mapping[i/xmodmap->max_keypermod] |= mask;
+
+      g_free (keyvals);
+      g_free (keys);
+
+      ++i;
+    }
+
+  /* Add in the not-really-virtual fixed entries */
+  modmap->mapping[EGG_MODMAP_ENTRY_SHIFT] |= EGG_VIRTUAL_SHIFT_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_CONTROL] |= EGG_VIRTUAL_CONTROL_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_LOCK] |= EGG_VIRTUAL_LOCK_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD1] |= EGG_VIRTUAL_ALT_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD2] |= EGG_VIRTUAL_MOD2_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD3] |= EGG_VIRTUAL_MOD3_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD4] |= EGG_VIRTUAL_MOD4_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD5] |= EGG_VIRTUAL_MOD5_MASK;
+
+  XFreeModifiermap (xmodmap);
+}
+
+const EggModmap*
+egg_keymap_get_modmap (GdkKeymap *keymap)
+{
+  EggModmap *modmap;
+
+  /* This is all a hack, much simpler when we can just
+   * modify GDK directly.
+   */
+
+  modmap = g_object_get_data (G_OBJECT (keymap),
+                              "egg-modmap");
+
+  if (modmap == NULL)
+    {
+      modmap = g_new0 (EggModmap, 1);
+
+      /* FIXME modify keymap change events with an event filter
+       * and force a reload if we get one
+       */
+
+      reload_modmap (keymap, modmap);
+
+      g_object_set_data_full (G_OBJECT (keymap),
+                              "egg-modmap",
+                              modmap,
+                              g_free);
+    }
+
+  g_assert (modmap != NULL);
+
+  return modmap;
+}
+
+
+
+
+ + + diff --git a/2020-08-20-160620-0353-cppcheck@fb7b816f4a78_master/index.html b/2020-08-20-160620-0353-cppcheck@fb7b816f4a78_master/index.html new file mode 100644 index 0000000..6b9ddd5 --- /dev/null +++ b/2020-08-20-160620-0353-cppcheck@fb7b816f4a78_master/index.html @@ -0,0 +1,117 @@ + + + + + + Cppcheck - HTML report - mate-indicator-applet + + + + + + +
+ +
+ + + + + + + +
LineIdCWESeverityMessage
0missingIncludeSysteminformationCppcheck cannot find all the include files (use --check-config for details)
src/eggaccelerators.c
321duplicateExpression398styleSame expression on both sides of '-='.
+
+
+ + + diff --git a/2020-08-20-160620-0353-cppcheck@fb7b816f4a78_master/stats.html b/2020-08-20-160620-0353-cppcheck@fb7b816f4a78_master/stats.html new file mode 100644 index 0000000..7489ae4 --- /dev/null +++ b/2020-08-20-160620-0353-cppcheck@fb7b816f4a78_master/stats.html @@ -0,0 +1,105 @@ + + + + + + Cppcheck - HTML report - mate-indicator-applet + + + + + + +
+ +
+

Top 10 files for style severity, total findings: 1
+   1  src/eggaccelerators.c
+

+ +
+
+ + + diff --git a/2020-08-20-160620-0353-cppcheck@fb7b816f4a78_master/style.css b/2020-08-20-160620-0353-cppcheck@fb7b816f4a78_master/style.css new file mode 100644 index 0000000..07125f4 --- /dev/null +++ b/2020-08-20-160620-0353-cppcheck@fb7b816f4a78_master/style.css @@ -0,0 +1,137 @@ + +body { + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif; + font-size: 13px; + line-height: 1.5; + margin: 0; + width: auto; +} + +h1 { + margin: 10px; +} + +.header { + border-bottom: thin solid #aaa; +} + +.footer { + border-top: thin solid #aaa; + font-size: 90%; + margin-top: 5px; +} + +.footer ul { + list-style-type: none; + padding-left: 0; +} + +.footer > p { + margin: 4px; +} + +.wrapper { + display: -webkit-box; + display: -ms-flexbox; + display: flex; + -webkit-box-pack: justify; + -ms-flex-pack: justify; + justify-content: space-between; +} + +#menu, +#menu_index { + text-align: left; + width: 350px; + height: 90vh; + min-height: 200px; + overflow: auto; + position: -webkit-sticky; + position: sticky; + top: 0; + padding: 0 15px 15px 15px; +} + +#menu > a { + display: block; + margin-left: 10px; + font-size: 12px; + z-index: 1; +} + +#content, +#content_index { + background-color: #fff; + -webkit-box-sizing: content-box; + -moz-box-sizing: content-box; + box-sizing: content-box; + padding: 0 15px 15px 15px; + width: calc(100% - 350px); + height: 100%; + overflow-x: auto; +} + +#filename { + margin-left: 10px; + font-size: 12px; + z-index: 1; +} + +.error { + background-color: #ffb7b7; +} + +.error2 { + background-color: #faa; + display: inline-block; + margin-left: 4px; +} + +.inconclusive { + background-color: #b6b6b4; +} + +.inconclusive2 { + background-color: #b6b6b4; + display: inline-block; + margin-left: 4px; +} + +.verbose { + display: inline-block; + vertical-align: top; + cursor: help; +} + +.verbose .content { + display: none; + position: absolute; + padding: 10px; + margin: 4px; + max-width: 40%; + white-space: pre-wrap; + border: 1px solid #000; + background-color: #ffffcc; + cursor: auto; +} + +.highlight .hll { + padding: 1px; +} + +.highlighttable { + background-color: #fff; + z-index: 10; + position: relative; + margin: -10px; +} + +.linenos { + border-right: thin solid #aaa; + color: #d3d3d3; + padding-right: 6px; +} + +.d-none { + display: none; +} diff --git a/2020-08-20-161040-7825-cppcheck@fb7b816f4a78_v1.25.0/0.html b/2020-08-20-161040-7825-cppcheck@fb7b816f4a78_v1.25.0/0.html new file mode 100644 index 0000000..501a2f5 --- /dev/null +++ b/2020-08-20-161040-7825-cppcheck@fb7b816f4a78_v1.25.0/0.html @@ -0,0 +1,1224 @@ + + + + + + Cppcheck - HTML report - mate-indicator-applet + + + + + + +
+ +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
/* eggaccelerators.c
+ * Copyright (C) 2002  Red Hat, Inc.; Copyright 1998, 2001 Tim Janik
+ * Developed by Havoc Pennington, Tim Janik
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
+ */
+
+#include "eggaccelerators.h"
+
+#include <string.h>
+#include <gdk/gdkx.h>
+#include <gdk/gdkkeysyms.h>
+
+enum
+{
+  EGG_MODMAP_ENTRY_SHIFT   = 0,
+  EGG_MODMAP_ENTRY_LOCK    = 1,
+  EGG_MODMAP_ENTRY_CONTROL = 2,
+  EGG_MODMAP_ENTRY_MOD1    = 3,
+  EGG_MODMAP_ENTRY_MOD2    = 4,
+  EGG_MODMAP_ENTRY_MOD3    = 5,
+  EGG_MODMAP_ENTRY_MOD4    = 6,
+  EGG_MODMAP_ENTRY_MOD5    = 7,
+  EGG_MODMAP_ENTRY_LAST    = 8
+};
+
+#define MODMAP_ENTRY_TO_MODIFIER(x) (1 << (x))
+
+typedef struct
+{
+  EggVirtualModifierType mapping[EGG_MODMAP_ENTRY_LAST];
+
+} EggModmap;
+
+const EggModmap* egg_keymap_get_modmap (GdkKeymap *keymap);
+
+static inline gboolean
+is_alt (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'a' || string[1] == 'A') &&
+	  (string[2] == 'l' || string[2] == 'L') &&
+	  (string[3] == 't' || string[3] == 'T') &&
+	  (string[4] == '>'));
+}
+
+static inline gboolean
+is_ctl (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'c' || string[1] == 'C') &&
+	  (string[2] == 't' || string[2] == 'T') &&
+	  (string[3] == 'l' || string[3] == 'L') &&
+	  (string[4] == '>'));
+}
+
+static inline gboolean
+is_modx (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'm' || string[1] == 'M') &&
+	  (string[2] == 'o' || string[2] == 'O') &&
+	  (string[3] == 'd' || string[3] == 'D') &&
+	  (string[4] >= '1' && string[4] <= '5') &&
+	  (string[5] == '>'));
+}
+
+static inline gboolean
+is_ctrl (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'c' || string[1] == 'C') &&
+	  (string[2] == 't' || string[2] == 'T') &&
+	  (string[3] == 'r' || string[3] == 'R') &&
+	  (string[4] == 'l' || string[4] == 'L') &&
+	  (string[5] == '>'));
+}
+
+static inline gboolean
+is_shft (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 's' || string[1] == 'S') &&
+	  (string[2] == 'h' || string[2] == 'H') &&
+	  (string[3] == 'f' || string[3] == 'F') &&
+	  (string[4] == 't' || string[4] == 'T') &&
+	  (string[5] == '>'));
+}
+
+static inline gboolean
+is_shift (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 's' || string[1] == 'S') &&
+	  (string[2] == 'h' || string[2] == 'H') &&
+	  (string[3] == 'i' || string[3] == 'I') &&
+	  (string[4] == 'f' || string[4] == 'F') &&
+	  (string[5] == 't' || string[5] == 'T') &&
+	  (string[6] == '>'));
+}
+
+static inline gboolean
+is_control (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'c' || string[1] == 'C') &&
+	  (string[2] == 'o' || string[2] == 'O') &&
+	  (string[3] == 'n' || string[3] == 'N') &&
+	  (string[4] == 't' || string[4] == 'T') &&
+	  (string[5] == 'r' || string[5] == 'R') &&
+	  (string[6] == 'o' || string[6] == 'O') &&
+	  (string[7] == 'l' || string[7] == 'L') &&
+	  (string[8] == '>'));
+}
+
+static inline gboolean
+is_release (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'r' || string[1] == 'R') &&
+	  (string[2] == 'e' || string[2] == 'E') &&
+	  (string[3] == 'l' || string[3] == 'L') &&
+	  (string[4] == 'e' || string[4] == 'E') &&
+	  (string[5] == 'a' || string[5] == 'A') &&
+	  (string[6] == 's' || string[6] == 'S') &&
+	  (string[7] == 'e' || string[7] == 'E') &&
+	  (string[8] == '>'));
+}
+
+static inline gboolean
+is_meta (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'm' || string[1] == 'M') &&
+	  (string[2] == 'e' || string[2] == 'E') &&
+	  (string[3] == 't' || string[3] == 'T') &&
+	  (string[4] == 'a' || string[4] == 'A') &&
+	  (string[5] == '>'));
+}
+
+static inline gboolean
+is_super (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 's' || string[1] == 'S') &&
+	  (string[2] == 'u' || string[2] == 'U') &&
+	  (string[3] == 'p' || string[3] == 'P') &&
+	  (string[4] == 'e' || string[4] == 'E') &&
+	  (string[5] == 'r' || string[5] == 'R') &&
+	  (string[6] == '>'));
+}
+
+static inline gboolean
+is_hyper (const gchar *string)
+{
+  return ((string[0] == '<') &&
+	  (string[1] == 'h' || string[1] == 'H') &&
+	  (string[2] == 'y' || string[2] == 'Y') &&
+	  (string[3] == 'p' || string[3] == 'P') &&
+	  (string[4] == 'e' || string[4] == 'E') &&
+	  (string[5] == 'r' || string[5] == 'R') &&
+	  (string[6] == '>'));
+}
+
+/**
+ * egg_accelerator_parse_virtual:
+ * @accelerator:      string representing an accelerator
+ * @accelerator_key:  return location for accelerator keyval
+ * @accelerator_mods: return location for accelerator modifier mask
+ *
+ * Parses a string representing a virtual accelerator. The format
+ * looks like "&lt;Control&gt;a" or "&lt;Shift&gt;&lt;Alt&gt;F1" or
+ * "&lt;Release&gt;z" (the last one is for key release).  The parser
+ * is fairly liberal and allows lower or upper case, and also
+ * abbreviations such as "&lt;Ctl&gt;" and "&lt;Ctrl&gt;".
+ *
+ * If the parse fails, @accelerator_key and @accelerator_mods will
+ * be set to 0 (zero) and %FALSE will be returned. If the string contains
+ * only modifiers, @accelerator_key will be set to 0 but %TRUE will be
+ * returned.
+ *
+ * The virtual vs. concrete accelerator distinction is a relic of
+ * how the X Window System works; there are modifiers Mod2-Mod5 that
+ * can represent various keyboard keys (numlock, meta, hyper, etc.),
+ * the virtual modifier represents the keyboard key, the concrete
+ * modifier the actual Mod2-Mod5 bits in the key press event.
+ *
+ * Returns: %TRUE on success.
+ */
+gboolean
+egg_accelerator_parse_virtual (const gchar            *accelerator,
+                               guint                  *accelerator_key,
+                               EggVirtualModifierType *accelerator_mods)
+{
+  guint keyval;
+  GdkModifierType mods;
+  gint len;
+  gboolean bad_keyval;
+
+  if (accelerator_key)
+    *accelerator_key = 0;
+  if (accelerator_mods)
+    *accelerator_mods = 0;
+
+  g_return_val_if_fail (accelerator != NULL, FALSE);
+
+  bad_keyval = FALSE;
+
+  keyval = 0;
+  mods = 0;
+  len = strlen (accelerator);
+  while (len)
+    {
+      if (*accelerator == '<')
+	{
+	  if (len >= 9 && is_release (accelerator))
+	    {
+	      accelerator += 9;
+	      len -= 9;
+	      mods |= EGG_VIRTUAL_RELEASE_MASK;
+	    }
+	  else if (len >= 9 && is_control (accelerator))
+	    {
+	      accelerator += 9;
+	      len -= 9;
+	      mods |= EGG_VIRTUAL_CONTROL_MASK;
+	    }
+	  else if (len >= 7 && is_shift (accelerator))
+	    {
+	      accelerator += 7;
+	      len -= 7;
+	      mods |= EGG_VIRTUAL_SHIFT_MASK;
+	    }
+	  else if (len >= 6 && is_shft (accelerator))
+	    {
+	      accelerator += 6;
+	      len -= 6;
+	      mods |= EGG_VIRTUAL_SHIFT_MASK;
+	    }
+	  else if (len >= 6 && is_ctrl (accelerator))
+	    {
+	      accelerator += 6;
+	      len -= 6;
+	      mods |= EGG_VIRTUAL_CONTROL_MASK;
+	    }
+	  else if (len >= 6 && is_modx (accelerator))
+	    {
+	      static const guint mod_vals[] = {
+		EGG_VIRTUAL_ALT_MASK, EGG_VIRTUAL_MOD2_MASK, EGG_VIRTUAL_MOD3_MASK,
+		EGG_VIRTUAL_MOD4_MASK, EGG_VIRTUAL_MOD5_MASK
+	      };
+
+	      len -= 6;
+	      accelerator += 4;
+	      mods |= mod_vals[*accelerator - '1'];
+	      accelerator += 2;
+	    }
+	  else if (len >= 5 && is_ctl (accelerator))
+	    {
+	      accelerator += 5;
+	      len -= 5;
+	      mods |= EGG_VIRTUAL_CONTROL_MASK;
+	    }
+	  else if (len >= 5 && is_alt (accelerator))
+	    {
+	      accelerator += 5;
+	      len -= 5;
+	      mods |= EGG_VIRTUAL_ALT_MASK;
+	    }
+          else if (len >= 6 && is_meta (accelerator))
+	    {
+	      accelerator += 6;
+	      len -= 6;
+	      mods |= EGG_VIRTUAL_META_MASK;
+	    }
+          else if (len >= 7 && is_hyper (accelerator))
+	    {
+	      accelerator += 7;
+	      len -= 7;
+	      mods |= EGG_VIRTUAL_HYPER_MASK;
+	    }
+          else if (len >= 7 && is_super (accelerator))
+	    {
+	      accelerator += 7;
+	      len -= 7;
+	      mods |= EGG_VIRTUAL_SUPER_MASK;
+	    }
+	  else
+	    {
+	      gchar last_ch;
+
+	      last_ch = *accelerator;
+	      while (last_ch && last_ch != '>')
+		{
+		  last_ch = *accelerator;
+		  accelerator += 1;
+		  len -= 1;
+		}
+	    }
+	}
+      else
+	{
+          keyval = gdk_keyval_from_name (accelerator);
+
+          if (keyval == 0)
+            bad_keyval = TRUE;
+
+          accelerator += len;
+          len -= len;
+	}
+    }
+
+  if (accelerator_key)
+    *accelerator_key = gdk_keyval_to_lower (keyval);
+  if (accelerator_mods)
+    *accelerator_mods = mods;
+
+  return !bad_keyval;
+}
+
+void
+egg_keymap_resolve_virtual_modifiers (GdkKeymap              *keymap,
+                                      EggVirtualModifierType  virtual_mods,
+                                      GdkModifierType        *concrete_mods)
+{
+  GdkModifierType concrete;
+  int i;
+  const EggModmap *modmap;
+
+  g_return_if_fail (GDK_IS_KEYMAP (keymap));
+  g_return_if_fail (concrete_mods != NULL);
+
+  modmap = egg_keymap_get_modmap (keymap);
+
+  /* Not so sure about this algorithm. */
+
+  concrete = 0;
+  i = 0;
+  while (i < EGG_MODMAP_ENTRY_LAST)
+    {
+      if (modmap->mapping[i] & virtual_mods)
+        concrete |= (1 << i);
+
+      ++i;
+    }
+
+  *concrete_mods = concrete;
+}
+
+void
+egg_keymap_virtualize_modifiers (GdkKeymap              *keymap,
+                                 GdkModifierType         concrete_mods,
+                                 EggVirtualModifierType *virtual_mods)
+{
+  GdkModifierType virtual;
+  int i;
+  const EggModmap *modmap;
+
+  g_return_if_fail (GDK_IS_KEYMAP (keymap));
+  g_return_if_fail (virtual_mods != NULL);
+
+  modmap = egg_keymap_get_modmap (keymap);
+
+  /* Not so sure about this algorithm. */
+
+  virtual = 0;
+  i = 0;
+  while (i < EGG_MODMAP_ENTRY_LAST)
+    {
+      if ((1 << i) & concrete_mods)
+        {
+          EggVirtualModifierType cleaned;
+
+          cleaned = modmap->mapping[i] & ~(EGG_VIRTUAL_MOD2_MASK |
+                                           EGG_VIRTUAL_MOD3_MASK |
+                                           EGG_VIRTUAL_MOD4_MASK |
+                                           EGG_VIRTUAL_MOD5_MASK);
+
+          if (cleaned != 0)
+            {
+              virtual |= cleaned;
+            }
+          else
+            {
+              /* Rather than dropping mod2->mod5 if not bound,
+               * go ahead and use the concrete names
+               */
+              virtual |= modmap->mapping[i];
+            }
+        }
+
+      ++i;
+    }
+
+  *virtual_mods = virtual;
+}
+
+static void
+reload_modmap (GdkKeymap *keymap,
+               EggModmap *modmap)
+{
+  XModifierKeymap *xmodmap;
+  int map_size;
+  int i;
+
+  /* FIXME multihead */
+  xmodmap = XGetModifierMapping (gdk_x11_get_default_xdisplay ());
+
+  memset (modmap->mapping, 0, sizeof (modmap->mapping));
+
+  /* there are 8 modifiers, and the first 3 are shift, shift lock,
+   * and control
+   */
+  map_size = 8 * xmodmap->max_keypermod;
+  i = 3 * xmodmap->max_keypermod;
+  while (i < map_size)
+    {
+      /* get the key code at this point in the map,
+       * see if its keysym is one we're interested in
+       */
+      int keycode = xmodmap->modifiermap[i];
+      GdkKeymapKey *keys;
+      guint *keyvals;
+      int n_entries;
+      int j;
+      EggVirtualModifierType mask;
+
+      keys = NULL;
+      keyvals = NULL;
+      n_entries = 0;
+
+      gdk_keymap_get_entries_for_keycode (keymap,
+                                          keycode,
+                                          &keys, &keyvals, &n_entries);
+
+      mask = 0;
+      j = 0;
+      while (j < n_entries)
+        {
+          if (keyvals[j] == GDK_KEY_Num_Lock)
+            mask |= EGG_VIRTUAL_NUM_LOCK_MASK;
+          else if (keyvals[j] == GDK_KEY_Scroll_Lock)
+            mask |= EGG_VIRTUAL_SCROLL_LOCK_MASK;
+          else if (keyvals[j] == GDK_KEY_Meta_L ||
+                   keyvals[j] == GDK_KEY_Meta_R)
+            mask |= EGG_VIRTUAL_META_MASK;
+          else if (keyvals[j] == GDK_KEY_Hyper_L ||
+                   keyvals[j] == GDK_KEY_Hyper_R)
+            mask |= EGG_VIRTUAL_HYPER_MASK;
+          else if (keyvals[j] == GDK_KEY_Super_L ||
+                   keyvals[j] == GDK_KEY_Super_R)
+            mask |= EGG_VIRTUAL_SUPER_MASK;
+          else if (keyvals[j] == GDK_KEY_Mode_switch)
+            mask |= EGG_VIRTUAL_MODE_SWITCH_MASK;
+
+          ++j;
+        }
+
+      /* Mod1Mask is 1 << 3 for example, i.e. the
+       * fourth modifier, i / keyspermod is the modifier
+       * index
+       */
+      modmap->mapping[i/xmodmap->max_keypermod] |= mask;
+
+      g_free (keyvals);
+      g_free (keys);
+
+      ++i;
+    }
+
+  /* Add in the not-really-virtual fixed entries */
+  modmap->mapping[EGG_MODMAP_ENTRY_SHIFT] |= EGG_VIRTUAL_SHIFT_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_CONTROL] |= EGG_VIRTUAL_CONTROL_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_LOCK] |= EGG_VIRTUAL_LOCK_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD1] |= EGG_VIRTUAL_ALT_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD2] |= EGG_VIRTUAL_MOD2_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD3] |= EGG_VIRTUAL_MOD3_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD4] |= EGG_VIRTUAL_MOD4_MASK;
+  modmap->mapping[EGG_MODMAP_ENTRY_MOD5] |= EGG_VIRTUAL_MOD5_MASK;
+
+  XFreeModifiermap (xmodmap);
+}
+
+const EggModmap*
+egg_keymap_get_modmap (GdkKeymap *keymap)
+{
+  EggModmap *modmap;
+
+  /* This is all a hack, much simpler when we can just
+   * modify GDK directly.
+   */
+
+  modmap = g_object_get_data (G_OBJECT (keymap),
+                              "egg-modmap");
+
+  if (modmap == NULL)
+    {
+      modmap = g_new0 (EggModmap, 1);
+
+      /* FIXME modify keymap change events with an event filter
+       * and force a reload if we get one
+       */
+
+      reload_modmap (keymap, modmap);
+
+      g_object_set_data_full (G_OBJECT (keymap),
+                              "egg-modmap",
+                              modmap,
+                              g_free);
+    }
+
+  g_assert (modmap != NULL);
+
+  return modmap;
+}
+
+
+
+
+ + + diff --git a/2020-08-20-161040-7825-cppcheck@fb7b816f4a78_v1.25.0/index.html b/2020-08-20-161040-7825-cppcheck@fb7b816f4a78_v1.25.0/index.html new file mode 100644 index 0000000..6b9ddd5 --- /dev/null +++ b/2020-08-20-161040-7825-cppcheck@fb7b816f4a78_v1.25.0/index.html @@ -0,0 +1,117 @@ + + + + + + Cppcheck - HTML report - mate-indicator-applet + + + + + + +
+ +
+ + + + + + + +
LineIdCWESeverityMessage
0missingIncludeSysteminformationCppcheck cannot find all the include files (use --check-config for details)
src/eggaccelerators.c
321duplicateExpression398styleSame expression on both sides of '-='.
+
+
+ + + diff --git a/2020-08-20-161040-7825-cppcheck@fb7b816f4a78_v1.25.0/stats.html b/2020-08-20-161040-7825-cppcheck@fb7b816f4a78_v1.25.0/stats.html new file mode 100644 index 0000000..7489ae4 --- /dev/null +++ b/2020-08-20-161040-7825-cppcheck@fb7b816f4a78_v1.25.0/stats.html @@ -0,0 +1,105 @@ + + + + + + Cppcheck - HTML report - mate-indicator-applet + + + + + + +
+ +
+

Top 10 files for style severity, total findings: 1
+   1  src/eggaccelerators.c
+

+ +
+
+ + + diff --git a/2020-08-20-161040-7825-cppcheck@fb7b816f4a78_v1.25.0/style.css b/2020-08-20-161040-7825-cppcheck@fb7b816f4a78_v1.25.0/style.css new file mode 100644 index 0000000..07125f4 --- /dev/null +++ b/2020-08-20-161040-7825-cppcheck@fb7b816f4a78_v1.25.0/style.css @@ -0,0 +1,137 @@ + +body { + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif; + font-size: 13px; + line-height: 1.5; + margin: 0; + width: auto; +} + +h1 { + margin: 10px; +} + +.header { + border-bottom: thin solid #aaa; +} + +.footer { + border-top: thin solid #aaa; + font-size: 90%; + margin-top: 5px; +} + +.footer ul { + list-style-type: none; + padding-left: 0; +} + +.footer > p { + margin: 4px; +} + +.wrapper { + display: -webkit-box; + display: -ms-flexbox; + display: flex; + -webkit-box-pack: justify; + -ms-flex-pack: justify; + justify-content: space-between; +} + +#menu, +#menu_index { + text-align: left; + width: 350px; + height: 90vh; + min-height: 200px; + overflow: auto; + position: -webkit-sticky; + position: sticky; + top: 0; + padding: 0 15px 15px 15px; +} + +#menu > a { + display: block; + margin-left: 10px; + font-size: 12px; + z-index: 1; +} + +#content, +#content_index { + background-color: #fff; + -webkit-box-sizing: content-box; + -moz-box-sizing: content-box; + box-sizing: content-box; + padding: 0 15px 15px 15px; + width: calc(100% - 350px); + height: 100%; + overflow-x: auto; +} + +#filename { + margin-left: 10px; + font-size: 12px; + z-index: 1; +} + +.error { + background-color: #ffb7b7; +} + +.error2 { + background-color: #faa; + display: inline-block; + margin-left: 4px; +} + +.inconclusive { + background-color: #b6b6b4; +} + +.inconclusive2 { + background-color: #b6b6b4; + display: inline-block; + margin-left: 4px; +} + +.verbose { + display: inline-block; + vertical-align: top; + cursor: help; +} + +.verbose .content { + display: none; + position: absolute; + padding: 10px; + margin: 4px; + max-width: 40%; + white-space: pre-wrap; + border: 1px solid #000; + background-color: #ffffcc; + cursor: auto; +} + +.highlight .hll { + padding: 1px; +} + +.highlighttable { + background-color: #fff; + z-index: 10; + position: relative; + margin: -10px; +} + +.linenos { + border-right: thin solid #aaa; + color: #d3d3d3; + padding-right: 6px; +} + +.d-none { + display: none; +} diff --git a/CNAME b/CNAME new file mode 100644 index 0000000..8108cac --- /dev/null +++ b/CNAME @@ -0,0 +1 @@ +mate-indicator-applet.mate-desktop.dev diff --git a/index.html b/index.html new file mode 100644 index 0000000..6d5de32 --- /dev/null +++ b/index.html @@ -0,0 +1,46 @@ + + + + + mate-indicator-applet Code Analyzer results + + +

+ mate-desktop/mate-indicator-applet Static analyzer results +

+ GitHub + Build Status +
+Commit: fb7b816f4a78f93578ef7c8a2475a9ada0bd1527
+Compare:
+Branch: v1.25.0
+Time: 2020-08-20 16:10:40+00:00
+Messages:
+
+release 1.25.0
+
+
+ + + -- cgit v1.2.1